* 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.
73 lines
1.9 KiB
JavaScript
73 lines
1.9 KiB
JavaScript
import { clearLinearAuth, getLinearAuth } from './auth.js';
|
|
import { fetchLinearGraphql, getValidLinearAccessToken } from './client.js';
|
|
import { isPlainObject, readTrimmedString } from './parse.js';
|
|
|
|
const TEAMS_QUERY = `
|
|
query ListLinearTeams($first: Int!, $after: String) {
|
|
teams(first: $first, after: $after) {
|
|
nodes { id key name }
|
|
pageInfo { hasNextPage endCursor }
|
|
}
|
|
}
|
|
`;
|
|
const PAGE_SIZE = 50;
|
|
const MAX_PAGES = 20;
|
|
|
|
function readTeam(node) {
|
|
if (!isPlainObject(node)) {
|
|
return null;
|
|
}
|
|
const id = readTrimmedString(node.id);
|
|
const key = readTrimmedString(node.key);
|
|
const name = readTrimmedString(node.name);
|
|
if (!id || !key || !name) {
|
|
return null;
|
|
}
|
|
return { id, key, name };
|
|
}
|
|
|
|
export async function listLinearTeams() {
|
|
try {
|
|
const token = await getValidLinearAccessToken();
|
|
if (!token) {
|
|
return { connected: false };
|
|
}
|
|
|
|
const teams = [];
|
|
let after = null;
|
|
for (let page = 0; page < MAX_PAGES; page += 1) {
|
|
const variables = { first: PAGE_SIZE };
|
|
if (after) {
|
|
variables.after = after;
|
|
}
|
|
const data = await fetchLinearGraphql(token, TEAMS_QUERY, variables);
|
|
const connection = isPlainObject(data.teams) ? data.teams : null;
|
|
const nodes = isPlainObject(connection) && Array.isArray(connection.nodes)
|
|
? connection.nodes
|
|
: [];
|
|
for (const node of nodes) {
|
|
const team = readTeam(node);
|
|
if (team) {
|
|
teams.push(team);
|
|
}
|
|
}
|
|
const pageInfo = isPlainObject(connection) ? connection.pageInfo : null;
|
|
if (!isPlainObject(pageInfo) || pageInfo.hasNextPage !== true) {
|
|
break;
|
|
}
|
|
after = readTrimmedString(pageInfo.endCursor);
|
|
if (!after) {
|
|
break;
|
|
}
|
|
}
|
|
|
|
return { connected: true, teams };
|
|
} catch (error) {
|
|
if (error?.status === 401) {
|
|
clearLinearAuth(getLinearAuth()?.workspaceId);
|
|
return { connected: false };
|
|
}
|
|
throw error;
|
|
}
|
|
}
|