Skip to content

Commit a743556

Browse files
donjor-agent[bot]rsi-pr-agent
authored andcommitted
fix(web): issues and links closed as not planned no longer show the merged or completed purple
## What Changed Issue reads carry GitHub's close reason; a closed issue that did not land drops the merged purple. | Layer | Change | | --- | --- | | Contracts | optional `closeReason` on list and detail entries | | Server | reads `stateReason`; maps completed and not planned | | Web | not planned and missing reason use the draft grey | `REOPENED`, duplicate, and unknown reasons read as none, so they show grey. Sub-issues and thread-link snapshots keep the completed tone: `gh` sends no `stateReason` on sub-issue nodes, and snapshots store none. ## Why Every closed issue showed the merged purple, even one closed as not planned, which GitHub shows in grey. Closes #1449 ## Close conditions - [x] **Reason:** issue reads carry the close reason - [x] **Completed:** stays purple - [x] **Not planned:** shows a neutral tone - [x] **Older server:** a missing reason shows neutral The older-server case is covered by the presentation test; an upstream client still decodes the entries. ## Checks ```text vp test run <touched tests> → exit 0 (40 passed) vp test run <adjacent issue tests> → exit 0 (103 passed) vp test run upstream-client-compat → exit 0 (7 passed) typecheck contracts, server, web → exit 0 vp run knip:check → exit 0 vp run fork:ci → exit 0 ``` ## Evidence Closed issues on `/issues`: #1450 (not planned) in grey between completed issues in purple. ![closed-rows-crop.png](https://github.com/user-attachments/assets/7914d5a9-5514-499f-b7e1-53f7c4d0756a) Full list, where #1443 (duplicate) is grey too: ![closed-list-hidpi.png](https://github.com/user-attachments/assets/66bd8437-f408-47bb-836d-7112c9af9363) ## 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 Before, every closed glyph was purple. No motion changed. Pi peer worker, hosted by Opus 5.5 via Claude Code in T3 Code. ## Fork trailers Squashes: - 8527cad fix(web): issues and links closed as not planned no longer show the merged or completed purple (#1456) (#1463) - 373225c test(web): the issue detail draft fixture carries upstream's threadContexts Fork-Domain: github-issues Fork-Tier: bugfix Fork-Upstreamable: no
1 parent a75bcda commit a743556

17 files changed

Lines changed: 520 additions & 35 deletions

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

Lines changed: 124 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import * as ProjectService from "../project/ProjectService.ts";
1111
import * as RepositoryIdentityResolver from "../project/RepositoryIdentityResolver.ts";
1212
import * as GitHubCli from "../sourceControl/GitHubCli.ts";
1313
import * as GitHubIssueService from "./GitHubIssueService.ts";
14+
import { SUB_ISSUE_REASONS_QUERY } from "./subIssueCloseReasons.fork.ts";
1415

