Skip to content

fix(extension): avoid automatic provider transport tabs - #2974

Merged
Sinity merged 1 commit into
masterfrom
feature/fix/no-auto-provider-tabs
Jul 17, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/fix/no-auto-provider-tabs

Conversation

@Sinity

@Sinity Sinity commented Jul 17, 2026 •

Copy link
Copy Markdown
Owner

Summary

Prevent passive ChatGPT/Claude capture work from opening an empty provider root tab. Passive inventory, recovery, and freshness now observe an already-open supported surface or defer; explicit queued browser actions retain the intentional inactive transport path.

Problem

The periodic freshness sweep and ordinary backfill used the same provider-tab helper as UI-mutating browser actions. When no ChatGPT tab was open, that helper created the ChatGPT root page, so closing all ChatGPT tabs caused another empty tab to materialize on the next automatic pass.

Solution

  • Split passive observation from explicit action transport in background.js.
  • Make passive provider access return a typed provider_transport_no_surface condition rather than create a page.
  • Preserve extension-owned inactive tab creation only for queued provider actions that require a UI mutation.
  • Cover existing-page reuse and zero-tab-create behavior for unsupported/no provider surfaces.

Ref polylogue-yyvg.6.

Verification

  • npm test -- --run tests/background.test.js: 75 tests passed.
  • npm run lint -- --quiet: completed successfully.

Summary by CodeRabbit

  • Bug Fixes

    • Backfill now uses an already-open supported provider page instead of creating or replacing tabs.
    • Passive backfill waits when no supported provider page is open, avoiding unnecessary tab creation and cleanup.
    • Concurrent backfill operations now consistently share the existing provider page.
  • Improvements

    • ChatGPT browser actions can open a provider page when needed for transport.

Problem: passive backfill and freshness requests created empty ChatGPT\nroot tabs whenever no provider page was open. This disturbed the operator\nbrowser and caused a recurring tab loop.\n\nWhat changed: passive page-context operations now use only an existing\nsupported provider surface and fail with a typed no-surface condition\notherwise. Creating an extension-owned background transport remains limited\nto explicit queued browser actions that mutate provider UI.\n\nCompatibility: passive backfill defers until the next normal provider visit\ninstead of opening a tab itself.
@coderabbitai

coderabbitai Bot commented Jul 17, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 36d0de29-c676-495f-9d47-4c350bc3c1df

📥 Commits

Reviewing files that changed from the base of the PR and between df37b5b and f9ca9e0.

📒 Files selected for processing (2)
  • browser-extension/src/background.js
  • browser-extension/tests/background.test.js

📝 Walkthrough

Walkthrough

Changes

Provider transport routing

Layer / File(s) Summary
Transport acquisition modes
browser-extension/src/background.js
Provider tab acquisition observes existing surfaces by default, separates concurrent observation and creation requests, and allows ChatGPT browser-action transport creation.
Existing-surface backfill behavior
browser-extension/tests/background.test.js
Backfill tests verify reuse and concurrent sharing of existing provider tabs, updated checkpoint fixtures, and deferral without supported provider surfaces.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant BrowserAction
  participant background.js
  participant chrome.tabs
  participant ProviderPage
  BrowserAction->>background.js: request ChatGPT transport with allowCreate=true
  background.js->>chrome.tabs: find or create provider tab
  chrome.tabs-->>background.js: return provider tab
  background.js->>ProviderPage: execute transport bridge
  ProviderPage-->>background.js: provide transport surface
Loading
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/fix/no-auto-provider-tabs

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.44.1)
browser-extension/tests/background.test.js

ast-grep timed out on this file


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Sinity
Sinity merged commit 492fc74 into master Jul 17, 2026
1 of 2 checks passed
@Sinity
Sinity deleted the feature/fix/no-auto-provider-tabs branch July 17, 2026 05:49

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f9ca9e06d3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread browser-extension/src/background.js Resolved
Sinity added a commit that referenced this pull request Jul 31, 2026
## Summary

`tests/build.test.js`'s packaged-service-worker fixture test was failing
on master because two of its mocks were stale relative to intentional,
already-shipped, already-tested production behavior. This PR fixes only
the fixture — no production code changed.

## Problem

Ref polylogue-uegw. `tests/build.test.js`'s "executes the packaged
service worker fixture without foreground tab activation" test failed:
`vi.waitFor` at line 274 timed out because `polylogue.backfill.start`
never issued a page request.

## Root-cause evidence

