Skip to content

fix(extension): reconcile terminal captures before fetch - #2977

Merged
Sinity merged 1 commit into
masterfrom
feature/fix/terminal-capture-circuit
Jul 17, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/fix/terminal-capture-circuit

Conversation

@Sinity

@Sinity Sinity commented Jul 17, 2026 •

Copy link
Copy Markdown
Owner

Summary

Stops the installed extension from re-fetching provider conversation data for conversations the receiver already accepted or archived.

Problem

Live Chrome evidence showed fetchNativePayloadFromContentScript repeatedly retrieving a completed Sol-Pro conversation and two attachments every few seconds. Startup, tab activation, and tab-update paths directly captured terminal conversations; service-worker restarts reset their in-memory throttle and amplified receiver faults into authenticated ChatGPT traffic.

Solution

Automatic lifecycle paths now reconcile each tab against receiver archive state. Only a missing state triggers automatic capture; spooled_only and archived states remain receiver-owned convergence. Explicit popup sync remains an operator-requested direct capture. Focused tests cover terminal startup/activation non-recapture and missing-state capture.

Ref polylogue-yyvg.6.1.

Verification

  • npm test -- --run tests/background.test.js — 76 passed.
  • npm run lint — passed.
  • devtools verify --quick — 16/16 steps passed.
  • npm test — 314 passed; one inherited failure in tests/build.test.js > executes the packaged service worker fixture without foreground tab activation, reproduced unchanged on current master.

Summary by CodeRabbit

  • Bug Fixes
    • Reduced duplicate background captures when activating, updating, or synchronizing open conversation tabs.
    • Improved archive-state reconciliation during extension updates and tab events.
    • Ensured missing conversations are automatically captured only once.
    • Prevented unnecessary capture messages and throttling events when conversations are already archived.

Problem: automatic startup and tab lifecycle paths directly captured already
spooled or archived conversations. Each capture performs authenticated
conversation and attachment retrieval, so receiver faults or worker restarts
could amplify terminal campaign work into a provider request loop.

What changed: automatic paths now reconcile archive state first and capture
only missing conversations. Explicit operator sync retains its direct capture
behavior. Tests prove startup and activation do not recapture terminal state,
while a missing conversation is still captured.

Co-Authored-By: Claude <[email protected]>
@Sinity
Sinity merged commit d762eb4 into master Jul 17, 2026
1 check passed
@Sinity
Sinity deleted the feature/fix/terminal-capture-circuit branch July 17, 2026 07:17
@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: 24d0f9fe-9f41-4a17-a82a-8e2c6436068c

📥 Commits

Reviewing files that changed from the base of the PR and between 486662f and e7c720f.

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

📝 Walkthrough

Walkthrough

Background tab reconciliation now refreshes archive state instead of unconditionally recapturing tabs. Activation and update handlers use the same path, while tests cover archived-tab suppression and one-time capture for missing conversations.

Changes

Archive reconciliation

Layer / File(s) Summary
Reconciliation flow
browser-extension/src/background.js
Popup synchronization, tab activation, and tab updates refresh archive state without direct background recapture.
Reconciliation validation
browser-extension/tests/background.test.js
Tests verify update reconciliation without capture messaging, archived-tab suppression, and one-time capture when archive state is missing.

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

Possibly related PRs

  • Sinity/polylogue#2928: Refactors capture convergence toward provider-neutral, receiver-authoritative archive-state reconciliation.
✨ 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/terminal-capture-circuit

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 restored the feature/fix/terminal-capture-circuit branch July 17, 2026 07:17

@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: e7c720ffce

ℹ️ 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
Comment thread browser-extension/src/background.js Resolved
@Sinity
Sinity deleted the feature/fix/terminal-capture-circuit branch July 17, 2026 19:55
Sinity added a commit that referenced this pull request Jul 18, 2026
…3098)

## Summary
Four commits closing AC gaps on the three P0 extension beads flagged by
the 2026-07-17 warroom It.17 sweep, all scoped to `browser-extension/` +
receiver code:

