Repository navigation
fix(cooperation): stop false human_intervention on scripted edits/clicks, cap readiness waits, and unblock failed-load tab management - #783
Merged
NianJiuZst merged 1 commit intoNov 19, 2026
Conversation
…cks, cap readiness waits, and unblock failed-load tab management
Why:
1. In Chromium, programmatic `document.execCommand('insertHTML' | 'delete' | 'insertText', ...)` on contenteditable/form editors dispatches a trusted `InputEvent("input")` with no preceding `beforeinput`/pointer/key/wheel/drop/IME event, and programmatic `checkbox.click()` / `radio.click()` / `label.click()` dispatches an untrusted `click` whose synchronous default activation emits trusted `input`/`change` events. `cooperation-capture.ts` previously treated any trusted `input`/`change` with no native agent lease as human input, causing `bsk evaluate` (and page scripts) to falsely abort with `human_intervention` ("the user has control of this tab" / "User activity revoked this action") and freeze the intent ledger even when no user touched the browser.
2. `CooperationController.run` polled transient `target_hidden` / `target_disabled` / `target_readonly` checks for the full `params.timeout_ms ?? 30_000` (which CLI interaction commands default to 30s and file transfers default to 2m) with no reply headroom below the daemon's RPC timeout, causing clicks on permanently hidden controls (such as visually hidden WeUI checkbox `<input>` elements) to hang for 30s and lose the race to a generic `tool RPC timed out after 30s`.
3. While PR Tencent#762 allowed navigation actions to recover off `page_load_failed` error pages, `CooperationController.manageTabs` and `tool.tab_close` still refused when any owned non-borrowed agent tab (including human-preserved `observedTabs`) sat on a settled `page_load_failed` interstitial, deadlocking `tab create` / `tab select` / `tab close` behind `cooperation_sync_required` ("shared page control or observation changed").
What:
- Track untrusted programmatic `click` events within the current task in `cooperation-capture.ts` (when no human pointer/key gesture is active) so synchronous default checkbox/radio `input`/`change` activations are not misclassified as human input, and skip `humanInput` on bare trusted `InputEvent("input")` (plus its same-task blur `change`) fired on editable elements with no originating `beforeinput`, key, pointer, wheel, drop, or IME composition while continuing to update `fields`/`revision` and preserving all genuine human input detection.
- Cap pre-execution `target_hidden`/`target_disabled`/`target_readonly` readiness polling in `CooperationController` at `DEFAULT_TARGET_READINESS_TIMEOUT_MS` (5s) and below explicit short `timeout_ms` with a reply margin anchored to `runEnteredAt`, keeping the full `deadline` intact for `prepareFrames` and tool execution.
- Exempt owned non-borrowed tabs (`isAgentControlledTab && !borrowedTabs.has`) on a settled `page_load_failed` error page (`!tab.pendingUrl`) in `manageTabs` and `tool.tab_close`, preserving borrowed-tab restrictions and in-flight `pendingUrl` gating.
- Add full-stack real-Chrome CLI + daemon + extension regression coverage in `settlement.browser.test.ts` and failed-load tab management assertions in `borrowed-blank-tab.test.ts`, and update bilingual `CHANGELOG.md` / `CHANGELOG.zh-CN.md`.
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 three real-world cooperation failure modes diagnosed from a production
bskinterruption log on WeChat MP (mp.weixin.qq.com) wherebsk evaluaterepeatedly aborted with"the user has control of this tab"despite zero human activity,bsk clickon a hidden checkbox timed out after 30s without reportingtarget_hidden, and a failed-load agent tab deadlockedtab create/tab select/tab close.Root Causes & Fixes
False
human_intervention("the user has control of this tab"/"User activity revoked this action") on scriptedexecCommandand.click()(apps/extension/src/content/cooperation-capture.ts):document.execCommand('insertHTML' | 'delete' | 'insertText', ...)dispatches a trustedInputEvent("input")(isTrusted: true) with no precedingbeforeinput, keyboard, pointer, wheel, drop, or IME event. Similarly, programmaticcheckbox.click()/radio.click()/label.click()dispatches an untrustedclick(isTrusted: false, previously ignored) followed synchronously by trustedinput/changedefault-activation events (isTrusted: true).cooperation-capture.tstreated any trustedinput/changewithout a nativeInput.*agent lease as human input, revoking completedbsk evaluatecalls and freezing the intent ledger.clickevents within the current task (when no human pointer/key gesture is active) so synchronous default checkbox/radioinput/changeactivations are not misclassified as human activity.humanInputon bare trustedInputEvent("input")(and its same-task blurchange) dispatched on editable fields with no originatingbeforeinput, key, pointer, wheel, drop, or IME composition, while still updatingfields/sampledValues/revisionand preserving detection of all genuine user interactions.Hidden/disabled target readiness wait racing Daemon's 30s RPC timeout (
apps/extension/src/cooperation/controller.ts):CooperationController.runpolled transienttarget_hidden/target_disabled/target_readonlychecks up toDate.now() + (params.timeout_ms ?? 30_000). Because CLI commands passtimeout_ms: 30000(and transfers pass120000) by default withresponse_grace: false, permanently hidden elements (such as visually hidden WeUI<input type="checkbox">controls) hung for 30s and lost the race to Daemon's generictool RPC timed out after 30s.DEFAULT_TARGET_READINESS_TIMEOUT_MS(5s) and below explicit shorttimeout_mswith a reply margin anchored torunEnteredAt, keeping the fulldeadlineintact forprepareFramesand tool execution.Tab management deadlocked by an owned agent tab on a
page_load_failederror page (apps/extension/src/cooperation/controller.ts):navigate/reload/navigate_back/navigate_forward) offpage_load_failederror pages, butmanageTabs(tab_create/tab_select/tab_borrow/tab_return) andtool.tab_closestill refused when any owned non-borrowed agent tab (including human-preservedobservedTabs) sat on a settledpage_load_failederror page.isAgentControlledTab && !borrowedTabs.has) on a settledpage_load_failedinterstitial (!tab.pendingUrl) inmanageTabsandtool.tab_close, while keeping borrowed-tab restrictions and in-flightpendingUrlchecks intact.Changelogs: Updated both
CHANGELOG.mdandCHANGELOG.zh-CN.md.Verification
node scripts/run-browser-tests.mjs src/cooperation/settlement.browser.test.tswith realbskCLI, daemon, built Chrome MV3 extension, and Google Chrome): 13/13 passed (0 skipped), including a new end-to-end test coveringbsk evaluatewithexecCommand(delete/insertHTML/insertText+ reformat + blur) andcheckbox/label/radio.click(), negative controls confirming genuine human checkbox click and typing still triggerhuman_intervention, hidden-checkboxbsk clickreturning structuredtarget_hidden(effect_state: "none") under both default and explicit--timeout, andtab create/tab select/tab closeescaping apage_load_failedagent tab.cooperation-capture.browser.test.ts+live-text.browser.test.ts: 36/36 passed.pnpm --filter @browser-skill/extension test: 4,103 passed (190 test files, including new failed-load tab assertions inborrowed-blank-tab.test.ts).tsc --noEmitandpnpm lint(biome check . && stylelint "**/*.css"): 0 errors.