Skip to content

Commit aa584b2

Browse files
donjor-agent[bot]donjor
authored andcommitted
feat(web): issue list narrows in place while GitHub answers (#1422)
> 🤖 claude/anthropic claude-opus-5-5 (high) ## What Changed The issue list keeps its rows while a new state or search loads, like the Pull Requests list. - **Held rows:** the last answer for the same projects stands in - **Narrowed:** held rows filter to the new state and search terms - **Search terms:** title, number, repository, author, labels - **Qualifiers:** `label:bug` and the like stay GitHub's to apply - **Marked:** rows dim; the group header says what is loading - **Ghosts:** only when nothing held fits, or a first load - **No false empty:** a narrowed-to-nothing carry shows ghosts, not "No issues" The carry is a pure helper with focused tests; `useGitHubIssueList` returns `carried` beside `data`. ## Why Every new state or search was a new query that started empty, so the whole list blanked to skeletons for a few seconds. The rows the reader already had were the best answer until GitHub replied. ## UI Changes | Before | After | | --- | --- | | ![switching before](https://github.com/user-attachments/assets/4c28db52-be3c-4c00-b829-c4cc93c3ddc6) | ![switching after](https://github.com/user-attachments/assets/2e3b06ba-a693-4fae-84a7-c213f7ece9be) | | ![searching before](https://github.com/user-attachments/assets/98fc1e96-a0e7-47c0-9919-644fae7baf60) | ![searching after](https://github.com/user-attachments/assets/0173a4a1-b6f2-462c-b6ae-6191a816f627) | **Before:** Open to All, then search; the list blanks each time https://github.com/user-attachments/assets/fec4ef5c-abe5-48c8-bf52-a9092617e503 **After:** same flow; rows stay and narrow in place https://github.com/user-attachments/assets/8365227c-1205-4008-b32f-9a1b7a54867c ## Checks ```text tsc --noEmit (apps/web) → exit 0 vp test run carry logic + issues page → exit 0 (10 tests) vp lint (changed files) → exit 0 vp run fork:ci → exit 0 ``` ## Checklist - [x] This PR is small and focused - [x] I explained what changed and why - [x] I included before/after screenshots for any UI changes - [x] I included a video for animation/interaction changes Stacked on #1421. Opus 5.5 via Claude Code in T3 Code. ## Fork trailers Fork-Domain: github-issues Fork-Tier: qol Fork-Upstreamable: no Co-authored-by: donjor <[email protected]>
1 parent 3b011c0 commit aa584b2

4 files changed

Lines changed: 175 additions & 13 deletions

File tree

‎apps/web/src/components/githubIssue/GitHubIssueGhosts.tsx‎

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,16 @@ function GhostBar({ className }: { readonly className?: string }) {
55
return <div aria-hidden className={cn("h-3 rounded bg-muted-foreground/15", className)} />;
66
}
77

8+
/** Names what is on its way, for the ghost and for held rows alike. */
9+
export function searchingCaption(query?: string): string {
10+
return query
11+
? `Searching GitHub for “${query.length > 48 ? `${query.slice(0, 48)}…` : query}”`
12+
: "Reading issues from GitHub";
13+
}
14+
815
/** The pull request list's ghost, named for what is actually on its way. */
916
export function GitHubIssueListGhosts({ query }: { readonly query?: string }) {
10-
return (
11-
<PullRequestListGhost
12-
rows={7}
13-
caption={
14-
query
15-
? `Searching GitHub for “${query.length > 48 ? `${query.slice(0, 48)}…` : query}”`
16-
: "Reading issues from GitHub"
17-
}
18-
/>
19-
);
17+
return <PullRequestListGhost rows={7} caption={searchingCaption(query)} />;
2018
}
2119

2220
/** The detail's own shape: title, meta line, facts, then the description section. */
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import type { EnvironmentGitHubIssueListEntry } from "@t3tools/client-runtime/state/github-issues";
2+
import { describe, expect, it } from "vite-plus/test";
3+
4+
import { carryGitHubIssueList, gitHubIssueListScope } from "./githubIssueListCarry.logic";
5+
6+
function entry(
7+
number: number,
8+
title: string,
9+
state: "open" | "closed",
10+
labels: ReadonlyArray<string> = [],
11+
): EnvironmentGitHubIssueListEntry {
12+
return {
13+
environmentId: "env",
14+
projectId: "project",
15+
projectTitle: "Project",
16+
repository: "acme/app",
17+
number,
18+
title,
19+
url: `https://github.com/acme/app/issues/${number}`,
20+
author: { login: "octo" },
21+
assignees: [],
22+
labels: labels.map((name) => ({ name, color: "ededed" })),
23+
state,
24+
createdAt: "2026-01-01T00:00:00.000Z",
25+
updatedAt: "2026-01-01T00:00:00.000Z",
26+
} as unknown as EnvironmentGitHubIssueListEntry;
27+
}
28+
29+
const held = {
30+
entries: [
31+
entry(1, "Fork fold absorbs repairs", "open", ["dx"]),
32+
entry(2, "Sync blocked on nightly", "open", ["ci"]),
33+
entry(3, "Fork tooling sheds flags", "closed"),
34+
],
35+
errors: [],
36+
environmentErrors: [],
37+
truncated: true,
38+
};
39+
40+
const numbers = (list: ReturnType<typeof carryGitHubIssueList>) =>
41+
list?.entries.map((issue) => issue.number) ?? null;
42+
43+
describe("carryGitHubIssueList", () => {
44+
it("narrows held rows by every free-text term across title, number and labels", () => {
45+
expect(numbers(carryGitHubIssueList(held, { state: "all", query: "fork" }))).toEqual([1, 3]);
46+
expect(numbers(carryGitHubIssueList(held, { state: "all", query: "fork dx" }))).toEqual([1]);
47+
expect(numbers(carryGitHubIssueList(held, { state: "all", query: "#2" }))).toEqual([2]);
48+
});
49+
50+
it("narrows by state, and leaves qualifiers to GitHub", () => {
51+
expect(numbers(carryGitHubIssueList(held, { state: "closed" }))).toEqual([3]);
52+
expect(numbers(carryGitHubIssueList(held, { state: "open", query: "label:bug" }))).toEqual([
53+
1, 2,
54+
]);
55+
});
56+
57+
it("carries nothing rather than an empty list GitHub has not confirmed", () => {
58+
expect(carryGitHubIssueList(held, { state: "open", query: "nothing matches" })).toBeNull();
59+
});
60+
61+
it("drops the held answer's errors and truncation, which describe another question", () => {
62+
const carried = carryGitHubIssueList(held, { state: "all" });
63+
expect(carried?.truncated).toBe(false);
64+
expect(carried?.errors).toEqual([]);
65+
});
66+
});
67+
68+
describe("gitHubIssueListScope", () => {
69+
it("ignores state and search, but not which projects are asked", () => {
70+
const open = [{ environmentId: "env", input: { state: "open" as const, projectId: "p" } }];
71+
const closed = [
72+
{ environmentId: "env", input: { state: "closed" as const, projectId: "p", query: "x" } },
73+
];
74+
const other = [{ environmentId: "env", input: { state: "open" as const, projectId: "q" } }];
75+
expect(gitHubIssueListScope(open as never)).toBe(gitHubIssueListScope(closed as never));
76+
expect(gitHubIssueListScope(open as never)).not.toBe(gitHubIssueListScope(other as never));
77+
});
78+
});
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import type {
2+
EnvironmentGitHubIssueListEntry,
3+
MergedGitHubIssueList,
4+
} from "@t3tools/client-runtime/state/github-issues";
5+
import type { GitHubIssueListInput } from "@t3tools/contracts";
6+
7+
/**
8+
* Which projects a question covers, leaving out the state and search that narrow it. Rows read for
9+
* one scope can stand in for another question in the same scope; rows from other projects cannot.
10+
*/
11+
export function gitHubIssueListScope(
12+
targets: ReadonlyArray<{ readonly environmentId: string; readonly input: GitHubIssueListInput }>,
13+
): string {
14+
return JSON.stringify(
15+
targets.map((target) => [target.environmentId, target.input.projectId ?? null]),
16+
);
17+
}
18+
19+
/** Free-text terms only: a qualifier like `label:bug` is GitHub's to apply, not this list's. */
20+
function searchTerms(query: string): ReadonlyArray<string> {
21+
return query
22+
.toLowerCase()
23+
.split(/\s+/)
24+
.filter((term) => term.length > 0 && !term.includes(":"));
25+
}
26+
27+
function entryMatches(entry: EnvironmentGitHubIssueListEntry, terms: ReadonlyArray<string>) {
28+
if (terms.length === 0) return true;
29+
const text = [
30+
`#${entry.number}`,
31+
entry.title,
32+
entry.repository,
33+
entry.author?.login ?? "",
34+
...entry.labels.map((label) => label.name),
35+
]
36+
.join(" ")
37+
.toLowerCase();
38+
return terms.every((term) => text.includes(term));
39+
}
40+
41+
/**
42+
* Rows already read, narrowed to what the question on its way could still show, so the list
43+
* narrows in place while GitHub answers instead of blanking to skeletons.
44+
*
45+
* Only a stand-in: GitHub also searches bodies and comments, so its answer may hold more. Null
46+
* when nothing held fits, because an empty list would claim "no issues" before GitHub has said so.
47+
*/
48+
export function carryGitHubIssueList(
49+
held: MergedGitHubIssueList,
50+
input: Pick<GitHubIssueListInput, "state" | "query">,
51+
): MergedGitHubIssueList | null {
52+
const terms = searchTerms(input.query ?? "");
53+
const entries = held.entries.filter(
54+
(entry) => (input.state === "all" || entry.state === input.state) && entryMatches(entry, terms),
55+
);
56+
if (entries.length === 0) return null;
57+
return { entries, errors: [], environmentErrors: [], truncated: false };
58+
}

‎apps/web/src/state/githubIssues.ts‎

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ import type {
88
GitHubIssueListInput,
99
GitHubIssueListResult,
1010
} from "@t3tools/contracts";
11-
import { useMemo } from "react";
11+
import { useMemo, useState } from "react";
1212

13+
import {
14+
carryGitHubIssueList,
15+
gitHubIssueListScope,
16+
} from "../components/githubIssue/githubIssueListCarry.logic";
1317
import { connectionAtomRuntime } from "../connection/runtime";
1418
import type { EnvironmentQueryTarget } from "./pullRequests";
1519
import { createMergedEnvironmentQueryFork } from "./pullRequests.fork";
@@ -31,18 +35,42 @@ const useGitHubIssueListsQuery = createMergedEnvironmentQueryFork<
3135
GitHubIssueListResult
3236
>("web-github-issues:list", githubIssueEnvironment.list);
3337

38+
/**
39+
* The merged list for these targets. A new state or search is a new query that starts empty, so
40+
* while it travels the last answer for the same projects stands in, narrowed to what the new
41+
* question could show, and `carried` says so.
42+
*/
3443
export function useGitHubIssueList(targets: ReadonlyArray<GitHubIssueQueryTarget>): {
3544
readonly data: MergedGitHubIssueList | null;
45+
readonly carried: boolean;
3646
readonly isPending: boolean;
3747
readonly refresh: () => void;
3848
} {
3949
const query = useGitHubIssueListsQuery(targets);
40-
const data = useMemo(
50+
const answered = useMemo(
4151
() =>
4252
query.values.length === 0 && query.errors.length === 0
4353
? null
4454
: mergeGitHubIssueLists(query.values, query.errors),
4555
[query.errors, query.values],
4656
);
47-
return { data, isPending: query.isPending, refresh: query.refresh };
57+
const scope = gitHubIssueListScope(targets);
58+
const [held, setHeld] = useState<{ scope: string; list: MergedGitHubIssueList } | null>(null);
59+
if (answered !== null && (held?.list !== answered || held.scope !== scope)) {
60+
setHeld({ scope, list: answered });
61+
}
62+
const input = targets[0]?.input;
63+
const carried = useMemo(
64+
() =>
65+
answered === null && query.isPending && input && held?.scope === scope
66+
? carryGitHubIssueList(held.list, input)
67+
: null,
68+
[answered, held, input, query.isPending, scope],
69+
);
70+
return {
71+
data: answered ?? carried,
72+
carried: carried !== null,
73+
isPending: query.isPending,
74+
refresh: query.refresh,
75+
};
4876
}

0 commit comments

Comments
 (0)