Repository navigation
test: add setIssueThreadResolved to AppSubmitFailure transport mocks - #317
Merged
Merged
Conversation
This was referenced Sep 20, 2026
nownabe
added a commit
that referenced
this pull request
Sep 20, 2026
…#314) ## Why `parseRightRanges` skipped patch lines starting with `+++` / `---` to avoid unified-diff file headers. GitHub's `patch` field starts at the first `@@` and never contains those headers, so the guards only ever matched real content: an added `+++` (TOML front matter in a Hugo/Zola file) or a removed `---` (Markdown thematic break) was dropped and the new-file line counter was not advanced. Every later line in the hunk was then off by one per dropped line, so in-diff comments were routed to issue comments and out-of-diff ones to the review batch — the latter fails with a GitHub 422. ## What - `lib/pr/diff.ts`: test `line[0] === "+"` / `"-"` unconditionally; the docstring now records why no header filtering is needed. - `tests/pr/diff.test.ts`: two regression cases — a 4-line new file fenced by `+++`, and a removed `---` followed by added lines. All callers of `parseRightRanges` (`buildIsInDiff` and four sites in `entrypoints/review/App.tsx`) feed `ChangedFile.patch` straight from `GET /pulls/{n}/files`, so none of them can pass a full unified diff with headers. ## Red-test evidence Before the fix, `bun run test tests/pr/diff.test.ts`: ``` (fail) diff — parseRightRanges > counts added lines that start with +++ (TOML front matter) error: expect(received).toEqual(expected) - "newEnd": 4, + "newEnd": 2, "newStart": 1, (fail) diff — parseRightRanges > a removed --- line does not stop the counters for the added lines after it error: expect(received).toEqual(expected) - "newEnd": 4, + "newEnd": 3, "newStart": 1, ``` `newEnd: 2` on a 4-line new file is exactly the symptom reported in the issue. After the fix: 10 pass, 0 fail. ## Note `typecheck` is already red on `main` (7e0ecb9) for two unrelated errors in `tests/AppSubmitFailure.test.tsx`. This branch cherry-picks the fix from #317 (`356dc4b`) so CI goes green; that commit disappears on rebase once #317 merges. Closes #284
nownabe
added a commit
that referenced
this pull request
Sep 20, 2026
…paginate (#318) ## Why `fetchPage` cached only `{etag, body}` per page and read the `rel=next` link off whatever response came back. A `304 Not Modified` is not required to repeat the `Link` header, so when GitHub omits it the page walk stops after page 1. On a PR with more than 100 review comments (or changed files), a refresh silently dropped everything after the first page: those comments looked deleted and `mergeRemoteIntoLocal` discarded the synced local copies. ## What - `lib/pr/github-api.ts`: the ETag cache entry now carries `next` alongside `etag`/`body`; `fetchPage` uses the cached `next` on a 304 and falls back to the response header when the entry has none. `next` stays optional because non-paginated GETs (`sendRequest`) share the same cache and never set it. - `tests/pr/github-api.test.ts`: regression test — a 304 without a `Link` header still yields page 2. ## Red-test evidence Before the fix, `bun run test tests/pr/github-api.test.ts`: ``` (fail) github-api — ETag caching > ghPaginate still follows to page 2 when the 304 carries no Link header error: expect(received).toEqual(expected) }, - { - "id": 2, - }, ] ``` The second listing returned only `[{id: 1}]`. After the fix: 18 pass, 0 fail. ## Note `typecheck` is already red on `main` (7e0ecb9) for two unrelated errors in `tests/AppSubmitFailure.test.tsx`. This branch cherry-picks the fix from #317 (`356dc4b`) so CI goes green; that commit disappears on rebase once #317 merges. Closes #286
nownabe
added a commit
that referenced
this pull request
Sep 20, 2026
#319) ## Why Dragging through a line's trailing newline — or triple-clicking a paragraph, the most common way to select one — leaves the CodeMirror selection at the **next** line's first offset. `cmSelectionToAnchor` called `doc.lineAt(to)` on that offset, so a selection of `line1` in `"line1\nline2"` reported `endLine 2, endCol 1`. Two consequences downstream: - The comment is posted as `start_line: N, line: N+1`, spanning a line the reviewer never selected, which lets `isRangeInDiff` flip an in-diff selection to out-of-diff. - Past the file's trailing newline that line does not exist in the file at all, and GitHub rejects the whole review batch with a 422 — not just the offending comment. ## What - `entrypoints/review/cmAnchor.ts`: `endLine` is taken from `lineAt(to - 1)` (a non-empty selection always has `to > from`, so that offset is inside it), and `endCol` clamps to `Math.min(to, endLine.to)`. A selection ending mid-line is unaffected — `to - 1` is still on the same line and the clamp is a no-op — so this only changes the case that was wrong. - `entrypoints/review/AppV2.tsx`: its `onUpdate` hand-rolled the same `lineAt(sel.to)` computation and carried an identical copy of the bug. It now calls `cmSelectionToAnchor` and maps the result, so the fix lives in one place (net −7 lines). - `tests/cmAnchor.test.ts`: first direct tests of `cmSelectionToAnchor` — the whole-line case, the EOF case, and a mid-line selection as a guard that the common path did not move. ## Red test evidence `bun run test tests/cmAnchor.test.ts` before the fix: ``` (fail) cmSelectionToAnchor on a whole-line selection > ends on the selected line, not the one the newline leads into expect(a.endLine).toBe(1) Expected: 1 Received: 2 (fail) cmSelectionToAnchor on a whole-line selection > stays on the last line when the selection ends past the trailing newline expect(a.endLine).toBe(1) Expected: 1 Received: 2 6 pass 2 fail ``` The mid-line guard passed before and after, which is the point of it. ## Checks `bun run test` 697 pass / 0 fail, `check:lint`, `check:format`, `bun run build` all clean. `bun run typecheck` still reports the two pre-existing `tests/AppSubmitFailure.test.tsx` errors that `origin/main` already reports (fixed separately in #317); this branch adds none. Closes #291
nownabe
added a commit
that referenced
this pull request
Sep 20, 2026
## Why ADR 0001 §3 said every failed Executor step returns the entity to `draft`; ADR 0002 §2 says a `draft` never carries a remote identifier. The only `synced → syncing` edge — toggling `Thread.resolved` on a thread that exists on GitHub — broke one of the two on failure, and #188 had to paper over it by letting a `draft` thread with a `remoteThreadId` re-enter `syncing`. ## What - A failed `resolve-review-thread` / `unresolve-review-thread` / `set-issue-thread-resolved` now returns the Thread to `synced` with `lastError` and `resolved` rolled back to the last-known remote value. The Reconciler only emits the step when local differs from remote, so the remote value is exactly `!desired` — no `RemoteState` lookup is needed. The desired-value expression `applyStepResultToRemote` already used is extracted as `desiredResolvedOf` and shared by both. - `revertOrphanedSyncing` (hydrate) applies the same rule: a `syncing` Thread with a remote identity reverts to `synced + lastError` (the bootstrap refresh then overwrites it with GitHub's value); one without reverts to `draft` as before. Comments and FileEdits are unchanged. - `setThreadResolvedToSyncing` drops the `draft && hasRemoteIdentity` branch added for #188: retry after a failure is now the plain `synced → syncing` edge. - ADR 0001 §3, the state diagram, "Failure handling", and ADR 0003 §6 (the 1:1-step and hydrate bullets) are updated to match. No `App.tsx` change is needed: `resolvableThreadKeys` filters on `hasRemoteIdentity` and `reportSubmitErrors` reads `lastError` regardless of state. ## Red-test evidence `bun run test tests/pr/state-machine.test.ts tests/pr/repository.test.ts` before the fix — 5 failures: - `state-machine — applyStepResults: resolve failure (issue #275) > a failed resolve-review-thread returns the Thread to synced with resolved reverted and lastError` → got `{ state: "draft", resolved: true }`, expected `{ state: "synced", resolved: false }`. - `… > a failed unresolve-review-thread reverts resolved back to true` → got `{ state: "draft", resolved: false }`. - `… > a failed set-issue-thread-resolved reverts resolved to the opposite of the step` → got `{ state: "draft", resolved: false }`. - `state-machine — revertOrphanedSyncing > a syncing Thread with a remote identity reverts to synced, one without reverts to draft (issue #275)` → thread `a` came back `state: "draft"`. - `repository — setThreadResolved > a failed resolve leaves the Thread synced and unresolved; the retry succeeds (issues #188, #275)` → after the failed resolve the thread was `{ state: "draft", resolved: true }`. After the fix: 697 pass, 0 fail across 62 files. ## Checks `bun run test` (697 pass / 0 fail), `check:lint`, `check:format`, `typecheck`, `build` — all clean. Rebased on `main` after #317 merged, so the `setIssueThreadResolved` test-mock fix this branch briefly carried is gone; only the commit above remains. Closes #275
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
bun run typecheckis red onmainsince #310 merged: it addedsetIssueThreadResolvedto theTransportinterface, whiletests/AppSubmitFailure.test.tsx(added by #307, which branched before #310) still builds twoTransportmocks without it. Every open PR's CI inherits the failure.What
Add a
setIssueThreadResolvedstub ({ ok: true }) tofailingTransport()andhappyTransport()intests/AppSubmitFailure.test.tsx. No behaviour change; the five tests in that file still pass.Checks:
typecheckclean,test tests/AppSubmitFailure.test.tsx5 pass,check:lintandcheck:formatclean.Merge this first so the CI of #315 and the other open PRs goes green.