Skip to content

fix(extension): reattach the write_cookies doc block, and name the writable cookies as writable - #215

Merged
chrischall merged 1 commit into
mainfrom
fix/write-cookies-docs-and-popup
Aug 5, 2026
Merged

fix(extension): reattach the write_cookies doc block, and name the writable cookies as writable#215
chrischall merged 1 commit into
mainfrom
fix/write-cookies-docs-and-popup

Conversation

@chrischall

Copy link
Copy Markdown
Owner

Closes #212 — the two round-4 findings on #211, which merged before they could be addressed on that PR.

Orphaned doc block

partialWriteError was spliced in between handleWriteCookiesRequest's doc block and the function, so ~40 lines documenting the verb's four gates, its all-or-nothing refusal and the cookie-shadowing trap ended up describing a five-line string helper. The helper moves above the block; nothing else changes.

Worth naming the cause: I was editing source by matching a string anchor. The anchor matched, the edit applied, the build passed, the tests passed — and the result was still wrong, because nothing verifies that prose sits on the function it describes.

Cookie names headed "Read cookies" while granting a write

popup.ts listed cookieKeys under 'Read cookies' unconditionally. That sub-list is the only place those names appear, so a user granting write_cookies saw the affected cookies filed under a read verb — directly contradicting the capability line above it, which says "Overwrite cookies it can already read (can change your signed-in session)".

It now reads "Read and overwrite cookies" when the capability is present. The user sees one consistent story at the moment they decide, which is the whole point of itemising the names in the first place.

Pinned by a rendering test — renderPopup into a container, then read the actual <dt> — not a source-text match. The earlier popup test in this series asserted on source text and would have passed on a comment containing the right words; not worth repeating that mistake two PRs later.

Verified the test fails against the unfixed heading before fixing it.

Note on #212

I reopened it. Closes #212 went into #211's body when only the round-3 items were resolved, and round 4 then added these two to the same issue — so the merge closed it with both outstanding. Closes belongs on a PR only once every item is genuinely done, and I added it a round early.

1194 tests pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_012o2nXwu7tov6j7ciBEpigo

…itable cookies as writable

Two round-4 review findings on #211, both mine.

`partialWriteError` was spliced in between `handleWriteCookiesRequest`'s
doc block and the function, so ~40 lines documenting the verb's gates,
its all-or-nothing refusal and the cookie-shadowing trap ended up
describing a five-line string helper instead. The helper moves above the
block; nothing else changes. That came from editing source by matching a
string anchor — the anchor matched and the result was still wrong, which
no test can catch.

The pair popup listed the cookie names under "Read cookies" even when
`write_cookies` was granted. That sub-list is the ONLY place the names
appear, so at the moment the user decides, the affected cookies were
filed under a read verb — contradicting the capability line directly
above it, which says "Overwrite cookies it can already read (can change
your signed-in session)". It now reads "Read and overwrite cookies" when
the capability is present.

The heading is pinned by a rendering test rather than a source-text
match: `renderPopup` into a container, then read the actual `<dt>`. The
previous popup test in this feature asserted on source text and would
have passed on a comment containing the right words — worth not
repeating in the same PR series.

Closes #212

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012o2nXwu7tov6j7ciBEpigo
@github-actions github-actions Bot added the auto-review Trigger Claude + Copilot review on this PR label Aug 5, 2026
@claude

claude Bot commented Aug 5, 2026

Copy link
Copy Markdown

Claude finished @chrischall's task in 3m 1s —— View job


Review complete

  • Read CLAUDE.md for conventions
  • Read PR diff
  • Review background.ts changes
  • Review popup.ts changes
  • Review popup.test.ts changes
  • Post findings

Summary

Both fixes described in the PR body check out:

  • Orphaned doc blockgit diff origin/main...HEAD -- packages/extension-core/src/background.ts confirms partialWriteError (background.ts:1858-1870) now sits entirely above the handleWriteCookiesRequest doc block, which is contiguous with the function it describes (background.ts:1872-1906). No logic changed, pure reordering.
  • Cookie heading contradictionpopup.ts:699-703 now heads the cookie sub-list "Read and overwrite cookies" when write_cookies is granted, matching the capability line's "Overwrite …" wording. popup.test.ts:1011-1055 pins this with a real renderPopup + <dt> read (not a source-text match), and per the PR body the author verified it fails against the unfixed heading.

