Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

fix(github): one issue closed as 'duplicate' no longer stops a repository syncing

reviewccd8760897a5
diff --git a/src/core/github/client.test.ts b/src/core/github/client.test.ts
index 83a5d4716..787645c99 100644
--- a/src/core/github/client.test.ts
+++ b/src/core/github/client.test.ts
@@ -357,4 +357,27 @@ describe('GitHubIssuesClient', () => {
expect(bodies).toEqual([])
})
})
+ describe('state_reason values GitHub adds later', () => {
+ const list = (reason: unknown) => new GitHubIssuesClient({
+ token: 'secret',
+ fetch: async () => response([issue(1), issue(2, { state: 'closed', state_reason: reason })])
+ }).listIssues('nodeterm/nodeterm', { state: 'all', page: 1, perPage: 50 })
+
+ it('decodes a duplicate instead of failing the whole page', async () => {
+ // Measured 2026-09-29: one of cli/cli's last 100 closed issues carries it. Rejecting it made
+ // the scan fail as malformed, and that repository never synced at all.
+ const page = await list('duplicate')
+ expect(page.items.map((item) => item.stateReason)).toEqual([null, 'duplicate'])
+ })
+
+ it('reads a reason it does not know yet as no reason, keeping the rest of the page', async () => {
+ const page = await list('some_future_reason')
+ expect(page.items.map((item) => item.number)).toEqual([1, 2])
+ expect(page.items[1].stateReason).toBeNull()
+ })
+
+ it('still rejects a state_reason that is not a string at all', async () => {
+ await expect(list(7)).rejects.toMatchObject({ code: 'malformed-response' })
+ })
+ })
})
diff --git a/src/core/github/client.ts b/src/core/github/client.ts
index 65262421a..0d8ca3940 100644
--- a/src/core/github/client.ts
+++ b/src/core/github/client.ts
@@ -115,15 +115,24 @@ function pullFrom(item: Record<string, unknown>): GitHubPullMeta | null | undefi
return { draft: item.draft === true, mergedAt: (mergedAt ?? null) as string | null }
}
+const KNOWN_STATE_REASONS: ReadonlySet<string> = new Set(['completed', 'not_planned', 'reopened', 'duplicate'])
+
+/** GitHub grows this enum (`duplicate` arrived after the decoder was written, and one such issue
+ * failed the WHOLE scan as malformed, so that repository never synced). A value we do not know
+ * yet is read as "no reason" — the issue itself is perfectly valid. */
+function stateReasonFrom(value: unknown): GitHubIssue['stateReason'] {
+ return typeof value === 'string' && KNOWN_STATE_REASONS.has(value)
+ ? value as GitHubIssue['stateReason']
+ : null
+}
+
function issueFrom(value: unknown): GitHubIssue | null {
const item = object(value)
if (!item || !positiveInteger(Number(item.id), Number.MAX_SAFE_INTEGER) ||
!positiveInteger(Number(item.number), Number.MAX_SAFE_INTEGER) ||
!string(item.title, 1_024) || !(item.body === null || string(item.body, 1_000_000)) ||
(item.state !== 'open' && item.state !== 'closed') ||
- !(item.state_reason === null || item.state_reason === undefined ||
- item.state_reason === 'completed' || item.state_reason === 'not_planned' ||
- item.state_reason === 'reopened') ||
+ !(item.state_reason === null || item.state_reason === undefined || string(item.state_reason, 64)) ||
!string(item.html_url, 2_048) || !string(item.url, 2_048) ||
!Array.isArray(item.labels) || item.labels.length > 100 ||
!Array.isArray(item.assignees) || item.assignees.length > 100 ||
@@ -150,7 +159,7 @@ function issueFrom(value: unknown): GitHubIssue | null {
title: item.title,
body: item.body ?? '',
state: item.state,
- stateReason: (item.state_reason ?? null) as GitHubIssue['stateReason'],
+ stateReason: stateReasonFrom(item.state_reason),
htmlUrl: html.toString(),
apiUrl: api.toString(),
labels: labels as GitHubIssueLabel[],
diff --git a/src/shared/github-issues.ts b/src/shared/github-issues.ts
index d7ca5af29..d0b6c84d7 100644
--- a/src/shared/github-issues.ts
+++ b/src/shared/github-issues.ts
@@ -115,7 +115,8 @@ export interface GitHubIssue {
title: string
body: string
state: 'open' | 'closed'
- stateReason: 'completed' | 'not_planned' | 'reopened' | null
+ /** `null` also stands for a reason GitHub added after this build (see `stateReasonFrom`). */
+ stateReason: 'completed' | 'not_planned' | 'reopened' | 'duplicate' | null
htmlUrl: string
apiUrl: string
labels: GitHubIssueLabel[]