Skip to content

fix(pr): post drafts in the current head's coordinates - #303

Merged
nownabe merged 4 commits into
mainfrom
fix/stale-draft-coordinates
Sep 20, 2026
Merged

nownabe merged 4 commits into
mainfrom
fix/stale-draft-coordinates

Conversation

@nownabe

@nownabe nownabe commented Sep 20, 2026 •

Copy link
Copy Markdown
Owner

Why

Closes #265.

Draft comments and suggestions keep the line numbers of the head sha they were created at (anchor.sha), but the Planner posted them with commit_id = current headSha and those stale lines. After the author pushed during a review, drafts landed on the wrong text on GitHub, suggestions applied to the wrong lines via "Apply suggestion", or the whole review batch failed with 422 when a stale line fell outside a hunk.

The ADRs never said which coordinate system the Executor posts in; ADR 0003 now does.

What

  • Planner re-anchors every CreateComment from anchor.sha to the current head using the same line map ADR 0004 uses for display, and posts (and routes in-diff/out-of-diff) with the mapped range. Comment.anchor in LocalState stays immutable; only the posted copy is rebased.
  • RejectComment step: a draft whose mapping is outdated never reaches GitHub and returns to draft + lastError with a clear message, so the rest of the submission still goes out and the batch cannot 422 on stale lines.
  • Remote fetcher also loads every anchored path at the head sha. Nothing fetched (headSha, path) before, so the line map (display re-anchoring included) had no target side.
  • Suggestion drafts carry their edit's baseSha instead of the current head, and submit refreshes first so both shas' sources are available for the mapping.
  • ADR 0003 §5/§6: posted coordinates are the current head's; RejectComment semantics.
  • Tests: draft at sha A → head advances to B with lines inserted above → submit posts the mapped line; unmappable draft is refused while mappable ones post; head-sha contents are fetched; pending suggestions carry baseSha.

