Skip to content

fix(review): resolve accepted-suggestion threads only after the commit lands - #341

Merged
nownabe merged 1 commit into
mainfrom
fix/278-resolve-after-commit
Sep 20, 2026
Merged

nownabe merged 1 commit into
mainfrom
fix/278-resolve-after-commit

Conversation

@nownabe

@nownabe nownabe commented Sep 20, 2026

Copy link
Copy Markdown
Owner

Why

Author Submit resolved accepted-suggestion threads on GitHub before running the commit that
applies them, and did not undo the resolve when the commit failed. GitHub then showed the
suggestion as resolved while the change was not in the branch, and "Discard all" afterwards
dropped the accepted decision locally without unresolving — a reviewer's suggestion silently lost.

What

The dependency is expressed as a state transition triggered by commit success, not as step
ordering or compensation:

  • FileEdit gains resolveOnCommit?: LocalId[] — the Threads of the suggestions accepted into
    that edit.
  • applyCommitSuccess flips each listed Thread synced → syncing (resolved: true); the next
    reconcile cycle emits UpdateThreadResolved and the ordinary resolve step runs. On commit
    failure the FileEdit parks as draft + lastError as before and the Threads are untouched —
    nothing on GitHub claims the change landed, so no compensating unresolve is ever needed.
  • App.tsx stops calling setThreadResolved per accepted thread before submitDrafts. A new
    file-local fileEditsFromEdits() builds the wanted FileEdits with their resolveOnCommit, and
    is used by both the mirror effect and submitAuthor step 2, so the two can never persist
    the same path with and without the field. The one case with no FileEdit (the accepted
    replacement already equals the file text, so isMeaningfulEdit is false and nothing is
    committed) keeps the immediate setThreadResolved — there is no commit to wait for.
  • ADR 0002 §3 (FileEdit), ADR 0003 §3 "Ordering" and ADR 0001 §3's synced → syncing bullet
    record the rule.

Rejected: a compensating UnresolveReviewThread on commit failure — two writes where one
suffices, a visible flicker on GitHub, and a second failure mode. Rejected: ordering Commit
before all resolves in the planner — an unrelated manual resolve in the same submit would be
blocked by a conflict in a file it has nothing to do with.

Red-test evidence

