Skip to content

fix(pr): offer Resolve only when GitHub would accept it - #335

Merged
nownabe merged 1 commit into
mainfrom
fix/274-viewer-can-resolve
Sep 20, 2026
Merged

nownabe merged 1 commit into
mainfrom
fix/274-viewer-can-resolve

Conversation

@nownabe

@nownabe nownabe commented Sep 20, 2026

Copy link
Copy Markdown
Owner

Why

GitHub only accepts resolveReviewThread from the PR author or a user with write access, and only accepts the out-of-diff root rewrite (#310's transport, PATCH /issues/comments/{id}) from that comment's author or a writer. Bark showed Resolve/Reopen to every reviewer, so for a read-only reviewer — the usual external reviewer on a public repo — the mutation always failed: the Thread landed in draft + lastError and the Snackbar showed a raw GraphQL error. A dead-end control.

What

  • Thread.viewerCanResolve?: boolean — a mirrored fact like resolved, undefined while the thread is a local draft.
  • fetchRepoPushPermission(client, ref) reads permissions.push from GET /repos/{o}/{r}. It joins the existing Promise.all in fetchRemoteState and is .catch(() => false)-guarded: a refresh must never fail because of the permission probe, and without the signal we withhold the affordance rather than offer a dead end. The GET is ETag-cached by github-api, so every refresh after the first is a 304 at no rate-limit cost.
  • Per-thread rule, from data the fetcher already has: a review thread is resolvable when canWrite || viewer.login === pullRequest.author.login; an out-of-diff thread when canWrite || viewer.login === rootIssueComment.user.login (logins compared case-insensitively). fetchThreads standalone passes nothing and its output is unchanged.
  • canResolveThread(t) in types.ts (hasRemoteIdentity(t) && t.viewerCanResolve === true) replaces the bare hasRemoteIdentity filter behind App.tsx's resolvableThreadKeys. ThreadItem keeps the [Medium] Resolve/Reopen silently no-ops for Bark out-of-diff (issue-comment) threads #182 pattern: a thread that cannot be resolved simply shows no control.
  • ADR 0002 §3 documents the field; ADR 0003 §5 records that the gate lives in the UI, not the Planner — the Executor still runs any Op it receives, and a GitHub refusal still lands the Thread in draft + lastError.

Rejected: GraphQL's per-thread viewerCanResolve (precise for review threads, but out-of-diff threads still need the write signal — two mechanisms plus a change to listReviewThreads's return shape); PullRequest.viewerCanUpdate (true for the PR author, who still cannot PATCH a reviewer's issue comment); disabling with a tooltip (a new UI state for a control the user cannot use).

Known limitation, to carry into #278's design rather than fix here: a PR author without write access cannot resolve an out-of-diff thread rooted in a reviewer's issue comment, because the transport edits that comment. With this change they at least see no Resolve button there.

Red-test evidence (before the fix)

bun run test tests/pr/types.test.ts tests/pr/remote-fetcher.test.ts → 6 fail, 1 error:

  • canResolveThread (issue #274) (4 tests) — SyntaxError: Export named 'canResolveThread' not found in module '.../lib/pr/types.ts'.
  • remote-fetcher — viewerCanResolve (issue #274) > a read-only reviewer cannot resolve a review thread — Expected: false, Received: undefined.
  • > write access can resolve a review thread — Expected: true, Received: undefined.
  • > the PR author can resolve a review thread without write access — Expected: true, Received: undefined.
  • > an out-of-diff thread is resolvable by its root comment's author — Expected: true, Received: undefined.
  • > a failed permission probe defaults to no write access and does not fail the refresh — Expected: false, Received: undefined.

Fixture churn, as predicted: the existing whole-object toEquals on out.threads gained viewerCanResolve: true (their viewer is alice, who is both PR author and root author). Test fetch handlers also gained a /repos/o/r branch — without it the probe's thrown fetch is treated as a transient failure and retried with backoff, which added ~1.2 s per affected test (the suite went 2.4 s → 9.8 s). With the stubs it is back to 2.5 s.

Checks

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

Closes #274

@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/274-viewer-can-resolve branch from c99e97d to 4082c77 Compare September 20, 2026 07:32
@nownabe
nownabe force-pushed the fix/274-viewer-can-resolve branch from 4082c77 to 3411b35 Compare September 20, 2026 08:37
Base automatically changed from fix/285-reply-remote-kind to main September 20, 2026 08:42
GitHub accepts resolveReviewThread from the PR author or a user with write access, and a rewrite of an out-of-diff root from that comment's author or a writer. Bark offered the control to everyone, so a read-only reviewer hit a guaranteed 403 that parked the Thread in draft + lastError. Derive the permission once per refresh and hide the dead-end control instead.
@nownabe
nownabe force-pushed the fix/274-viewer-can-resolve branch from 3411b35 to c4dd0f5 Compare September 20, 2026 08:42
@nownabe
nownabe merged commit b05fdcc into main Sep 20, 2026
10 checks passed
@nownabe
nownabe deleted the fix/274-viewer-can-resolve branch September 20, 2026 08:43
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] Resolve is offered to read-only reviewers whom GitHub rejects

1 participant