Skip to content

fix(pr): route replies on the parent's GitHub object kind - #326

Merged
nownabe merged 1 commit into
mainfrom
fix/285-reply-remote-kind
Sep 20, 2026
Merged

nownabe merged 1 commit into
mainfrom
fix/285-reply-remote-kind

Conversation

@nownabe

@nownabe nownabe commented Sep 20, 2026

Copy link
Copy Markdown
Owner

Why

Reply routing (review-reply endpoint vs. flat issue comment) was re-derived from whether the parent's creation-time line range sits in the current diff. That is a property of the diff, not of the parent, and it drifts as the author pushes:

  • an issue-comment parent whose lines drift into a hunk → the reply POSTs to /pulls/{n}/comments/{issueId}/replies and 404s;
  • a review-comment parent whose lines drift out of the diff → the reply becomes a flat issue comment, splitting the thread.

addReply had the mirror-image bug: it copied the root's old-sha range but stamped sha: headSha, so reanchor reported current for a stale range.

What

  • Comment.remoteKind?: "review" | "issue" records which GitHub object remoteId names. The fetcher sets it from the endpoint the comment came from (Bark-authored and foreign alike); the state machine sets it from the step kind when a post succeeds (post-review-batch / post-reply → review, post-issue-comment → issue), on both the LocalState and the RemoteState mirror.
  • The planner routes create-reply on op.parent.remoteKind and never consults isInDiff for replies. The old heuristic stays as a one-line fallback for remoteKind === undefined, i.e. LocalState persisted before the field existed — those are all synced comments, which the first refresh replaces with the remote copy anyway.
  • replyAnchor(thread, headSha) extracted from App.tsx's inline addReply block into reviewItems.ts next to canReplyToThread. The sha now travels with the range it belongs to: a Bark or draft root's own sha, and only the foreign-review-root branch anchors at the head (GitHub's line is head-side). The permalink still uses headSha — it has to link to a commit that exists.
  • ADR 0002 §3 documents remoteKind; ADR 0003 §3 and the §5 Step table record the new reply routing.

Red-test evidence (before the fix)

bun run test tests/pr/remote-fetcher.test.ts tests/pr/planner.test.ts tests/pr/state-machine.test.ts tests/reviewItems.test.ts → 10 fail, 1 error:

  • remote-fetcher — remoteKind (issue #285) > a fetched review comment carries remoteKind 'review'
    expect(received).toEqual(expected) — Expected ["review", "review"], Received [undefined, undefined] (same for the issue-comment case).
  • planner — CreateReply > a reply to an issue-comment parent is a PostIssueComment even when the parent's lines are in the current diff
    Expected kind: "post-issue-comment", Received kind: "post-reply" (+ the parent object).
  • planner — CreateReply > a reply to a review-comment parent is a PostReply even when the parent's lines left the diff
    Expected kind: "post-reply", Received kind: "post-issue-comment" — the two misrouting directions of the issue.
  • state-machine — remoteKind (issue #285) > a successful post-issue-comment records remoteKind 'issue'
    toMatchObject failed on the missing remoteKind key (same for post-reply, review-batch, and applyStepResultsToRemote: Expected: "issue", Received: undefined).
  • replyAnchor (issue #285) (4 tests)
    SyntaxError: Export named 'replyAnchor' not found in module '.../entrypoints/review/reviewItems.ts'.

One pre-existing whole-object toEqual in remote-fetcher.test.ts ("Bark-authored review comments restore cid / threadId / anchor from metadata") gained the new remoteKind: "review" field, as expected.

Checks

bun run test 706 pass / 0 fail (62 files) · check:lint OK · check:format OK · typecheck OK · build OK.

Closes #285

@nownabe nownabe self-assigned this Sep 20, 2026
@nownabe
nownabe added this pull request to stack #343 September 20, 2026 06:34
@nownabe
nownabe force-pushed the fix/285-reply-remote-kind branch from b9474e2 to ec30ddd Compare September 20, 2026 07:32
The current diff is not a property of the parent comment: after the author pushes, an issue-comment parent can look in-diff (reply 404s on the review-reply endpoint) and a review-comment parent can look out-of-diff (the reply splits off as a flat issue comment). Record what the parent actually became and route on that. addReply now keeps the root's own sha with the root's range, so reanchor no longer reports stale lines as current.
@nownabe
nownabe force-pushed the fix/285-reply-remote-kind branch from ec30ddd to 1500dd0 Compare September 20, 2026 08:37
@nownabe
nownabe merged commit 1df6462 into main Sep 20, 2026
10 checks passed
@nownabe
nownabe deleted the fix/285-reply-remote-kind branch September 20, 2026 08:42
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] Reply routing is re-derived from the parent's stale anchor instead of its GitHub object kind

1 participant