1516
function project(id: string): OrchestrationProjectShell {
1617
return {
@@ -69,10 +70,14 @@ function makeService(
6970
}
7071

7172
describe("GitHubIssueService summary", () => {
72-
it.effect("reads only the title and state a linked-issue sync stores", () =>
73+
it.effect("reads only the fields a linked-issue sync stores", () =>
7374
Effect.gen(function* () {
7475
const execute = vi.fn<GitHubCli.GitHubCli["Service"]["execute"]>(() =>
75-
Effect.succeed(output(JSON.stringify({ title: "Issue 42", state: "OPEN" }))),
76+
Effect.succeed(
77+
output(
78+
JSON.stringify({ title: "Issue 42", state: "CLOSED", stateReason: "NOT_PLANNED" }),
79+
),
80+
),
7681
);
7782
const service = yield* makeService([project("p1")], execute);
7883

@@ -89,9 +94,124 @@ describe("GitHubIssueService summary", () => {
8994
"--repo",
9095
"github.com/acme/web",
9196
"--json",
92-
"title,state",
97+
"title,state,stateReason",
98+
]);
99+
assert.deepStrictEqual(summary, {
100+
title: "Issue 42",
101+
state: "closed",
102+
closeReason: "not planned",
103+
});
104+
}),
105+
);
106+
});
107+
108+
// One GraphQL read attaches the children's close reasons `gh` omits, fired only when a closed
109+
// child exists (RSI-Software/t3code-hyprws#1461).
110+
describe("GitHubIssueService detail sub-issue reasons", () => {
111+
const detailPayload = (children: ReadonlyArray<Record<string, unknown>>) =>
112+
JSON.stringify({
113+
number: 42,
114+
title: "Parent",
115+
url: "https://github.com/acme/web/issues/42",
116+
author: null,
117+
assignees: [],
118+
labels: [],
119+
state: "OPEN",
120+
createdAt: "2026-08-20T00:00:00Z",
121+
updatedAt: "2026-08-21T00:00:00Z",
122+
closedAt: null,
123+
subIssues: { nodes: children },
124+
});
125+
126+
const closedChild = {
127+
number: 43,
128+
title: "Drop the list",
129+
url: "https://github.com/acme/web/issues/43",
130+
state: "CLOSED",
131+
};
132+
const openChild = {
133+
number: 44,
134+
title: "Render the list",
135+
url: "https://github.com/acme/web/issues/44",
136+
state: "OPEN",
137+
};
138+
139+
const makeDetailService = (execute: GitHubCli.GitHubCli["Service"]["execute"]) =>
140+
makeService([project("p1")], execute).pipe(
141+
Effect.flatMap((service) =>
142+
service.detail({ projectId: "p1" as ProjectId, repository: "acme/web", number: 42 }),
143+
),
144+
);
145+
146+
it.effect("attaches a closed child's reason with exactly one graphql read", () =>
147+
Effect.gen(function* () {
148+
const execute = vi.fn<GitHubCli.GitHubCli["Service"]["execute"]>((input) =>
149+
input.args[0] === "issue"
150+
? Effect.succeed(output(detailPayload([closedChild, openChild])))
151+
: Effect.succeed(
152+
output(
153+
JSON.stringify({
154+
data: {
155+
repository: {
156+
issue: { subIssues: { nodes: [{ number: 43, stateReason: "NOT_PLANNED" }] } },
157+
},
158+
},
159+
}),
160+
),
161+
),
162+
);
163+
const detail = yield* makeDetailService(execute);
164+
165+
assert.deepStrictEqual(execute.mock.calls[1]?.[0].args, [
166+
"api",
167+
"graphql",
168+
"--hostname",
169+
"github.com",
170+
"-f",
171+
`query=${SUB_ISSUE_REASONS_QUERY}`,
172+
"-f",
173+
"owner=acme",
174+
"-f",
175+
"name=web",
176+
"-F",
177+
"number=42",
178+
]);
179+
assert.deepStrictEqual(detail.subIssues, [
180+
{ ...closedChild, state: "closed", closeReason: "not planned" },
181+
{ ...openChild, state: "open", closeReason: null },
182+
]);
183+
}),
184+
);
185+
186+
it.effect("skips the graphql read when no sub-issue is closed", () =>
187+
Effect.gen(function* () {
188+
const execute = vi.fn<GitHubCli.GitHubCli["Service"]["execute"]>(() =>
189+
Effect.succeed(output(detailPayload([openChild]))),
190+
);
191+
const detail = yield* makeDetailService(execute);
192+
193+
assert.lengthOf(execute.mock.calls, 1);
194+
assert.deepStrictEqual(detail.subIssues, [
195+
{ ...openChild, state: "open", closeReason: null },
196+
]);
197+
}),
198+
);
199+
200+
it.effect("keeps the detail when the graphql read fails, reason unknown", () =>
201+
Effect.gen(function* () {
202+
const execute = vi.fn<GitHubCli.GitHubCli["Service"]["execute"]>((input) =>
203+
input.args[0] === "issue"
204+
? Effect.succeed(output(detailPayload([closedChild])))
205+
: Effect.fail(
206+
new GitHubCli.GitHubCliCommandError({ command: "gh", cwd: "/web", cause: "boom" }),
207+
),
208+
);
209+
const detail = yield* makeDetailService(execute);
210+
211+
assert.lengthOf(execute.mock.calls, 2);
212+
assert.deepStrictEqual(detail.subIssues, [
213+
{ ...closedChild, state: "closed", closeReason: null },
93214
]);
94-
assert.deepStrictEqual(summary, { title: "Issue 42", state: "open" });
95215
}),
96216
);
97217
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ describe("GitHubIssueService", () => {
123123
"--limit",
124124
"2",
125125
"--json",
126-
"number,title,url,author,assignees,labels,issueType,state,createdAt,updatedAt,comments,reactionGroups",
126+
"number,title,url,author,assignees,labels,issueType,state,stateReason,createdAt,updatedAt,comments,reactionGroups",
127127
"--search",
128128
"websocket sort:updated-desc",
129129
]);

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

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,23 @@ import {
3232
decodeGitHubIssueSummary,
3333
type GitHubIssueSummary,
3434
} from "./gitHubIssueJson.ts";
35+
import { attachSubIssueCloseReasons } from "./subIssueCloseReasons.fork.ts";
3536

3637
const DEFAULT_LIMIT = 50;
3738
const PROJECT_CONCURRENCY = 8;
3839
const DETAIL_COMMENT_LIMIT = 100;
39-
// `issueType` and `subIssues` need a recent `gh`; an older CLI rejects the unknown field name and
40-
// degrades the whole project, which the list already reports per project rather than swallowing.
40+
// `issueType`, `subIssues`, and `stateReason` need a recent `gh`; an older CLI rejects the unknown
41+
// field name and degrades the whole project, which the list already reports per project rather
42+
// than swallowing.
4143
// `comments` is asked for by count alone: `gh` has no count field, and the entry keeps only the
4244
// length, so the cost is one subprocess read rather than anything crossing the socket.
4345
const ISSUE_LIST_FIELDS =
44-
"number,title,url,author,assignees,labels,issueType,state,createdAt,updatedAt,comments,reactionGroups";
46+
"number,title,url,author,assignees,labels,issueType,state,stateReason,createdAt,updatedAt,comments,reactionGroups";
4547
const ISSUE_DETAIL_FIELDS = `${ISSUE_LIST_FIELDS},body,subIssues,closedAt`;
46-
// The linked-issue sync reads this alone: a snapshot stores a title and a state, so refreshing one
47-
// never hauls the body, comments, and reactions a detail read asks for
48-
// (RSI-Software/t3code-hyprws#1451).
49-
const ISSUE_SUMMARY_FIELDS = "title,state";
48+
// The linked-issue sync reads this alone: a snapshot stores a title, a state, and a close
49+
// reason, so refreshing one never hauls the body, comments, and reactions a detail read asks
50+
// for (RSI-Software/t3code-hyprws#1451). `stateReason` rides the same single read.
51+
const ISSUE_SUMMARY_FIELDS = "title,state,stateReason";
5052

5153
type GitHubIssueCliError = GitHubIssueCliMissingError | GitHubIssueCliUnauthenticatedError;
5254
type GitHubIssueError = GitHubIssueCliError | GitHubIssueOperationError;
@@ -272,8 +274,18 @@ export const make = Effect.gen(function* () {
272274
const issue = yield* decodeGitHubIssueDetail(output.stdout).pipe(
273275
Effect.mapError((cause) => decodeError("detail", cause)),
274276
);
277+
// Fork-hook: github-issues/sub-issue-close-reasons — `gh` omits a child's close reason, so
278+
// one extra read attaches it when a closed child exists (RSI-Software/t3code-hyprws#1461).
279+
const subIssues = yield* attachSubIssueCloseReasons(cli, {
280+
host: project.host,
281+
workspaceRoot: project.project.workspaceRoot,
282+
repository: input.repository,
283+
parentNumber: input.number,
284+
children: issue.subIssues,
285+
});
275286
return {
276287
...issue,
288+
subIssues,
277289
comments: issue.comments.slice(-DETAIL_COMMENT_LIMIT),
278290
projectId: project.project.id,
279291
projectTitle: project.project.title,

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function makeThread(id: string, issues: ReadonlyArray<ThreadIssueLink>) {
5757
}
5858

5959
function makeSummary(input: GitHubIssueRef): GitHubIssueSummary {
60-
return { title: `Issue ${input.number}`, state: "closed" };
60+
return { title: `Issue ${input.number}`, state: "closed", closeReason: "not planned" };
6161
}
6262

6363
const makeHarness = Effect.fn("makeThreadIssueSyncHarness")(function* (
@@ -142,6 +142,7 @@ describe("ThreadIssueSyncReactor", () => {
142142
assert.deepStrictEqual(sync?.snapshot, {
143143
title: "Issue 7",
144144
state: "closed",
145+
closeReason: "not planned",
145146
syncedAt: NOW,
146147
});
147148
}),

‎apps/server/src/githubIssue/ThreadIssueSyncReactor.fork.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export const make = Effect.gen(function* () {
8282
const started = yield* DateTime.now;
8383
read.startedAtMs = DateTime.toEpochMillis(started);
8484
inFlight.set(id, read);
85-
// A snapshot stores a title and a state, so the read asks for exactly that.
85+
// A snapshot stores a title, a state, and a close reason, so the read asks for exactly that.
8686
const summary = yield* githubIssues
8787
.summary({
8888
projectId: read.projectId,
@@ -100,6 +100,7 @@ export const make = Effect.gen(function* () {
100100
const snapshot = {
101101
title: summary.value.title,
102102
state: summary.value.state,
103+
closeReason: summary.value.closeReason,
103104
syncedAt: DateTime.formatIso(started),
104105
};
105106
yield* Effect.forEach(

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

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ import * as Exit from "effect/Exit";
44
import * as Schema from "effect/Schema";
55

66
import issue152Fixture from "./__fixtures__/issue-152.json" with { type: "json" };
7-
import { decodeGitHubIssueDetail, decodeGitHubIssueList } from "./gitHubIssueJson.ts";
7+
import {
8+
decodeGitHubIssueDetail,
9+
decodeGitHubIssueList,
10+
decodeGitHubSubIssueReasons,
11+
} from "./gitHubIssueJson.ts";
812

913
const encodeJson = Schema.encodeSync(Schema.fromJsonString(Schema.Unknown));
1014

@@ -103,10 +107,32 @@ describe("GitHub issue JSON", () => {
103107
expect(issue.comments).toStrictEqual([]);
104108
expect(issue.subIssues).toStrictEqual([]);
105109
expect(issue.issueType).toBeNull();
110+
expect(issue.closeReason).toBeNull();
106111
expect(issue.closedAt).toBeNull();
107112
}),
108113
);
109114

115+
it.effect("maps the close reason, reading anything but a real close as none", () =>
116+
Effect.gen(function* () {
117+
const issues = yield* decodeGitHubIssueList(
118+
encodeJson([
119+
{ ...rawIssue, state: "CLOSED", stateReason: "COMPLETED" },
120+
{ ...rawIssue, state: "CLOSED", stateReason: "NOT_PLANNED" },
121+
// GitHub keeps a reopened issue's last close reason; neither word is a close now.
122+
{ ...rawIssue, state: "OPEN", stateReason: "REOPENED" },
123+
{ ...rawIssue, state: "CLOSED" },
124+
]),
125+
);
126+
127+
expect(issues.map((issue) => issue.closeReason)).toStrictEqual([
128+
"completed",
129+
"not planned",
130+
null,
131+
null,
132+
]);
133+
}),
134+
);
135+
110136
it.effect("normalizes the issue type and the sub-issue hierarchy", () =>
111137
Effect.gen(function* () {
112138
const issue = yield* decodeGitHubIssueDetail(
@@ -122,6 +148,14 @@ describe("GitHub issue JSON", () => {
122148
url: `${rawIssue.url.replace("42", "43")}`,
123149
state: "OPEN",
124150
},
151+
{
152+
id: "I_2",
153+
number: 44,
154+
title: "Drop the list",
155+
url: `${rawIssue.url.replace("42", "44")}`,
156+
state: "CLOSED",
157+
stateReason: "NOT_PLANNED",
158+
},
125159
],
126160
},
127161
}),
@@ -134,11 +168,45 @@ describe("GitHub issue JSON", () => {
134168
title: "Render the list",
135169
url: "https://github.com/t3tools/t3code/issues/43",
136170
state: "open",
171+
closeReason: null,
172+
},
173+
{
174+
number: 44,
175+
title: "Drop the list",
176+
url: "https://github.com/t3tools/t3code/issues/44",
177+
state: "closed",
178+
closeReason: "not planned",
137179
},
138180
]);
139181
}),
140182
);
141183

184+
it.effect("keys the graphql sub-issue reasons by child number", () =>
185+
Effect.gen(function* () {
186+
const reasons = yield* decodeGitHubSubIssueReasons(
187+
encodeJson({
188+
data: {
189+
repository: {
190+
issue: {
191+
subIssues: {
192+
nodes: [
193+
{ number: 43, stateReason: "NOT_PLANNED" },
194+
{ number: 44, stateReason: "COMPLETED" },
195+
{ number: 45, stateReason: null },
196+
],
197+
},
198+
},
199+
},
200+
},
201+
}),
202+
);
203+
204+
expect(reasons.get(43)).toBe("not planned");
205+
expect(reasons.get(44)).toBe("completed");
206+
expect(reasons.get(45)).toBeNull();
207+
}),
208+
);
209+
142210
it.effect("rejects a comment missing its URL", () => {
143211
const comment = {
144212
id: "comment-1",

0 commit comments

Comments
 (0)