From ac3bfcb8b1cd0129e538a78c21e3dca0d9555e70 Mon Sep 17 00:00:00 2001 From: Wout Stiens <71498452+StiensWout@users.noreply.github.com> Date: Tue, 17 Nov 2026 07:49:04 +0100 Subject: [PATCH 1/6] test(client-runtime): Linear filter choices survive a search with no matches Co-authored-by: Claude Opus 5.5 --- packages/client-runtime/src/issueList.test.ts | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/packages/client-runtime/src/issueList.test.ts b/packages/client-runtime/src/issueList.test.ts index 3923519abf06c..aa749e60ca86c 100644 --- a/packages/client-runtime/src/issueList.test.ts +++ b/packages/client-runtime/src/issueList.test.ts @@ -7,6 +7,9 @@ import type { ProjectId, } from "@t3tools/contracts"; import { describe, expect, it } from "vite-plus/test"; +import { AsyncResult, Atom, AtomRegistry } from "effect/reactivity"; + +import { createMergedIssueCandidatesAtoms } from "./state/issues.ts"; import { continueIssuePage, @@ -130,6 +133,38 @@ describe("issueFilterScopes", () => { ]); }); + it("keeps a Linear team's filter choices after a search returns no issues", () => { + const candidates = { + labels: [{ name: "bug", color: null, description: null }], + assignees: [{ id: "user-1", login: "julius", name: "Julius", avatarUrl: null }], + truncated: false, + }; + const merged = createMergedIssueCandidatesAtoms( + () => Atom.make(AsyncResult.success(candidates)), + () => "Candidates could not be read", + ); + const registry = AtomRegistry.make(); + try { + const first = holdIssuePages( + [[environmentId, answer({ trackers: [tracker({})], entries: [linearRow] })]], + new Map(), + ); + expect(registry.get(merged(issueFilterScopes(first, []))).labels).toEqual(candidates.labels); + const searched = holdIssuePages( + [[environmentId, answer({ trackers: [tracker({})], entries: [] })]], + first, + ); + const choices = registry.get(merged(issueFilterScopes(searched, []))); + expect( + choices.labels, + "a search with no matches must retain the team's label choices", + ).toEqual(candidates.labels); + expect(choices.assignees).toEqual(candidates.assignees); + } finally { + registry.dispose(); + } + }); + it("skips a tracker that cannot be read", () => { const held = new Map([ [ From 50760efdf781a47c70421a6f4d0d0441e6bb4526 Mon Sep 17 00:00:00 2001 From: Wout Stiens <71498452+StiensWout@users.noreply.github.com> Date: Tue, 17 Nov 2026 07:51:59 +0100 Subject: [PATCH 2/6] fix(client-runtime): Linear filters keep their choices when a search has no matches A bound Linear team is named only by its rows, so a search with no matches left the label and assignee filters with nothing to offer. Held pages now remember every scope their rows named, and the web and mobile lists carry their held pages across new first pages. Co-authored-by: Claude Opus 5.5 --- .../src/features/issues/IssuesScreen.tsx | 5 +- apps/web/src/components/issue/IssuesPage.tsx | 3 + packages/client-runtime/src/issueList.ts | 69 +++++++++++++++---- 3 files changed, 62 insertions(+), 15 deletions(-) diff --git a/apps/mobile/src/features/issues/IssuesScreen.tsx b/apps/mobile/src/features/issues/IssuesScreen.tsx index a1a40d04bf7fb..94346b3ca44c8 100644 --- a/apps/mobile/src/features/issues/IssuesScreen.tsx +++ b/apps/mobile/src/features/issues/IssuesScreen.tsx @@ -4,6 +4,7 @@ import { continueIssuePage, groupIssues, holdIssuePages, + keepIssuePages, issueFilterScopes, issueOrder, type EnvironmentIssueEntry, @@ -153,6 +154,8 @@ export function IssuesScreen( const [pages, setPages] = useState>(new Map()); const held = holdIssuePages(list.answers, pages); + const kept = keepIssuePages(pages, held); + if (kept !== pages) setPages(kept); const loadPage = useAtomCommand(issueEnvironment.listPage, { reportFailure: false }); const [loadingMore, setLoadingMore] = useState(false); const loading = useRef(false); @@ -182,7 +185,7 @@ export function IssuesScreen( ); loading.current = false; setLoadingMore(false); - setPages(new Map([...held, ...loaded])); + setPages(new Map([...pages, ...loaded])); }; const groups = groupIssues(held, query, projects, sort); diff --git a/apps/web/src/components/issue/IssuesPage.tsx b/apps/web/src/components/issue/IssuesPage.tsx index c3c340ce40021..026eb0f1e3c5e 100644 --- a/apps/web/src/components/issue/IssuesPage.tsx +++ b/apps/web/src/components/issue/IssuesPage.tsx @@ -3,6 +3,7 @@ import { continueIssuePage, groupIssues, holdIssuePages, + keepIssuePages, issueCursorsForHost, issueFilterScopes, issueTrackerKey, @@ -191,6 +192,8 @@ export function IssuesPage() { const [pages, setPages] = useState>(new Map()); const held = holdIssuePages(list.answers, pages); + const kept = keepIssuePages(pages, held); + if (kept !== pages) setPages(kept); const loadPage = useAtomCommand(issueEnvironment.listPage, { reportFailure: false }); const [loadingMore, setLoadingMore] = useState(null); // One tracker group's button carries on that tracker's scopes only. diff --git a/packages/client-runtime/src/issueList.ts b/packages/client-runtime/src/issueList.ts index c1ade3fc9002b..ecd493236f3f4 100644 --- a/packages/client-runtime/src/issueList.ts +++ b/packages/client-runtime/src/issueList.ts @@ -31,13 +31,46 @@ export interface HeldIssuePage { readonly nextCursors: IssueListCursors; /** Why the last "Load more" failed, until a retry succeeds or a new first page arrives. */ readonly moreFailure: string | null; + /** + * Every scope a row has named since the list was opened. A bound Linear team is named only by + * its rows, so a search that matches none must not take the team's filter choices away. + */ + readonly rowScopes: ReadonlyArray; } export function issueTrackerKey(tracker: Pick): string { return `${tracker.tracker} ${tracker.host.toLowerCase()}`; } -/** Continuations are laid over the first page they continue; a new first page forgets them. */ +function withRowScopes( + scopes: ReadonlyArray, + entries: ReadonlyArray, +): ReadonlyArray { + const next = [...scopes]; + for (const entry of entries) { + if ( + next.some( + (s) => + s.tracker === entry.tracker && + s.host?.toLowerCase() === entry.host.toLowerCase() && + s.scope.toLowerCase() === entry.scope.toLowerCase(), + ) + ) + continue; + next.push({ + projectId: entry.projectId, + tracker: entry.tracker, + host: entry.host, + scope: entry.scope, + }); + } + return next; +} + +/** + * Continuations are laid over the first page they continue; a new first page forgets them but + * keeps the scopes the pages before it named. Pass back what `keepIssuePages` kept. + */ export function holdIssuePages( answers: ReadonlyArray, pages: ReadonlyMap, @@ -56,12 +89,26 @@ export function holdIssuePages( moreErrors: [], nextCursors: answer.nextCursors, moreFailure: null, + rowScopes: withRowScopes(previous?.rowScopes ?? [], answer.entries), }, ); } return next; } +/** + * What a list keeps for its next `holdIssuePages`: every page held, beside the last page of an + * environment still loading its next answer. The same map when nothing new arrived, so a client + * can store it during render without looping. + */ +export function keepIssuePages( + pages: ReadonlyMap, + held: ReadonlyMap, +): ReadonlyMap { + if ([...held].every(([environmentId, page]) => pages.get(environmentId) === page)) return pages; + return new Map([...pages, ...held]); +} + /** The cursors of one tracker host, so its "Load more" leaves the other trackers where they are. */ export function issueCursorsForHost(cursors: IssueListCursors, host: string): IssueListCursors { return Object.fromEntries(Object.entries(cursors).filter(([key]) => key.startsWith(`${host} `))); @@ -90,6 +137,7 @@ export function continueIssuePage( ...next.nextCursors, }, moreFailure: null, + rowScopes: withRowScopes(page.rowScopes, next.entries), }; } @@ -190,29 +238,22 @@ export function issueFilterScopes( }); } // A tracker bound in settings (a Linear team) is no repository's; its rows name its scope. - for (const entry of page.entries) { + for (const input of page.rowScopes) { + const host = input.host?.toLowerCase(); const tracker = page.answer.trackers.find( - (t) => t.tracker === entry.tracker && t.host.toLowerCase() === entry.host.toLowerCase(), + (t) => t.tracker === input.tracker && t.host.toLowerCase() === host, ); if (!tracker?.configured) continue; if (!tracker.capabilities?.labels && !tracker.capabilities?.assignees) continue; if ( scopes.some( (s) => - s.input.scope.toLowerCase() === entry.scope.toLowerCase() && - s.input.host?.toLowerCase() === entry.host.toLowerCase(), + s.input.scope.toLowerCase() === input.scope.toLowerCase() && + s.input.host?.toLowerCase() === host, ) ) continue; - scopes.push({ - environmentId, - input: { - projectId: entry.projectId, - tracker: entry.tracker, - host: entry.host, - scope: entry.scope, - }, - }); + scopes.push({ environmentId, input }); } } return scopes; From 59ff0c43b49a1350c054a99e907c89447b634a77 Mon Sep 17 00:00:00 2001 From: Wout Stiens <71498452+StiensWout@users.noreply.github.com> Date: Tue, 17 Nov 2026 08:00:48 +0100 Subject: [PATCH 3/6] test(client-runtime): cover filter scopes across search loading Co-authored-by: GPT 6.1 Sol --- packages/client-runtime/src/issueList.test.ts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/packages/client-runtime/src/issueList.test.ts b/packages/client-runtime/src/issueList.test.ts index aa749e60ca86c..3f2de672c5abe 100644 --- a/packages/client-runtime/src/issueList.test.ts +++ b/packages/client-runtime/src/issueList.test.ts @@ -16,6 +16,7 @@ import { holdIssuePages, issueCursorsForHost, issueFilterScopes, + keepIssuePages, } from "./issueList.ts"; const environmentId = "env-1" as EnvironmentId; @@ -165,6 +166,26 @@ describe("issueFilterScopes", () => { } }); + it("keeps a Linear team's filter scope across a search's loading gap", () => { + const first = holdIssuePages( + [[environmentId, answer({ trackers: [tracker({})], entries: [linearRow] })]], + new Map(), + ); + const pages = keepIssuePages(new Map(), first); + const loading = holdIssuePages([], pages); + const kept = keepIssuePages(pages, loading); + const searched = holdIssuePages( + [[environmentId, answer({ trackers: [tracker({})], entries: [] })]], + kept, + ); + expect(issueFilterScopes(searched, [])).toEqual([ + { + environmentId, + input: { projectId: api, tracker: "linear", host: "linear.app", scope: "ENG" }, + }, + ]); + }); + it("skips a tracker that cannot be read", () => { const held = new Map([ [ From bed32df8f3b04474913473a8818052b431155b8e Mon Sep 17 00:00:00 2001 From: Wout Stiens <71498452+StiensWout@users.noreply.github.com> Date: Tue, 17 Nov 2026 08:02:17 +0100 Subject: [PATCH 4/6] fix(client-runtime): refresh remembered issue scope projects Co-authored-by: GPT 6.1 Sol --- packages/client-runtime/src/issueList.test.ts | 41 +++++++++++++++++++ packages/client-runtime/src/issueList.ts | 21 +++++----- 2 files changed, 51 insertions(+), 11 deletions(-) diff --git a/packages/client-runtime/src/issueList.test.ts b/packages/client-runtime/src/issueList.test.ts index 3f2de672c5abe..5bc882c91b529 100644 --- a/packages/client-runtime/src/issueList.test.ts +++ b/packages/client-runtime/src/issueList.test.ts @@ -186,6 +186,47 @@ describe("issueFilterScopes", () => { ]); }); + it("refreshes a remembered team's project while retaining other teams", () => { + const remaining = "remaining-project" as ProjectId; + const first = holdIssuePages( + [ + [ + environmentId, + answer({ + trackers: [tracker({})], + entries: [ + { ...linearRow, projectId: "deleted-project" as ProjectId }, + { ...linearRow, key: "OPS-1", scope: "OPS" }, + ], + }), + ], + ], + new Map(), + ); + const refreshed = holdIssuePages( + [ + [ + environmentId, + answer({ + trackers: [tracker({})], + entries: [{ ...linearRow, projectId: remaining }], + }), + ], + ], + first, + ); + expect(issueFilterScopes(refreshed, [])).toEqual([ + { + environmentId, + input: { projectId: remaining, tracker: "linear", host: "linear.app", scope: "ENG" }, + }, + { + environmentId, + input: { projectId: api, tracker: "linear", host: "linear.app", scope: "OPS" }, + }, + ]); + }); + it("skips a tracker that cannot be read", () => { const held = new Map([ [ diff --git a/packages/client-runtime/src/issueList.ts b/packages/client-runtime/src/issueList.ts index ecd493236f3f4..5af808aa32b9c 100644 --- a/packages/client-runtime/src/issueList.ts +++ b/packages/client-runtime/src/issueList.ts @@ -48,21 +48,20 @@ function withRowScopes( ): ReadonlyArray { const next = [...scopes]; for (const entry of entries) { - if ( - next.some( - (s) => - s.tracker === entry.tracker && - s.host?.toLowerCase() === entry.host.toLowerCase() && - s.scope.toLowerCase() === entry.scope.toLowerCase(), - ) - ) - continue; - next.push({ + const index = next.findIndex( + (s) => + s.tracker === entry.tracker && + s.host?.toLowerCase() === entry.host.toLowerCase() && + s.scope.toLowerCase() === entry.scope.toLowerCase(), + ); + const scope = { projectId: entry.projectId, tracker: entry.tracker, host: entry.host, scope: entry.scope, - }); + }; + if (index === -1) next.push(scope); + else next[index] = scope; } return next; } From e8850b1ccf61b65ab46b4fbc351a7ffc68f3c759 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Tue, 17 Nov 2026 07:18:52 +0000 Subject: [PATCH 5/6] test(client-runtime): drop the candidate-atom case the loading-gap case already covers Co-Authored-By: Claude Opus 5.5 --- packages/client-runtime/src/issueList.test.ts | 35 ------------------- 1 file changed, 35 deletions(-) diff --git a/packages/client-runtime/src/issueList.test.ts b/packages/client-runtime/src/issueList.test.ts index 5bc882c91b529..b5556024ea127 100644 --- a/packages/client-runtime/src/issueList.test.ts +++ b/packages/client-runtime/src/issueList.test.ts @@ -7,9 +7,6 @@ import type { ProjectId, } from "@t3tools/contracts"; import { describe, expect, it } from "vite-plus/test"; -import { AsyncResult, Atom, AtomRegistry } from "effect/reactivity"; - -import { createMergedIssueCandidatesAtoms } from "./state/issues.ts"; import { continueIssuePage, @@ -134,38 +131,6 @@ describe("issueFilterScopes", () => { ]); }); - it("keeps a Linear team's filter choices after a search returns no issues", () => { - const candidates = { - labels: [{ name: "bug", color: null, description: null }], - assignees: [{ id: "user-1", login: "julius", name: "Julius", avatarUrl: null }], - truncated: false, - }; - const merged = createMergedIssueCandidatesAtoms( - () => Atom.make(AsyncResult.success(candidates)), - () => "Candidates could not be read", - ); - const registry = AtomRegistry.make(); - try { - const first = holdIssuePages( - [[environmentId, answer({ trackers: [tracker({})], entries: [linearRow] })]], - new Map(), - ); - expect(registry.get(merged(issueFilterScopes(first, []))).labels).toEqual(candidates.labels); - const searched = holdIssuePages( - [[environmentId, answer({ trackers: [tracker({})], entries: [] })]], - first, - ); - const choices = registry.get(merged(issueFilterScopes(searched, []))); - expect( - choices.labels, - "a search with no matches must retain the team's label choices", - ).toEqual(candidates.labels); - expect(choices.assignees).toEqual(candidates.assignees); - } finally { - registry.dispose(); - } - }); - it("keeps a Linear team's filter scope across a search's loading gap", () => { const first = holdIssuePages( [[environmentId, answer({ trackers: [tracker({})], entries: [linearRow] })]], From 837c642746225525efc828da22161d7c84d162c7 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Tue, 17 Nov 2026 07:30:17 +0000 Subject: [PATCH 6/6] fix(server): issue listings name the scopes they cover A Linear team bound in settings was found only from the rows a listing returned, so a search with no matches (including one restored on return or reload) lost its label and assignee choices. The listing now names every scope it reads and the filter reads those, falling back to rows for older servers. This replaces the client-side scope memory. Co-Authored-By: Claude Opus 5.5 --- .../src/features/issues/IssuesScreen.tsx | 5 +- apps/server/src/issue/IssueService.test.ts | 6 ++ apps/server/src/issue/IssueService.ts | 6 ++ apps/web/src/components/issue/IssuesPage.tsx | 3 - packages/client-runtime/src/issueList.test.ts | 69 +++---------------- packages/client-runtime/src/issueList.ts | 62 ++++------------- packages/contracts/src/issue.ts | 5 ++ 7 files changed, 40 insertions(+), 116 deletions(-) diff --git a/apps/mobile/src/features/issues/IssuesScreen.tsx b/apps/mobile/src/features/issues/IssuesScreen.tsx index 94346b3ca44c8..a1a40d04bf7fb 100644 --- a/apps/mobile/src/features/issues/IssuesScreen.tsx +++ b/apps/mobile/src/features/issues/IssuesScreen.tsx @@ -4,7 +4,6 @@ import { continueIssuePage, groupIssues, holdIssuePages, - keepIssuePages, issueFilterScopes, issueOrder, type EnvironmentIssueEntry, @@ -154,8 +153,6 @@ export function IssuesScreen( const [pages, setPages] = useState>(new Map()); const held = holdIssuePages(list.answers, pages); - const kept = keepIssuePages(pages, held); - if (kept !== pages) setPages(kept); const loadPage = useAtomCommand(issueEnvironment.listPage, { reportFailure: false }); const [loadingMore, setLoadingMore] = useState(false); const loading = useRef(false); @@ -185,7 +182,7 @@ export function IssuesScreen( ); loading.current = false; setLoadingMore(false); - setPages(new Map([...pages, ...loaded])); + setPages(new Map([...held, ...loaded])); }; const groups = groupIssues(held, query, projects, sort); diff --git a/apps/server/src/issue/IssueService.test.ts b/apps/server/src/issue/IssueService.test.ts index fd6f7b2f0a0c1..ccbeb87279728 100644 --- a/apps/server/src/issue/IssueService.test.ts +++ b/apps/server/src/issue/IssueService.test.ts @@ -467,6 +467,12 @@ describe("IssueService with a standalone tracker", () => { ["github", "github.com"], ["linear", "linear.app"], ]); + expect(result.scopes).toContainEqual({ + projectId: "web", + tracker: "linear", + host: "linear.app", + scope: "ENG", + }); // A reference picks the project's tracker by kind; both are the project's own, so writable. const linearRef = { projectId: "web" as ProjectId, diff --git a/apps/server/src/issue/IssueService.ts b/apps/server/src/issue/IssueService.ts index a53aeb698ce89..e2312582dbc17 100644 --- a/apps/server/src/issue/IssueService.ts +++ b/apps/server/src/issue/IssueService.ts @@ -424,6 +424,12 @@ const make = Effect.gen(function* () { entries, errors, nextCursors, + scopes: [...scopes.values()].map((project) => ({ + projectId: project.project.id, + tracker: project.tracker, + host: project.host, + scope: project.scope, + })), }; }); diff --git a/apps/web/src/components/issue/IssuesPage.tsx b/apps/web/src/components/issue/IssuesPage.tsx index 026eb0f1e3c5e..c3c340ce40021 100644 --- a/apps/web/src/components/issue/IssuesPage.tsx +++ b/apps/web/src/components/issue/IssuesPage.tsx @@ -3,7 +3,6 @@ import { continueIssuePage, groupIssues, holdIssuePages, - keepIssuePages, issueCursorsForHost, issueFilterScopes, issueTrackerKey, @@ -192,8 +191,6 @@ export function IssuesPage() { const [pages, setPages] = useState>(new Map()); const held = holdIssuePages(list.answers, pages); - const kept = keepIssuePages(pages, held); - if (kept !== pages) setPages(kept); const loadPage = useAtomCommand(issueEnvironment.listPage, { reportFailure: false }); const [loadingMore, setLoadingMore] = useState(null); // One tracker group's button carries on that tracker's scopes only. diff --git a/packages/client-runtime/src/issueList.test.ts b/packages/client-runtime/src/issueList.test.ts index b5556024ea127..591c410876565 100644 --- a/packages/client-runtime/src/issueList.test.ts +++ b/packages/client-runtime/src/issueList.test.ts @@ -13,7 +13,6 @@ import { holdIssuePages, issueCursorsForHost, issueFilterScopes, - keepIssuePages, } from "./issueList.ts"; const environmentId = "env-1" as EnvironmentId; @@ -131,65 +130,17 @@ describe("issueFilterScopes", () => { ]); }); - it("keeps a Linear team's filter scope across a search's loading gap", () => { - const first = holdIssuePages( - [[environmentId, answer({ trackers: [tracker({})], entries: [linearRow] })]], - new Map(), - ); - const pages = keepIssuePages(new Map(), first); - const loading = holdIssuePages([], pages); - const kept = keepIssuePages(pages, loading); - const searched = holdIssuePages( - [[environmentId, answer({ trackers: [tracker({})], entries: [] })]], - kept, - ); - expect(issueFilterScopes(searched, [])).toEqual([ - { - environmentId, - input: { projectId: api, tracker: "linear", host: "linear.app", scope: "ENG" }, - }, - ]); - }); - - it("refreshes a remembered team's project while retaining other teams", () => { - const remaining = "remaining-project" as ProjectId; - const first = holdIssuePages( - [ - [ - environmentId, - answer({ - trackers: [tracker({})], - entries: [ - { ...linearRow, projectId: "deleted-project" as ProjectId }, - { ...linearRow, key: "OPS-1", scope: "OPS" }, - ], - }), - ], - ], - new Map(), - ); - const refreshed = holdIssuePages( - [ - [ - environmentId, - answer({ - trackers: [tracker({})], - entries: [{ ...linearRow, projectId: remaining }], - }), - ], - ], - first, - ); - expect(issueFilterScopes(refreshed, [])).toEqual([ - { - environmentId, - input: { projectId: remaining, tracker: "linear", host: "linear.app", scope: "ENG" }, - }, - { - environmentId, - input: { projectId: api, tracker: "linear", host: "linear.app", scope: "OPS" }, - }, + it("offers a bound tracker's scope the answer names when a search matches nothing", () => { + const scope = { + projectId: api, + tracker: "linear" as IssueTrackerKind, + host: "linear.app", + scope: "ENG", + }; + const held = new Map([ + [environmentId, hold(answer({ trackers: [tracker({})], entries: [], scopes: [scope] }))], ]); + expect(issueFilterScopes(held, [])).toEqual([{ environmentId, input: scope }]); }); it("skips a tracker that cannot be read", () => { diff --git a/packages/client-runtime/src/issueList.ts b/packages/client-runtime/src/issueList.ts index 5af808aa32b9c..34d421231382f 100644 --- a/packages/client-runtime/src/issueList.ts +++ b/packages/client-runtime/src/issueList.ts @@ -31,45 +31,13 @@ export interface HeldIssuePage { readonly nextCursors: IssueListCursors; /** Why the last "Load more" failed, until a retry succeeds or a new first page arrives. */ readonly moreFailure: string | null; - /** - * Every scope a row has named since the list was opened. A bound Linear team is named only by - * its rows, so a search that matches none must not take the team's filter choices away. - */ - readonly rowScopes: ReadonlyArray; } export function issueTrackerKey(tracker: Pick): string { return `${tracker.tracker} ${tracker.host.toLowerCase()}`; } -function withRowScopes( - scopes: ReadonlyArray, - entries: ReadonlyArray, -): ReadonlyArray { - const next = [...scopes]; - for (const entry of entries) { - const index = next.findIndex( - (s) => - s.tracker === entry.tracker && - s.host?.toLowerCase() === entry.host.toLowerCase() && - s.scope.toLowerCase() === entry.scope.toLowerCase(), - ); - const scope = { - projectId: entry.projectId, - tracker: entry.tracker, - host: entry.host, - scope: entry.scope, - }; - if (index === -1) next.push(scope); - else next[index] = scope; - } - return next; -} - -/** - * Continuations are laid over the first page they continue; a new first page forgets them but - * keeps the scopes the pages before it named. Pass back what `keepIssuePages` kept. - */ +/** Continuations are laid over the first page they continue; a new first page forgets them. */ export function holdIssuePages( answers: ReadonlyArray, pages: ReadonlyMap, @@ -88,26 +56,12 @@ export function holdIssuePages( moreErrors: [], nextCursors: answer.nextCursors, moreFailure: null, - rowScopes: withRowScopes(previous?.rowScopes ?? [], answer.entries), }, ); } return next; } -/** - * What a list keeps for its next `holdIssuePages`: every page held, beside the last page of an - * environment still loading its next answer. The same map when nothing new arrived, so a client - * can store it during render without looping. - */ -export function keepIssuePages( - pages: ReadonlyMap, - held: ReadonlyMap, -): ReadonlyMap { - if ([...held].every(([environmentId, page]) => pages.get(environmentId) === page)) return pages; - return new Map([...pages, ...held]); -} - /** The cursors of one tracker host, so its "Load more" leaves the other trackers where they are. */ export function issueCursorsForHost(cursors: IssueListCursors, host: string): IssueListCursors { return Object.fromEntries(Object.entries(cursors).filter(([key]) => key.startsWith(`${host} `))); @@ -136,7 +90,6 @@ export function continueIssuePage( ...next.nextCursors, }, moreFailure: null, - rowScopes: withRowScopes(page.rowScopes, next.entries), }; } @@ -236,8 +189,17 @@ export function issueFilterScopes( input: { projectId: project.id, tracker: tracker.tracker, host, scope }, }); } - // A tracker bound in settings (a Linear team) is no repository's; its rows name its scope. - for (const input of page.rowScopes) { + // A tracker bound in settings (a Linear team) is no repository's; the answer names its scope, + // matched or not. Older servers do not, so their rows stand in. + const covered: ReadonlyArray = + page.answer.scopes ?? + page.entries.map(({ projectId, tracker, host, scope }) => ({ + projectId, + tracker, + host, + scope, + })); + for (const input of covered) { const host = input.host?.toLowerCase(); const tracker = page.answer.trackers.find( (t) => t.tracker === input.tracker && t.host.toLowerCase() === host, diff --git a/packages/contracts/src/issue.ts b/packages/contracts/src/issue.ts index b2fc5532dac49..acd0eed54a421 100644 --- a/packages/contracts/src/issue.ts +++ b/packages/contracts/src/issue.ts @@ -308,6 +308,11 @@ export const IssueListResult = Schema.Struct({ errors: Schema.Array(IssueListProjectError), /** Where each scope carries on, sent straight back as `cursors`. Absent once a scope is done. */ nextCursors: IssueListCursors, + /** + * Every scope the listing covers, matched or not, with one project that reads it. A Linear team + * bound in settings is named nowhere else. Absent from servers that predate it. + */ + scopes: Schema.optional(Schema.Array(IssueScopeRef)), }); export type IssueListResult = typeof IssueListResult.Type;