fix(extension): reattach the write_cookies doc block, and name the writable cookies as writable - #215
Conversation
…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
|
Claude finished @chrischall's task in 3m 1s —— View job Review complete
SummaryBoth fixes described in the PR body check out:
🟡 Nit
No other issues found — Verdict: warn |
| // "Overwrite …". | ||
| appendScopeSubList( | ||
| dl, | ||
| pending.capabilities.includes('write_cookies') ? 'Read and overwrite cookies' : 'Read cookies', |
There was a problem hiding this comment.
🟡 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.
|
🟡 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. |
🤖 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>
Closes #212 — the two round-4 findings on #211, which merged before they could be addressed on that PR.
Orphaned doc block
partialWriteErrorwas spliced in betweenhandleWriteCookiesRequest'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.tslistedcookieKeysunder'Read cookies'unconditionally. That sub-list is the only place those names appear, so a user grantingwrite_cookiessaw 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 —
renderPopupinto 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 #212went 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.Closesbelongs 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