Skip to content

fix(desktop): Clear cookies also forgets clipboard and location answers - #45201

Open
iamshadmantaqi wants to merge 2 commits into
pingdotgg:mainfrom
iamshadmantaqi:fix/clear-cookies-site-permissions
Open

iamshadmantaqi wants to merge 2 commits into
pingdotgg:mainfrom
iamshadmantaqi:fix/clear-cookies-site-permissions

Conversation

@iamshadmantaqi

Copy link
Copy Markdown
Contributor

Problem

In the desktop browser panel, "Clear cookies" does not make a page ask again for clipboard or location access.

Steps (Linux works, no sign-in):

  1. Open the browser panel and load any https page, for example https://example.com.
  2. In DevTools for the tab, run await navigator.clipboard.readText() and click Block. It rejects.
  3. Browser panel ... menu > Clear cookies (or Settings > Integrations, browser profile).
  4. Run await navigator.clipboard.readText() again. It rejects at once with no prompt. Expected: the prompt shows again.

An Allow survives the clear too, so clearing a profile does not revoke clipboard read or location access. navigator.permissions.query({ name: "clipboard-read" }) keeps reporting the old answer.

Camera and microphone answers (#38146) are already reset by Clear cookies. This makes clipboard and location match.

Cause

In apps/desktop/src/preview/BrowserSession.ts, the clipboard and location answers (permissionDecisions) are Maps made per session. forgetMediaDecisions, which clearCookies and cookiesCleared call, clears only the camera and microphone Map. Nothing clears the other two. Also, an answer to a prompt that was open during the clear is stored after it, because only the camera path checks the reset counter.

Change

The clipboard and location Maps now sit on the session's consent record next to the camera and microphone one, so forgetMediaDecisions clears all of them. The prompt callback skips storing an answer when a reset happened while it was open, using the same resets guard the camera and microphone code already has. 14 lines added, 4 removed, one file.

Scope

Small fix of an obvious bug, steps reproduce it, so it needs no issue.

Verification

New test in BrowserSession.test.ts, run for clipboard-read and geolocation: block, clear cookies, ask again (a prompt shows, allow), then cookiesCleared revokes the allow and the next request prompts again.

Test commit alone, fails on main 867da42:

 × forgets clipboard-read answers when the profile's cookies are cleared
 × forgets geolocation answers when the profile's cookies are cleared
AssertionError: expected false to be true   (BrowserSession.test.ts:741, the request after clearCookies)
 Tests  2 failed | 25 passed (27)

With the fix, the whole file:

 Test Files  1 passed (1)
      Tests  27 passed (27)

vp run check:changed: format, lint, knip, typecheck (2 packages) and test (1 file) all pass.

Not verified: I did not click Block and Clear cookies by hand in the running app; the unit test drives the session's permission request and check handlers directly. Chrome keeps site permissions when cookies are cleared, and #26173 says clipboard answers last for the browser session, so the maintainers may prefer the old behaviour.

Model: Claude Opus 5.5. Harness: Claude Code in T3 Code.

@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Nov 28, 2026
@coderabbitai

coderabbitai Bot commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Clipboard and geolocation permission decisions now reset with media consent. Answers are stored only if the consent reset counter remains unchanged while a prompt is open. Tests cover decision reuse and invalidation during cookie clearing.

Changes: Origin permission consent

Layer / File(s) Summary
Permission decision reset lifecycle
apps/desktop/src/preview/BrowserSession.ts, apps/desktop/src/preview/BrowserSession.test.ts
Session consent state now includes clipboard and geolocation decision maps. Consent resets clear these maps. Prompt answers are stored only if the reset counter has not changed. Tests cover decision reuse and invalidation during cookie clearing.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: nasimawabdy, juliusmarminge

Merge Risk: Minimal · up to 72f54

Clear cookies now also makes the desktop browser panel forget clipboard and location permission answers, as it already did for camera and microphone. No merge-blocking risk was found. The author did not manually test this in the running app.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(desktop): Clear cookies also forgets clipboard and location answers" follows conventional commit format and names the main change: clearing cookies now also resets clipboard-read and ge…
Description check Passed The description follows the template well. It has Problem, Change, Scope, and Verification sections. The problem has clear reproduction steps and expected behavior. The change explains the fix and the…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix(desktop): Clear cookies also forgets clipboard and location answers" follows conventional commit format and names the main change: clearing cookies now also resets clipboard-read and geolocation permission answers in the desktop browser panel. The raw summary and objectives confirm this change, which is the primary purpose of the PR.

Full details: Description check

Explanation

The description follows the template well. It has Problem, Change, Scope, and Verification sections. The problem has clear reproduction steps and expected behavior. The change explains the fix and the reset guard. Scope explains why no issue is linked and cites #38146 and #26173. Verification gives focused test names, before/after failing and passing results, and a candid note of what was not verified. The template's model/harness attribution line is present. Minor gap: the Scope section says no issue is needed, which the template accepts for small obvious bugs, so this is acceptable.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 867da42 and 72f5482.

Files selected for processing: 2

  • apps/desktop/src/preview/BrowserSession.test.ts
  • apps/desktop/src/preview/BrowserSession.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant