Skip to content

Open-source AI browser agent for Chrome and Firefox (monorepo) 🧠

Don't let model or approval waits expire an unchanged action target

Claude02ebfbcac9c5
diff --git a/docs/page-feedback-monitor.md b/docs/page-feedback-monitor.md
index d3b490cbc..27f121e7f 100644
--- a/docs/page-feedback-monitor.md
+++ b/docs/page-feedback-monitor.md
@@ -248,8 +248,16 @@ Steer or grant authorization. Enter and Alt+Enter retain their existing behavior
guard for the next key. Preflight messages that sent no input preserve the
original snapshot through native preparation. Submissions retain the existing
authorization, form and recipient gates.
- Snapshots are bounded, expire after two minutes and are discarded with the run;
- unavailable or ambiguous targets retain conservative validation. Coordinates,
+ Snapshots are bounded, expire after two minutes of WebBrain's own time and
+ are discarded with the run. The background reports with each check how long
+ it waited for the model's decision and for the user's answers to WebBrain's
+ own cards (permission, submit and deletion confirmations, questions) since
+ the capture (`modelHeldMs`, at most 30 minutes); that time does not age the
+ snapshot, and page changes during it are judged as usual. A slow provider or
+ a user reading a permission card for a minute no longer expires an unchanged
+ target as "The browser changed during action preparation", with the same
+ card shown again on every retry. Unavailable or ambiguous targets retain
+ conservative validation. Coordinates,
scripts, child-frame actions, human activity, navigation and unknown feedback
retain strict fences. Without a private snapshot, legacy AX comparisons and
native-submit restrictions remain in force.
diff --git a/package.json b/package.json
index ccb36325f..fc38abcb3 100644
--- a/package.json
+++ b/package.json
@@ -64,8 +64,8 @@
"benchmark:relevance": "node scripts/benchmark-offline-relevance.mjs --verbose",
"test:social-contract": "node --test test/social-publish-contract.mjs test/publication-quote-markup.mjs test/publication-prefetch.mjs",
"test:social-contract:dom": "node test/social-publish-contract-dom.mjs",
- "test:runtime-lifecycle": "node test/bot-memory-dom.mjs && node --test test/agent-lifecycle.mjs test/runtime-startup.mjs test/run-ui-scheduled-lifecycle.mjs test/transport-deadlines.mjs test/cdp-worker-restart.mjs test/bot-memory.mjs test/bot-memory-registries.mjs test/bot-memory-cloud-controller.mjs test/cdp-clear-receipt.mjs test/cdp-field-submit-recovery.mjs test/conversation-persistence.mjs test/history-recovery-state.mjs test/history-recovery-scheduler.mjs test/history-recovery-atomic.mjs test/context-live-tool-group.mjs test/integration-races.mjs test/watch-completion-checkpoint.mjs test/runtime-model-identity.mjs test/provider-message-privacy.mjs test/runtime-task-authority.mjs test/planner-repair-authority.mjs test/runtime-progress-continuation.mjs test/chat-resume-chain.mjs test/chat-resume-completion.mjs test/native-chat-execution-ledger.mjs test/chat-send-dispatch-result.mjs test/chat-reply-dedup-race.mjs test/memcode-lifecycle.mjs test/runtime-peer-review.mjs test/read-continuation-schema.mjs test/completion-submit-acknowledgement.mjs test/completion-live-status.mjs test/completion-iframe-submit.mjs test/form-validation-alert-readings.mjs test/control-effect-readings.mjs test/trusted-retry-readings.mjs test/completion-semantic-commit.mjs test/completion-diagnostics.mjs test/mastodon-publication.mjs test/calculator.mjs test/chat-recovery-protocol.mjs test/chat-pending-reconciliation.mjs test/semantic-page-retry.mjs test/pdf-detection.mjs test/runtime-lifecycle.mjs test/collection-read-progress.mjs test/network-lifecycle.mjs test/text-write-cancellation.mjs test/guard-advisory-writes.mjs test/trusted-field-preparation.mjs test/draftjs-text.mjs test/codemirror-text.mjs test/rich-text-frameworks.mjs test/cdp-managed-text-selection.mjs test/firefox-rich-text-readback.mjs test/contenteditable-beforeinput.mjs test/trusted-field-preparation-ownership.mjs test/typing-preparation-geometry.mjs test/chat-steering.mjs test/lifecycle-steering-restart.mjs test/resource-mutation-guards.mjs test/completion-steering-receipt-authority.mjs test/steering-revision-recovery.mjs test/pending-clarification-hydration.mjs test/clarify-timeout-policy.mjs test/guard-ask-cards.mjs test/permission-steering-wakeup.mjs test/pure-calculation-reply.mjs test/pure-calculation-tools.mjs test/page-feedback.mjs test/page-feedback-progress.mjs test/page-feedback-unbindable-target.mjs test/guard-advisory-actions.mjs test/rich-text-preflight-page-change.mjs test/keyboard-receiver-frame.mjs test/ask-response-scope.mjs test/ask-completion-churn.mjs test/page-feedback-policy.mjs test/research-escalation-page-feedback.mjs test/page-feedback-transport-races.mjs test/page-feedback-recovery.mjs test/telegram-read-preparation-agent.mjs test/media-download-agent-handler.mjs test/code-scanning-url-recipient.mjs test/apocalypse-comm-parsing.mjs test/apocalypse-scalar-decoding.mjs test/bitgpu-chat-security.mjs test/social-media-url-upgrades.mjs test/downloaded-file-saved-bytes.mjs test/downloaded-file-local-probe.mjs test/formless-verification-recovery.mjs test/file-upload-accept.mjs test/file-upload-accept-agent.mjs test/workflow-route-generic-completion.mjs test/release-publication-completion.mjs test/workflow-implicit-metadata.mjs test/workflow-field-readings.mjs test/workflow-field-anchors.mjs test/user-turn-kind.mjs test/follow-up-task-context.mjs test/completion-current-execution-evidence.mjs test/monitor-intervention-contract.mjs test/monitor-owned-geometry.mjs test/monitor-viewport-remainder.mjs test/monitor-scroll-churn.mjs test/monitor-local-attribution.mjs test/monitor-lifecycle-leaks.mjs test/feedback-automatic-churn.mjs test/feedback-navigation-idle.mjs test/feedback-run-boundaries.mjs test/feedback-ask-viewing.mjs test/lifecycle-terminal-done.mjs test/incomplete-completion-recovery.mjs test/guard-advisory-completion.mjs test/guard-policy.mjs test/lean-mode.mjs test/lifecycle-planner-digest.mjs test/lifecycle-vision-fallback.mjs test/guards-control-classification.mjs test/guards-unbound-deletion.mjs test/guards-steering-receipts.mjs && node test/ui-content-lifecycle.mjs && node --test test/native-telegram-chat.mjs test/native-telegram-recipient.mjs test/telegram-native-baseline.mjs test/telegram-native-latest.mjs test/native-chat-pre-enter-draft.mjs test/chat-draft-dispatch-ownership.mjs test/native-telegram-alias-preparation.mjs test/telegram-read-preparation-content.mjs test/queued-composer-ownership.mjs test/onboarding-provider-ready.mjs test/sidepanel-permission-gate-ui.mjs test/workflow-native-targets.mjs test/native-whatsapp-chat.mjs test/native-chat-context-identity.mjs test/native-whatsapp-contact.mjs test/whatsapp-native-bootstrap.mjs test/whatsapp-drawer-identity.mjs test/whatsapp-read-latest.mjs test/whatsapp-read-preparation.mjs test/whatsapp-chat-completion.mjs test/whatsapp-chat-restart.mjs test/chat-goal-lifecycle.mjs test/chat-completion.mjs test/chat-generic-dispatch.mjs test/completion-live-status-browser.mjs test/native-confirmation-visibility.mjs test/read-continuation-browser.mjs test/iframe-preparation-focus.mjs test/contenteditable-literal.mjs test/native-chat-empty-editor.mjs test/native-chat-trusted-clear.mjs test/chat-steering-ui.mjs test/recipient-confirmation-ui.mjs test/assistant-message-visibility-ui.mjs test/history-recovery.mjs test/history-recovery-ui.mjs test/page-monitor-ui.mjs test/x-compose-trusted-typing.mjs test/page-monitor-dialog.mjs test/page-monitor-dialog-native.mjs test/page-monitor-inline-post.mjs test/bluesky-composer-context.mjs test/page-monitor-anchored.mjs test/page-monitor-upload-owner.mjs test/page-monitor-upload-release.mjs test/page-monitor-native-controls.mjs test/page-monitor-native-preparation.mjs test/native-preparation-cold.mjs test/page-monitor-navigation.mjs test/page-monitor-main-owner.mjs test/page-monitor-collateral-controls.mjs test/accessibility-tree-scoped-budget.mjs test/ax-reference-origin.mjs test/page-monitor-decorative-hit.mjs test/social-ui-navigation.mjs test/native-resource-deletion-binding.mjs test/native-mastodon-confirmation.mjs test/dropdown-menu-inventory.mjs test/page-monitor-passive-progress.mjs test/page-monitor-feed-items.mjs test/media-download-binding.mjs test/media-download-capture-integration.mjs test/social-media-downloader-reinjection.mjs test/upload-file-local-state-guidance.mjs && node test/message-recipient-upload.mjs && node test/message-recipient-clarify-binding.mjs && node --test test/message-recipient-whatsapp.mjs test/message-control-readings.mjs && node test/quality/integration-mv3.mjs --full-form && node test/quality/literal-calculate-midrun-mv3.mjs && node test/quality/ask-completion-churn-mv3.mjs && node test/quality/ask-person-activity-mv3.mjs && node test/quality/telegram-cold-preparation-mv3.mjs && node test/quality/native-chat-mv3.mjs && node test/quality/native-chat-presubmit-mv3.mjs && node test/quality/cloud-bot-memory-mv3.mjs && node test/quality/whatsapp-contact-matrix.mjs && node test/quality/pdf-detection-mv3.mjs && node test/quality/download-upload-mv3.mjs && node test/quality/upload-release-binding-mv3.mjs && node test/quality/release-review-world-mv3.mjs && node test/quality/downloaded-file-saved-bytes-mv3.mjs && node test/quality/file-upload-accept-mv3.mjs && node test/quality/bulk-resume-mv3.mjs && node test/quality/literal-frame-mv3.mjs && node test/quality/mastodon-publication-mv3.mjs && node test/quality/mastodon-reply-route-mv3.mjs && node test/quality/mastodon-deletion-mv3.mjs && node test/quality/mastodon-delete-confirmation-mv3.mjs && node test/quality/mastodon-delete-confirmation-mv3.mjs --menu-read && node test/quality/mastodon-delete-confirmation-mv3.mjs --vague && node test/quality/mastodon-delete-after-correction-mv3.mjs && node test/quality/unbound-deletion-mv3.mjs && node test/quality/recipient-clarify-mv3.mjs && node test/quality/open-chat-recipients-mv3.mjs && node test/quality/correction-cross-site-mv3.mjs && node test/quality/anchored-action-mv3.mjs && node test/quality/inline-social-composer-mv3.mjs && node test/quality/x-compose-dialog-mv3.mjs && node test/quality/bluesky-composer-mv3.mjs && node test/quality/dropdown-menu-matrix.mjs && node test/quality/mastodon-deletion-navigation-mv3.mjs && node test/quality/semantic-navigation-matrix.mjs && node test/quality/workflow-replay-mv3.mjs && node test/quality/generative-media-mv3.mjs && node test/quality/cdp-worker-restart-mv3.mjs && node test/quality/steering-worker-restart-mv3.mjs",
- "test:page-feedback": "node --test test/trusted-field-preparation.mjs test/guard-advisory-writes.mjs test/draftjs-text.mjs test/codemirror-text.mjs test/rich-text-frameworks.mjs test/cdp-managed-text-selection.mjs test/firefox-rich-text-readback.mjs test/contenteditable-beforeinput.mjs test/trusted-field-preparation-ownership.mjs test/typing-preparation-geometry.mjs test/pure-calculation-reply.mjs test/pure-calculation-tools.mjs test/page-feedback.mjs test/page-feedback-progress.mjs test/page-feedback-unbindable-target.mjs test/guard-advisory-actions.mjs test/rich-text-preflight-page-change.mjs test/keyboard-receiver-frame.mjs test/ask-response-scope.mjs test/ask-completion-churn.mjs test/page-feedback-policy.mjs test/research-escalation-page-feedback.mjs test/page-feedback-transport-races.mjs test/page-feedback-recovery.mjs test/telegram-read-preparation-agent.mjs test/media-download-agent-handler.mjs test/page-monitor-ui.mjs test/x-compose-trusted-typing.mjs test/page-monitor-dialog.mjs test/page-monitor-dialog-native.mjs test/page-monitor-inline-post.mjs test/bluesky-composer-context.mjs test/page-monitor-anchored.mjs test/page-monitor-upload-owner.mjs test/page-monitor-upload-release.mjs test/page-monitor-native-controls.mjs test/page-monitor-passive-progress.mjs test/page-monitor-feed-items.mjs test/media-download-binding.mjs test/media-download-capture-integration.mjs test/monitor-intervention-contract.mjs test/monitor-owned-geometry.mjs test/monitor-viewport-remainder.mjs test/monitor-scroll-churn.mjs test/monitor-local-attribution.mjs test/monitor-lifecycle-leaks.mjs test/feedback-automatic-churn.mjs test/feedback-navigation-idle.mjs test/feedback-run-boundaries.mjs test/feedback-ask-viewing.mjs test/delivery-click-ax-response-loss.mjs test/delivery-stop-compound.mjs test/delivery-cdp-input.mjs test/delivery-click-locks.mjs test/delivery-native-button-geometry.mjs test/delivery-hover-transition.mjs test/delivery-native-button-route.mjs test/delivery-dispatch-boundary.mjs && node test/message-recipient-upload.mjs && node test/message-recipient-clarify-binding.mjs && node --test test/message-recipient-whatsapp.mjs",
+ "test:runtime-lifecycle": "node test/bot-memory-dom.mjs && node --test test/agent-lifecycle.mjs test/runtime-startup.mjs test/run-ui-scheduled-lifecycle.mjs test/transport-deadlines.mjs test/cdp-worker-restart.mjs test/bot-memory.mjs test/bot-memory-registries.mjs test/bot-memory-cloud-controller.mjs test/cdp-clear-receipt.mjs test/cdp-field-submit-recovery.mjs test/conversation-persistence.mjs test/history-recovery-state.mjs test/history-recovery-scheduler.mjs test/history-recovery-atomic.mjs test/context-live-tool-group.mjs test/integration-races.mjs test/watch-completion-checkpoint.mjs test/runtime-model-identity.mjs test/provider-message-privacy.mjs test/runtime-task-authority.mjs test/planner-repair-authority.mjs test/runtime-progress-continuation.mjs test/chat-resume-chain.mjs test/chat-resume-completion.mjs test/native-chat-execution-ledger.mjs test/chat-send-dispatch-result.mjs test/chat-reply-dedup-race.mjs test/memcode-lifecycle.mjs test/runtime-peer-review.mjs test/read-continuation-schema.mjs test/completion-submit-acknowledgement.mjs test/completion-live-status.mjs test/completion-iframe-submit.mjs test/form-validation-alert-readings.mjs test/control-effect-readings.mjs test/trusted-retry-readings.mjs test/completion-semantic-commit.mjs test/completion-diagnostics.mjs test/mastodon-publication.mjs test/calculator.mjs test/chat-recovery-protocol.mjs test/chat-pending-reconciliation.mjs test/semantic-page-retry.mjs test/pdf-detection.mjs test/runtime-lifecycle.mjs test/collection-read-progress.mjs test/network-lifecycle.mjs test/text-write-cancellation.mjs test/guard-advisory-writes.mjs test/trusted-field-preparation.mjs test/draftjs-text.mjs test/codemirror-text.mjs test/rich-text-frameworks.mjs test/cdp-managed-text-selection.mjs test/firefox-rich-text-readback.mjs test/contenteditable-beforeinput.mjs test/trusted-field-preparation-ownership.mjs test/typing-preparation-geometry.mjs test/chat-steering.mjs test/lifecycle-steering-restart.mjs test/resource-mutation-guards.mjs test/completion-steering-receipt-authority.mjs test/steering-revision-recovery.mjs test/pending-clarification-hydration.mjs test/clarify-timeout-policy.mjs test/guard-ask-cards.mjs test/permission-steering-wakeup.mjs test/pure-calculation-reply.mjs test/pure-calculation-tools.mjs test/page-feedback.mjs test/page-feedback-progress.mjs test/page-feedback-unbindable-target.mjs test/guard-advisory-actions.mjs test/rich-text-preflight-page-change.mjs test/keyboard-receiver-frame.mjs test/ask-response-scope.mjs test/ask-completion-churn.mjs test/page-feedback-policy.mjs test/page-feedback-held-time.mjs test/research-escalation-page-feedback.mjs test/page-feedback-transport-races.mjs test/page-feedback-recovery.mjs test/telegram-read-preparation-agent.mjs test/media-download-agent-handler.mjs test/code-scanning-url-recipient.mjs test/apocalypse-comm-parsing.mjs test/apocalypse-scalar-decoding.mjs test/bitgpu-chat-security.mjs test/social-media-url-upgrades.mjs test/downloaded-file-saved-bytes.mjs test/downloaded-file-local-probe.mjs test/formless-verification-recovery.mjs test/file-upload-accept.mjs test/file-upload-accept-agent.mjs test/workflow-route-generic-completion.mjs test/release-publication-completion.mjs test/workflow-implicit-metadata.mjs test/workflow-field-readings.mjs test/workflow-field-anchors.mjs test/user-turn-kind.mjs test/follow-up-task-context.mjs test/completion-current-execution-evidence.mjs test/monitor-intervention-contract.mjs test/monitor-owned-geometry.mjs test/monitor-viewport-remainder.mjs test/monitor-scroll-churn.mjs test/monitor-local-attribution.mjs test/monitor-lifecycle-leaks.mjs test/feedback-automatic-churn.mjs test/feedback-navigation-idle.mjs test/feedback-run-boundaries.mjs test/feedback-ask-viewing.mjs test/lifecycle-terminal-done.mjs test/incomplete-completion-recovery.mjs test/guard-advisory-completion.mjs test/guard-policy.mjs test/lean-mode.mjs test/lifecycle-planner-digest.mjs test/lifecycle-vision-fallback.mjs test/guards-control-classification.mjs test/guards-unbound-deletion.mjs test/guards-steering-receipts.mjs && node test/ui-content-lifecycle.mjs && node --test test/native-telegram-chat.mjs test/native-telegram-recipient.mjs test/telegram-native-baseline.mjs test/telegram-native-latest.mjs test/native-chat-pre-enter-draft.mjs test/chat-draft-dispatch-ownership.mjs test/native-telegram-alias-preparation.mjs test/telegram-read-preparation-content.mjs test/queued-composer-ownership.mjs test/onboarding-provider-ready.mjs test/sidepanel-permission-gate-ui.mjs test/workflow-native-targets.mjs test/native-whatsapp-chat.mjs test/native-chat-context-identity.mjs test/native-whatsapp-contact.mjs test/whatsapp-native-bootstrap.mjs test/whatsapp-drawer-identity.mjs test/whatsapp-read-latest.mjs test/whatsapp-read-preparation.mjs test/whatsapp-chat-completion.mjs test/whatsapp-chat-restart.mjs test/chat-goal-lifecycle.mjs test/chat-completion.mjs test/chat-generic-dispatch.mjs test/completion-live-status-browser.mjs test/native-confirmation-visibility.mjs test/read-continuation-browser.mjs test/iframe-preparation-focus.mjs test/contenteditable-literal.mjs test/native-chat-empty-editor.mjs test/native-chat-trusted-clear.mjs test/chat-steering-ui.mjs test/recipient-confirmation-ui.mjs test/assistant-message-visibility-ui.mjs test/history-recovery.mjs test/history-recovery-ui.mjs test/page-monitor-ui.mjs test/x-compose-trusted-typing.mjs test/page-monitor-dialog.mjs test/page-monitor-dialog-native.mjs test/page-monitor-inline-post.mjs test/bluesky-composer-context.mjs test/page-monitor-anchored.mjs test/page-monitor-upload-owner.mjs test/page-monitor-upload-release.mjs test/page-monitor-native-controls.mjs test/page-monitor-held-observation.mjs test/page-monitor-native-preparation.mjs test/native-preparation-cold.mjs test/page-monitor-navigation.mjs test/page-monitor-main-owner.mjs test/page-monitor-collateral-controls.mjs test/accessibility-tree-scoped-budget.mjs test/ax-reference-origin.mjs test/page-monitor-decorative-hit.mjs test/social-ui-navigation.mjs test/native-resource-deletion-binding.mjs test/native-mastodon-confirmation.mjs test/dropdown-menu-inventory.mjs test/page-monitor-passive-progress.mjs test/page-monitor-feed-items.mjs test/media-download-binding.mjs test/media-download-capture-integration.mjs test/social-media-downloader-reinjection.mjs test/upload-file-local-state-guidance.mjs && node test/message-recipient-upload.mjs && node test/message-recipient-clarify-binding.mjs && node --test test/message-recipient-whatsapp.mjs test/message-control-readings.mjs && node test/quality/integration-mv3.mjs --full-form && node test/quality/literal-calculate-midrun-mv3.mjs && node test/quality/ask-completion-churn-mv3.mjs && node test/quality/ask-person-activity-mv3.mjs && node test/quality/telegram-cold-preparation-mv3.mjs && node test/quality/native-chat-mv3.mjs && node test/quality/native-chat-presubmit-mv3.mjs && node test/quality/cloud-bot-memory-mv3.mjs && node test/quality/whatsapp-contact-matrix.mjs && node test/quality/pdf-detection-mv3.mjs && node test/quality/download-upload-mv3.mjs && node test/quality/upload-release-binding-mv3.mjs && node test/quality/release-review-world-mv3.mjs && node test/quality/downloaded-file-saved-bytes-mv3.mjs && node test/quality/file-upload-accept-mv3.mjs && node test/quality/bulk-resume-mv3.mjs && node test/quality/literal-frame-mv3.mjs && node test/quality/mastodon-publication-mv3.mjs && node test/quality/mastodon-reply-route-mv3.mjs && node test/quality/mastodon-deletion-mv3.mjs && node test/quality/mastodon-delete-confirmation-mv3.mjs && node test/quality/mastodon-delete-confirmation-mv3.mjs --menu-read && node test/quality/mastodon-delete-confirmation-mv3.mjs --vague && node test/quality/mastodon-delete-after-correction-mv3.mjs && node test/quality/unbound-deletion-mv3.mjs && node test/quality/recipient-clarify-mv3.mjs && node test/quality/open-chat-recipients-mv3.mjs && node test/quality/correction-cross-site-mv3.mjs && node test/quality/anchored-action-mv3.mjs && node test/quality/inline-social-composer-mv3.mjs && node test/quality/x-compose-dialog-mv3.mjs && node test/quality/bluesky-composer-mv3.mjs && node test/quality/dropdown-menu-matrix.mjs && node test/quality/mastodon-deletion-navigation-mv3.mjs && node test/quality/semantic-navigation-matrix.mjs && node test/quality/workflow-replay-mv3.mjs && node test/quality/generative-media-mv3.mjs && node test/quality/cdp-worker-restart-mv3.mjs && node test/quality/steering-worker-restart-mv3.mjs",
+ "test:page-feedback": "node --test test/trusted-field-preparation.mjs test/guard-advisory-writes.mjs test/draftjs-text.mjs test/codemirror-text.mjs test/rich-text-frameworks.mjs test/cdp-managed-text-selection.mjs test/firefox-rich-text-readback.mjs test/contenteditable-beforeinput.mjs test/trusted-field-preparation-ownership.mjs test/typing-preparation-geometry.mjs test/pure-calculation-reply.mjs test/pure-calculation-tools.mjs test/page-feedback.mjs test/page-feedback-progress.mjs test/page-feedback-unbindable-target.mjs test/guard-advisory-actions.mjs test/rich-text-preflight-page-change.mjs test/keyboard-receiver-frame.mjs test/ask-response-scope.mjs test/ask-completion-churn.mjs test/page-feedback-policy.mjs test/page-feedback-held-time.mjs test/research-escalation-page-feedback.mjs test/page-feedback-transport-races.mjs test/page-feedback-recovery.mjs test/telegram-read-preparation-agent.mjs test/media-download-agent-handler.mjs test/page-monitor-ui.mjs test/x-compose-trusted-typing.mjs test/page-monitor-dialog.mjs test/page-monitor-dialog-native.mjs test/page-monitor-inline-post.mjs test/bluesky-composer-context.mjs test/page-monitor-anchored.mjs test/page-monitor-upload-owner.mjs test/page-monitor-upload-release.mjs test/page-monitor-native-controls.mjs test/page-monitor-held-observation.mjs test/page-monitor-passive-progress.mjs test/page-monitor-feed-items.mjs test/media-download-binding.mjs test/media-download-capture-integration.mjs test/monitor-intervention-contract.mjs test/monitor-owned-geometry.mjs test/monitor-viewport-remainder.mjs test/monitor-scroll-churn.mjs test/monitor-local-attribution.mjs test/monitor-lifecycle-leaks.mjs test/feedback-automatic-churn.mjs test/feedback-navigation-idle.mjs test/feedback-run-boundaries.mjs test/feedback-ask-viewing.mjs test/delivery-click-ax-response-loss.mjs test/delivery-stop-compound.mjs test/delivery-cdp-input.mjs test/delivery-click-locks.mjs test/delivery-native-button-geometry.mjs test/delivery-hover-transition.mjs test/delivery-native-button-route.mjs test/delivery-dispatch-boundary.mjs && node test/message-recipient-upload.mjs && node test/message-recipient-clarify-binding.mjs && node --test test/message-recipient-whatsapp.mjs",
"test:history-recovery": "node --test test/history-recovery.mjs test/history-recovery-ui.mjs test/history-recovery-state.mjs test/history-recovery-scheduler.mjs test/history-recovery-atomic.mjs test/conversation-persistence.mjs",
"test:chat-steering": "node --test test/chat-steering.mjs test/chat-steering-ui.mjs test/recipient-confirmation-ui.mjs test/lifecycle-steering-latency.mjs test/lifecycle-steering-restart.mjs test/lifecycle-run-ui.mjs test/lifecycle-menu-prompts-held.mjs",
"test:rich-text-dom": "node test/ui-content-lifecycle.mjs --dom",
@@ -98,8 +98,8 @@
"test:chat-draft-recovery": "node --test test/native-chat-pre-enter-draft.mjs test/chat-draft-dispatch-ownership.mjs && node test/quality/native-chat-presubmit-mv3.mjs",
"test:upload-owner": "node --test test/page-monitor-upload-owner.mjs test/page-monitor-upload-release.mjs",
"test:shard:quick": "npm run test:cms && npm run test:markdown && npm run test:generative-media && npm run test:systemone && npm run test:systemone:fast && node --test test/guard-policy.mjs test/browser-dialogs.mjs test/capsolver-cloud-broker.mjs test/captcha-providers.mjs test/captcha-weighted-fallback.mjs test/captcha-hcaptcha-providers.mjs test/captcha-native-providers.mjs test/captcha-runtime-policy.mjs test/captcha-callback-bridge.mjs test/captcha-bridge-registration.mjs test/captcha-aws-recovery.mjs test/captcha-documented-contracts.mjs test/huggingface-signup-recovery.mjs test/trace-full-export.mjs test/feedback-traces.mjs && npm run test:firefox-bidi && npm run test:billing-notice && npm run test:compass-quota && npm run test:provider-limits && npm run test:provider-catalog && npm run test:provider-instances:ui && npm run test:openrouter-capabilities && npm run test:anthropic && npm run test:browser-batch && npm run test:accessibility-tree-benchmark && npm run test:toolbar-guard && npm run test:cloud-bridge-approval && npm run test:discord && npm run test:pdf-read && npm run test:pdf-selection && npm run test:social-contract && npm run test:safesocial && npm run test:build-unpacked && npm run test:attachment-drop && npm run test:workflow-editor && node --test test/profile-sync-stats.mjs && node --test test/memcode-recall.mjs",
- "test:shard:runtime-unit": "node --test test/skill-download-wait.mjs && node --test test/agent-lifecycle.mjs test/runtime-startup.mjs test/run-ui-scheduled-lifecycle.mjs test/transport-deadlines.mjs test/cdp-worker-restart.mjs test/bot-memory.mjs test/bot-memory-click-guard.mjs test/bot-memory-registries.mjs test/bot-memory-cloud-controller.mjs test/cdp-clear-receipt.mjs test/cdp-field-submit-recovery.mjs test/conversation-persistence.mjs test/context-live-tool-group.mjs test/integration-races.mjs test/watch-completion-checkpoint.mjs test/runtime-model-identity.mjs test/provider-message-privacy.mjs test/runtime-task-authority.mjs test/planner-repair-authority.mjs test/runtime-progress-continuation.mjs test/chat-resume-chain.mjs test/chat-resume-completion.mjs test/native-chat-execution-ledger.mjs test/chat-send-dispatch-result.mjs test/chat-reply-dedup-race.mjs test/memcode-lifecycle.mjs test/runtime-peer-review.mjs test/read-continuation-schema.mjs test/completion-submit-acknowledgement.mjs test/completion-live-status.mjs test/completion-iframe-submit.mjs test/form-validation-alert-readings.mjs test/control-effect-readings.mjs test/trusted-retry-readings.mjs test/completion-semantic-commit.mjs test/completion-diagnostics.mjs test/mastodon-publication.mjs test/calculator.mjs test/chat-recovery-protocol.mjs test/chat-pending-reconciliation.mjs test/semantic-page-retry.mjs test/pdf-detection.mjs test/runtime-lifecycle.mjs test/collection-read-progress.mjs test/network-lifecycle.mjs test/text-write-cancellation.mjs test/guard-advisory-writes.mjs test/trusted-field-preparation.mjs test/draftjs-text.mjs test/codemirror-text.mjs test/rich-text-frameworks.mjs test/cdp-managed-text-selection.mjs test/firefox-rich-text-readback.mjs test/contenteditable-beforeinput.mjs test/trusted-field-preparation-ownership.mjs test/typing-preparation-geometry.mjs test/chat-steering.mjs test/resource-mutation-guards.mjs test/completion-steering-receipt-authority.mjs test/steering-revision-recovery.mjs test/pending-clarification-hydration.mjs test/clarify-timeout-policy.mjs test/guard-ask-cards.mjs test/permission-steering-wakeup.mjs test/pure-calculation-reply.mjs test/pure-calculation-tools.mjs test/page-feedback.mjs test/page-feedback-progress.mjs test/page-feedback-unbindable-target.mjs test/guard-advisory-actions.mjs test/rich-text-preflight-page-change.mjs test/keyboard-receiver-frame.mjs test/ask-response-scope.mjs test/auto-mode.mjs test/model-picker-icon.mjs test/ask-completion-churn.mjs test/page-feedback-policy.mjs test/research-escalation-page-feedback.mjs test/page-feedback-transport-races.mjs test/page-feedback-recovery.mjs test/telegram-read-preparation-agent.mjs test/media-download-agent-handler.mjs test/code-scanning-url-recipient.mjs test/apocalypse-comm-parsing.mjs test/apocalypse-scalar-decoding.mjs test/bitgpu-chat-security.mjs test/social-media-url-upgrades.mjs test/downloaded-file-saved-bytes.mjs test/downloaded-file-local-probe.mjs test/formless-verification-recovery.mjs test/file-upload-accept.mjs test/file-upload-accept-agent.mjs test/workflow-route-generic-completion.mjs test/release-publication-completion.mjs test/workflow-implicit-metadata.mjs test/workflow-field-readings.mjs test/workflow-field-anchors.mjs test/user-turn-kind.mjs test/follow-up-task-context.mjs test/completion-current-execution-evidence.mjs test/video-upload-attachment.mjs test/feedback-automatic-churn.mjs test/feedback-navigation-idle.mjs test/feedback-run-boundaries.mjs test/feedback-ask-viewing.mjs test/lifecycle-terminal-done.mjs test/incomplete-completion-recovery.mjs test/guard-advisory-completion.mjs test/lean-mode.mjs test/lifecycle-planner-digest.mjs test/lifecycle-steering-latency.mjs test/lifecycle-steering-restart.mjs test/lifecycle-vision-fallback.mjs test/delivery-click-locks.mjs test/guards-steering-receipts.mjs test/terminal-user-messages.mjs test/improver-providers.mjs test/improver-providers-agent.mjs test/improver-guards-ledger.mjs test/improver-guards-tools.mjs test/improver-clarify.mjs test/improver-clarify-scheduler.mjs test/improver-misc.mjs test/improver-forms.mjs test/improver-forms-strict-secrets.mjs test/improver-content-press-keys-hint.mjs && npm run test:plan-notifications",
- "test:shard:browser-a": "node --test test/captcha-draft-content.mjs test/captcha-challenge-surfaces.mjs && node test/bot-memory-dom.mjs && node test/bot-memory-click-dom.mjs && node test/ui-content-lifecycle.mjs && node --test test/native-telegram-chat.mjs test/native-telegram-recipient.mjs test/telegram-native-baseline.mjs test/telegram-native-latest.mjs test/native-chat-pre-enter-draft.mjs test/chat-draft-dispatch-ownership.mjs test/native-telegram-alias-preparation.mjs test/telegram-read-preparation-content.mjs test/queued-composer-ownership.mjs test/onboarding-provider-ready.mjs test/sidepanel-permission-gate-ui.mjs test/workflow-native-targets.mjs test/native-whatsapp-chat.mjs test/native-chat-context-identity.mjs test/native-whatsapp-contact.mjs test/whatsapp-native-bootstrap.mjs test/whatsapp-drawer-identity.mjs test/whatsapp-read-latest.mjs test/whatsapp-read-preparation.mjs test/whatsapp-chat-completion.mjs test/whatsapp-chat-restart.mjs test/chat-goal-lifecycle.mjs test/chat-completion.mjs test/chat-generic-dispatch.mjs test/completion-live-status-browser.mjs test/native-confirmation-visibility.mjs test/native-button-preparation.mjs test/read-continuation-browser.mjs test/iframe-preparation-focus.mjs test/contenteditable-literal.mjs test/native-chat-empty-editor.mjs test/native-chat-trusted-clear.mjs test/chat-steering-ui.mjs test/recipient-confirmation-ui.mjs test/assistant-message-visibility-ui.mjs test/page-monitor-ui.mjs test/x-compose-trusted-typing.mjs test/page-monitor-dialog.mjs test/page-monitor-dialog-native.mjs test/page-monitor-inline-post.mjs test/bluesky-composer-context.mjs test/page-monitor-anchored.mjs test/page-monitor-upload-owner.mjs test/page-monitor-upload-release.mjs test/page-monitor-native-controls.mjs test/page-monitor-native-preparation.mjs test/native-preparation-cold.mjs test/page-monitor-navigation.mjs test/page-monitor-main-owner.mjs test/page-monitor-collateral-controls.mjs test/accessibility-tree-scoped-budget.mjs test/ax-reference-origin.mjs test/page-monitor-decorative-hit.mjs test/social-ui-navigation.mjs test/native-resource-deletion-binding.mjs test/native-mastodon-confirmation.mjs test/dropdown-menu-inventory.mjs test/page-monitor-passive-progress.mjs test/page-monitor-feed-items.mjs test/media-download-binding.mjs test/media-download-capture-integration.mjs test/social-media-downloader-reinjection.mjs test/upload-file-local-state-guidance.mjs test/monitor-intervention-contract.mjs test/monitor-owned-geometry.mjs test/monitor-viewport-remainder.mjs test/monitor-scroll-churn.mjs test/monitor-local-attribution.mjs test/monitor-lifecycle-leaks.mjs test/lifecycle-run-ui.mjs test/lifecycle-menu-prompts-held.mjs test/delivery-cdp-input.mjs test/delivery-click-ax-response-loss.mjs test/delivery-native-button-geometry.mjs test/delivery-hover-transition.mjs test/delivery-native-button-route.mjs test/delivery-dispatch-boundary.mjs test/delivery-stop-compound.mjs test/guards-control-classification.mjs test/guards-unbound-deletion.mjs test/submit-probe-readings.mjs test/improver-content-account-chrome.mjs test/improver-content-recipient.mjs test/improver-content-truncated-replacement.mjs test/improver-forms-probe.mjs test/improver-misc-trace-browser.mjs",
+ "test:shard:runtime-unit": "node --test test/skill-download-wait.mjs && node --test test/agent-lifecycle.mjs test/runtime-startup.mjs test/run-ui-scheduled-lifecycle.mjs test/transport-deadlines.mjs test/cdp-worker-restart.mjs test/bot-memory.mjs test/bot-memory-click-guard.mjs test/bot-memory-registries.mjs test/bot-memory-cloud-controller.mjs test/cdp-clear-receipt.mjs test/cdp-field-submit-recovery.mjs test/conversation-persistence.mjs test/context-live-tool-group.mjs test/integration-races.mjs test/watch-completion-checkpoint.mjs test/runtime-model-identity.mjs test/provider-message-privacy.mjs test/runtime-task-authority.mjs test/planner-repair-authority.mjs test/runtime-progress-continuation.mjs test/chat-resume-chain.mjs test/chat-resume-completion.mjs test/native-chat-execution-ledger.mjs test/chat-send-dispatch-result.mjs test/chat-reply-dedup-race.mjs test/memcode-lifecycle.mjs test/runtime-peer-review.mjs test/read-continuation-schema.mjs test/completion-submit-acknowledgement.mjs test/completion-live-status.mjs test/completion-iframe-submit.mjs test/form-validation-alert-readings.mjs test/control-effect-readings.mjs test/trusted-retry-readings.mjs test/completion-semantic-commit.mjs test/completion-diagnostics.mjs test/mastodon-publication.mjs test/calculator.mjs test/chat-recovery-protocol.mjs test/chat-pending-reconciliation.mjs test/semantic-page-retry.mjs test/pdf-detection.mjs test/runtime-lifecycle.mjs test/collection-read-progress.mjs test/network-lifecycle.mjs test/text-write-cancellation.mjs test/guard-advisory-writes.mjs test/trusted-field-preparation.mjs test/draftjs-text.mjs test/codemirror-text.mjs test/rich-text-frameworks.mjs test/cdp-managed-text-selection.mjs test/firefox-rich-text-readback.mjs test/contenteditable-beforeinput.mjs test/trusted-field-preparation-ownership.mjs test/typing-preparation-geometry.mjs test/chat-steering.mjs test/resource-mutation-guards.mjs test/completion-steering-receipt-authority.mjs test/steering-revision-recovery.mjs test/pending-clarification-hydration.mjs test/clarify-timeout-policy.mjs test/guard-ask-cards.mjs test/permission-steering-wakeup.mjs test/pure-calculation-reply.mjs test/pure-calculation-tools.mjs test/page-feedback.mjs test/page-feedback-progress.mjs test/page-feedback-unbindable-target.mjs test/guard-advisory-actions.mjs test/rich-text-preflight-page-change.mjs test/keyboard-receiver-frame.mjs test/ask-response-scope.mjs test/auto-mode.mjs test/model-picker-icon.mjs test/ask-completion-churn.mjs test/page-feedback-policy.mjs test/page-feedback-held-time.mjs test/research-escalation-page-feedback.mjs test/page-feedback-transport-races.mjs test/page-feedback-recovery.mjs test/telegram-read-preparation-agent.mjs test/media-download-agent-handler.mjs test/code-scanning-url-recipient.mjs test/apocalypse-comm-parsing.mjs test/apocalypse-scalar-decoding.mjs test/bitgpu-chat-security.mjs test/social-media-url-upgrades.mjs test/downloaded-file-saved-bytes.mjs test/downloaded-file-local-probe.mjs test/formless-verification-recovery.mjs test/file-upload-accept.mjs test/file-upload-accept-agent.mjs test/workflow-route-generic-completion.mjs test/release-publication-completion.mjs test/workflow-implicit-metadata.mjs test/workflow-field-readings.mjs test/workflow-field-anchors.mjs test/user-turn-kind.mjs test/follow-up-task-context.mjs test/completion-current-execution-evidence.mjs test/video-upload-attachment.mjs test/feedback-automatic-churn.mjs test/feedback-navigation-idle.mjs test/feedback-run-boundaries.mjs test/feedback-ask-viewing.mjs test/lifecycle-terminal-done.mjs test/incomplete-completion-recovery.mjs test/guard-advisory-completion.mjs test/lean-mode.mjs test/lifecycle-planner-digest.mjs test/lifecycle-steering-latency.mjs test/lifecycle-steering-restart.mjs test/lifecycle-vision-fallback.mjs test/delivery-click-locks.mjs test/guards-steering-receipts.mjs test/terminal-user-messages.mjs test/improver-providers.mjs test/improver-providers-agent.mjs test/improver-guards-ledger.mjs test/improver-guards-tools.mjs test/improver-clarify.mjs test/improver-clarify-scheduler.mjs test/improver-misc.mjs test/improver-forms.mjs test/improver-forms-strict-secrets.mjs test/improver-content-press-keys-hint.mjs && npm run test:plan-notifications",
+ "test:shard:browser-a": "node --test test/captcha-draft-content.mjs test/captcha-challenge-surfaces.mjs && node test/bot-memory-dom.mjs && node test/bot-memory-click-dom.mjs && node test/ui-content-lifecycle.mjs && node --test test/native-telegram-chat.mjs test/native-telegram-recipient.mjs test/telegram-native-baseline.mjs test/telegram-native-latest.mjs test/native-chat-pre-enter-draft.mjs test/chat-draft-dispatch-ownership.mjs test/native-telegram-alias-preparation.mjs test/telegram-read-preparation-content.mjs test/queued-composer-ownership.mjs test/onboarding-provider-ready.mjs test/sidepanel-permission-gate-ui.mjs test/workflow-native-targets.mjs test/native-whatsapp-chat.mjs test/native-chat-context-identity.mjs test/native-whatsapp-contact.mjs test/whatsapp-native-bootstrap.mjs test/whatsapp-drawer-identity.mjs test/whatsapp-read-latest.mjs test/whatsapp-read-preparation.mjs test/whatsapp-chat-completion.mjs test/whatsapp-chat-restart.mjs test/chat-goal-lifecycle.mjs test/chat-completion.mjs test/chat-generic-dispatch.mjs test/completion-live-status-browser.mjs test/native-confirmation-visibility.mjs test/native-button-preparation.mjs test/read-continuation-browser.mjs test/iframe-preparation-focus.mjs test/contenteditable-literal.mjs test/native-chat-empty-editor.mjs test/native-chat-trusted-clear.mjs test/chat-steering-ui.mjs test/recipient-confirmation-ui.mjs test/assistant-message-visibility-ui.mjs test/page-monitor-ui.mjs test/x-compose-trusted-typing.mjs test/page-monitor-dialog.mjs test/page-monitor-dialog-native.mjs test/page-monitor-inline-post.mjs test/bluesky-composer-context.mjs test/page-monitor-anchored.mjs test/page-monitor-upload-owner.mjs test/page-monitor-upload-release.mjs test/page-monitor-native-controls.mjs test/page-monitor-held-observation.mjs test/page-monitor-native-preparation.mjs test/native-preparation-cold.mjs test/page-monitor-navigation.mjs test/page-monitor-main-owner.mjs test/page-monitor-collateral-controls.mjs test/accessibility-tree-scoped-budget.mjs test/ax-reference-origin.mjs test/page-monitor-decorative-hit.mjs test/social-ui-navigation.mjs test/native-resource-deletion-binding.mjs test/native-mastodon-confirmation.mjs test/dropdown-menu-inventory.mjs test/page-monitor-passive-progress.mjs test/page-monitor-feed-items.mjs test/media-download-binding.mjs test/media-download-capture-integration.mjs test/social-media-downloader-reinjection.mjs test/upload-file-local-state-guidance.mjs test/monitor-intervention-contract.mjs test/monitor-owned-geometry.mjs test/monitor-viewport-remainder.mjs test/monitor-scroll-churn.mjs test/monitor-local-attribution.mjs test/monitor-lifecycle-leaks.mjs test/lifecycle-run-ui.mjs test/lifecycle-menu-prompts-held.mjs test/delivery-cdp-input.mjs test/delivery-click-ax-response-loss.mjs test/delivery-native-button-geometry.mjs test/delivery-hover-transition.mjs test/delivery-native-button-route.mjs test/delivery-dispatch-boundary.mjs test/delivery-stop-compound.mjs test/guards-control-classification.mjs test/guards-unbound-deletion.mjs test/submit-probe-readings.mjs test/improver-content-account-chrome.mjs test/improver-content-recipient.mjs test/improver-content-truncated-replacement.mjs test/improver-forms-probe.mjs test/improver-misc-trace-browser.mjs",
"test:shard:browser-b1": "node test/message-recipient-upload.mjs && node test/message-recipient-clarify-binding.mjs && node --test test/message-recipient-whatsapp.mjs test/message-control-readings.mjs && node test/quality/integration-mv3.mjs --full-form && node test/quality/integration-mv3.mjs --batch && node test/quality/literal-calculate-midrun-mv3.mjs && node test/quality/ask-completion-churn-mv3.mjs && node test/quality/ask-person-activity-mv3.mjs && node test/quality/telegram-cold-preparation-mv3.mjs && node test/quality/native-chat-mv3.mjs && node test/quality/native-chat-presubmit-mv3.mjs && node test/quality/cloud-bot-memory-mv3.mjs",
"test:shard:browser-b2": "node test/quality/whatsapp-contact-matrix.mjs && node test/quality/pdf-detection-mv3.mjs && node test/quality/download-upload-mv3.mjs && node test/quality/upload-release-binding-mv3.mjs && node test/quality/upload-release-binding-mv3.mjs --selector-recovery && node test/quality/upload-release-binding-mv3.mjs --sequential-assets && node test/quality/release-review-world-mv3.mjs && node test/quality/downloaded-file-saved-bytes-mv3.mjs && node test/quality/file-upload-accept-mv3.mjs && node test/quality/bulk-resume-mv3.mjs && node test/quality/shared-action-guards-mv3.mjs && node test/quality/video-upload-attachment-mv3.mjs",
"test:shard:browser-c": "node test/quality/literal-frame-mv3.mjs && node test/quality/mastodon-publication-mv3.mjs && node test/quality/mastodon-reply-route-mv3.mjs && node test/quality/mastodon-deletion-mv3.mjs && node test/quality/mastodon-delete-confirmation-mv3.mjs && node test/quality/mastodon-delete-confirmation-mv3.mjs --menu-read && node test/quality/mastodon-delete-confirmation-mv3.mjs --vague && node test/quality/mastodon-delete-after-correction-mv3.mjs && node test/quality/unbound-deletion-mv3.mjs && node test/quality/recipient-clarify-mv3.mjs && node test/quality/open-chat-recipients-mv3.mjs && node test/quality/correction-cross-site-mv3.mjs && node test/quality/anchored-action-mv3.mjs && node test/quality/inline-social-composer-mv3.mjs && node test/quality/x-compose-dialog-mv3.mjs && node test/quality/bluesky-composer-mv3.mjs && node test/quality/dropdown-menu-matrix.mjs && node test/quality/mastodon-deletion-navigation-mv3.mjs && node test/quality/semantic-navigation-matrix.mjs && node test/quality/workflow-replay-mv3.mjs && node test/quality/generative-media-mv3.mjs && node test/quality/cdp-worker-restart-mv3.mjs && node test/quality/steering-worker-restart-mv3.mjs",
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index c406807fa..5b72c051d 100644
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@ -21719,6 +21719,9 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
if (!tabPending) return false;
const entry = tabPending.get(clarifyId);
if (!entry) return false;
+ // The time the user took to answer one of WebBrain's own cards does not
+ // age the page observation the pending action was decided on.
+ if (!entry.settled && Number.isFinite(entry.ts)) this._notePageFeedbackUserDecision?.(tabId, Date.now() - entry.ts);
this._settleClarification(entry, { answer, source });
return true;
}
@@ -55241,6 +55244,8 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
break;
}
+ // The model's thinking time does not age its page observation.
+ this._notePageFeedbackModelResponse(tabId);
const feedbackCalls = result?.toolCalls?.length ? result.toolCalls
: !this._containsProviderReplayState(result?.responseItems) ? this._tryParseToolCallsFromText(result?.content || '', allowedToolNames) : [];
// A pending correction supersedes this response anyway; do not first
@@ -56719,6 +56724,8 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
toolCalls: streamedToolCalls,
}));
+ // The model's thinking time does not age its page observation.
+ this._notePageFeedbackModelResponse(tabId);
const feedbackCalls = streamedToolCalls?.length ? streamedToolCalls
: !this._containsProviderReplayState(responseItems) ? this._tryParseToolCallsFromText(fullText || '', allowedToolNames) : [];
// A pending correction supersedes this response anyway; do not first
diff --git a/src/chrome/src/agent/page-feedback.js b/src/chrome/src/agent/page-feedback.js
index 34acda548..fc14f7c1f 100644
--- a/src/chrome/src/agent/page-feedback.js
+++ b/src/chrome/src/agent/page-feedback.js
@@ -319,6 +319,7 @@ export async function beforePageAgentDispatch(api, tabId, details = {}) {
let acknowledgement;
let preparationAcknowledgement;
const expectedModelSnapshot = owner.expectedModelSnapshot?.();
+ const modelHeldMs = expectedModelSnapshot ? owner.modelHeldMs?.() : 0;
const batchId = owner.batchId?.();
const relaxedMonitorGrantToken = owner.relaxedMonitorGrantToken?.();
try {
@@ -328,7 +329,8 @@ export async function beforePageAgentDispatch(api, tabId, details = {}) {
allowPassiveRebase: owner.allowPassiveRebase?.() === true,
...(relaxedMonitorGrantToken ? { relaxedMonitorGrantToken } : {}),
...(batchId ? { batchId } : {}),
- ...(expectedModelSnapshot ? { expectedModelSnapshot } : {}) } }, { frameId: Number(details.frameId) || 0 });
+ ...(expectedModelSnapshot ? { expectedModelSnapshot } : {}),
+ ...(modelHeldMs > 0 ? { modelHeldMs } : {}) } }, { frameId: Number(details.frameId) || 0 });
}
acknowledgement = await api.tabs.sendMessage(tabId, { target: 'content', action: 'page_monitor_dispatch',
params: monitorParams }, { frameId: Number(details.frameId) || 0 });
@@ -472,6 +474,7 @@ export const pageFeedbackMethods = {
pending: () => this._pageFeedbackBlocksCall(tabId, run.dispatchCall?.name, run.dispatchCall?.args),
allowPassiveRebase: () => run.dispatchCall?.allowPassiveRebase === true,
expectedModelSnapshot: () => run.dispatchCall?.dispatchState?.started ? undefined : run.dispatchCall?.expectedModelSnapshot,
+ modelHeldMs: () => this._pageFeedbackModelHeldMs(run.dispatchCall?.modelState),
batchId: () => run.dispatchCall?.batchId,
relaxedMonitorGrantToken: () => this._monitoringRetryCurrent(tabId, run)?.grantToken,
clearNavigation: () => { run.navigation = null; run.sameDocumentNavigation = null; },
@@ -915,6 +918,31 @@ export const pageFeedbackMethods = {
return observation ? `${prompt}\n\n${observation}` : prompt;
},
+ // A pre-inference observation's certificate lasts two minutes of WebBrain's
+ // own time (MODEL_SNAPSHOT_MS in page-monitor.js). The model's thinking and
+ // the user's answers to WebBrain's own cards (permission, submit and
+ // deletion confirmations, questions) do not count: a slow provider or a
+ // user who reads a card for a minute otherwise expired an unchanged target
+ // as "The browser changed during action preparation", and every retry
+ // showed the same card again. What changes on the page meanwhile is still
+ // reported by the monitor and judged by the binding checks.
+ _notePageFeedbackModelResponse(tabId) {
+ const binding = this._pageFeedbackRuns?.get(tabId)?.modelState?.actionBinding;
+ if (binding?.capturedAt && !binding.respondedAt) binding.respondedAt = Date.now();
+ },
+
+ _notePageFeedbackUserDecision(tabId, waitedMs) {
+ const binding = this._pageFeedbackRuns?.get(tabId)?.modelState?.actionBinding;
+ if (binding && Number.isFinite(waitedMs) && waitedMs > 0) binding.userDecisionMs = (binding.userDecisionMs || 0) + waitedMs;
+ },
+
+ _pageFeedbackModelHeldMs(state) {
+ const binding = state?.actionBinding;
+ if (!binding) return 0;
+ const thinking = binding.capturedAt && binding.respondedAt ? Math.max(0, binding.respondedAt - binding.capturedAt) : 0;
+ return Math.round(thinking + Math.max(0, binding.userDecisionMs || 0));
+ },
+
_hasPendingPageFeedback(tabId) {
return !!this._pageFeedbackRuns?.get(tabId)?.events.size;
},
@@ -1245,7 +1273,7 @@ export const pageFeedbackMethods = {
if (monitoringRetry && capture.monitoringRelaxed === false) this._invalidateMonitoringRetry(tabId, 'grant_expired');
actionTargetCount = Number.isSafeInteger(capture.targetCount) ? Math.max(0, Math.min(512, capture.targetCount)) : 0;
state.actionBinding = { snapshotToken: capture.snapshotToken, runToken: run.token, documentToken: capture.documentToken,
- focusedTargetAvailable: capture.focusedTargetAvailable === true,
+ focusedTargetAvailable: capture.focusedTargetAvailable === true, capturedAt: Date.now(),
...(monitoringRetry && this._monitoringRetryCurrent(tabId, run) === monitoringRetry
? { relaxedMonitorGrantToken: monitoringRetry.grantToken } : {}) };
if (capture.observationScopeCaptured === false) run.actionObservationScope = null;
@@ -1328,6 +1356,7 @@ export const pageFeedbackMethods = {
const relaxedMonitorGrantToken = retry && retry.grantToken === binding.relaxedMonitorGrantToken ? retry.grantToken : null;
const response = await apiFor().tabs.sendMessage(tabId, { target: 'content', action: 'page_monitor_validate_model',
params: { ...safeAction(name, args), runToken: run.token, snapshotToken: binding.snapshotToken,
+ ...(this._pageFeedbackModelHeldMs(state) > 0 ? { modelHeldMs: this._pageFeedbackModelHeldMs(state) } : {}),
...(batchId ? { batchId } : {}),
...(relaxedMonitorGrantToken ? { relaxedMonitorGrantToken } : {}) } }, { frameId: 0 });
const owned = response?.runToken === binding.runToken
@@ -1839,11 +1868,13 @@ export function installPageFeedback(Agent) {
const revision = run.revision;
let prepared;
try {
+ const modelHeldMs = expectedModelSnapshot ? this._pageFeedbackModelHeldMs(modelState) : 0;
prepared = await apiFor().tabs.sendMessage(tabId, { target: 'content', action: 'page_monitor_prepare',
params: { ...safeAction(name, args), runToken: run.token, operationId, allowPassiveRebase: allowPassiveRebase === true,
...(batchId ? { batchId } : {}),
...(relaxedMonitorGrantToken ? { relaxedMonitorGrantToken } : {}),
- ...(expectedModelSnapshot ? { expectedModelSnapshot } : {}) } }, { frameId: 0 });
+ ...(expectedModelSnapshot ? { expectedModelSnapshot } : {}),
+ ...(modelHeldMs > 0 ? { modelHeldMs } : {}) } }, { frameId: 0 });
} catch {}
// Certified targets keep their pre-inference footprint across passive
// updates during preparation; legacy preparation retains its revision fence.
diff --git a/src/chrome/src/content/page-monitor.js b/src/chrome/src/content/page-monitor.js
index 94f584cd2..c90892178 100644
--- a/src/chrome/src/content/page-monitor.js
+++ b/src/chrome/src/content/page-monitor.js
@@ -17,6 +17,11 @@
const modelSnapshots = new Map();
let ownedPreparationBindings = new WeakMap();
const MODEL_SNAPSHOT_MS = 120000;
+ // Time the background waited for the model's decision, or for the user's
+ // answer to one of WebBrain's own cards, does not age an observation: what
+ // changes on the page meanwhile is what the monitor reports and the binding
+ // checks judge. The background reports that time (modelHeldMs), bounded.
+ const MODEL_SNAPSHOT_HOLD_LIMIT_MS = 30 * 60 * 1000;
const MODEL_TARGET_LIMIT = 512;
const MODEL_SCAN_LIMIT = 2048;
const MODEL_PUBLIC_MAX = 12000;
@@ -1771,10 +1776,17 @@
&& (!item.files || (item.files.length === current.files?.length && item.files.every((file, fileIndex) => file === current.files[fileIndex])));
}));
}
+ function holdModelSnapshot(snapshot, heldMs) {
+ const held = Math.min(MODEL_SNAPSHOT_HOLD_LIMIT_MS, Math.max(0, Math.floor(Number(heldMs) || 0)));
+ if (snapshot && held > (snapshot.heldMs || 0)) snapshot.heldMs = held;
+ }
+ function modelSnapshotLive(snapshot) {
+ return !!snapshot && snapshot.until + (snapshot.heldMs || 0) >= Date.now();
+ }
function sealBrowserBatchInput(owner, params) {
const op = owner?.batchInputOperation || owner;
const snapshot = modelSnapshots.get(op?.expectedModelSnapshot);
- if (!op?.batchId || !snapshot || snapshot.until < Date.now() || snapshot.runToken !== runToken
+ if (!op?.batchId || !modelSnapshotLive(snapshot) || snapshot.runToken !== runToken
|| op.batchId !== owner.batchId || op.modelBindingInvalid || op.preparedBinding?.relaxed || authorityChanged(op)
|| typeof params.batchInputText !== 'string') return false;
const current = operationBinding(op);
@@ -1953,7 +1965,8 @@
function modelBindingResult(params = {}) {
const snapshot = modelSnapshots.get(params.snapshotToken || params.expectedModelSnapshot);
if (!active || params.runToken !== runToken || snapshot?.runToken !== runToken) return { reason: 'model_snapshot_invalid' };
- if (!snapshot || snapshot.until < Date.now()) return { reason: 'model_snapshot_expired' };
+ holdModelSnapshot(snapshot, params.modelHeldMs);
+ if (!modelSnapshotLive(snapshot)) return { reason: 'model_snapshot_expired' };
const relaxed = snapshot.relaxedGrantToken && snapshot.relaxedGrantToken === params.relaxedMonitorGrantToken
&& currentRelaxedGrant(params.relaxedMonitorGrantToken);
if (snapshot.relaxedGrantToken && !relaxed) return { reason: 'relaxed_grant_expired' };
@@ -2332,7 +2345,7 @@
modelSnapshots.set(snapshotToken, { runToken, until: Date.now() + MODEL_SNAPSHOT_MS, targets, uncertified, refs,
relaxedGrantToken, relaxedTargets, relaxedInvalidated, captureFailures,
hasRefs: !!page || !!window.__wbElementMap, focusTarget, userAt: lastUserAt, interventionRevision });
- for (const [key, snapshot] of modelSnapshots) if (snapshot.until < Date.now()) modelSnapshots.delete(key);
+ for (const [key, snapshot] of modelSnapshots) if (!modelSnapshotLive(snapshot)) modelSnapshots.delete(key);
while (modelSnapshots.size > 2) modelSnapshots.delete(modelSnapshots.keys().next().value);
return { ready: true, runToken, documentToken, snapshotToken, targetCount: targets.size, focusedTargetAvailable,
monitoringRelaxed: !!relaxedGrantToken && currentRelaxedGrant(relaxedGrantToken),
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index 88e9fa925..21f50fffc 100644
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@ -18759,6 +18759,9 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
if (!tabPending) return false;
const entry = tabPending.get(clarifyId);
if (!entry) return false;
+ // The time the user took to answer one of WebBrain's own cards does not
+ // age the page observation the pending action was decided on.
+ if (!entry.settled && Number.isFinite(entry.ts)) this._notePageFeedbackUserDecision?.(tabId, Date.now() - entry.ts);
this._settleClarification(entry, { answer, source });
return true;
}
@@ -46701,6 +46704,8 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
break;
}
+ // The model's thinking time does not age its page observation.
+ this._notePageFeedbackModelResponse(tabId);
const feedbackCalls = result?.toolCalls?.length ? result.toolCalls
: !this._containsProviderReplayState(result?.responseItems) ? this._tryParseToolCallsFromText(result?.content || '', allowedToolNames) : [];
// A pending correction supersedes this response anyway; do not first
@@ -48018,6 +48023,8 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
await this._observeAfterCloudHandoff(tabId, messages, onUpdate, runOptions, responseHandoff);
continue;
}
+ // The model's thinking time does not age its page observation.
+ this._notePageFeedbackModelResponse(tabId);
const feedbackCalls = streamedToolCalls?.length ? streamedToolCalls
: !this._containsProviderReplayState(responseItems) ? this._tryParseToolCallsFromText(fullText || '', allowedToolNames) : [];
// A pending correction supersedes this response anyway; do not first
diff --git a/src/firefox/src/agent/page-feedback.js b/src/firefox/src/agent/page-feedback.js
index 34acda548..fc14f7c1f 100644
--- a/src/firefox/src/agent/page-feedback.js
+++ b/src/firefox/src/agent/page-feedback.js
@@ -319,6 +319,7 @@ export async function beforePageAgentDispatch(api, tabId, details = {}) {
let acknowledgement;
let preparationAcknowledgement;
const expectedModelSnapshot = owner.expectedModelSnapshot?.();
+ const modelHeldMs = expectedModelSnapshot ? owner.modelHeldMs?.() : 0;
const batchId = owner.batchId?.();
const relaxedMonitorGrantToken = owner.relaxedMonitorGrantToken?.();
try {
@@ -328,7 +329,8 @@ export async function beforePageAgentDispatch(api, tabId, details = {}) {
allowPassiveRebase: owner.allowPassiveRebase?.() === true,
...(relaxedMonitorGrantToken ? { relaxedMonitorGrantToken } : {}),
...(batchId ? { batchId } : {}),
- ...(expectedModelSnapshot ? { expectedModelSnapshot } : {}) } }, { frameId: Number(details.frameId) || 0 });
+ ...(expectedModelSnapshot ? { expectedModelSnapshot } : {}),
+ ...(modelHeldMs > 0 ? { modelHeldMs } : {}) } }, { frameId: Number(details.frameId) || 0 });
}
acknowledgement = await api.tabs.sendMessage(tabId, { target: 'content', action: 'page_monitor_dispatch',
params: monitorParams }, { frameId: Number(details.frameId) || 0 });
@@ -472,6 +474,7 @@ export const pageFeedbackMethods = {
pending: () => this._pageFeedbackBlocksCall(tabId, run.dispatchCall?.name, run.dispatchCall?.args),
allowPassiveRebase: () => run.dispatchCall?.allowPassiveRebase === true,
expectedModelSnapshot: () => run.dispatchCall?.dispatchState?.started ? undefined : run.dispatchCall?.expectedModelSnapshot,
+ modelHeldMs: () => this._pageFeedbackModelHeldMs(run.dispatchCall?.modelState),
batchId: () => run.dispatchCall?.batchId,
relaxedMonitorGrantToken: () => this._monitoringRetryCurrent(tabId, run)?.grantToken,
clearNavigation: () => { run.navigation = null; run.sameDocumentNavigation = null; },
@@ -915,6 +918,31 @@ export const pageFeedbackMethods = {
return observation ? `${prompt}\n\n${observation}` : prompt;
},
+ // A pre-inference observation's certificate lasts two minutes of WebBrain's
+ // own time (MODEL_SNAPSHOT_MS in page-monitor.js). The model's thinking and
+ // the user's answers to WebBrain's own cards (permission, submit and
+ // deletion confirmations, questions) do not count: a slow provider or a
+ // user who reads a card for a minute otherwise expired an unchanged target
+ // as "The browser changed during action preparation", and every retry
+ // showed the same card again. What changes on the page meanwhile is still
+ // reported by the monitor and judged by the binding checks.
+ _notePageFeedbackModelResponse(tabId) {
+ const binding = this._pageFeedbackRuns?.get(tabId)?.modelState?.actionBinding;
+ if (binding?.capturedAt && !binding.respondedAt) binding.respondedAt = Date.now();
+ },
+
+ _notePageFeedbackUserDecision(tabId, waitedMs) {
+ const binding = this._pageFeedbackRuns?.get(tabId)?.modelState?.actionBinding;
+ if (binding && Number.isFinite(waitedMs) && waitedMs > 0) binding.userDecisionMs = (binding.userDecisionMs || 0) + waitedMs;
+ },
+
+ _pageFeedbackModelHeldMs(state) {
+ const binding = state?.actionBinding;
+ if (!binding) return 0;
+ const thinking = binding.capturedAt && binding.respondedAt ? Math.max(0, binding.respondedAt - binding.capturedAt) : 0;
+ return Math.round(thinking + Math.max(0, binding.userDecisionMs || 0));
+ },
+
_hasPendingPageFeedback(tabId) {
return !!this._pageFeedbackRuns?.get(tabId)?.events.size;
},
@@ -1245,7 +1273,7 @@ export const pageFeedbackMethods = {
if (monitoringRetry && capture.monitoringRelaxed === false) this._invalidateMonitoringRetry(tabId, 'grant_expired');
actionTargetCount = Number.isSafeInteger(capture.targetCount) ? Math.max(0, Math.min(512, capture.targetCount)) : 0;
state.actionBinding = { snapshotToken: capture.snapshotToken, runToken: run.token, documentToken: capture.documentToken,
- focusedTargetAvailable: capture.focusedTargetAvailable === true,
+ focusedTargetAvailable: capture.focusedTargetAvailable === true, capturedAt: Date.now(),
...(monitoringRetry && this._monitoringRetryCurrent(tabId, run) === monitoringRetry
? { relaxedMonitorGrantToken: monitoringRetry.grantToken } : {}) };
if (capture.observationScopeCaptured === false) run.actionObservationScope = null;
@@ -1328,6 +1356,7 @@ export const pageFeedbackMethods = {
const relaxedMonitorGrantToken = retry && retry.grantToken === binding.relaxedMonitorGrantToken ? retry.grantToken : null;
const response = await apiFor().tabs.sendMessage(tabId, { target: 'content', action: 'page_monitor_validate_model',
params: { ...safeAction(name, args), runToken: run.token, snapshotToken: binding.snapshotToken,
+ ...(this._pageFeedbackModelHeldMs(state) > 0 ? { modelHeldMs: this._pageFeedbackModelHeldMs(state) } : {}),
...(batchId ? { batchId } : {}),
...(relaxedMonitorGrantToken ? { relaxedMonitorGrantToken } : {}) } }, { frameId: 0 });
const owned = response?.runToken === binding.runToken
@@ -1839,11 +1868,13 @@ export function installPageFeedback(Agent) {
const revision = run.revision;
let prepared;
try {
+ const modelHeldMs = expectedModelSnapshot ? this._pageFeedbackModelHeldMs(modelState) : 0;
prepared = await apiFor().tabs.sendMessage(tabId, { target: 'content', action: 'page_monitor_prepare',
params: { ...safeAction(name, args), runToken: run.token, operationId, allowPassiveRebase: allowPassiveRebase === true,
...(batchId ? { batchId } : {}),
...(relaxedMonitorGrantToken ? { relaxedMonitorGrantToken } : {}),
- ...(expectedModelSnapshot ? { expectedModelSnapshot } : {}) } }, { frameId: 0 });
+ ...(expectedModelSnapshot ? { expectedModelSnapshot } : {}),
+ ...(modelHeldMs > 0 ? { modelHeldMs } : {}) } }, { frameId: 0 });
} catch {}
// Certified targets keep their pre-inference footprint across passive
// updates during preparation; legacy preparation retains its revision fence.
diff --git a/src/firefox/src/content/page-monitor.js b/src/firefox/src/content/page-monitor.js
index 94f584cd2..c90892178 100644
--- a/src/firefox/src/content/page-monitor.js
+++ b/src/firefox/src/content/page-monitor.js
@@ -17,6 +17,11 @@
const modelSnapshots = new Map();
let ownedPreparationBindings = new WeakMap();
const MODEL_SNAPSHOT_MS = 120000;
+ // Time the background waited for the model's decision, or for the user's
+ // answer to one of WebBrain's own cards, does not age an observation: what
+ // changes on the page meanwhile is what the monitor reports and the binding
+ // checks judge. The background reports that time (modelHeldMs), bounded.
+ const MODEL_SNAPSHOT_HOLD_LIMIT_MS = 30 * 60 * 1000;
const MODEL_TARGET_LIMIT = 512;
const MODEL_SCAN_LIMIT = 2048;
const MODEL_PUBLIC_MAX = 12000;
@@ -1771,10 +1776,17 @@
&& (!item.files || (item.files.length === current.files?.length && item.files.every((file, fileIndex) => file === current.files[fileIndex])));
}));
}
+ function holdModelSnapshot(snapshot, heldMs) {
+ const held = Math.min(MODEL_SNAPSHOT_HOLD_LIMIT_MS, Math.max(0, Math.floor(Number(heldMs) || 0)));
+ if (snapshot && held > (snapshot.heldMs || 0)) snapshot.heldMs = held;
+ }
+ function modelSnapshotLive(snapshot) {
+ return !!snapshot && snapshot.until + (snapshot.heldMs || 0) >= Date.now();
+ }
function sealBrowserBatchInput(owner, params) {
const op = owner?.batchInputOperation || owner;
const snapshot = modelSnapshots.get(op?.expectedModelSnapshot);
- if (!op?.batchId || !snapshot || snapshot.until < Date.now() || snapshot.runToken !== runToken
+ if (!op?.batchId || !modelSnapshotLive(snapshot) || snapshot.runToken !== runToken
|| op.batchId !== owner.batchId || op.modelBindingInvalid || op.preparedBinding?.relaxed || authorityChanged(op)
|| typeof params.batchInputText !== 'string') return false;
const current = operationBinding(op);
@@ -1953,7 +1965,8 @@
function modelBindingResult(params = {}) {
const snapshot = modelSnapshots.get(params.snapshotToken || params.expectedModelSnapshot);
if (!active || params.runToken !== runToken || snapshot?.runToken !== runToken) return { reason: 'model_snapshot_invalid' };
- if (!snapshot || snapshot.until < Date.now()) return { reason: 'model_snapshot_expired' };
+ holdModelSnapshot(snapshot, params.modelHeldMs);
+ if (!modelSnapshotLive(snapshot)) return { reason: 'model_snapshot_expired' };
const relaxed = snapshot.relaxedGrantToken && snapshot.relaxedGrantToken === params.relaxedMonitorGrantToken
&& currentRelaxedGrant(params.relaxedMonitorGrantToken);
if (snapshot.relaxedGrantToken && !relaxed) return { reason: 'relaxed_grant_expired' };
@@ -2332,7 +2345,7 @@
modelSnapshots.set(snapshotToken, { runToken, until: Date.now() + MODEL_SNAPSHOT_MS, targets, uncertified, refs,
relaxedGrantToken, relaxedTargets, relaxedInvalidated, captureFailures,
hasRefs: !!page || !!window.__wbElementMap, focusTarget, userAt: lastUserAt, interventionRevision });
- for (const [key, snapshot] of modelSnapshots) if (snapshot.until < Date.now()) modelSnapshots.delete(key);
+ for (const [key, snapshot] of modelSnapshots) if (!modelSnapshotLive(snapshot)) modelSnapshots.delete(key);
while (modelSnapshots.size > 2) modelSnapshots.delete(modelSnapshots.keys().next().value);
return { ready: true, runToken, documentToken, snapshotToken, targetCount: targets.size, focusedTargetAvailable,
monitoringRelaxed: !!relaxedGrantToken && currentRelaxedGrant(relaxedGrantToken),
diff --git a/test/page-feedback-held-time.mjs b/test/page-feedback-held-time.mjs
new file mode 100644
index 000000000..152ca900a
--- /dev/null
+++ b/test/page-feedback-held-time.mjs
@@ -0,0 +1,84 @@
+import assert from 'node:assert/strict';
+import { test } from 'node:test';
+
+// The background side of a held observation: the model's thinking time and
+// the user's answers to WebBrain's own cards are reported with every check of
+// the pre-inference certificate (see page-monitor-held-observation.mjs for
+// the content side).
+const PAGE_URL = 'https://held-time.test/login';
+const sent = [];
+const area = { get: async () => ({}), set: async () => {}, remove: async () => {} };
+globalThis.chrome = globalThis.browser = {
+ storage: { local: area, session: area },
+ runtime: { getURL: value => `extension://test/${value}`, sendMessage: async () => ({}) },
+ tabs: {
+ get: async id => ({ id, url: PAGE_URL, title: 'Sign in' }),
+ async sendMessage(_tab, message) {
+ sent.push(message);
+ const params = message.params || {};
+ return { ready: true, modelBindingValid: true, runToken: params.runToken, documentToken: 'doc-token',
+ snapshotToken: params.snapshotToken || params.expectedModelSnapshot };
+ },
+ },
+ webNavigation: { getAllFrames: async () => [{ frameId: 0, parentFrameId: -1, documentId: 'main-document', url: PAGE_URL }] },
+ scripting: { executeScript: async () => [{ result: null }] },
+};
+
+let nextTab = 9900;
+for (const build of ['chrome', 'firefox']) {
+ const { Agent } = await import(`../src/${build}/src/agent/agent.js`);
+
+ const withClock = async work => {
+ const realNow = Date.now;
+ let now = realNow();
+ Date.now = () => now;
+ try { await work(ms => { now += ms; }); } finally { Date.now = realNow; }
+ };
+ const watched = () => {
+ const tab = nextTab++;
+ const agent = new Agent({ getActive: () => null, getProvider: () => null, getVisionProvider: async () => null });
+ const state = { token: 'run-token', url: PAGE_URL, frames: new Map(), steeringRevision: 0,
+ actionBinding: { snapshotToken: 'snapshot-1', runToken: 'run-token', documentToken: 'doc-token', capturedAt: Date.now() } };
+ const run = { token: 'run-token', url: PAGE_URL, events: new Map(), frames: new Map(), documents: new Map(), modelState: state };
+ agent._pageFeedbackRuns = new Map([[tab, run]]);
+ return { agent, tab, state, run };
+ };
+
+ test(`${build}: the model's thinking and the user's card decisions are reported as held time`, () => withClock(async advance => {
+ const { agent, tab, state } = watched();
+ assert.equal(agent._pageFeedbackModelHeldMs(state), 0);
+ advance(46000);
+ agent._notePageFeedbackModelResponse(tab);
+ advance(3000); // WebBrain's own checks keep counting
+ agent._notePageFeedbackModelResponse(tab);
+ assert.equal(agent._pageFeedbackModelHeldMs(state), 46000, 'the response is noted once');
+ // A permission card the user answers after 112 seconds.
+ let answer = null;
+ agent._pendingClarifications.set(tab, new Map([['perm-1', { resolve: value => { answer = value; }, ts: Date.now() }]]));
+ advance(112000);
+ assert.equal(agent.submitClarifyResponse(tab, 'perm-1', 'once'), true);
+ assert.deepEqual(answer, { answer: 'once', source: 'user' });
+ assert.equal(agent._pageFeedbackModelHeldMs(state), 158000);
+ // A card that was already settled (timed out) adds nothing.
+ agent._pendingClarifications.set(tab, new Map([['perm-2', { resolve() {}, ts: Date.now() - 5000, settled: true }]]));
+ agent.submitClarifyResponse(tab, 'perm-2', 'once');
+ assert.equal(agent._pageFeedbackModelHeldMs(state), 158000);
+ }));
+
+ test(`${build}: every check of the pre-inference certificate carries the held time`, () => withClock(async advance => {
+ const { agent, tab, state } = watched();
+ advance(46000);
+ agent._notePageFeedbackModelResponse(tab);
+ agent._notePageFeedbackUserDecision(tab, 112000);
+ sent.length = 0;
+ assert.equal(await agent._validatePageFeedbackAction(tab, 'click_ax', { ref_id: 'ref_submit' }, state), true);
+ const validation = sent.find(message => message.action === 'page_monitor_validate_model');
+ assert.equal(validation?.params.modelHeldMs, 158000);
+ assert.equal(validation.params.snapshotToken, 'snapshot-1');
+ // A fresh observation that nothing held reports none.
+ const fresh = watched();
+ sent.length = 0;
+ await fresh.agent._validatePageFeedbackAction(fresh.tab, 'click_ax', { ref_id: 'ref_submit' }, fresh.state);
+ assert.equal('modelHeldMs' in sent.find(message => message.action === 'page_monitor_validate_model').params, false);
+ }));
+}
diff --git a/test/page-monitor-held-observation.mjs b/test/page-monitor-held-observation.mjs
new file mode 100644
index 000000000..a1d8bf66c
--- /dev/null
+++ b/test/page-monitor-held-observation.mjs
@@ -0,0 +1,125 @@
+import assert from 'node:assert/strict';
+import { readFile } from 'node:fs/promises';
+import { test } from 'node:test';
+import { chromium, firefox } from 'playwright';
+
+// A pre-inference observation certifies its targets for two minutes of
+// WebBrain's own time. The background reports how long it then waited for the
+// model's decision and for the user's answers to its own cards (modelHeldMs);
+// that time does not age the observation, while every page change is still
+// judged as before. Without it a slow provider or a user reading a permission
+// card for a minute expired an unchanged login button (E2, K1, M1 traces).
+const html = `<!doctype html><style>body{margin:20px;font:16px sans-serif}button{min-height:40px;width:240px}</style>
+<main id="owner"><h1>Sign in</h1><form id="login" onsubmit="event.preventDefault()">
+<label>Username <input id="user" name="username"></label>
+<button id="submit" type="submit">Log in</button></form></main><aside id="clock">0</aside>`;
+const sources = new Map();
+for (const build of ['chrome', 'firefox']) {
+ const files = new Map();
+ for (const name of ['rich-text-toolbar-heuristic.js', 'file-upload-policy.js', 'accessibility-tree.js', 'page-monitor.js', 'content.js']) {
+ files.set(name, await readFile(new URL(`../src/${build}/src/content/${name}`, import.meta.url), 'utf8'));
+ }
+ sources.set(build, files);
+}
+
+async function fixture(browser, build) {
+ const context = await browser.newContext({ viewport: { width: 1000, height: 700 } });
+ await context.route('https://held-observation.test/**', route => route.fulfill({ contentType: 'text/html', body: html }));
+ await context.addInitScript(() => {
+ window.qaListeners = []; window.qaRunToken = 'held-observation-run';
+ // The page's clock moves on without real waiting.
+ const realNow = Date.now.bind(Date);
+ window.qaClockOffset = 0;
+ Date.now = () => realNow() + window.qaClockOffset;
+ window.chrome = window.browser = { runtime: {
+ onMessage: { addListener: fn => qaListeners.push(fn), removeListener() {} }, getURL: value => value,
+ async sendMessage(message) {
+ if (message.action === 'get_page_monitor_state') return { active: true, runToken: qaRunToken, documentToken: message.documentToken };
+ if (message.action === 'page_feedback') return { accepted: true };
+ return {};
+ },
+ } };
+ window.qaMessage = (action, params = {}) => new Promise(resolve => {
+ let answered = false;
+ const respond = value => { answered = true; resolve(value); };
+ for (const listener of qaListeners) {
+ const message = { target: 'content', action, params: { runToken: 'held-observation-run', ...params } };
+ const asynchronous = listener(message, {}, respond);
+ if (answered || asynchronous === true) break;
+ }
+ });
+ });
+ for (const content of sources.get(build).values()) await context.addInitScript({ content });
+ const page = await context.newPage();
+ await page.goto('https://held-observation.test/login');
+ await page.waitForFunction(() => window.__wbPageMonitor?.active);
+ await page.waitForTimeout(180);
+ return { context, page };
+}
+
+const capture = page => page.evaluate(async () => {
+ const snapshot = await qaMessage('page_monitor_capture_model', { includeTree: true });
+ return { snapshotToken: snapshot.snapshotToken, ref_id: __wb_ax_ref(document.getElementById('submit')) };
+});
+const validate = (page, captured, extra = {}) => page.evaluate(({ captured, extra }) => qaMessage('page_monitor_validate_model', {
+ tool: 'click_ax', ref_id: captured.ref_id, snapshotToken: captured.snapshotToken, ...extra,
+}), { captured, extra });
+const prepare = (page, captured, extra = {}) => page.evaluate(({ captured, extra }) => qaMessage('page_monitor_prepare', {
+ tool: 'click_ax', ref_id: captured.ref_id, operationId: 'held-observation-click',
+ expectedModelSnapshot: captured.snapshotToken, allowPassiveRebase: true, ...extra,
+}), { captured, extra });
+const advance = (page, ms) => page.evaluate(ms => { window.qaClockOffset += ms; }, ms);
+
+for (const [build, engine] of [['chrome', chromium], ['firefox', firefox]]) {
+ test(`${build}: time spent waiting for the model and the user does not expire an unchanged target`, { timeout: 120000 }, async t => {
+ const browser = await engine.launch({ headless: true });
+ try {
+ const withFixture = async work => {
+ const { context, page } = await fixture(browser, build);
+ try { await work(page); } finally { await context.close(); }
+ };
+
+ await t.test('two minutes of WebBrain time still expire the observation', () => withFixture(async page => {
+ const captured = await capture(page);
+ assert.equal((await validate(page, captured)).ready, true);
+ // A 46-second answer, then a 112-second wait on the permission card.
+ await advance(page, 158000);
+ const expired = await validate(page, captured);
+ assert.deepEqual([expired.ready, expired.reason], [false, 'model_snapshot_expired']);
+ // Held time that does not cover the gap leaves it expired.
+ assert.equal((await validate(page, captured, { modelHeldMs: 30000 })).reason, 'model_snapshot_expired');
+ // The background reports that the model and the user held it for 158 s.
+ assert.equal((await validate(page, captured, { modelHeldMs: 158000 })).ready, true);
+ // Preparation and later checks of the same call see the same hold.
+ const prepared = await prepare(page, captured);
+ assert.equal(prepared.modelBindingValid, true, JSON.stringify(prepared));
+ assert.equal((await validate(page, captured, { modelHeldMs: 10 })).ready, true, 'a hold never shrinks');
+ // WebBrain's own time keeps counting after the hold.
+ await advance(page, 121000);
+ assert.equal((await validate(page, captured)).reason, 'model_snapshot_expired');
+ }));
+
+ await t.test('a page change during the wait still retires the target', () => withFixture(async page => {
+ const captured = await capture(page);
+ await advance(page, 150000);
+ await page.evaluate(() => { document.getElementById('submit').textContent = 'Delete account'; });
+ await page.waitForTimeout(180);
+ assert.equal((await validate(page, captured, { modelHeldMs: 150000 })).ready, false);
+ }));
+
+ await t.test('an unrelated counter changing during the wait does not', () => withFixture(async page => {
+ const captured = await capture(page);
+ await advance(page, 150000);
+ await page.evaluate(() => { document.getElementById('clock').textContent = '1'; });
+ await page.waitForTimeout(180);
+ assert.equal((await validate(page, captured, { modelHeldMs: 150000 })).ready, true);
+ }));
+
+ await t.test('the hold is bounded', () => withFixture(async page => {
+ const captured = await capture(page);
+ await advance(page, 3 * 60 * 60 * 1000);
+ assert.equal((await validate(page, captured, { modelHeldMs: 10 * 60 * 60 * 1000 })).reason, 'model_snapshot_expired');
+ }));
+ } finally { await browser.close(); }
+ });
+}