🟡 Nit

  • popup.ts:701pending.capabilities.includes('write_cookies') dereferences pending.capabilities directly, while the same function computes a defensively-guarded caps local 8 lines earlier (popup.ts:672-674) precisely because pending.capabilities can be falsy for non-bootstrap callers ("Defensive: callers in test code may omit capabilities"). The one real production caller (popup.ts:931) always normalises to ['fetch'] at worst, so this isn't a live production bug today, but it's inconsistent with the established defensive pattern in the same function and would throw (blanking the whole popup) if a future/test caller omits the field. Swapping in caps.includes('write_cookies') matches the existing convention at no cost. Left as an inline comment with a fix link.

No other issues found — write_cookies handling, gate ordering, and the rest of the diff are unaffected.

Verdict: warn

// "Overwrite …".
appendScopeSubList(
dl,
pending.capabilities.includes('write_cookies') ? 'Read and overwrite cookies' : 'Read cookies',

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Nit: this dereferences pending.capabilities directly, but the caps local computed 8 lines above (packages/extension-core/src/popup/popup.ts:672-674) exists specifically because this same function treats pending.capabilities as possibly falsy:

// Defensive: callers in test code may omit `capabilities`, in which case we fall back to ['fetch'].
const caps = pending.capabilities && pending.capabilities.length > 0
  ? pending.capabilities
  : ['fetch'];

In the real bootstrap path this is safe today — the only production caller of renderPopup('pending-pair', …) normalises with capabilities: [...(pending.capabilities ?? ['fetch'])] (packages/extension-core/src/popup/popup.ts:931), so pending.capabilities can't actually be undefined there. But per the adjacent comment, non-bootstrap callers (test code, and any future caller) aren't guaranteed to supply it, and .includes on undefined would throw and blank the whole popup rather than just mis-labelling the cookie heading. Swapping in the already-computed caps.includes('write_cookies') would match the established defensive pattern in this same function at no cost.

Fix this →

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

🟡 Auto-review verdict: warn — Both claimed fixes (doc-block reattachment, cookie-heading wording) check out against the diff and are covered by a genuine rendering test. One minor robustness nit found and posted inline.
📋 Tracking follow-ups: #216

@chrischall chrischall added the ready-to-merge Owner has reviewed; arm auto-merge to land when CI is green label Aug 5, 2026
@chrischall
chrischall enabled auto-merge (squash) August 5, 2026 23:15
@chrischall
chrischall merged commit 2730c4a into main Aug 5, 2026
13 checks passed
@chrischall
chrischall deleted the fix/write-cookies-docs-and-popup branch August 5, 2026 23:16
chrischall added a commit that referenced this pull request Aug 6, 2026
🤖 I have created a release *beep* *boop*
---


##
[2.0.0](v1.11.0...v2.0.0)
(2026-08-06)


### ⚠ BREAKING CHANGES

* **protocol:** bind the ephemeral key into the ready signature
([#222](#222))

### Features

* **protocol:** add write_cookies, the one verb that can repair a
rotated session
([#211](#211))
([b2557c2](b2557c2))
* **protocol:** bind the ephemeral key into the ready signature
([#222](#222))
([c13aeed](c13aeed))
* **server:** let a request name the tab that relays it
([#207](#207))
([c5d3f4d](c5d3f4d))
* **server:** pin the extension's identity, and verify it on the peer
path ([#213](#213))
([0eeced7](0eeced7))


### Bug Fixes

* **cli:** let a real filesystem error be itself, not "no extension pin"
([#221](#221))
([c87a864](c87a864)),
closes [#220](#220)
* **cli:** validate --via-tab before connecting, like the request URL
([#210](#210))
([959fcc5](959fcc5))
* **extension:** reattach the write_cookies doc block, and name the
writable cookies as writable
([#215](#215))
([2730c4a](2730c4a))
* **extension:** use the guarded caps local for the cookie heading
([#217](#217))
([f95c832](f95c832))
* **server:** release only our own extension claim, and stop guessing
scoped names
([#219](#219))
([3d90a64](3d90a64)),
closes [#218](#218)
* **server:** type no-tab rejections so they stop reading as version
mismatches ([#205](#205))
([dc30bd9](dc30bd9))


### Refactor

* **server:** drop the concatBytes imports the signature change orphaned
([#224](#224))
([4985ba7](4985ba7)),
closes [#223](#223)

---
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: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-review Trigger Claude + Copilot review on this PR ready-to-merge Owner has reviewed; arm auto-merge to land when CI is green

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto-review follow-ups for PR #211: feat(protocol): add write_cookies, the one verb that can repair a rotated session

1 participant