Tooling / CI (separate commits)

  • style: reformats two untouched test files that oxfmt 0.62 (pinned since chore: update dependency oxfmt to ^0.62.0 #261) flagged.
  • chore(tooling): the shared Common Checks / oxfmt job runs the oxfmt version hardcoded in nownabe/workflows at the pinned sha (0.59.0), which disagrees with this repo's 0.62.0 pin, so a branch that passes bun run check:format failed CI. This bumps the repo pin to 0.68.0 (mise.toml, package.json, lockfiles), moves the shared-workflow pin to current main (also 0.68.0), and reformats the one file 0.68 changes.
  • ci: moving the shared-workflow pin made the GitHub Workflow job run zizmor 1.30.1, which flagged pre-existing issues: three hash pins whose # vN comment drifted from the pinned commit (fixed to the exact tags), and the ./ reusable-workflow reference. actionlint 1.7.12 (latest; what CI runs) rejects the $/ syntax zizmor wants, so that one finding is suppressed inline.

How to verify

  1. Draft a comment near the end of a changed .md, and a suggestion in another file.
  2. Push a commit that inserts 10+ lines above them, then reload Bark (or refresh via the debug FAB).
  3. Submit: on github.com the comment sits on the original sentence and "Apply suggestion" edits the right lines.
  4. Delete a drafted line upstream instead and submit: only that draft returns with "Could not map the commented lines to the current head commit…", the others post.

Drafts keep the line numbers of the sha they were created at, but a review is posted against the current head. After the author pushes, those stale lines landed comments on the wrong text (and suggestions applied to the wrong lines), or 422'd the whole review batch. The Planner now re-anchors every CreateComment to the head with the ADR 0004 line map, refuses unmappable drafts locally (draft + lastError) instead of failing the batch, and the fetcher loads each anchored path at the head so the map has both sides. Suggestion drafts carry their edit's baseSha rather than the head. Closes #265.
oxfmt was bumped to 0.62 in #261 without reformatting; these two files failed 'bun run check:format' under the pinned version.
@nownabe nownabe self-assigned this Sep 20, 2026
The 'Common Checks / oxfmt' job runs the oxfmt version hardcoded in nownabe/workflows at the pinned sha (0.59.0), while this repo pinned 0.62.0; the two disagree on formatting, so a branch that passes 'bun run check:format' fails CI. Bump the repo pin (mise.toml, package.json, lockfiles) to 0.68.0, move the shared-workflow pin to current main (also 0.68.0), and reformat the one file 0.68 changes.
Bumping the shared-workflow pin made the 'GitHub Workflow' job run zizmor 1.30.1, which flags pre-existing issues: three hash pins whose '# vN' comment no longer matches the pinned commit (mise-action 7e36c90 is v4.2.4, deploy-pages cd2ce8f is v5.0.0), and the './' reusable-workflow reference. actionlint 1.7.12 (the latest, and what CI runs) rejects the '$/' syntax zizmor wants, so that finding is suppressed inline instead.
@nownabe
nownabe merged commit 28ef345 into main Sep 20, 2026
12 checks passed
@nownabe
nownabe deleted the fix/stale-draft-coordinates branch September 20, 2026 03:38
nownabe added a commit that referenced this pull request Sep 20, 2026
…the fetch scope (#306)

## Why

The runtime defect in #267 — head-sha file content never reaching
`RemoteState`, so re-anchoring ran against an empty document — was
already fixed by #303 (`fetchRemoteState` now adds `(headSha, path)` for
every anchored path). Two things were left behind:

1. Nothing pinned the *derived* behaviour. The fetcher test added in
#303 asserts which URLs are requested; no test asserts that a comment
anchored at an older sha ends up `mapped` after bootstrap.
2. ADR 0004 §1/§2/§6 and ADR 0005 §2 still described head `FileContent`
as living at `(newHeadSha, currentPath)` — a rule the Repository cannot
execute, because the viewed path is ephemeral UI state above it (ADR
0002 §1/§4).

The design settles the scope question the issue's acceptance criteria
left open:

- The Repository fetches `(headSha, path)` for **every anchored path**
(it needs both ends of the line map, and nothing else knows the anchored
paths). It does **not** fetch every changed Markdown file —
`AppState.currentFiles` has no consumer today, and that would cost one
`GET contents` per changed `.md` on every refresh.
- `useSelectedFileContent` keeps fetching the **viewed** path itself.
Where the two overlap, the hook's request is a conditional GET answered
from `ghRequest`'s ETag cache — a 304 costs no rate-limit budget, so the
duplication is one free round trip, not a second download. The issue's
third acceptance criterion is satisfied by the "or the duplication is
explicitly justified" branch, and the justification is now written down
in the hook header and ADR 0005 §2.

## What

- `tests/pr/bootstrap.test.ts`: new end-to-end regression test —
bootstrap with one comment anchored at `oldsha` on a file that is
byte-identical at `headsha`, then `deriveAppState`. Asserts both that
`contentsRefs` is `["headsha", "oldsha"]` and that `displayPosition` is
`{ status: "mapped", range: … }`.
- `docs/adr/0005-refresh-policy.md` §2: refresh scope restated as every
`(anchor.sha, path)` plus `(headSha, path)` for each anchored path, with
an explicit note that the viewed path is not in scope and is loaded by
the editor hook.
- `docs/adr/0004-reanchoring.md` §1/§2/§6 and Consequences → Negative:
current source is `(headSha, comment.path)` guaranteed by the prefetch;
§2 includes the head-sha copy; cost restated as up to `(N+1)×M` calls.
- `entrypoints/review/hooks/useSelectedFileContent.ts`: header comment
rewritten (stale "Pack B / R8d" / "legacy Effect 2" wording dropped) to
state that fetching above the Repository is deliberate and why.

No changes to `lib/pr` code.

## Regression test verified against the pre-#303 behaviour

The new test is green on first run — as expected, since #303 already
fixed the behaviour. To prove it has teeth, the #303 loop in
`fetchRemoteState` (`lib/pr/remote-fetcher.ts`, the `for (const t of
Array.from(targetSet.values()))` block that adds `(headSha, path)`
targets) was temporarily deleted and the file then restored with `git
checkout --`.

With that loop removed, the head-sha content is never fetched:

```
expect(received).toEqual(expected)

@@ -1,3 +1,3 @@
  [
-   "headsha",
    "oldsha",

- Expected  - 1
+ Received  + 0

(fail) bootstrap — head-sha content for re-anchoring (issue #267) > a comment anchored at an older sha re-anchors as mapped when the file is unchanged at head
```

and the derived status is exactly the bug the issue reports (captured by
running the `displayPosition` assertion first):

```
expect(received).toEqual(expected)

  {
-   "range": {
-     "ec": 6,
-     "el": 2,
-     "sc": 1,
-     "sl": 2,
-   },
-   "status": "mapped",
+   "status": "outdated",
  }

- Expected  - 7
+ Received  + 1

(fail) bootstrap — head-sha content for re-anchoring (issue #267) > a comment anchored at an older sha re-anchors as mapped when the file is unchanged at head
```

With `lib/pr/remote-fetcher.ts` restored: 654 pass, 0 fail across 61
files.

## Checks

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

## Manual verification (optional, needs a real PR)

Open a PR with a Bark comment from an earlier push on a file the later
push did not touch: the comment should be highlighted inline (no
"position not found" badge) and Accept enabled for a suggestion. In
DevTools → Network filtered on `contents/`, the viewed commented file
should show one 200 (bootstrap) and one 304 (hook); a changed file with
no comments should show exactly one request.

## Noted, out of scope

- `AppState.currentFiles` has no consumer — a candidate for the refactor
sweep, not this issue. This is why the issue's "and for every changed
Markdown file, so `currentFiles` is populated" criterion is deliberately
not implemented.
- ADR 0005 §2's "already-fetched `(sha, path)` pairs are retained" is
not implemented today (every refresh refetches, cheaply via ETag). That
gap is item 8 of the docs-drift issue #294 and the sentence is left as
is.

Closes #267
nownabe added a commit that referenced this pull request Sep 20, 2026
## Why

`PullRequest.state` and `merged` were mirrored but never consulted. An
author's commit to
a merged PR succeeds — it pushes onto the now-merged head ref — but
nothing ever merges
that branch again, so the edit never reaches the base branch. Bark
reported success and
cleared the FileEdits, losing the work silently.

Comments are a different case: commenting on a merged or closed PR is
legitimate, just
easy to do by accident. So the commit is refused and comments are only
warned about.

## What

- New `RejectCommitStep` (`lib/pr/steps.ts`), modelled exactly on the
existing
`RejectCommentStep` from #303: it never reaches the Transport, the
Executor reports it as
a failed outcome, and the state machine routes it through the existing
`applyCommitFailure`
  so the FileEdits park back as `draft` with `lastError`.
- `PlannerContext` gains `pullRequest`; `planExecution` emits the
refusal instead of a
`CommitStep` when `merged || state === "closed"`. Comment/reply/resolve
steps are untouched.
- The refusal reaches the Snackbar through the path App.tsx already has:
it reads the first
`fileEdits[].lastError` after `submitDrafts()` and reports "Commit
failed: …", keeping the
  author's pending edits rather than discarding them.
- `SubmitConfirmModal` takes `prStatus` and shows a one-line
`notice--error` warning when the
PR is merged or closed. No new CSS; `App.tsx` already computes
`prStatus`.

## Red tests

`tests/pr/planner.test.ts`:

- `a merged PR gets no CommitStep — the edits are refused instead
(#288)`
→ `expect(steps.some((s) => s.kind === "commit")).toBe(false)` —
`Expected: false, Received: true`
- `a closed PR gets no CommitStep — the edits are refused instead
(#288)`
→ step was `{kind: "commit", baseSha, headRef, …}` instead of `{kind:
"reject-commit"}`

`tests/pr/state-machine.test.ts` → `a refused Commit parks its FileEdits
as draft + lastError (#288)`
→ `TypeError: undefined is not an object (evaluating 'out.fileEdits')`
(the unknown step kind
fell off the exhaustive switch).

`tests/SubmitConfirmModal.test.tsx` → `warns when the PR is merged or
closed, and stays silent
when it is open (#288)` → `expect(received).toMatch(/merged/i);
Received: ""`.

A fourth test pins that comments still go out on a merged PR, so the
gate cannot grow into a
blanket block.

## Known limit

The gate reads the last-fetched `pullRequest`, so a PR merged between
refresh and submit still
slips through. The commit then lands on a dead branch exactly as before
— this narrows the
window rather than closing it; GitHub itself does not reject the push.

Closes #288
nownabe added a commit that referenced this pull request Sep 20, 2026
)

