Skip to content

Commit 7c7faf7

Browse files
donjor-agent[bot]rsi-pr-agent
authored andcommitted
fix(issues): persist controls, show parents, and search all issues (#1744)
## Problem Issues list controls reset on remount, detail panels omit the parent, and filters/order only affect a capped page. Closes #151. Closes #152. Closes #153. ## Change - **Controls:** persist order and filters. - **Parent:** show it and follow it in place. - **Search:** filter before page selection. - **Order:** retain client cross-project merging. - **Footer:** describe capped results. The existing search operation now accepts filter and sort qualifiers, using `ISSUE_ADVANCED` for native issue types. Labels retain OR inclusion and AND exclusion; multiple types use grouped OR. Local narrowing remains as a compatibility fallback for older servers that ignore `listViewFork`; those servers still filter only their returned page. **Reaction limitation:** GitHub supports total or individual reaction sorts, not the client's positive/negative sums. Both reaction controls request `sort:reactions-asc/desc`, then preserve aggregate ordering locally. The footer only says “More issues match than are shown.” No filter semantics were intentionally dropped. Qualifier references: [issue filters](https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/filtering-and-searching-issues-and-pull-requests), [search qualifiers](https://docs.github.com/en/search-github/searching-on-github/searching-issues-and-pull-requests), and [sort qualifiers](https://docs.github.com/en/search-github/getting-started-with-searching-on-github/sorting-search-results). ## Scope and approval The maintainer approved these three Issues fixes as one PR in the implementation brief, including server qualifiers and retained client merging. Web and desktop share this surface; optional wire fields preserve older-client decoding. No provider, server runtime, or upstream publication changes. ## Verification - [x] **Tests:** 145 passed, 0 failed. - [x] **Types:** web/server/contracts, exit 0. - [x] **Build:** web production, exit 0. - [x] **Gate:** `vp run fork:ci`, exit 0. - [ ] **Host:** browser grounding and UI evidence. Tests cover search query construction, an older issue selected by comment rank, parent decoding, restored local matching, and preferences restored after a remount. The mocked parent-panel test is removed; the host owns real-browser parent display and navigation verification. No browser or development server was started; this PR remains draft for the host's integrated verification. Implementation: gpt-6.1-sol in Pi; host: claude-opus-5-5 in Claude Code. ## Fork trailers Squashes: - 7b7b88e fix(issues): persist controls, show parents, and search all issues (#1744) (#1744) - 185c96d fixup! fix(issues): persist controls, show parents, and search all issues (#1744) (#1744) Fork-Domain: github-issues Fork-Tier: bugfix Fork-Upstreamable: no
1 parent cdd21bc commit 7c7faf7

12 files changed

Lines changed: 350 additions & 74 deletions

‎apps/server/src/githubIssue/GitHubIssueService.fork.test.ts‎

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,66 @@ describe("GitHubIssueService detail sub-issue reasons", () => {
141141
),
142142
);
143143

144+
it.effect("selects and decodes the parent without an extra read", () =>
145+
Effect.gen(function* () {
146+
const payload = JSON.parse(detailPayload([]));
147+
payload.data.repository.issue.parent = { ...openChild, title: "Parent tracker" };
148+
const graphql = vi.fn<GitHubApi.GitHubApi["Service"]["graphql"]>(() =>
149+
Effect.succeed(JSON.stringify(payload)),
150+
);
151+
const detail = yield* makeDetailService(graphql);
152+
assert.include(
153+
graphql.mock.calls[0]?.[0].query ?? "",
154+
"parent { number title url state stateReason }",
155+
);
156+
assert.deepStrictEqual(detail.parent, {
157+
...openChild,
158+
title: "Parent tracker",
159+
state: "open",
160+
closeReason: null,
161+
});
162+
assert.lengthOf(graphql.mock.calls, 1);
163+
}),
164+
);
165+
166+
it.effect("uses advanced search for issue types and preserves an older ranked issue", () =>
167+
Effect.gen(function* () {
168+
const row = JSON.parse(detailPayload([])).data.repository.issue;
169+
const graphql = vi.fn<GitHubApi.GitHubApi["Service"]["graphql"]>(() =>
170+
Effect.succeed(
171+
JSON.stringify({
172+
data: {
173+
search: {
174+
nodes: Array.from({ length: 51 }, (_, index) => ({
175+
...row,
176+
number: index + 1,
177+
title: `Issue ${index + 1}`,
178+
updatedAt: index === 50 ? "2025-01-01T00:00:00Z" : row.updatedAt,
179+
comments: { totalCount: index === 50 ? 100 : 0 },
180+
})).toSorted((left, right) => right.comments.totalCount - left.comments.totalCount),
181+
},
182+
},
183+
}),
184+
),
185+
);
186+
const service = yield* makeService([project("p1")], graphql);
187+
const list = yield* service.list({
188+
state: "open",
189+
listViewFork: {
190+
filters: [{ field: "type", operator: "is", values: ["Bug"] }],
191+
order: { sort: "comments", direction: "desc" },
192+
},
193+
});
194+
assert.strictEqual(graphql.mock.calls[0]?.[0].variables?.type, "ISSUE_ADVANCED");
195+
assert.strictEqual(
196+
graphql.mock.calls[0]?.[0].variables?.query,
197+
'repo:acme/web is:issue state:open type:"Bug" sort:comments-desc',
198+
);
199+
assert.strictEqual(list.entries[0]?.number, 51);
200+
assert.lengthOf(list.entries, 50);
201+
}),
202+
);
203+
144204
it.effect("attaches a closed child's reason with exactly one graphql read", () =>
145205
Effect.gen(function* () {
146206
const graphql = vi.fn<GitHubApi.GitHubApi["Service"]["graphql"]>((call) =>

‎apps/server/src/githubIssue/GitHubIssueService.ts‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
type GitHubIssueSummary,
3535
} from "./gitHubIssueJson.ts";
3636
import { attachSubIssueCloseReasons } from "./subIssueCloseReasons.fork.ts";
37+
import { gitHubIssueSearchQueryFork, compareGitHubIssuesFork } from "./listView.fork.ts";
3738

3839
const DEFAULT_LIMIT = 50;
3940
const PROJECT_CONCURRENCY = 8;
@@ -52,9 +53,9 @@ const ISSUE_ACTOR_SELECTION =
5253
"login ... on User { name avatarUrl } ... on Organization { name avatarUrl }";
5354
const ISSUE_BASE_SELECTION = `number title url author { ${ISSUE_ACTOR_SELECTION} } assignees(first: 100) { nodes { login name avatarUrl } } labels(first: 100) { nodes { name color } } issueType { name color } state stateReason createdAt updatedAt reactionGroups { content users { totalCount } }`;
5455
const ISSUE_SUMMARY_SELECTION = "title state stateReason";
55-
const ISSUE_DETAIL_SELECTION = `${ISSUE_BASE_SELECTION} body subIssues(first: 100) { nodes { number title url state stateReason } } closedAt comments(last: ${DETAIL_COMMENT_LIMIT}) { totalCount nodes { id author { ${ISSUE_ACTOR_SELECTION} } body createdAt updatedAt url } }`;
56+
const ISSUE_DETAIL_SELECTION = `${ISSUE_BASE_SELECTION} body parent { number title url state stateReason } subIssues(first: 100) { nodes { number title url state stateReason } } closedAt comments(last: ${DETAIL_COMMENT_LIMIT}) { totalCount nodes { id author { ${ISSUE_ACTOR_SELECTION} } body createdAt updatedAt url } }`;
5657

57-
const ISSUE_SEARCH_QUERY = `query($query:String!,$first:Int!){search(query:$query,type:ISSUE,first:$first){nodes{... on Issue{${ISSUE_BASE_SELECTION} comments{totalCount}}}}}`;
58+
const ISSUE_SEARCH_QUERY = `query($query:String!,$first:Int!,$type:SearchType!){search(query:$query,type:$type,first:$first){nodes{... on Issue{${ISSUE_BASE_SELECTION} comments{totalCount}}}}}`;
5859
const ISSUE_DETAIL_QUERY = `query($owner:String!,$name:String!,$number:Int!){repository(owner:$owner,name:$name){issue(number:$number){${ISSUE_DETAIL_SELECTION}}}}`;
5960
const ISSUE_SUMMARY_QUERY = `query($owner:String!,$name:String!,$number:Int!){repository(owner:$owner,name:$name){issue(number:$number){${ISSUE_SUMMARY_SELECTION}}}}`;
6061
const ISSUE_ID_QUERY = `query($owner:String!,$name:String!,$number:Int!){repository(owner:$owner,name:$name){issue(number:$number){id}}}`;
@@ -80,6 +81,7 @@ const GraphQlIssueRow = Schema.Struct({
8081
updatedAt: Schema.String,
8182
reactionGroups: Schema.NullOr(Schema.Array(Schema.Unknown)),
8283
body: Schema.optional(Schema.String),
84+
parent: Schema.optional(Schema.NullOr(Schema.Unknown)),
8385
subIssues: Schema.optional(Schema.Struct({ nodes: Schema.Array(Schema.Unknown) })),
8486
closedAt: Schema.optional(Schema.NullOr(Schema.String)),
8587
comments: Schema.optional(
@@ -212,6 +214,7 @@ function toRawIssue(row: GraphQlIssueRowType): Record<string, unknown> {
212214
updatedAt: row.updatedAt,
213215
reactionGroups: row.reactionGroups,
214216
...(row.body === undefined ? {} : { body: row.body }),
217+
...(row.parent === undefined ? {} : { parent: row.parent }),
215218
...(row.subIssues === undefined ? {} : { subIssues: row.subIssues }),
216219
...(row.closedAt === undefined ? {} : { closedAt: row.closedAt }),
217220
// A list row asks for the count alone; a detail row carries the newest window's nodes.
@@ -278,13 +281,7 @@ export const make = Effect.gen(function* () {
278281
* qualifier stays `OWNER/REPO`; a host-qualified one matches nothing.
279282
*/
280283
const searchQueryFor = (project: GitHubProject, input: GitHubIssueListInput): string =>
281-
[
282-
`repo:${project.repository}`,
283-
"is:issue",
284-
...(input.state === "all" ? [] : [`state:${input.state}`]),
285-
...(input.query === undefined ? [] : [input.query]),
286-
"sort:updated-desc",
287-
].join(" ");
284+
gitHubIssueSearchQueryFork(project.repository, input);
288285

289286
/** One repository's search page, decoded, with each row's true comment count beside it. */
290287
const readSearchRows = Effect.fn("GitHubIssueService.readSearchRows")(function* (input: {
@@ -300,6 +297,9 @@ export const make = Effect.gen(function* () {
300297
variables: {
301298
query: searchQueryFor(input.project, input.listInput),
302299
first: Math.min(input.limit + 1, SEARCH_PAGE_MAX),
300+
type: input.listInput.listViewFork?.filters.some((filter) => filter.field === "type")
301+
? "ISSUE_ADVANCED"
302+
: "ISSUE",
303303
},
304304
})
305305
.pipe(Effect.mapError(fromApiError("list", input.project.host)));
@@ -359,8 +359,8 @@ export const make = Effect.gen(function* () {
359359
});
360360
}
361361
}
362-
const sortedEntries = entries.toSorted(
363-
(left, right) => Date.parse(right.updatedAt) - Date.parse(left.updatedAt),
362+
const sortedEntries = entries.toSorted((left, right) =>
363+
compareGitHubIssuesFork(left, right, input.listViewFork?.order),
364364
);
365365
truncated ||= sortedEntries.length > limit;
366366
return { entries: sortedEntries.slice(0, limit), errors, truncated };

‎apps/server/src/githubIssue/gitHubIssueJson.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ const RawIssue = Schema.Struct({
7373
// CLIs omit them entirely, so both stay optional rather than failing a whole project's batch.
7474
issueType: Schema.optional(Schema.NullOr(RawIssueType)),
7575
subIssues: Schema.optional(Schema.NullOr(Schema.Struct({ nodes: Schema.Array(RawSubIssue) }))),
76+
parent: Schema.optional(Schema.NullOr(RawSubIssue)),
7677
state: Schema.String,
7778
// A close reason in GitHub's GraphQL words; gh versions before it asked for `stateReason` omit
7879
// the key entirely, which an absent reason must survive.
@@ -106,6 +107,7 @@ const NormalizedIssueDetail = Schema.Struct({
106107
body: Schema.String,
107108
comments: Schema.Array(GitHubIssueComment),
108109
subIssues: Schema.Array(GitHubSubIssue),
110+
parent: Schema.NullOr(GitHubSubIssue),
109111
closedAt: Schema.NullOr(IsoDateTime),
110112
});
111113

@@ -233,6 +235,7 @@ function normalizeIssueDetail(decoded: RawGitHubIssue) {
233235
body: decoded.body ?? "",
234236
comments: (decoded.comments ?? []).map(comment),
235237
subIssues: (decoded.subIssues?.nodes ?? []).map(subIssue),
238+
parent: decoded.parent == null ? null : subIssue(decoded.parent),
236239
closedAt:
237240
decoded.closedAt === null || decoded.closedAt === undefined
238241
? null
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import type { GitHubIssueListInput } from "@t3tools/contracts";
2+
import { describe, expect, it } from "vite-plus/test";
3+
4+
import { gitHubIssueSearchQueryFork } from "./listView.fork.ts";
5+
6+
const input = (
7+
filters: NonNullable<GitHubIssueListInput["listViewFork"]>["filters"],
8+
sort: NonNullable<GitHubIssueListInput["listViewFork"]>["order"]["sort"] = "updated",
9+
direction: "asc" | "desc" = "desc",
10+
): GitHubIssueListInput => ({
11+
state: "open",
12+
query: "cache",
13+
listViewFork: { filters, order: { sort, direction } },
14+
});
15+
16+
describe("Issues search qualifiers", () => {
17+
it("combines search text with type and OR labels before page selection", () => {
18+
expect(
19+
gitHubIssueSearchQueryFork(
20+
"acme/web",
21+
input([
22+
{ field: "type", operator: "is", values: ["Bug"] },
23+
{ field: "label", operator: "is", values: ["ui", "help wanted"] },
24+
]),
25+
),
26+
).toBe(
27+
'repo:acme/web is:issue state:open cache type:"Bug" label:"ui","help wanted" sort:updated-desc',
28+
);
29+
});
30+
it("excludes every selected value rather than ANDing included values", () => {
31+
expect(
32+
gitHubIssueSearchQueryFork(
33+
"acme/web",
34+
input([
35+
{ field: "type", operator: "is-not", values: ["Bug", "Feature"] },
36+
{ field: "label", operator: "is-not", values: ["ui", "dx"] },
37+
]),
38+
),
39+
).toBe(
40+
'repo:acme/web is:issue state:open cache -type:"Bug" -type:"Feature" -label:"ui" -label:"dx" sort:updated-desc',
41+
);
42+
});
43+
it("groups multiple types as OR without widening the repository or label scope", () => {
44+
expect(
45+
gitHubIssueSearchQueryFork(
46+
"acme/web",
47+
input([{ field: "type", operator: "is", values: ["Bug", "Feature"] }]),
48+
),
49+
).toContain('(type:"Bug" OR type:"Feature")');
50+
});
51+
it.each(["created", "updated", "comments", "reactions-positive", "reactions-negative"] as const)(
52+
"sends both directions of %s to GitHub",
53+
(sort) => {
54+
for (const direction of ["asc", "desc"] as const) {
55+
const query = gitHubIssueSearchQueryFork("acme/web", input([], sort, direction));
56+
expect(query).toContain(
57+
`sort:${sort.startsWith("reactions-") ? "reactions" : sort}-${direction}`,
58+
);
59+
expect(query.match(/sort:/g)).toHaveLength(1);
60+
}
61+
},
62+
);
63+
it("keeps the ordinary empty-text search path and all-state scope", () => {
64+
expect(gitHubIssueSearchQueryFork("acme/web", { state: "all" })).toBe(
65+
"repo:acme/web is:issue sort:updated-desc",
66+
);
67+
});
68+
});
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import type {
2+
GitHubIssueListEntry,
3+
GitHubIssueListInput,
4+
GitHubIssueListViewFork,
5+
} from "@t3tools/contracts";
6+
7+
export function compareGitHubIssuesFork(
8+
left: GitHubIssueListEntry,
9+
right: GitHubIssueListEntry,
10+
order: GitHubIssueListViewFork["order"] = { sort: "updated", direction: "desc" },
11+
): number {
12+
const value = (entry: GitHubIssueListEntry) => {
13+
switch (order.sort) {
14+
case "created":
15+
return Date.parse(entry.createdAt);
16+
case "updated":
17+
return Date.parse(entry.updatedAt);
18+
case "comments":
19+
return entry.commentCount ?? 0;
20+
case "reactions-positive":
21+
return entry.reactions?.positive ?? 0;
22+
case "reactions-negative":
23+
return entry.reactions?.negative ?? 0;
24+
}
25+
};
26+
const difference = value(left) - value(right);
27+
const tie =
28+
order.sort === "updated" && order.direction === "desc" ? 0 : left.number - right.number;
29+
return (order.direction === "desc" ? -1 : 1) * (difference || tie);
30+
}
31+
32+
/** Qualifiers apply before GitHub selects its search page, including for an empty text query. */
33+
export function gitHubIssueSearchQueryFork(
34+
repository: string,
35+
input: GitHubIssueListInput,
36+
): string {
37+
const filters = (input.listViewFork?.filters ?? []).flatMap((filter) => {
38+
const values = filter.values.map((value) => JSON.stringify(value));
39+
if (values.length === 0) return [];
40+
if (filter.operator === "is-not") {
41+
return values.map((value) => `-${filter.field}:${value}`);
42+
}
43+
// Comma-separated labels are OR; types use the documented boolean grouping.
44+
return [
45+
filter.field === "label"
46+
? `label:${values.join(",")}`
47+
: values.length === 1
48+
? `type:${values[0]}`
49+
: `(${values.map((value) => `type:${value}`).join(" OR ")})`,
50+
];
51+
});
52+
const order = input.listViewFork?.order ?? { sort: "updated", direction: "desc" };
53+
// GitHub cannot sort the positive/negative sums exposed by the client. Total reactions
54+
// selects candidates across the repository; the client retains its aggregate ordering.
55+
const sort = order.sort.startsWith("reactions-") ? "reactions" : order.sort;
56+
return [
57+
`repo:${repository}`,
58+
"is:issue",
59+
...(input.state === "all" ? [] : [`state:${input.state}`]),
60+
...(input.query === undefined ? [] : [input.query]),
61+
...filters,
62+
`sort:${sort}-${order.direction}`,
63+
].join(" ");
64+
}

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,16 @@ export function GitHubIssueDetailContent({
332332
/>
333333
</GitHubIssueSection>
334334

335+
{detail.parent ? (
336+
<GitHubIssueSection key={`parent:${detail.url}`} title="Parent">
337+
<GitHubSubIssueRow
338+
child={detail.parent}
339+
repository={gitHubSubIssueRepository(detail.parent.url) ?? detail.repository}
340+
{...(onSelectSubIssue ? { onSelect: onSelectSubIssue } : {})}
341+
/>
342+
</GitHubIssueSection>
343+
) : null}
344+
335345
{subIssues.length > 0 ? (
336346
<GitHubIssueSection
337347
key={`sub-issues:${detail.url}`}
@@ -503,7 +513,7 @@ function GitHubIssueSection({
503513
*/
504514
const SUB_ISSUE_REPOSITORY = /^https?:\/\/[^/]+\/([^/]+\/[^/]+)\/issues\/\d+/;
505515

506-
function gitHubSubIssueRepository(url: string): string | null {
516+
export function gitHubSubIssueRepository(url: string): string | null {
507517
return SUB_ISSUE_REPOSITORY.exec(url)?.[1] ?? null;
508518
}
509519

‎apps/web/src/components/githubIssue/GitHubIssueDetailSurface.fork.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { ScopedThreadRef } from "@t3tools/contracts";
66

77
import { useRightPanelStore } from "../../rightPanelStore";
88
import type { GitHubIssueSurfaceFork } from "../../rightPanelStore.fork";
9-
import { GitHubIssueDetailPanel } from "./GitHubIssueDetailPanel";
9+
import { GitHubIssueDetailPanel, gitHubSubIssueRepository } from "./GitHubIssueDetailPanel";
1010
import { GitHubIssueEmptyState } from "./GitHubIssueEmptyState";
1111
import { GitHubIssueDetailGhost } from "./GitHubIssueGhosts";
1212

@@ -46,7 +46,7 @@ export function GitHubIssueDetailSurfaceFork(props: {
4646
useRightPanelStore.getState().openGitHubIssue(props.activeThreadRef, {
4747
environmentId: surface.environmentId,
4848
projectId: surface.projectId,
49-
repository: surface.repository,
49+
repository: gitHubSubIssueRepository(child.url) ?? surface.repository,
5050
number: child.number,
5151
});
5252
}}

‎apps/web/src/components/githubIssue/GitHubIssueListView.logic.ts‎

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
import type { EnvironmentGitHubIssueListEntry } from "@t3tools/client-runtime/state/github-issues";
22
import type { GitHubIssueLabel, GitHubIssueType } from "@t3tools/contracts";
33

4-
/**
5-
* Ordering and narrowing applied to the list the server already returned. The server sorts by
6-
* update time and caps each project at fifty, so these only reorder and hide what is on screen —
7-
* a narrowed list can never reach past that cap.
8-
*/
4+
/** GitHub search applies filters first; local narrowing also supports older servers. */
95

106
/**
117
* GitHub splits ordering in two: which field to sort on, then which end to start from. Borrowing
128
* that split keeps the menu four rows long instead of eight, and it means "newest" and "oldest"
139
* are one control rather than a pair of near-identical rows.
1410
*
15-
* `Best match` is GitHub's own and is deliberately absent: relevance is the search backend's
16-
* ranking, and this list re-sorts a page it has already been handed.
11+
* `Best match` is deliberately absent: the selected field also orders the merged project pages.
1712
*/
1813
export const GITHUB_ISSUE_SORTS = [
1914
{ value: "created", label: "Created on" },
@@ -133,9 +128,7 @@ export function toggleGitHubIssueNarrowing(
133128
}
134129

135130
/**
136-
* The types and labels present in this list, which is what the filter menu offers. Drawn from the
137-
* fetched entries rather than the repository, so the menu can never offer a choice that empties
138-
* the list. Each keeps its colour, so a menu row and a list row wear the same chip.
131+
* The filter menu offers types and labels from the current results, keeping their colours.
139132
*/
140133
export function gitHubIssueFacets(entries: ReadonlyArray<EnvironmentGitHubIssueListEntry>): {
141134
readonly types: ReadonlyArray<GitHubIssueType>;

0 commit comments

Comments
 (0)