Repository navigation
fix(cooperation,cdp,daemon): stop false coverage-changed freezes across SPA routes and subframe churn - #762
Merged
Conversation
…ss SPA routes and subframe churn
Why:
- Users on modern SPA apps and commercial sites with child iframes frequently hit
`permission_denied: Page interaction coverage changed; wait and synchronize`
(`reason: control_context_invalid`, `effect_state: unknown`), which also froze
the tab's `IntentWal` ledger until a manual sync/reconcile.
- Interacting root causes across CDP, content capture, cooperation controller,
interaction handlers, and daemon scope caching produced this failure mode:
1. `ChromiumCdp` routed root `Page.navigatedWithinDocument` (`pushState`,
`replaceState`, `#hash`) and parameterless `DOM.documentUpdated` (emitted on
`{ tabId }` whenever any same-process child `<iframe>` mounts or navigates
once `DOM` is active) to `onDocumentChanged` -> `cooperation.invalidate`,
setting `state.unavailable = true` on a live document, while `doAttach`
after `soft_detached` did not restore `entry.frameDiscovery.rootFrameId`.
2. `cooperation-capture.ts` rotated `state.document` on every root
`location.href` change, causing mid-action `prepareFrames` refreshes to
misclassify same-document `?query` / `#hash` updates as cross-document
replacements (`mainDocumentChanged = true`).
3. Multi-step actions (`fill` Step 3, main/child-frame `scroll-to` visibility
projection) that initiated their own form submission / `onBeforeNavigate`
(or instant-commit navigation after `Input.insertText` had already fired
`input`) aborted before returning their completed receipt.
4. Background `observeTab` raced `armCommittedFrame` on child `onCommitted`,
`COOPERATION_ARM` / `COOPERATION_RESUME` did not initialize leases on newly
mounted child frames, `collectCooperationFrames` blocked its replacement
pass when a sibling unobservable subframe was proven hidden, and non-owner
`refresh` failures mutated `state.unavailable` / `state.context` during
`state.working`.
5. Handler-diagnosed errors (`Page.navigate` network rejections,
`download_capture_failed`, `fill_target_changed`) were overwritten by the
post-invoke `interruption()` check.
6. `ImplicitScopeRegistry` kept auto-injecting revoked `target` `context_id`s
after navigations or `effect_state: unknown` errors, while recovery off
Chrome `page_load_failed` interstitials rejected `target` auto-injected
contexts after a broken-link click.
What:
- Add `ChromiumCdpOptions.onRouteChanged` + `CooperationController.invalidateRoute`
and `FrameState.url` on top frames, keeping `target` DOM contexts valid across
same-pathname query/fragment updates (while consuming strict baselines for
untargeted actions) and revoking stale contexts/refs on pathname or `#/...`
hash-router transitions after action settlement (`effect_state: none`); restore
`rootFrameId`, reconcile soft-detached child frames across same-document route
updates and post-dialog checks, and stop firing `onDocumentChanged` on
`DOM.documentUpdated`.
- Allow post-input `Runtime.callFunctionOn` (bound `objectId`) and `DOM.getBoxModel`
visibility measurement to finish across `onBeforeNavigate`, and complete
`handleFill` Step 3 when `Input.insertText` already notified the page before
cross-document navigation tore down the old V8 context.
- Sequence `scheduleObserveTab` behind `armCommittedFrame`, initialize leases on
newly mounted child frames across `COOPERATION_ARM` and `COOPERATION_RESUME`,
allow `collectCooperationFrames` replacement passes past proven-hidden failed
subframes, and isolate `state.working` / `target` contexts from non-owner
`refresh` failures.
- Preserve handler-diagnosed navigation and `result.data.reason` errors, track
`implicit_ctx_usable` in `ImplicitScopeRegistry` so `clear_implicit_tab_context`
revokes auto-injection without dropping `last_vom` or `c<N>`/`o<N>` aliases for
`unchanged`/`delta` hydration, and enable `navigate`/`reload`/`navigate_back`/
`navigate_forward` recovery off `page_load_failed` root error pages.
- Add real-Chrome E2E coverage in `settlement.browser.test.ts` exercising all
scenarios end-to-end across CLI, MCP, daemon `IntentWal`/`scopes`, and Chrome.
NianJiuZst
force-pushed
the
fix/page-coverage-changed
branch
from
November 17, 2026 13:04
23edba1 to
8df7721
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the high-frequency false-positive failure reported by users on modern SPA applications and sites with dynamic child
<iframe>s:{ "code": "permission_denied", "message": "Page interaction coverage changed; wait and synchronize", "exit_code": 1, "data": { "effect_state": "unknown", "phase": "control", "reason": "control_context_invalid" } }which also froze the tab's
IntentWalledger (effect_state: "unknown") and cascaded across subsequent commands.Root Causes
Same-document SPA URL updates and same-process child-iframe
DOM.documentUpdatedevents were treated as root document destruction (ChromiumCdp+cooperation-capture.ts)ChromiumCdprouted rootPage.navigatedWithinDocument(history.pushState,history.replaceState,#hash) and parameterlessDOM.documentUpdated(emitted by Chromium on{ tabId }whenever any same-process child<iframe>mounts or navigates onceDOMis enabled) toonDocumentChanged->cooperation.invalidate(tabId), settingstate.unavailable = truewhile the main document and its collector remained live.doAttachaftersoft_detachedpopulatedattachingEntry.frameswithout restoringentry.frameDiscovery.rootFrameId.cooperation-capture.tsrotatedstate.documenton every rootlocation.hrefupdate, causing mid-actionprepareFramesrefreshes to misclassify?query/#hashupdates as cross-document replacements (mainDocumentChanged = true).Multi-step actions self-locked across their own navigation / submission side effects
onBeforeNavigate, e.g. auto-submitting OTP/searchfills) or instant-commit navigation (Cannot find context/Execution context was destroyedafterInput.insertTexthad already notified the page) failed during Step 3 verification orscroll-tovisibility measurement instead of returning their completed receipt.Concurrent subframe lifecycle races poisoned in-flight actions and
targetcontextsscheduleObserveTabcould runcollectCooperationFramesahead ofarmCommittedFrameon childonCommittedevents;COOPERATION_ARMrejected newly mounted child frames whoseleasewas not yet initialized;collectCooperationFramesskipped its single replacement pass when a sibling failed frame was a proven-hidden unobservable subframe (e.g.display: none+sandbox=""srcdoc); and non-ownerrefreshfailures (observeTab,status,wait, passiveread --context) mutatedstate.unavailable/state.contextduringstate.working.Handler-diagnosed errors and daemon implicit
targetcontexts after failed navigationsinterruption()checks overwrote explicitnavigate/reloaderrors and structuredresult.data.reasonerrors (download_capture_failed,fill_target_changed) withcontrol_context_invalid.ImplicitScopeRegistrycontinued auto-injecting revokedtargetcontext_ids after navigations oreffect_state: "unknown"errors, preventing context-freenavigate/reload/navigate_backrecovery off Chromepage_load_failedinterstitial error pages.Changes
chromium-cdp.ts,background.ts,cooperation-capture.ts,types.ts,controller.ts):onRouteChanged->cooperation.invalidateRoute(tabId, url)and top-frameFrameState.url, keepingtarget-policy DOM contexts valid across same-pathname query/fragment updates (?q=...,?view=...,#section, includingbsk planbatches and post-mouseReleasedSPA handlers) while revoking stale contexts and refs on pathname /#/...hash-router transitions (deferring invalidation untilfinallywhen triggered by an in-flight action so the triggering receipt settles cleanly witheffect_state: "none"for subsequent un-synced actions).entry.frameDiscovery.rootFrameIdonsoft_detachedreattach and removedDOM.documentUpdatedfrom firingonDocumentChanged.Runtime.callFunctionOnon boundobjectIds (boundObjectCompletion) to finish acrossonBeforeNavigate, and completedhandleFillStep 3 whenInput.insertText(finalValueAlreadyNotified) already delivered input before cross-document navigation tore down the old V8 context.scheduleObserveTabbehind per-tabpendingArms, initialized collection leases on non-clearCOOPERATION_ARM, allowedcollectCooperationFramesreplacement passes past proven-hidden failed subframes, isolatedstate.working/targetcontexts from non-ownerrefresherrors, preserved handler-diagnosed errors, and enablednavigate/reload/navigate_back/navigate_forwardbootstrap recovery offpage_load_failedroot error pages.scopes.rs,tool_pipeline.rs):clear_implicit_tab_contextinreconcile_completed_tool_rpcso full-page navigations and context-revoking errors clear stale implicittargetcontexts while retainingc<N>/o<N>ring alias expansion.docs/dynamic-reading.md,CHANGELOG.md, andCHANGELOG.zh-CN.md.Verification
pnpm --filter @browser-skill/extension compile&pnpm --filter @browser-skill/extension test(190 suites, 4,076 tests)cargo test -p bsk --lib daemon::&cargo test -p bsk --test integration plan_cli.browser.test.tssuites (settlement.browser.test.tsincluding new end-to-end SPA/subframe/OTP/failed-navigation regression test,cooperation-capture.browser.test.ts,navigation-same-document.browser.test.ts,hidden-frames.browser.test.ts)pnpm eval:browser:dynamic-read(59 CLI/MCP/plancommands acrosstarget&strict) &BSK_COOP_TARGET_ONLY=1 node evals/browser/cases/regression/cooperation/run.mjspnpm lint,pnpm protocol:check,node scripts/check-skill-bundles.mjs,cargo fmt --all -- --check,cargo clippy -p bsk --lib --bins -- -D warnings