## Why

A comment body embedded the whole `anchor.quote` in the base64 fence
(4/3 inflation) and an out-of-diff body prepended the same quote again
as visible text; a suggestion adds the replacement on top. Nothing
capped that, so a large selection produced a body over GitHub's
65,536-character limit and got a 422 — and because `POST
/pulls/{n}/reviews` is atomic, one oversized comment failed every other
in-diff comment in the same submit.

## What

The quote is derivable, not just storable: `anchor.sha` is
content-addressed, so the full quote is exactly
`extractTextAtRange(FileContent(sha, path), range)` — and the fetcher
already loads that file for every anchored `(sha, path)` (#303). So the
fence carries a bound, and the full quote is restored on the way back
in.

- **lib/pr/metadata.ts** — `QUOTE_EXCERPT_CHARS = 1000`, `BODY_LIMIT =
65_536`. `embedMetadata` caps a longer quote to an excerpt and adds
`quoteDigest` + `quoteLength`; a quote at or under the cap produces the
same bytes as before, so every existing fence and fixture is unchanged.
`contentDigest` is cyrb53 — sync and dependency-free.
`envelopeOf(comment)` is the single definition of what the transport
posts (it replaces three copies of the same literal in
`github-transport.ts`), and `wireBodyLength` is the one size estimate
both the Planner and `addDraft` use.
- **Why not SHA-256 via Web Crypto:** `crypto.subtle.digest` is async,
which would make `embedMetadata` — plus four transport call sites and
every fence fixture — async for no security gain. The digest guards
against mis-restoration (wrong range, corrupt fence), not against an
attacker, who can already rewrite any fence field; identity trust is the
earliest-bearer rule (#190). Stated in a comment on the helper.
- **lib/pr/remote-fetcher.ts** — `restoreCappedQuotes` runs after the
file contents come back: for each comment whose fence was capped, it
re-extracts the quote at `anchor.range` and accepts it only when both
length and digest match. A missing file or a mismatch keeps the excerpt.
`bootstrap.refresh` is the only caller of `fetchRemoteState`, so
bootstrap and refresh are both covered.
- **lib/pr/planner.ts** — a `create-comment` / `create-reply` whose wire
body exceeds the limit is planned as `reject-comment` (the mechanism
#303 added for unmappable anchors), so it parks as `draft + lastError`
and the rest of the batch posts.
- **entrypoints/review/uiHelpers.ts** — `quoteBlock` bounds the visible
out-of-diff quote to 12 lines / 1,000 characters with a `> …` trailer;
`composeDraftBody` uses it.
- **entrypoints/review/App.tsx `addDraft`** — refuses an over-limit
draft with an immediate Snackbar instead of letting it fail at submit.
- **lib/pr/github-transport.ts** — `setIssueThreadResolved` now spreads
the *fetched* envelope instead of rebuilding it field by field, so a
capped fence's digest and length survive a resolve toggle.
- ADR 0002 §3/§5 and ADR 0003 §5/§7 updated. ADR 0004 needs no change:
verification is unchanged and runs on the full, restored quote.

## Red-test evidence (before the fix)

- `tests/pr/metadata.test.ts` — `metadata — bounded quote (issue #279)`
(all cases): `SyntaxError: Export named 'wireBodyLength' not found in
module '.../lib/pr/metadata.ts'`.
- `tests/uiHelpers.test.ts` — `quoteBlock (issue #279)`: `SyntaxError:
Export named 'quoteBlock' not found in module
'.../entrypoints/review/uiHelpers.ts'`.
- `tests/pr/github-transport.test.ts` — `a capped root fence keeps its
quoteDigest and quoteLength through the toggle`: `SyntaxError: Export
named 'contentDigest' not found`.
- `tests/pr/planner.test.ts` — `a comment whose wire body exceeds
GitHub's limit is rejected, the rest of the batch posts`:
`expect(received).toHaveLength(expected) — Expected length: 2, Received
length: 1` (both comments went into the one batch).
- `tests/pr/remote-fetcher.test.ts` — `capped quote restoration > a
digest mismatch keeps the excerpt rather than a wrong quote`: `Expected:
1000, Received: 3000` (nothing was capped, so nothing was verified).

## Manual verification (after `bun run build`)

Comment on a ~3,000-character paragraph out of diff: on github.com the
comment should show a 12-line excerpt ending in `> …`. Reopen Bark in a
fresh session: the sidebar should show the full quote and the highlight
should cover the whole paragraph.

## Checks

`bun run test` 714 pass / 0 fail (63 files), `check:lint`,
`check:format`, `typecheck`, `build` all clean.

Closes #279
nownabe added a commit that referenced this pull request Sep 20, 2026
…346)

## Why

The issue's first acceptance criterion already holds: since #303 and
#309 the
Planner routes every draft through the same `reanchor` entry point as
display.
What was missing is the **policy for `shifted`**, and this PR decides
it:
**refuse**.

A `shifted` draft is one whose line was located but whose quoted text
changed
upstream. Posting it would attach the reviewer's words — and, for a
suggestion,
a replacement block GitHub can apply — to text they never saw, and the
posted
copy would carry a `quote` that is no longer the text at its range,
which is the
definition ADR 0002 §3 gives it (and what #279's digest restoration
relies on).
The reviewer already sees the same "position shifted" badge on the draft
before
Submit, so what is refused is exactly what was flagged; the parked draft
keeps
its `lastError` in the sidebar (#268) and is re-created on the current
text.

This reverses the lean recorded in the #269 design ("post at the located
range"), which predates the `quote` definition.

## What

- **lib/pr/planner.ts** — `toHeadCoordinates` returns `{comment} |
{error}`
instead of `Comment | null`, so the caller can tell the two refusals
apart.
A `shifted` position yields the new `SHIFTED_ANCHOR` error; `outdated`
keeps
its own message. `mapped` — including a range recovered by the region
search —
  still posts at the mapped range.
- No state-machine change: `reject-comment` already parks the comment as
  `draft + lastError`.
- **docs/adr/0003-operations-and-execution.md §5** — the policy
paragraph.
- **docs/adr/0004-reanchoring.md §4** — the `shifted` row notes the
submit-time
  refusal.

## Red-test evidence

`tests/pr/planner.test.ts` → "a draft whose quoted text changed upstream
(shifted) is refused": expected a `reject-comment`, received

```
{ kind: "post-review-batch", commitId: "current-head",
  comments: [{ anchor: { sha: "current-head",
                         range: {sl: 2, sc: 1, el: 2, ec: 12},
                         quote: "hello world" }, ... }] }
```

— the draft was posted at the located range carrying a quote that no
longer
matches the text there.

Two guards in the same block passed before and after: a draft whose
paragraph
changed *elsewhere* still posts at the located columns (`{sl:2, sc:6,
el:2,
ec:10}`, quote `"Two."`), and a draft whose line is gone is still
refused with
the *outdated* message, not the shifted one.

## Checks

`bun run test` (729 pass, 0 fail), `check:lint`, `check:format`,
`typecheck`,
`build` all pass.

Closes #313
nownabe added a commit that referenced this pull request Sep 20, 2026
…#350)

## Why

`docs/` had accumulated statements that no longer describe the code: a
wire
format two versions old, a storage backend that was never built, an ADR
rule the
UI does not follow, and superpowers specs that contradict the ADRs
without saying
so. A newcomer following the reading order AGENTS.md prescribes was
being misled.

Documentation only — no behaviour change. The ADRs were amended heavily
between
the issue and this PR (#303–#348), so every item was re-audited against
the code
on `main` (`9465718`) before editing; two were already fixed and are
recorded as
such below.

## What

Per item of #294:

1. **ADR 0003 §7 "Legacy metadata is discarded"** → rewritten as "read,
never
rewritten". `lib/pr/metadata.ts` accepts `bark:v1` and its
`docreview:v1`
alias read-only (`extractMetadata` → `parseV1`) and maps them to the v2
shape;
only an unparseable, invalid or unknown-version payload is dropped. The
note
says why there is no migration path: v1 payloads live in comment bodies
on
github.com, which no client release can rewrite. The two
cross-references that
repeated the old claim (ADR 0001 and ADR 0002 closing notes) now
distinguish
local legacy keys, which *are* dropped, from on-GitHub metadata, which
is not.

2. **ADR 0004 §5 force-push bullet** → replaced. `GET
contents?ref={sha}`
addresses a commit object, not a ref, so a force-pushed sha normally
stays
fetchable (and PR heads are retained under `refs/pull/N/head`);
re-anchoring
proceeds through the line map as usual, and only a real 404
(garbage-collected
commit, path or repo gone) leaves `FileContent` missing and yields
`outdated`.
   Design doc §12-3 is closed accordingly.

3. **ADR 0005 §1/§5 manual refresh** → amended to match the code rather
than
gating the fab. `DebugFab` is always rendered; the Refresh button lives
one
click deeper, inside the debug popover, next to the internal-state dump.
§5
carries an explicit amendment note saying that is accepted for v1 and
why.
`docs/design-principle.md`'s floating-controls bullet now states the
rule the
   two FABs actually follow: reveal-only may ship, behaviour-changing is
   build-gated (`.role-fab` / `BARK_DEV_ROLE_SWITCH`).

4. **Design doc §7.1 / §7.7 / §10** → the raw-JSON `bark:v1` example is
replaced
by a real `bark:v2` base64 envelope with its decoded payload, the
optional
`resolved` and `quoteDigest`/`quoteLength` (#334) fields, and a pointer
to
`lib/pr/metadata.ts` as the authoritative field list. §7.7 now describes
`chrome.storage.local` as the only store, lists the three per-PR keys,
and
states plainly that the IndexedDB plan was never built; §10's "persist
state to
IndexedDB" bullet and its ETag sentence are rewritten to what the client
does.

5. **2026-06-18 resolve spec** → the superseded banner added by #310 is
present
and correct; verified, not touched. Its *plan* had none, so it got one.
The
design doc's authority paragraph now covers `docs/superpowers/`
explicitly:
history, not authority, and the absence of a banner is not a promise of
   currency.

6. **§7.9 `addressed` vs ADR 0004 `shifted`** → ADR 0004 §4 gains a
paragraph
stating that `shifted` is the raw mechanical signal and R9's `addressed`
(#3)
is derived from it plus the review rounds, specified separately and
stored
nowhere. Design doc §7.9 now references the ADR statuses instead of
inventing
   its own, and notes that the `addressedBySha` in `lib/github.ts` is an
   unreferenced legacy type, not part of the model.

7. **Design doc §11 status** → R8 cross-file navigation is marked
shipped (the
changed-`.md` selector in `Topbar.tsx`, fed by
`RemoteState.changedFiles`), so
   M5 is done and M4 (R9/R10) is the remaining open work.

8. **ADR statements not implemented** — decided in favour of the code:
- **ADR 0002 §6** rewritten to describe materialise-at-submit as
implemented:
`SuggestionEdit` is persisted on its own `:suggestion-edits` key (400 ms
debounce, read-modify-write per path), stays "live" in the editor until
Submit, and only then becomes draft `Comment`s whose id is derived, not
minted, from `(path, baseSha, range, replacement)` (#337/#308). The
stale
"lost on reload" trade-off and the auto-save Deferred item are replaced
by
the real consequence: two persistence paths, with folding
`SuggestionEdit`
     into the Repository as the deferred work.
- **ADR 0005 §2** "already-fetched pairs are retained" deleted. A full
refresh
replaces `RemoteState` wholesale, refetching every pair; the sentence is
replaced by why that is fine (ETag `If-None-Match` on every GET, 304
costs no
     rate limit) and a pointer to the still-deferred persistent cache.
- **ADR 0001 §4 `useAppState`** — already fixed by #329; §4 is the
conflict
     policy and names no hook. Verified, no change.

Also folded in (from the #299 agent, found while reviewing PR #349):

- **AGENTS.md / README.md layout** described `lib/github.ts` as "GitHub
API". It
  is not: it holds PR types and four pure helpers, while the client, the
Repository pipeline, re-anchoring and the wire format all live in
`lib/pr/`.
Both are rewritten around `lib/pr/` as the place to start, and the
non-existent
`lib/reanchor.ts` is dropped. (`CLAUDE.md` is a symlink to `AGENTS.md`,
so one
  edit covers both.)
- **2026-06-21 author-role-derivation spec and plan** describe
`deriveRole` and a
`GitHubClient.getAuthenticatedUser` lookup; the live derivation is
`computeRole`
in `lib/pr/appstate.ts`, which also withholds `author` when `headRepo`
is `null`
(#273). Both files get a Superseded banner pointing there and at ADR
0002 §4.

Every ADR amended here records it in the header in ADR 0004's existing
`- Amended: <date> (#issue) — <what>` format; two prior amendments that
had
changed an ADR body without a header line (#267 on ADR 0004/0005, #289
on
ADR 0001) are backfilled from their commits, and ADR 0002's in-place
2026-07-22
note is now also listed in the header.

## Testing

No test accompanies this change: it edits only Markdown, and there is no
assertion a docs edit could make fail. The verification was reading each
claim
against the code it describes — `lib/pr/metadata.ts`,
`lib/pr/reanchor.ts`,
`lib/pr/remote-fetcher.ts`, `lib/pr/chrome-storage.ts`, `lib/drafts.ts`,
`entrypoints/review/hooks/useSuggestionEdits.ts`,
`entrypoints/review/components/DebugFab.tsx`,
`entrypoints/review/reviewItems.ts`
— and the base64 example in §7.1 is generated, not hand-written, so it
decodes to
the JSON printed beneath it.

## Checks

`bun run test` (822 pass / 0 fail, 65 files) · `check:lint` ·
`check:format` ·
`typecheck` · `build` — all clean. Note for future docs PRs: `oxfmt`
**does**
format Markdown in this repo, and it reflowed the README table.

## Noted, out of scope

- `lib/storage.ts:2-3` still promises "IndexedDB: per-PR pending
comments/
suggestions, snapshots (later slice)" in its header comment — the same
drift as
item 4, but in code. Left for a code PR since this one touches no `.ts`.
- `lib/github.ts` keeps the dead `CommentStatus` / `ReviewComment` /
  `addressedBySha` types that nothing imports. PR #349 removes them.
- Nothing links to `docs/superpowers/` or `docs/chrome-web-store/`, and
`docs/adr/` has no index page. The authority paragraph now explains what
`superpowers/` is, which covers the misleading part; an index is a
separate
  question.

Closes #294
nownabe added a commit that referenced this pull request Sep 20, 2026
#353)

## Why

Comments that say where code *used to* live, or that name a
refactor-plan phase
(`Pack B / R8b`, `L7e-1`, `Phase 4`), send the reader looking for
something that
either moved or was never in this repo. CSS rules with no markup and
exports with
no importer cost the same kind of lookup. Two of them were worse than
noise: the
`pr:{owner}/{repo}#{n}` key prefix and the UTF-8 base64 decoder each had
two
independent definitions that could silently drift.

Net **-130 lines** (135 insertions / 265 deletions) across 29 files,
plus one
deleted file. No behaviour change.

## What

**1. Tombstone / phase-tag comments.** Re-located by content (the
issue's line
numbers are from before #303–#350). Rewritten to say what the code is,
or deleted
where the comment only described history: `App.tsx` (a garbled
half-sentence, six
"now lives in …" markers, and the `L5` / `L6c` / `L6d-1` / `L7e-1` /
`R3` / `R6`
tags), the five `hooks/` headers, both `adapters/` headers plus
`displayPositionToAnchorStatus.ts`, `highlight.ts`, `suggestionView.ts`,
`lib/drafts.ts`, `lib/comments.ts`, `lib/pr/repository.ts`.
`lib/storage.ts`'s
header advertised an IndexedDB layer that does not exist — it now says
chrome.storage.local and points at ADR 0001 §2. Real "why not" sentences
(the
reviewer note on thread visibility, the `canAccept` rationale, every
`simplify:`
and issue-numbered note) are untouched.

**2. Dead CSS.** Deleted `.field--mono`, `.badge--review`,
`.badge--suggestion`,
`.badge--anchored`, `.composer__routing`, `.radio-row` (+ `.radio-row
label`)
after an exact-token search over `entrypoints/`, `lib/`, `tests/` found
no
producer. `.badge--anchored` is unreachable by construction as well:
`ThreadItem`
builds `badge--${status}` from `AnchorStatus` (`current` | `reanchored`
|
`outdated`), gated on `STATUS_LABEL[status]`, which only defines
`reanchored` and
`outdated`. `docs/design-principle.md` no longer lists `.field--mono`.

**3. No-consumer leftovers.**
- Deleted the empty root `components/` directory (nothing in
`wxt.config.ts`,
`tsconfig.json` or the docs configures a root components dir; the real
one is
  `entrypoints/review/components/`).
- Dropped `useUiPanels.closePrInfo` (only the hook's own test called
it).
- Un-exported `APP_SLUG`, `SubmitCommitGroup`, `SubmitSummary` — all
used only in
their defining module. `SubmitGroup` stays exported:
`SubmitConfirmModal` imports it.
- `prStorageKey` / `prStorageKeys` now build on `storageKeys.pr`, the
same prefix
`lib/drafts.ts` builds, so #332's eviction and the drafts keys cannot
drift.
- `base64Decode` is exported from `lib/pr/metadata.ts` and reused by
`remote-fetcher.ts`; the fetcher keeps its own whitespace strip (GitHub
wraps
its base64 at 60 chars) rather than pushing that into the fence decoder.
- Deleted `fetchThreads` (no production caller — `fetchRemoteState`
inlines
  `listReviewThreads` + `threadsFromRaw`). Its four tests now call
`threadsFromRaw(await listReviewThreads(...))` through a 2-line local
helper, so
the paging coverage is unchanged and the only export is a function
production
  actually uses.

**4. `AppState.currentFiles`.** Verified no consumer anywhere in
`entrypoints/`;
deleted it with `buildCurrentFiles` and its two tests.

## Test evidence

This is a deletion PR, so there is no red step except for the two shared
helpers,
where the rule was to pin current behaviour *before* unifying:

- `tests/pr/chrome-storage.test.ts` — "shares its prefix with the keys
  lib/drafts.ts builds": `prStorageKey("acme","site",42)` ===
`` `${storageKeys.pr("acme","site",42)}:state` ``. Added and run **green
against
the two independent definitions**, then `prStorageKey` was rewritten
onto
  `storageKeys.pr`; still green.
- `tests/pr/remote-fetcher.test.ts` — "decodes UTF-8 from the
line-wrapped base64
GitHub returns": multibyte source, base64 wrapped at 60 chars. Added and
run
green against the fetcher's private decoder, then repointed at the
shared
  `base64Decode`; still green.

Full set on the rebased branch: **816 pass / 0 fail** (`bun run test`),
`check:lint`, `check:format`, `typecheck` and `build` all clean.

## Dropped from the issue (already fixed on main)

- `DebugFab.tsx`'s undefined `var(--green)` — gone with DebugFab's
preview.
- `lib/pr/bootstrap.ts:8-17` — the current header describes the live
composition
  accurately; nothing to remove.
- `lib/pr/repository.ts:159` — that line is live code today; only the
`(Phase 4)`
  tag on line 8 needed a fix.

## Left out, on purpose

Two phase tags remain in `App.tsx`'s submit flow — `// already
double-written by
L4/L6a` and `// (the L6d-1 effect is best-effort…)`. Both sit inside the
`composeDraftBody` call regions that the still-open #351 edits, so they
are left
for a one-line follow-up after that merges rather than handed #351 a
conflict.

Closes #301
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.

[High] Drafts are submitted with creation-sha line numbers against the current head commit

1 participant