bun run test tests/AppSubmitFailure.test.tsx (new author-mode harness: viewer == PR author, one
submitted suggestion comment accepted in the dismissed-suggestions store, one persisted editor
edit) before the fix — 2 failures:

  • App — author submit of an accepted suggestion (issue #278) > a failing commit does not resolve the accepted suggestion's thread
    → recorded ["resolve-review-thread"], expected [] (the Snackbar already said "Commit
    failed", so the resolve had reached GitHub for a change that never landed).
  • … > a succeeding commit resolves the accepted thread after the commit
    → call order was ["resolve-review-thread", "commit"], expected ["commit", "resolve-review-thread"].

bun run test tests/pr/state-machine.test.ts tests/pr/repository.test.ts — 2 more:

  • state-machine — applyStepResults: Commit > Commit success flips resolveOnCommit Threads to syncing with resolved=true (issue #278)
    → thread stayed { state: "synced", resolved: false }.
  • repository — accepted-suggestion threads resolve on commit (issue #278) > the resolve runs in the cycle after the commit
    → calls was ["commit"], missing the resolve.

Guards that passed before and still pass: commit failure leaves resolveOnCommit Threads
untouched and parks the edit; a failing commit sends no resolve at the Repository level.

After the fix: 722 pass, 0 fail across 62 files.

One extra change, and why it was needed

The mirror effect's deps had to gain acceptedSuggestionInfos and commentViewByRemoteId, both
of which change identity on every Repository notification. Since upsertFileEdit always
notifies, the effect re-ran forever ("Maximum update depth exceeded"). The effect now skips
writes that would change nothing (sameFileEdit), which breaks the cycle at its source and is
strictly fewer writes than before.

Manual verification still to do

Not runnable here (needs a real PR):

  1. Accept a suggestion, force a conflict by pushing to the branch from elsewhere, Submit →
    "Commit failed", thread still open on github.com.
  2. Resolve the conflict, Submit → commit, then the thread resolves.
  3. Accept a suggestion whose replacement is already in the file → thread resolves immediately
    with no commit.
  4. "Discard all" clears accepted decisions and the effect rebuilds the FileEdits without
    resolveOnCommit.

bun run build succeeds, so the artifact in .output/chrome-mv3 is current for loading.

Checks

bun run test (722 pass / 0 fail), check:lint, check:format, typecheck, build — all clean.

Closes #278

@nownabe nownabe self-assigned this Sep 20, 2026
@nownabe
nownabe added this pull request to stack #328 September 20, 2026 06:29
@nownabe
nownabe force-pushed the fix/278-resolve-after-commit branch from b5dc5e0 to 1ae2a4f Compare September 20, 2026 06:30
@nownabe
nownabe force-pushed the fix/278-resolve-after-commit branch from 1ae2a4f to e6ad750 Compare September 20, 2026 07:26
@nownabe
nownabe force-pushed the fix/278-resolve-after-commit branch from e6ad750 to c9358c7 Compare September 20, 2026 08:04
@nownabe
nownabe force-pushed the fix/278-resolve-after-commit branch from c9358c7 to 6cf0342 Compare September 20, 2026 08:06
@nownabe
nownabe force-pushed the fix/278-resolve-after-commit branch from 6cf0342 to 92f2559 Compare September 20, 2026 08:09
Base automatically changed from fix/281-repository-lock to main September 20, 2026 08:19
…t lands

Author Submit resolved the threads before running the commit that applies
them and never undid it on failure, so GitHub showed a suggestion as
resolved while the change was not in the branch. A successful Commit now
drives the transition, so a failed one needs no compensation.
@nownabe
nownabe force-pushed the fix/278-resolve-after-commit branch from 92f2559 to 88a6252 Compare September 20, 2026 08:19
@nownabe
nownabe merged commit 770f901 into main Sep 20, 2026
10 checks passed
@nownabe
nownabe deleted the fix/278-resolve-after-commit branch September 20, 2026 08:31
nownabe added a commit that referenced this pull request Sep 20, 2026
…per (#352)

## Why

`App.tsx` held the same logic two or three times, so a rule change (a
`baseSha`
fallback, a `parentLocalId` lookup) had to be made in every copy. This
gives each
one a single home.

Folding the FileEdit sync into one helper also removed a latent race,
see
"Behaviour change" below.

## What

Re-audited issue #300's six items against current `main`; three were
already
resolved by earlier PRs and are untouched here:

| # | Item | Status |
|---|------|--------|
| 1 | "drafts → Repository" loop in `submitReview` vs `submitAuthor` |
**already resolved** — #351 (issue #282) deleted `submitAuthor`'s loop;
only `submitReview` still has one |
| 2 | FileEdits sync (mirror effect vs `submitAuthor`) | **done** — #341
(issue #278) had unified the *building* via `fileEditsFromEdits`; the
upsert/discard loop was still duplicated, now
`syncFileEditsToRepository()` |
| 3 | `parentLocalId` resolution (`addReply`, `submitReview`) | **done**
— one `parentLocalIdFor(thread)` |
| 4 | "Drop accepted decisions" (two in-memory copies +
`clearAcceptedDecisions`) | **done** —
`useDismissedSuggestions.clearAccepted(ids)`; the `setDismissed` escape
hatch it existed for is gone from the hook's API |
| 5 | `resetSuggestionEdits(); saveSuggestionEdits(ref, {})` in
`discardAllPending` | **done** — `await discardAllPersistedEdits()`;
`saveSuggestionEdits` is no longer imported by `App.tsx` |
| 6 | `jumpTo` vs `jumpToOffsets` | **already resolved** — #348 (issue
#283) folded `jumpTo` into `jumpToCid` → `jumpToOffsets` |

Net line change: **−30 lines in `App.tsx`** (49 added / 79 removed);
**−15 lines
of production code overall** (`App.tsx` + the two hook files), +37 lines
of test.

## Behaviour change (one, deliberate)

`syncFileEditsToRepository` skips a FileEdit whose current state is past
`"draft"`. `submitAuthor` used to upsert unconditionally, and that
redundant
write was the only thing keeping the mirror effect from re-running
*during*
`submitDrafts()`, seeing the FileEdit as `"syncing"` and writing it back
as a
`"draft"` — cancelling the commit it belonged to. Without the guard,
both
`tests/AppSubmitFailure.test.tsx` author-submit tests fail (no `commit`
call at
all, so the accepted thread is never resolved); with it they pass.
Everything
else is pure extraction.

## Red-test evidence

New hook test, `tests/useDismissedSuggestions.test.tsx` →
`useDismissedSuggestions — clearAccepted`, written before the
implementation:

```
TypeError: result.current.clearAccepted is not a function.
  (In 'result.current.clearAccepted([1])', 'result.current.clearAccepted' is undefined)
(fail) useDismissedSuggestions — clearAccepted > drops only the named ids and purges them from storage
(fail) useDismissedSuggestions — clearAccepted > without a ref: updates state, does NOT touch storage
 5 pass  2 fail
```

The existing App-level suites (`AppSubmitFailure`,
`AppEditedCoordinates`,
`AppPrRef`, `AppRejectSuggestion`) are the safety net for the extraction
itself
and stay green.

## Checks

`bun run test` 818 pass / 0 fail (64 files) · `check:lint` ·
`check:format` ·
`typecheck` · `build` — all clean.

Closes #300
nownabe pushed a commit that referenced this pull request Sep 20, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.4.0](bark-v0.3.0...bark-v0.4.0)
(2026-09-20)


### Features

* **pr:** accept .markdown and .mdx as Markdown
([#322](#322))
([e22ee68](e22ee68)),
closes [#293](#293)
* **pr:** commit fork pull requests to the fork's repository
([#342](#342))
([4e2adef](4e2adef)),
closes [#273](#273)
* **pr:** create a top-level draft Comment's Thread with it
([#323](#323))
([6e192f3](6e192f3)),
closes [#272](#272)
* **pr:** resolve out-of-diff threads via the root comment fence
([#310](#310))
([7e0ecb9](7e0ecb9)),
closes [#270](#270)
* **reanchor:** bounded region search for single-line anchors and
line-local suggestion merge
([#309](#309))
([0f735da](0f735da)),
closes [#269](#269)
* **reanchor:** locate multi-line anchors per endpoint in the region
search ([#347](#347))
([f4fd457](f4fd457)),
closes [#311](#311)
* **review:** preview the merge for shifted suggestions in the editor
([#354](#354))
([f822f41](f822f41)),
closes [#312](#312)


### Bug Fixes

* **anchor:** define anchor.quote as the source text at anchor.range
([#327](#327))
([11a935d](11a935d)),
closes [#276](#276)
* **background:** focus an existing review tab instead of opening a
second one ([#325](#325))
([58efa63](58efa63)),
closes [#277](#277)
* **pr:** compose the quote and permalink for every out-of-diff post
([#351](#351))
([f85b99b](f85b99b)),
closes [#282](#282)
* **pr:** count patch lines starting with ++ or -- in parseRightRanges
([#314](#314))
([9dfbd46](9dfbd46)),
closes [#284](#284)
* **pr:** keep the rel=next link in the ETag cache so 304 pages still
paginate ([#318](#318))
([6472de2](6472de2)),
closes [#286](#286)
* **pr:** offer Resolve only when GitHub would accept it
([#335](#335))
([b05fdcc](b05fdcc)),
closes [#274](#274)
* **pr:** park a failed resolve toggle in synced, not draft
([#320](#320))
([56e815b](56e815b)),
closes [#275](#275)
* **pr:** post drafts in the current head's coordinates
([#303](#303))
([28ef345](28ef345))
* **pr:** recover comments stuck in syncing instead of re-posting them
([#305](#305))
([3548086](3548086))
* **pr:** refuse commits to a merged or closed PR
([#330](#330))
([2a239ff](2a239ff)),
closes [#288](#288)
* **pr:** refuse to submit a draft whose quoted text changed upstream
([#346](#346))
([d4118a4](d4118a4)),
closes [#313](#313)
* **pr:** route replies on the parent's GitHub object kind
([#326](#326))
([1df6462](1df6462)),
closes [#285](#285)
* **pr:** serialise refresh and execution under one Repository lock
([#336](#336))
([1864488](1864488)),
closes [#281](#281)
* **pr:** sweep entities left syncing at the end of a submit
([#331](#331))
([108caa9](108caa9)),
closes [#271](#271)
* **release:** pin publish-browser-extension to ^4.0.5
([#263](#263))
([b77104f](b77104f))
* **review:** derive a suggestion draft's cid from the hunk it
materialises ([#337](#337))
([963339d](963339d)),
closes [#308](#308)
* **review:** end a whole-line selection on the line it actually covers
([#319](#319))
([3364d18](3364d18)),
closes [#291](#291)
* **review:** map comment positions between head and edited coordinates
([#348](#348))
([9465718](9465718)),
closes [#283](#283)
* **review:** reject a suggestion by resolving its thread on GitHub
([#340](#340))
([d088a8d](d088a8d)),
closes [#287](#287)
* **review:** resolve accepted-suggestion threads only after the commit
lands ([#341](#341))
([770f901](770f901)),
closes [#278](#278)
* **review:** surface failed comment posts and keep the reviewer's edits
([#307](#307))
([48cb675](48cb675))
* **review:** validate the PR number from the review URL
([#321](#321))
([457a942](457a942)),
closes [#295](#295)
* **storage:** bound chrome.storage.local growth and stop quota errors
losing drafts ([#332](#332))
([1f96120](1f96120)),
closes [#289](#289)
* **suggest:** consume a longer closing fence instead of leaking a
backtick ([#316](#316))
([d2e0683](d2e0683)),
closes [#290](#290)


### Performance Improvements

* **reanchor:** replace the LCS table with a memoised line-level Myers
diff ([#344](#344))
([8caebdd](8caebdd)),
closes [#280](#280)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: release-please-nownabe-bark[bot] <295690643+release-please-nownabe-bark[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Medium] Accepted-suggestion threads are resolved before the commit and not undone on failure

1 participant