1. `polylogue-yyvg.6.1` AC1: a deterministic fixture proving no ChatGPT
conversation/attachment request occurs for a terminal conversation
across a receiver outage *combined with* a simulated service-worker
restart.
2. `polylogue-ptx` AC6: a static/contract test rejecting reintroduction
of the retired `BrowserPostCommand`/`BrowserLaunchJob` campaign
machinery or campaign-identity vocabulary.
3. `polylogue-ptx` AC7: receiver-side coverage of all six typed
pre-submit failure outcomes (the extension side already had it; the
receiver's identical state-machine branch did not).
4. `polylogue-yyvg.7`: a real (partial) slice of the exception-driven
popup redesign — a single-item `computeAttention()` surface plus a
pending-browser-action count, and progressive-disclosure diagnostics for
the previously always-visible machinery (receiver pairing/reset, work
queue, backfill panel, raw logs, receiver settings).

## Problem
All three beads had their core behavior land already (`yyvg.6.1` via
#2977/#2979/#2981/#2983/#2986; `ptx` via #2928; `yyvg.7`'s first UX
slice via #2928/#2929) but were left open pending explicit AC-by-AC
checks, and several AC clauses specifically wanted *fixtures*, *guards*,
or *UI surfaces* that didn't exist yet — see full AC-by-AC verdicts
recorded in each bead's notes (`polylogue-yyvg.6.1`, `polylogue-ptx`,
`polylogue-yyvg.7`).

## Solution
- `browser-extension/tests/background.test.js`: new fixture combining a
receiver outage with a simulated service-worker restart against a
terminal conversation.
- `tests/unit/architecture/test_browser_action_conduit_vocabulary.py`:
static scan over `polylogue/browser_capture/`,
`polylogue/daemon/browser_capture.py`, and `browser-extension/src/`.
- `tests/unit/browser_capture/test_actions.py`: parametrized
`test_typed_provider_failures_block_and_release_the_lease` over all six
receiver failure outcomes.
- `browser-extension/src/operator_status.js`: new `computeAttention()`
(strict single-item typed priority list: auth/pairing mismatch → action
`outcome_unknown` → capability mismatch → archive failure → null) and
`pendingBrowserActionCount()`, added to the existing shared status
module already used by ambient/message-layer/popup.
- `browser-extension/src/popup.html` + `popup.js`: a "Pending browser
actions" count and hidden-by-default "Attention" section under the
header; receiver pairing/reset, work queue, backfill panel, recent
capture log, debug log, and receiver settings now live inside one
collapsed `<details id="diagnostics">`. Clicking an attention item's
action opens diagnostics and drives the real underlying control (no
second authority copy).

**Honesty on scope**: commit 4 is explicitly a partial yyvg.7 slice, not
full closure — pixel-level mockup convergence, a compact bounded "Now"
summary, the "explicit submit/destructive approval" and "destructive
conflict" attention categories (no backing data model yet), a DOM/height
budget check, and the live installed proof all remain open. Recorded
honestly in the bead notes rather than claimed done.

## Verification
- `npx vitest run` (in `browser-extension/`) → 335 passed, 1
pre-existing unrelated failure (packaged service-worker backfill fixture
in `tests/build.test.js`; reproduced unchanged on a clean tree with this
branch's changes stashed out)
- `npm run lint` / `npm run validate` (in `browser-extension/`) → clean
/ manifest ok
- `devtools test
tests/unit/architecture/test_browser_action_conduit_vocabulary.py` → 1
passed
- `devtools test tests/unit/browser_capture/test_actions.py` → 18 passed
- `devtools verify --quick` (pre-push hook, all four pushes) → exit 0

Ref polylogue-yyvg.6.1, polylogue-ptx, polylogue-yyvg.7

---------

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.F008 / P1: Fix and current-source recheck assigned to polylogue-jlme.7; not claimed fixed. browser-extension/src/background/runtime.js:3317 sends installation events to captureSupportedTabs, which only reconciles archive state at line 2575. Archived ChatGPT and spooled-only states take the no-capture branch at line 3039, leaving existing pages without ensureCaptureScripts and its freshness observer.
  • 52.F009 / P1: Fix and current-source recheck assigned to polylogue-jlme.7; not claimed fixed. browser-extension/src/background/runtime.js:3024 now requests lifecycle recapture for providers without freshness convergence, but browser-extension/src/content/claude.js:327 still chooses its cached native payload before an on-demand fetch. The stale-archive failure remains reachable for Claude even though the activation handler was restored.

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