OPE-296: Add linear integration for starting sessions from issues (#3235)
* feat(linear): start sessions from Linear issues Authorize a Linear workspace on this OpenChamber server, map teams to projects, attach an issue from chat, start a session or worktree from an issue, and post started/completed/failed comments that open the session. Hidden in VS Code. * feat(linear): connect more than one Linear workspace Store each OAuth grant on this OpenChamber server and keep one current, so Settings can add and switch workspaces without dropping the others. Project mapping is per workspace. Remove the Linear button next to New Chat; start-from-issue stays on New Worktree. * feat(linear): add a right-hand issues panel Browse and filter issues in the rail, open a card to change status or start a session, and collapse search plus most filters to icons on a narrow panel. * feat(linear): open issues in the rail and filter by Linear status The rail icon only shows after Linear is connected. Clicking a Linear row on work status opens the panel. Status options match the card, including Done, Canceled, and Duplicate. The Integrations experimental warning sits under Third-party integrations. * fix(linear): use stable OAuth callback broker * fix(chat): preview Linear issue attachments The context switch missed linear-issue, so tsc treated the preview helpers as incomplete. * fix(ui): restore Linear i18n parity and the #2903 sync harness Turkish was missing the Linear dictionaries, and the subagent test still wrapped only SyncContext after reads moved to SyncRuntimeContext. * fix(linear): drop changelog hunks and close review races Keep changelogs out of this PR, restore CodeMirror ranges, ignore stale Linear list pages, and leave a persisted Linear tab open until auth has actually resolved. * fix(linear): tint active issue filters and clear them in one click * fix(markdown): read escaped brackets as text, not display math `\[...\]` is display math in LaTeX and an escaped bracket pair in CommonMark. The block tokenizer claimed every `\[`, so prose like `[title \[Bug\] more](url)` was handed to KaTeX: "Bug" rendered as a centered formula and the block token split the paragraph, tearing the link into three pieces. Linear, GitHub and any other source that escapes brackets the way CommonMark requires hit this. Display math now has to own its line — `\[` starts one and `\]` ends one. A formula on its own line still renders; `\[` mid-sentence stays an escape, which is what CommonMark says it is and what prose almost always means. Inline `\(...\)` keeps the same ambiguity, but inline math is legitimately mid-sentence, so there is no position to judge it by. Covered by regression tests, including the verbatim comment body that surfaced this. * feat(linear): make session status comments opt-in and public-only A status comment lands in a Linear workspace the whole team reads, and the link it carried pointed at whatever origin started the session — usually loopback or a LAN address. Everyone but its author got a dead link, and nobody had agreed to the comments in the first place. Comments are now off until the user turns them on in Settings -> Integrations -> Linear, and the check lives on the server: the event hub posts completed and failure without going through the interface, so a client-side gate would not hold. When the resolved origin is not publicly reachable the server posts nothing at all rather than a link only its author can open; `isPublicSessionOrigin` rejects loopback, private LAN, carrier-grade NAT, link-local and single-label hosts. The desktop deep-link origin is gone with it, since no one else can follow one either. The comment body also dropped the session title. It repeated the issue the comment already sits on, and issue titles routinely carry brackets ("[Bug] ...") that broke the markdown link. The body is now one short link, and `sessionTitle` is gone from the route, client and types. Also caps the dedupe file at the newest 500 sessions; it grew forever. * fix(linear): match the pull request panel and clear review findings Comments in the Linear panel now render as the same avatar timeline the pull request panel uses, with the shared time-format preference instead of a raw locale string. Comment authors carry `avatarUrl`, which the GraphQL selection was not requesting. Review findings from the same pass: - `status-runtime.js` hand-rolled `typeof` narrowing and failed the vendored anti-slop lint; it now parses through `parse.js` like every other file in the module. - `useLinearAuthStore` turned any failed request into `connected: false` with `hasChecked: true`. Since the rail icon, the composer entry and the worktree option all gate on `connected === true`, one network blip hid Linear for the rest of the session, and Settings only re-checked when it had never checked. It now keeps the last known status and leaves `hasChecked` false so the next caller retries. - `LinearIssuesView` (1096 lines) was a static import in `ContextPanel`, shipping in the main bundle although its rail icon stays hidden until a workspace is connected. It is lazy now, like `GitView`. - Dropped dead code: the unused port helpers left over from the loopback callback, two re-exported default values nothing read, and a redundant export in `linkedIssues`. - Integrations is no longer badged beta.
This commit is contained in:
@@ -26,10 +26,10 @@ edge (`components/layout/ContextPanelRail.tsx`) and rendered by
|
||||
(`useUIStore.contextRailHiddenSurfaces`, edited from the rail's trailing
|
||||
configure button — `ContextRailSurfacesDialog`), drops the plan surface
|
||||
unless plan mode is enabled,
|
||||
drops the walkthrough on VS Code and below `WALKTHROUGH_MIN_WIDTH`, and hides
|
||||
`has-content` surfaces until a tab of their mode exists. Both consumers use
|
||||
it so the digit shown on a rail badge always maps to the same surface the
|
||||
shortcut opens.
|
||||
drops the walkthrough on VS Code and below `WALKTHROUGH_MIN_WIDTH`, hides
|
||||
Linear unless a workspace is connected, and hides `has-content` surfaces
|
||||
until a tab of their mode exists. Both consumers use it so the digit shown
|
||||
on a rail badge always maps to the same surface the shortcut opens.
|
||||
|
||||
## Adding a surface
|
||||
|
||||
@@ -53,7 +53,22 @@ the `openContext*` actions in `useUIStore`.
|
||||
positions). Chat tab records stay open, but only the active chat iframe is
|
||||
mounted while the panel is open. A selected chat restores its state from
|
||||
the session stores. A closed panel mounts no chat iframe.
|
||||
Singleton surfaces (git, pr, notes, plan, context) remount on switch. These
|
||||
Singleton surfaces (git, pr, linear, notes, plan, context) remount on switch. These
|
||||
surfaces must restore their state from stores or snapshots.
|
||||
- Runtime scope: desktop/web `MainLayout` only. VS Code and the dedicated
|
||||
mobile shell have their own layouts and do not consume this registry.
|
||||
Linear is a desktop/web singleton on this rail. VS Code and mobile omit it
|
||||
(no this registry, and VS Code has no `RuntimeAPIs.linear`). The Linear
|
||||
rail icon is hidden until a Linear workspace is connected. A persisted Linear
|
||||
tab stays open across reload until auth has resolved; only a confirmed
|
||||
disconnect closes the panel. The surface lists
|
||||
issues with status (All, Backlog, To Do, In Progress, In Review, Done, Canceled, Duplicate), assignee, team, and priority filters, can switch
|
||||
the current workspace, and keeps Start session in a footer on the issue card.
|
||||
Those filters restore from `useUIStore` when the surface remounts. Non-default
|
||||
status, assignee, team, priority, and search tint the filter icon `text-primary`,
|
||||
same as the context rail; one control clears them. Workspace switch is not a
|
||||
filter. Work-status Context sources
|
||||
can open a specific issue here through `linearIssueFocus`. Below 520px
|
||||
search and the filters other than status drop to icons; status keeps its label. The card
|
||||
shows priority and labels. Changing filters keeps the previous list
|
||||
until the next page arrives.
|
||||
|
||||
@@ -12,6 +12,7 @@ const baseOptions = {
|
||||
isVSCode: false,
|
||||
screenWidth: 1200,
|
||||
tabs: [],
|
||||
linearConnected: true,
|
||||
} as const;
|
||||
|
||||
describe('getVisibleContextRailSurfaces', () => {
|
||||
@@ -63,4 +64,17 @@ describe('getVisibleContextRailSurfaces', () => {
|
||||
const surfaces = getVisibleContextRailSurfaces({ ...baseOptions, railOrder: ['git', 'context'] });
|
||||
expect(surfaces.slice(0, 2).map((surface) => surface.id)).toEqual(['git', 'context']);
|
||||
});
|
||||
|
||||
test('places Linear after Pull Request in the default order', () => {
|
||||
const ids = getVisibleContextRailSurfaces(baseOptions).map((surface) => surface.id);
|
||||
const pr = ids.indexOf('pr');
|
||||
const linear = ids.indexOf('linear');
|
||||
expect(pr).toBeGreaterThanOrEqual(0);
|
||||
expect(linear).toBe(pr + 1);
|
||||
});
|
||||
|
||||
test('hides Linear until a workspace is connected', () => {
|
||||
expect(getVisibleContextRailSurfaces({ ...baseOptions, linearConnected: false }).some((s) => s.id === 'linear')).toBe(false);
|
||||
expect(getVisibleContextRailSurfaces({ ...baseOptions, linearConnected: true }).some((s) => s.id === 'linear')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -6,6 +6,7 @@ export type ContextSurfaceId =
|
||||
| 'editor'
|
||||
| 'git'
|
||||
| 'pr'
|
||||
| 'linear'
|
||||
| 'diff'
|
||||
| 'walkthrough'
|
||||
| 'terminal'
|
||||
@@ -65,6 +66,15 @@ export const CONTEXT_SURFACES: readonly ContextSurfaceDescriptor[] = [
|
||||
labelKey: 'contextPanel.mode.pr',
|
||||
availability: 'always',
|
||||
},
|
||||
{
|
||||
id: 'linear',
|
||||
descriptionKey: 'contextRail.surface.linear.description',
|
||||
defaultWidthFraction: 0.45,
|
||||
mode: 'linear',
|
||||
icon: 'linear',
|
||||
labelKey: 'contextPanel.mode.linear',
|
||||
availability: 'always',
|
||||
},
|
||||
{
|
||||
id: 'diff',
|
||||
descriptionKey: 'contextRail.surface.diff.description',
|
||||
@@ -194,6 +204,8 @@ type VisibleRailSurfacesOptions = {
|
||||
isVSCode: boolean;
|
||||
screenWidth: number;
|
||||
tabs: readonly { mode: ContextPanelMode }[];
|
||||
/** Linear's rail icon stays off until a workspace is connected. */
|
||||
linearConnected: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -225,6 +237,9 @@ export const getVisibleContextRailSurfaces = (options: VisibleRailSurfacesOption
|
||||
if (surface.id === 'browser' && options.isVSCode) {
|
||||
return false;
|
||||
}
|
||||
if (surface.id === 'linear' && !options.linearConnected) {
|
||||
return false;
|
||||
}
|
||||
if (surface.availability === 'has-content') {
|
||||
return options.tabs.some((tab) => tab.mode === surface.mode);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user