Bisected two independent, unrelated fixture defects:

1. **Dead `chrome.tabs.query` mock.** It was `vi.fn(async () => [])`,
   never reflecting the fixture's own `ownedTabs` array, so
   `observedProviderTab()` could never find a provider tab. Passive/
   automatic backfill is intentionally observe-only by design
   (`fix(extension): avoid automatic provider transport tabs`, #2974:
   "Only explicit queued UI actions may create an extension-owned
   inactive transport"), and is heavily pinned by `background.test.js`
   ("never creates a transport tab when passive backfill has no
   provider page", "defers backfill when no supported provider surface
   is open", "shares an existing provider surface across concurrent
   backfill jobs"). The fixture's `tabs.create` assertion (expecting
   the extension to create its own tab) directly contradicted that
   tested contract.

2. **No seeded receiver pairing.** `stored` never set
   `polylogueReceiverPairing`, and the fetch mock had no `/v1/status`
   handler, so `requirePairedTrustedReceiver()` (`fix(extension):
   require pairing before provider capture`, #2983) always threw
   `receiver_unpaired` for the exact-capture path.
   `background.test.js`'s successful-capture fixtures all seed this
   pairing; `build.test.js` never did.

Both gaps were pre-existing, and were already known: PR #2986's own
verification note from 2026-07-17 says "one pre-existing
packaged-worker fixture failure reproduced unchanged" — this test broke
around the same time #2974/#2983 tightened the passive-capture and
pairing contracts, and was never updated.

**Anti-vacuity check (confirms this is a fixture bug, not a production
bug):** I first attempted a production-code fix, threading
`allowCreate`/`requirePairing` options through `providerPageFetch`,
`providerAccountHandle`, and `captureProviderConversation` in
`src/background.js` so backfill could create/use its own tab and skip
pairing. That DID make `build.test.js` pass, but it broke 4
`background.test.js` tests that explicitly pin the opposite behavior
("never creates a transport tab when passive backfill has no provider
page", "defers backfill when no supported provider surface is open",
"shares an existing provider surface across concurrent backfill jobs").
That change was reverted (`git checkout -- src/background.js`); this PR
only touches the test.

## Solution

In `browser-extension/tests/build.test.js`:

- Seed one already-open, operator-owned ChatGPT tab (id 42, matching
  `background.test.js`'s convention) instead of an empty tab list, and
  make `chrome.tabs.query` return it dynamically.
- Seed `polylogueReceiverPairing` in `stored` and add a `/v1/status`
  fetch handler, matching how `background.test.js`'s successful-capture
  fixtures already model a paired receiver.
- Replace the incorrect `tabs.create` assertion with
  `expect(tabs.create).not.toHaveBeenCalled()` — consistent with the
  test's own name ("without foreground tab activation" is about not
  materializing/activating a tab at all, not merely not making it
  foreground) and with the adjacent `tabs.update` assertion.
- Update the `tabs.sendMessage` assertion's tab id from the stale
  fixture-only id 77 to the pre-seeded tab id 42.

No production capture behavior changed. Shipped artifacts were never
affected by the fixture bug itself, but the two gates the fixture was
failing to model (observe-only passive/automatic transport,
pairing-gated exact capture) are real, already-shipped invariants this
fixture now correctly exercises instead of accidentally bypassing.

## Verification

- `npx vitest run tests/build.test.js` — 6/6 passed.
- `npx vitest run` (full extension suite) — 378/378 passed, run twice.
  `tests/background.test.js`'s one known-flaky timing test ("falls back
  to the adapter's full-fidelity normalization...") failed once on a
full-suite run and passed clean when re-run in isolation — pre-existing
  flake, unrelated to this change, matches the operator's advance note.
- `node scripts/validate-manifest.mjs` — manifest ok.
- pre-push `devtools verify --quick` — passed (18 steps, 68.7s).

Ref polylogue-uegw.

Co-authored-by: Claude <[email protected]>
@Sinity

Sinity commented Sep 30, 2026

Copy link
Copy Markdown
Owner Author

Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.

  • 52.F007 / P1: Fix and current-source recheck assigned to polylogue-jlme.7; not claimed fixed. browser-extension/src/background/runtime.js:265 catches provider-surface recovery errors and returns a partial recovery instead of rejecting initialization. Line 399 then caches the resolved coordinator; activation only refreshes archive state at line 3325 and does not repeat receiver job discovery.

Only the rows listed above are dispositioned. Held findings remain open.

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.

1 participant