Skip to content

Fix double-prompt caused by www-redirect chain (v1.22) - #1

Merged
aidankeighron merged 2 commits into
mainfrom
claude/jolly-ramanujan-sz3y1l
Aug 11, 2026
Merged

Fix double-prompt caused by www-redirect chain (v1.22)#1
aidankeighron merged 2 commits into
mainfrom
claude/jolly-ramanujan-sz3y1l

Conversation

@aidankeighron

Copy link
Copy Markdown
Owner

Problem

The blocking UI was appearing twice every time a user opened a target app. The first prompt showed correctly; after pressing the button to proceed, a second prompt appeared immediately. This was consistent across all target sites and session types.

Root Cause

Commit 50f838e introduced pendingPromptTabs to guard against duplicate processing, but its clearing logic was too aggressive. When a user navigated to youtube.com (without www), the browser automatically redirected to www.youtube.com. This fired a second tabs.onUpdated event with a new changeInfo.url — which the guard cleared pendingPromptTabs on, treating it as a "user navigating away from prompt." The tab had not yet committed to prompt.html, so the second event fell through to checkAccess and issued a duplicate redirect.

The same pattern occurs for instagram.com → www.instagram.com and reddit.com → www.reddit.com, which is why it affected every target site consistently.

Fix

Introduced tabsCurrentlyAtPrompt — a Set that tracks when a tab has actually committed to prompt.html. The tabs.onUpdated handler now uses this to distinguish:

  • Redirect-chain event (tab is pending but hasn't reached prompt.html yet) → suppressed
  • User navigating away from prompt (tab is confirmed at prompt.html and now leaving) → processed normally, clears both sets

Also clear processingTabs when the tab commits to prompt.html so back-button navigation is processed correctly without waiting for the 1-second debounce.

Test changes

  • tests/setup.js: Added chrome.webNavigation mock — was missing entirely, causing all 62 existing tests to crash with TypeError: Cannot read properties of undefined (reading 'onCommitted').
  • tests/helpers.js: Added fireCommitted helper for webNavigation.onCommitted events.
  • tests/flows.test.js: Updated "fresh URL navigation away from prompt" test to use the correct flow (tab must commit to prompt.html before navigating away); added two new tests:
    • www-redirect chain does not double-prompt
    • back button without session re-shows prompt

All 64 tests pass.


Generated by Claude Code

The blocking UI was appearing twice consistently: once when navigating to
a target site, and again immediately after pressing the allow button.
Root cause was commit 50f838e's pendingPromptTabs guard clearing too
eagerly on any changeInfo.url event, which fired for the browser's
automatic site.com → www.site.com redirect before the tab had committed
to prompt.html. The second event fell through to checkAccess and issued
a duplicate prompt.

Fix: introduce tabsCurrentlyAtPrompt to track when a tab has actually
committed to prompt.html. Only clear pendingPromptTabs when the tab is
genuinely navigating away from the prompt (i.e. tabsCurrentlyAtPrompt
is set). Redirect-chain events arriving before the prompt commit are now
suppressed correctly. Also clear processingTabs on prompt commit so
back-button navigation is processed without waiting for the 1-second
debounce to expire.

Test infrastructure: add chrome.webNavigation mock to setup.js (was
missing, causing all 62 tests to crash), add fireCommitted helper to
helpers.js, and add two new flow tests covering the www-redirect chain
and back-button without session scenarios.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018tjmes3dCNNYxB5n7LzYzL
@aidankeighron

Copy link
Copy Markdown
Owner Author

@copilot please fix the merge conflicts in this pull request, version should be v23

Co-authored-by: aidankeighron <78337317+aidankeighron@users.noreply.github.com>
@aidankeighron
aidankeighron merged commit 0234ebc into main Aug 11, 2026

Copilot AI commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

@copilot please fix the merge conflicts in this pull request, version should be v23

Done in 185d642 — I merged main, resolved the manifest merge conflicts, and set the extension version to v1.23.

Copilot stopped work on behalf of aidankeighron due to an error August 11, 2026 19:20
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.

3 participants