Open-source AI browser agent for Chrome and Firefox (monorepo) đź§
JavaScript ai-agentai-agentsai-toolsbrowser-aibrowser-automationbrowser-extensionchrome-aichrome-devtoolschrome-extensionchrome-extensionsfirefox-addonfirefox-addonsfirefox-extensionfirefox-extensionsgemmagemma4minimaxoffline-aioffline-llmqwen
Unblock Discord sends whose Enter never fired
Claude2a968f3ff35d
diff --git a/docs/accessibility-tree-and-refs.md b/docs/accessibility-tree-and-refs.mdindex 82874fead..ccbd63352 100644--- a/docs/accessibility-tree-and-refs.md+++ b/docs/accessibility-tree-and-refs.md@@ -199,7 +199,7 @@ Rejects non-typeable input types (checkbox, radio, submit, file) with a clear erAtomically focuses + (optionally clears) + types + (optionally submits). The one-shot equivalent of `click_ax` + `type_ax`.-**Combobox-aware submit**: when `submit:true`, the tool detects if the field is a combobox/autocomplete (role=combobox, aria-autocomplete, aria-controls pointing at a listbox, or a visible listbox on the page). If so, dispatches `ArrowDown` → `Enter` with small delays to commit the highlighted option. Otherwise falls back to `form.requestSubmit()` or a plain `Enter` key press.+**Combobox-aware submit**: when `submit:true`, the tool detects if the field is a combobox/autocomplete (role=combobox, aria-autocomplete, aria-controls pointing at a listbox, or a visible listbox on the page). If so, dispatches `ArrowDown` → `Enter` with small delays to commit the highlighted option. Otherwise falls back to `form.requestSubmit()` or a plain `Enter` key press. A rich-text (contenteditable) editor gets that `ArrowDown` only when its role is `combobox` or `searchbox`: a message box's `aria-autocomplete`, `aria-expanded` and suggestion list belong to its @mention pop-up, where an `ArrowDown` moves the pop-up's choice instead of letting Enter send. This holds for the content script's submit and for Chrome's trusted retry for Slate, ProseMirror and DraftJS editors. In the trusted retry, a page-change veto of either key before it reaches the page returns the verified draft with `submissionDispatched:false`, never a possibly-submitted result.**Truncated-preview refusal**: a tree line shows only the start of a long field value, so a replacing write copied from it would delete the rest. `set_field`, `type_ax` and `type_text` with `clear` refuse, before anything is typed, a text that ends in `...`, `…` or one of the runtime's own cut markers (such as `[...truncated]`) when the text before that ending (at least 20 characters) starts the field's current value and at least 10 more characters follow it there. A text the value itself continues, ending included, is not a preview. The result is `{success:false, noDispatch:true, errorCode:'truncated_value_replacement', currentValueLength, recoveryRequired:'read_full_value'}`: read the full value first (`read_page` lists form values), or add text with `clear:false`; to shorten the field to exactly that text, clear it with an empty text, then add it. The markers are `TRUNCATED_PREVIEW_MARKERS` in content.js, which `test/improver-content-truncated-replacement.mjs` keeps equal to the markers the runtime appends to model-visible text.diff --git a/docs/native-chat-observation.md b/docs/native-chat-observation.mdindex 44dffbe37..12fd97e73 100644--- a/docs/native-chat-observation.md+++ b/docs/native-chat-observation.md@@ -429,6 +429,26 @@ automatic answers and timeouts cannotapprove it. Actual verified delivery can instead clear pending state throughordinary `chat_observe`, without manual reconciliation.+A `chat_send` whose Enter never reached the page is not uncertain on a page+that empties its composer the moment it sends (Discord). When the+page-change fence refuses a key before Enter after the exact draft was+verified (`submissionBlockReason: 'page_feedback_pending'`), and a live read+finds that whole draft still in the same composer of the same conversation+with no new outgoing or unattributed copy, `chat_send` releases its pending+record and reports `chat_submit_not_dispatched` with `draftRetained: true`.+One guarded Enter then sends the draft. A changed draft, a sent copy, a+recipient refusal, a stopped run or another site keeps the record: a page+that keeps its text until the server answers could be mid-send. Telegram and+WhatsApp keep their private owned-draft lease for the same state, and a+direct `set_field` submit keeps its record for the card.++The confirmation card names the conversation as its page does, quoted on its+own line (`Conversation: “#announcements” on discord.com`), instead of+WebBrain's thread key, and states only what WebBrain reads: that a message+with the exact text is shown in the conversation, or else that the message+box contains it and no such message is shown. It never says whether the+message was delivered.+Permission and ordinary clarification cards can be recovered from the actuallive unanswered Agent entry after the panel reopens or its progress events havebeen acknowledged. Recovery requires the same request, run, task, provider anddiff --git a/package.json b/package.jsonindex 925086b24..5375dcaf7 100644--- a/package.json+++ b/package.json@@ -68,7 +68,7 @@"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/guard-reading-carry-over.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/run-ui-hidden-panel.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/prompt-unverified-pages.mjs test/prompt-missing-values.mjs test/lifecycle-planner-digest.mjs test/planner-clarify-loop.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-chat-selection.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: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-pre-enter-veto.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/guard-reading-carry-over.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/run-ui-hidden-panel.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/prompt-unverified-pages.mjs test/prompt-missing-values.mjs test/lifecycle-planner-digest.mjs test/planner-clarify-loop.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-chat-selection.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/page-feedback-held-time.mjs test/page-monitor-held-observation.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",@@ -102,7 +102,7 @@"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/cookie-banner-host.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:settings-pages: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/guard-reading-carry-over.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/run-ui-hidden-panel.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/plan-when-needed.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/prompt-unverified-pages.mjs test/prompt-missing-values.mjs test/lifecycle-planner-digest.mjs test/planner-clarify-loop.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: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-pre-enter-veto.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/guard-reading-carry-over.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/run-ui-hidden-panel.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/plan-when-needed.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/prompt-unverified-pages.mjs test/prompt-missing-values.mjs test/lifecycle-planner-digest.mjs test/planner-clarify-loop.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/model-picker-status-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-chat-selection.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/activity-brain-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/declined-submission-identity.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/page-feedback-held-time.mjs test/page-monitor-held-observation.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 && node --test test/iframe-probe-match-index.mjs",diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.jsindex 0a7ae26c6..b781adfce 100644--- a/src/chrome/src/agent/agent.js+++ b/src/chrome/src/agent/agent.js@@ -30910,7 +30910,44 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d}}- async _confirmPendingChatReconciliation(tabId, prior, observedThreadKey, onUpdate) {+ // The conversation as its page names it, for WebBrain's own card (plain+ // text, never sent to the model). The thread key is WebBrain's identifier+ // ("dom:discord:…") and stays the fallback when the page shows another chat.+ // The name is page text: invisible and control characters go, and it is+ // quoted on its own line so a chat's name cannot read as WebBrain speaking.+ _pendingChatConversationLabel(observation, observedThreadKey, threadKey) {+ const name = observedThreadKey === threadKey+ ? String(observation?.conversationIdentity || '').replace(/[\p{Cc}\p{Cf}\u2028\u2029]/gu, ' ')+ .replace(/\s+/g, ' ').trim().slice(0, 80) : '';+ if (!name) return threadKey;+ let host = '';+ try { host = new URL(String(observation?.url || '')).hostname.replace(/^www\./, ''); } catch {}+ return host ? `“${name}” on ${host}` : `“${name}”`;+ }++ // What WebBrain reads now, for the user's card: whether a copy of the+ // pending text is shown in the conversation, else whether the message box+ // holds it. Observations, never a verdict on delivery. Any shown copy+ // counts, seen before or not, so the card never says none is shown when+ // one is. Telegram and WhatsApp keep their own reconciliation reads.+ async _pendingChatCardFacts(tabId, pending) {+ if (!pending?.text || /^dom:(?:telegram|whatsapp):/.test(pending.threadKey || '')) return '';+ const now = await this._readChatObservation(tabId);+ if (now?.success !== true || normalizeChatSnapshot(now).threadKey !== pending.threadKey) return '';+ const body = this._workflowMessageBody(pending.text);+ if ((now.messages || []).some(message => message?.direction !== 'incoming'+ && this._workflowMessageBody(message?.authoredText ?? message?.text) === body)) {+ return 'A message with this exact text is shown in the conversation.';+ }+ if (now.composer?.available !== true || now.composer.empty !== false || !now.composer.ref) return '';+ const draft = await this._textMutationValueDigest(tabId,+ { locatorType: 'ax', refId: now.composer.ref, frameId: 0 }, pending.text);+ return draft?.verified === true+ ? 'The message box currently contains this exact text, and no message with this text is shown in the conversation.'+ : '';+ }++ async _confirmPendingChatReconciliation(tabId, prior, observedThreadKey, onUpdate, observation = null) {const provider = this._activeProvider(tabId), pending = prior.pendingOutbound;const conversationId = this.conversationIds.get(tabId), taskKey = this._progressTaskKeyHash(tabId);const taskText = this._progressTaskAnchorText(tabId) || this._originalTaskText(tabId);@@ -30931,6 +30968,11 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d&& context.isCurrent() && !this._checkAbort(tabId) && !this._hasPendingSteering(tabId)&& !this._hasUnvalidatedSteering(tabId);if (!isCurrent()) return null;+ // Tell the user what WebBrain reads itself. It informs; only the answer+ // clears this record.+ const facts = await this._pendingChatCardFacts(tabId, pending);+ if (!isCurrent()) return null;+ const conversation = this._pendingChatConversationLabel(observation, observedThreadKey, pending.threadKey);const clarifyId = `chat_reconcile_${crypto.randomUUID()}`;const approve = 'I verified this message was not delivered; clear this pending send';const tabPending = this._pendingClarifications.get(tabId) || new Map();@@ -30943,7 +30985,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dtry {try {onUpdate('clarify', { promptKind: 'clarify', pendingReconciliation: true, clarifyId, requireExplicitAnswer: true, timeoutSec: 0,- question: `An earlier outgoing message has an unknown delivery result. Its conversation is ${pending.threadKey}.\n\n${pending.text}\n\nHave you independently checked that this exact message was not delivered?`,+ question: `An earlier outgoing message has an unknown delivery result.\nConversation: ${conversation}\n\n${pending.text}\n\n${facts ? `${facts}\n\n` : ''}Have you independently checked that this exact message was not delivered?`,options: ['Keep the pending send blocked', approve],reason: 'Clearing this record can permit a duplicate. This choice only reconciles the exact pending send; it does not authorize a new message.' });} catch { this._settleClarification(entry, { cancelled: true }); }@@ -31092,7 +31134,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d// A fresh private draft witness proves this explicit Enter was never sent.// Keep its pending record; observation/viewport repair authorizes no send.if (!knownPreEnterDraft) {- const confirmation = await this._confirmPendingChatReconciliation(tabId, prior, observedThreadKey, onUpdate);+ const confirmation = await this._confirmPendingChatReconciliation(tabId, prior, observedThreadKey, onUpdate, observation);if (confirmation?.isCurrent()) {observation = confirmation.observation;// An actual delivery arriving during the dialog takes the ordinary@@ -31327,6 +31369,39 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dtry { await this._persistNow(tabId); } catch {}}+ // A key before Enter was refused by the page-change fence after the exact+ // draft was verified: the draft is in the composer and Enter was never+ // dispatched. A stop or a recipient refusal is not this state.+ _chatSubmitVetoedBeforeEnter(result) {+ return result?.submissionBlockedBeforeDispatch === true && result.submissionDispatched === false+ && result.submissionBlockReason === 'page_feedback_pending' && result.verified === true+ && result.cancelled !== true;+ }++ // Whether this chat_send's own draft, whose Enter never left, is still+ // unsent: the composer it typed into, in the same conversation, holds the+ // whole body, and no new outgoing or unattributed copy of it appeared.+ // Only where the page empties its composer the moment it sends (Discord)+ // does a draft still there prove nothing went out; a site that keeps the+ // text until its server answers could be mid-send. Telegram and WhatsApp+ // keep their own owned-draft lease. Anything less keeps the pending send.+ async _unsentChatDraftRetained(tabId, session, composerRef) {+ const pending = session?.pendingOutbound;+ if (!pending?.key || !pending.text || !composerRef+ || !/^dom:discord:/.test(pending.threadKey || '')) return null;+ const after = await this._readChatObservation(tabId);+ if (after?.success !== true || after.composer?.available !== true || after.composer.empty !== false+ || after.composer.ref !== composerRef) return null;+ const advanced = advanceChatSession(session, after);+ if (advanced.snapshot.threadKey !== pending.threadKey+ || advanced.session.pendingOutbound?.key !== pending.key) return null;+ const body = this._workflowMessageBody(pending.text);+ if ((advanced.newMessages || []).some(message => message?.direction !== 'incoming'+ && this._workflowMessageBody(message.authoredText ?? message.text) === body)) return null;+ const draft = await this._textMutationValueDigest(tabId,+ { locatorType: 'ax', refId: after.composer.ref, frameId: 0 }, pending.text);+ return draft?.verified === true ? { after, advanced } : null;+ }async _sendChatWorkflow(tabId, args = {}, onUpdate = null, executionContext = null) {const originalSendOwner = this._nativeChatOwnerScope(tabId);@@ -31537,6 +31612,27 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dmessageKey:decision.messageKey, dispatch };}if (recoverDraft) this._nativeChatPreparedDrafts?.delete(tabId);+ // Enter never left, and the composer still holds this exact draft with no+ // sent copy: nothing went out. Kept, the pending record refused every+ // later Enter as a duplicate and asked the user to certify a+ // non-delivery WebBrain can read for itself (Discord, where a key before+ // Enter was vetoed). The draft stays for one guarded Enter.+ if (!recoverDraft && !preparedDraftBinding?.token && this._chatSubmitVetoedBeforeEnter(dispatch)) {+ const retained = await this._unsentChatDraftRetained(tabId, pending, composerRef);+ if (retained) {+ const session = { ...retained.advanced.session, pendingOutbound: null };+ this.chatSessions.set(tabId, session);+ this._persist(tabId);+ return {+ ...this._chatObservationResult(retained.after, { ...retained.advanced, session }),+ success: false, sent: false, dispatched: true,+ draftMutationDispatched: true, submissionDispatched: false, submissionOutcomeUnknown: false,+ draftRetained: true, outcomeUnknown: false, deliveryVerified: false, verificationRequired: false,+ reason: 'chat_submit_not_dispatched',+ error: 'Nothing was sent: Enter never reached the page, and the exact message is still in the composer with no sent copy in the conversation, so no send is pending. Send it once with press_keys({key:"Enter"}) while the composer has focus (click the composer first if focus moved), then call chat_observe to verify delivery. Do not retype it or call chat_send while it is in the composer.',+ messageKey: decision.messageKey, dispatch };+ }+ }// A dispatch that proves it never reached the page is not an uncertain// send: keeping the pending record would strand the workflow behind an// explicit user reconciliation for a message that was never typed.@@ -54376,13 +54472,47 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d// set_field({submit:true}) must never submit until the trusted retry has// itself settled and verified. Use trusted CDP keys for the submission.if (toolName === 'set_field' && args?.submit === true) {+ // The native-input transport rejected a key before Enter was+ // dispatched. Keep the exact settled draft proof, but retain+ // uncertainty from typing: a page-owned beforeinput handler may+ // already have acted on it.+ const submissionBlockedBeforeEnter = () => ({+ ...recovered,+ success: false,+ submitted: false,+ messageDispatched: false,+ draftMutationDispatched: true,+ submissionDispatched: false,+ submissionBlockedBeforeDispatch: true,+ submissionBlockReason: 'page_feedback_pending',+ submissionOutcomeUnknown: false,+ outcomeUnknown: true,+ mutationMayHaveOccurred: true,+ repeatBlocked: true,+ retryable: false,+ pageFeedbackPending: true,+ recoveryRequired: 'verify_or_restore_field',+ error: 'The exact draft was verified, but the browser changed before Enter could be dispatched. Observe the conversation and reconcile any pending send before another mutation; no automatic retry occurred.',+ });this._throwIfAborted(abortSignal);if (prepared.isCombobox) {await new Promise(resolve => setTimeout(resolve, 80));this._throwIfAborted(abortSignal);- await cdpClient.sendCommand(tabId, 'Input.dispatchKeyEvent', {- type: 'keyDown', key: 'ArrowDown', code: 'ArrowDown', windowsVirtualKeyCode: 40,- });+ // The picker nudge submits nothing, so a veto before it reaches the+ // page is the same pre-Enter state as a vetoed Enter. Reported as a+ // generic failure, a chat send kept a possibly-delivered pending+ // record for a message that was never sent. Once the nudge is sent+ // it may have changed a combobox's value: later failures stay+ // uncertain.+ let nudgeDispatched = false;+ try {+ await sendTrusted('Input.dispatchKeyEvent', {+ type: 'keyDown', key: 'ArrowDown', code: 'ArrowDown', windowsVirtualKeyCode: 40,+ }, () => { nudgeDispatched = true; });+ } catch (error) {+ if (error?.code !== 'page_feedback_pending' || nudgeDispatched) throw error;+ return submissionBlockedBeforeEnter();+ }await cdpClient.sendCommand(tabId, 'Input.dispatchKeyEvent', {type: 'keyUp', key: 'ArrowDown', code: 'ArrowDown', windowsVirtualKeyCode: 40,});@@ -54422,27 +54552,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d});} catch (error) {if (error?.code !== 'page_feedback_pending' || enterDispatched) throw error;- // The native-input transport rejected Enter before dispatch. Keep- // the exact settled draft proof, but retain uncertainty from typing:- // a page-owned beforeinput handler may already have acted on it.- return {- ...recovered,- success: false,- submitted: false,- messageDispatched: false,- draftMutationDispatched: true,- submissionDispatched: false,- submissionBlockedBeforeDispatch: true,- submissionBlockReason: 'page_feedback_pending',- submissionOutcomeUnknown: false,- outcomeUnknown: true,- mutationMayHaveOccurred: true,- repeatBlocked: true,- retryable: false,- pageFeedbackPending: true,- recoveryRequired: 'verify_or_restore_field',- error: 'The exact draft was verified, but the browser changed before Enter could be dispatched. Observe the conversation and reconcile any pending send before another mutation; no automatic retry occurred.',- };+ return submissionBlockedBeforeEnter();}recovered.submitted = true;}diff --git a/src/chrome/src/content/content.js b/src/chrome/src/content/content.jsindex 0b1cad0df..de7785fdd 100644--- a/src/chrome/src/content/content.js+++ b/src/chrome/src/content/content.js@@ -8410,7 +8410,12 @@identityCandidates: [],};}- if (editable(target) && (target !== composer || twitterConversation)) {+ // A click into an editor, the composer itself included, only focuses+ // it; Enter, a submit or a Send control commits the message. Left to+ // the geometry rule below, the composer is beside itself, so each+ // focus click counted as a send and armed a pending outbound record+ // that then refused the real Enter as a duplicate (Discord).+ if (editable(target)) {return { success: true, messageSend: false, conclusive: true, identityCandidates: [] };}if (verifiedConversationSelection(target, composer)) {@@ -10395,13 +10400,18 @@// selecting anything.const roleAttr = (el.getAttribute && el.getAttribute('role') || '').toLowerCase();const controls = el.getAttribute && el.getAttribute('aria-controls');+ // A rich-text message editor is no picker unless its role says+ // so: its aria-autocomplete, aria-expanded and pop-up lists+ // belong to @mention and emoji suggestions, where an ArrowDown+ // before Enter moves the suggestion instead of letting Enter send.+ const richTextEditor = el.isContentEditable && roleAttr !== 'searchbox' && roleAttr !== 'combobox';let isCombobox = roleAttr === 'searchbox' || roleAttr === 'combobox'- || (el.getAttribute && el.getAttribute('aria-autocomplete'))- || (el.getAttribute && el.getAttribute('aria-expanded') === 'true');- if (!isCombobox && controls) {+ || (!richTextEditor && ((el.getAttribute && el.getAttribute('aria-autocomplete'))+ || (el.getAttribute && el.getAttribute('aria-expanded') === 'true')));+ if (!isCombobox && controls && !richTextEditor) {try { if (document.getElementById(controls)) isCombobox = true; } catch {}}- if (!isCombobox) {+ if (!isCombobox && !richTextEditor) {// Last-resort check: any visible listbox on the page?try {const lbs = document.querySelectorAll('[role="listbox"],[role="menu"]');@@ -10626,9 +10636,13 @@el.setSelectionRange(0, String(el.value || '').length);}const role = (el.getAttribute && el.getAttribute('role') || '').toLowerCase();+ // A rich-text message editor (Discord's Slate box) carries+ // aria-autocomplete for its @mention and emoji pop-ups; it is no+ // picker. An ArrowDown before Enter there moves an open pop-up's+ // choice, so Enter inserts that instead of sending.const isCombobox = role === 'combobox'- || !!(el.getAttribute && el.getAttribute('aria-autocomplete'))- || (el.getAttribute && el.getAttribute('aria-expanded') === 'true');+ || (!el.isContentEditable && (!!(el.getAttribute && el.getAttribute('aria-autocomplete'))+ || (el.getAttribute && el.getAttribute('aria-expanded') === 'true')));const rect = el.getBoundingClientRect();// Whether a press at the field's centre reaches the field or its// plain contents (pressable), and whether what is there instead isdiff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.jsindex 17c15deea..a5173da88 100644--- a/src/firefox/src/agent/agent.js+++ b/src/firefox/src/agent/agent.js@@ -27884,7 +27884,44 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d}}- async _confirmPendingChatReconciliation(tabId, prior, observedThreadKey, onUpdate) {+ // The conversation as its page names it, for WebBrain's own card (plain+ // text, never sent to the model). The thread key is WebBrain's identifier+ // ("dom:discord:…") and stays the fallback when the page shows another chat.+ // The name is page text: invisible and control characters go, and it is+ // quoted on its own line so a chat's name cannot read as WebBrain speaking.+ _pendingChatConversationLabel(observation, observedThreadKey, threadKey) {+ const name = observedThreadKey === threadKey+ ? String(observation?.conversationIdentity || '').replace(/[\p{Cc}\p{Cf}\u2028\u2029]/gu, ' ')+ .replace(/\s+/g, ' ').trim().slice(0, 80) : '';+ if (!name) return threadKey;+ let host = '';+ try { host = new URL(String(observation?.url || '')).hostname.replace(/^www\./, ''); } catch {}+ return host ? `“${name}” on ${host}` : `“${name}”`;+ }++ // What WebBrain reads now, for the user's card: whether a copy of the+ // pending text is shown in the conversation, else whether the message box+ // holds it. Observations, never a verdict on delivery. Any shown copy+ // counts, seen before or not, so the card never says none is shown when+ // one is. Telegram and WhatsApp keep their own reconciliation reads.+ async _pendingChatCardFacts(tabId, pending) {+ if (!pending?.text || /^dom:(?:telegram|whatsapp):/.test(pending.threadKey || '')) return '';+ const now = await this._readChatObservation(tabId);+ if (now?.success !== true || normalizeChatSnapshot(now).threadKey !== pending.threadKey) return '';+ const body = this._workflowMessageBody(pending.text);+ if ((now.messages || []).some(message => message?.direction !== 'incoming'+ && this._workflowMessageBody(message?.authoredText ?? message?.text) === body)) {+ return 'A message with this exact text is shown in the conversation.';+ }+ if (now.composer?.available !== true || now.composer.empty !== false || !now.composer.ref) return '';+ const draft = await this._textMutationValueDigest(tabId,+ { locatorType: 'ax', refId: now.composer.ref, frameId: 0 }, pending.text);+ return draft?.verified === true+ ? 'The message box currently contains this exact text, and no message with this text is shown in the conversation.'+ : '';+ }++ async _confirmPendingChatReconciliation(tabId, prior, observedThreadKey, onUpdate, observation = null) {const provider = this._activeProvider(tabId), pending = prior.pendingOutbound;const conversationId = this.conversationIds.get(tabId), taskKey = this._progressTaskKeyHash(tabId);const taskText = this._progressTaskAnchorText(tabId) || this._originalTaskText(tabId);@@ -27905,6 +27942,11 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d&& context.isCurrent() && !this._checkAbort(tabId) && !this._hasPendingSteering(tabId)&& !this._hasUnvalidatedSteering(tabId);if (!isCurrent()) return null;+ // Tell the user what WebBrain reads itself. It informs; only the answer+ // clears this record.+ const facts = await this._pendingChatCardFacts(tabId, pending);+ if (!isCurrent()) return null;+ const conversation = this._pendingChatConversationLabel(observation, observedThreadKey, pending.threadKey);const clarifyId = `chat_reconcile_${crypto.randomUUID()}`;const approve = 'I verified this message was not delivered; clear this pending send';const tabPending = this._pendingClarifications.get(tabId) || new Map();@@ -27917,7 +27959,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dtry {try {onUpdate('clarify', { promptKind: 'clarify', pendingReconciliation: true, clarifyId, requireExplicitAnswer: true, timeoutSec: 0,- question: `An earlier outgoing message has an unknown delivery result. Its conversation is ${pending.threadKey}.\n\n${pending.text}\n\nHave you independently checked that this exact message was not delivered?`,+ question: `An earlier outgoing message has an unknown delivery result.\nConversation: ${conversation}\n\n${pending.text}\n\n${facts ? `${facts}\n\n` : ''}Have you independently checked that this exact message was not delivered?`,options: ['Keep the pending send blocked', approve],reason: 'Clearing this record can permit a duplicate. This choice only reconciles the exact pending send; it does not authorize a new message.' });} catch { this._settleClarification(entry, { cancelled: true }); }@@ -28066,7 +28108,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d// A fresh private draft witness proves this explicit Enter was never sent.// Keep its pending record; observation/viewport repair authorizes no send.if (!knownPreEnterDraft) {- const confirmation = await this._confirmPendingChatReconciliation(tabId, prior, observedThreadKey, onUpdate);+ const confirmation = await this._confirmPendingChatReconciliation(tabId, prior, observedThreadKey, onUpdate, observation);if (confirmation?.isCurrent()) {observation = confirmation.observation;// An actual delivery arriving during the dialog takes the ordinary@@ -28301,6 +28343,39 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dtry { await this._persistNow(tabId); } catch {}}+ // A key before Enter was refused by the page-change fence after the exact+ // draft was verified: the draft is in the composer and Enter was never+ // dispatched. A stop or a recipient refusal is not this state.+ _chatSubmitVetoedBeforeEnter(result) {+ return result?.submissionBlockedBeforeDispatch === true && result.submissionDispatched === false+ && result.submissionBlockReason === 'page_feedback_pending' && result.verified === true+ && result.cancelled !== true;+ }++ // Whether this chat_send's own draft, whose Enter never left, is still+ // unsent: the composer it typed into, in the same conversation, holds the+ // whole body, and no new outgoing or unattributed copy of it appeared.+ // Only where the page empties its composer the moment it sends (Discord)+ // does a draft still there prove nothing went out; a site that keeps the+ // text until its server answers could be mid-send. Telegram and WhatsApp+ // keep their own owned-draft lease. Anything less keeps the pending send.+ async _unsentChatDraftRetained(tabId, session, composerRef) {+ const pending = session?.pendingOutbound;+ if (!pending?.key || !pending.text || !composerRef+ || !/^dom:discord:/.test(pending.threadKey || '')) return null;+ const after = await this._readChatObservation(tabId);+ if (after?.success !== true || after.composer?.available !== true || after.composer.empty !== false+ || after.composer.ref !== composerRef) return null;+ const advanced = advanceChatSession(session, after);+ if (advanced.snapshot.threadKey !== pending.threadKey+ || advanced.session.pendingOutbound?.key !== pending.key) return null;+ const body = this._workflowMessageBody(pending.text);+ if ((advanced.newMessages || []).some(message => message?.direction !== 'incoming'+ && this._workflowMessageBody(message.authoredText ?? message.text) === body)) return null;+ const draft = await this._textMutationValueDigest(tabId,+ { locatorType: 'ax', refId: after.composer.ref, frameId: 0 }, pending.text);+ return draft?.verified === true ? { after, advanced } : null;+ }async _sendChatWorkflow(tabId, args = {}, onUpdate = null, executionContext = null) {const originalSendOwner = this._nativeChatOwnerScope(tabId);@@ -28511,6 +28586,27 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dmessageKey:decision.messageKey, dispatch };}if (recoverDraft) this._nativeChatPreparedDrafts?.delete(tabId);+ // Enter never left, and the composer still holds this exact draft with no+ // sent copy: nothing went out. Kept, the pending record refused every+ // later Enter as a duplicate and asked the user to certify a+ // non-delivery WebBrain can read for itself (Discord, where a key before+ // Enter was vetoed). The draft stays for one guarded Enter.+ if (!recoverDraft && !preparedDraftBinding?.token && this._chatSubmitVetoedBeforeEnter(dispatch)) {+ const retained = await this._unsentChatDraftRetained(tabId, pending, composerRef);+ if (retained) {+ const session = { ...retained.advanced.session, pendingOutbound: null };+ this.chatSessions.set(tabId, session);+ this._persist(tabId);+ return {+ ...this._chatObservationResult(retained.after, { ...retained.advanced, session }),+ success: false, sent: false, dispatched: true,+ draftMutationDispatched: true, submissionDispatched: false, submissionOutcomeUnknown: false,+ draftRetained: true, outcomeUnknown: false, deliveryVerified: false, verificationRequired: false,+ reason: 'chat_submit_not_dispatched',+ error: 'Nothing was sent: Enter never reached the page, and the exact message is still in the composer with no sent copy in the conversation, so no send is pending. Send it once with press_keys({key:"Enter"}) while the composer has focus (click the composer first if focus moved), then call chat_observe to verify delivery. Do not retype it or call chat_send while it is in the composer.',+ messageKey: decision.messageKey, dispatch };+ }+ }// A dispatch that proves it never reached the page is not an uncertain// send: keeping the pending record would strand the workflow behind an// explicit user reconciliation for a message that was never typed.diff --git a/src/firefox/src/content/content.js b/src/firefox/src/content/content.jsindex 7ee319006..c875421f2 100644--- a/src/firefox/src/content/content.js+++ b/src/firefox/src/content/content.js@@ -7561,7 +7561,12 @@identityCandidates: [],};}- if (editable(target) && (target !== composer || twitterConversation)) {+ // A click into an editor, the composer itself included, only focuses+ // it; Enter, a submit or a Send control commits the message. Left to+ // the geometry rule below, the composer is beside itself, so each+ // focus click counted as a send and armed a pending outbound record+ // that then refused the real Enter as a duplicate (Discord).+ if (editable(target)) {return { success: true, messageSend: false, conclusive: true, identityCandidates: [] };}if (verifiedConversationSelection(target, composer)) {@@ -9423,13 +9428,18 @@try {const roleAttr = (el.getAttribute && el.getAttribute('role') || '').toLowerCase();const controls = el.getAttribute && el.getAttribute('aria-controls');+ // A rich-text message editor is no picker unless its role says+ // so: its aria-autocomplete, aria-expanded and pop-up lists+ // belong to @mention and emoji suggestions, where an ArrowDown+ // before Enter moves the suggestion instead of letting Enter send.+ const richTextEditor = el.isContentEditable && roleAttr !== 'searchbox' && roleAttr !== 'combobox';let isCombobox = roleAttr === 'searchbox' || roleAttr === 'combobox'- || (el.getAttribute && el.getAttribute('aria-autocomplete'))- || (el.getAttribute && el.getAttribute('aria-expanded') === 'true');- if (!isCombobox && controls) {+ || (!richTextEditor && ((el.getAttribute && el.getAttribute('aria-autocomplete'))+ || (el.getAttribute && el.getAttribute('aria-expanded') === 'true')));+ if (!isCombobox && controls && !richTextEditor) {try { if (document.getElementById(controls)) isCombobox = true; } catch {}}- if (!isCombobox) {+ if (!isCombobox && !richTextEditor) {try {const lbs = document.querySelectorAll('[role="listbox"],[role="menu"]');for (const lb of lbs) {diff --git a/test/cdp-field-submit-recovery.mjs b/test/cdp-field-submit-recovery.mjsindex 882677ae0..64702baa4 100644--- a/test/cdp-field-submit-recovery.mjs+++ b/test/cdp-field-submit-recovery.mjs@@ -7,6 +7,8 @@ import { cdpClient } from '../src/chrome/src/cdp/cdp-client.js';// Isolate the fallback's submission boundary with real Chromium input. The// installed WhatsApp case separately verifies the actual monitor veto, durable// pending-send block and shipped reconciliation card before any later send.+// A combobox's ArrowDown nudge comes before Enter: a veto there is the same+// pre-Enter state (a Discord send once stayed pending behind it).test('trusted field fallback preserves draft proof only for a pre-Enter veto', async t => {const browser = await chromium.launch({ headless: true });const originalChrome = globalThis.chrome, originalBrowser = globalThis.browser;@@ -14,7 +16,8 @@ test('trusted field fallback preserves draft proof only for a pre-Enter veto', aconst area = { get: async () => ({}), set: async () => {}, remove: async () => {} };const body = 'One exact native draft with spaces and Unicode ı 🧠.';try {- for (const boundary of ['before-enter', 'lost-enter-response', 'after-enter']) await t.test(boundary, async () => {+ for (const boundary of ['before-enter', 'before-combobox-nudge', 'lost-enter-response', 'after-enter']) await t.test(boundary, async () => {+ const preEnter = boundary === 'before-enter' || boundary === 'before-combobox-nudge';const context = await browser.newContext();const posts = [], commands = [];await context.route('**/*', route => {@@ -26,10 +29,11 @@ test('trusted field fallback preserves draft proof only for a pre-Enter veto', a});const page = await context.newPage(); await page.goto('https://owned-submit.invalid/');await page.evaluate(() => {- window.qaInputs = []; window.qaEnter = 0;+ window.qaInputs = []; window.qaEnter = 0; window.qaArrows = 0;const editor = document.querySelector('#editor');editor.addEventListener('input', event => qaInputs.push({ trusted: event.isTrusted, value: editor.value }));editor.addEventListener('keydown', event => {+ if (event.key === 'ArrowDown') qaArrows++;if (event.key !== 'Enter') return;event.preventDefault(); qaEnter++;void fetch('/owned-save', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ body: editor.value }) });@@ -40,10 +44,10 @@ test('trusted field fallback preserves draft proof only for a pre-Enter veto', aconst params = message.params || {};if (message.action === 'field_value_digest') return { success: false };if (message.action === 'consume_message_recipient_dispatch_binding') return { success: true };- if (message.action === 'ax_prepare_field_for_trusted_type') return page.evaluate(() => {+ if (message.action === 'ax_prepare_field_for_trusted_type') return page.evaluate(isCombobox => {const editor = document.querySelector('#editor'); editor.focus(); editor.select();- return { success: true, contentEditable: false, isCombobox: false };- });+ return { success: true, contentEditable: false, isCombobox };+ }, boundary === 'before-combobox-nudge');if (message.action === 'ax_verify_field_value') return page.evaluate(expected => {const editor = document.querySelector('#editor');return { success: true, verified: editor.value === expected, actual: editor.value };@@ -54,6 +58,8 @@ test('trusted field fallback preserves draft proof only for a pre-Enter veto', acdpClient.attach = async () => {};cdpClient.sendCommand = async (_tab, method, params) => {const enterDown = method === 'Input.dispatchKeyEvent' && params.type === 'keyDown' && params.key === 'Enter';+ const nudgeDown = method === 'Input.dispatchKeyEvent' && params.type === 'keyDown' && params.key === 'ArrowDown';+ if (nudgeDown && boundary === 'before-combobox-nudge') throw Object.assign(new Error('Owned monitor veto before the nudge'), { code: 'page_feedback_pending' });const enterUp = method === 'Input.dispatchKeyEvent' && params.type === 'keyUp' && params.key === 'Enter';if (enterDown && boundary === 'before-enter') throw Object.assign(new Error('Owned monitor veto before dispatch'), { code: 'page_feedback_pending' });commands.push({ method, params });@@ -67,16 +73,18 @@ test('trusted field fallback preserves draft proof only for a pre-Enter veto', a{ ref_id: 'ref_owned', text: body, clear: true, submit: true },{ success: false, verified: false, noDispatch: true, dispatched: false, _expectedValue: body, error: 'Owned native input required' },{ messageRecipientGuardRequired: true });- const native = await page.evaluate(() => ({ body: document.querySelector('#editor').value, inputs: qaInputs, enter: qaEnter }));- for (let attempt = 0; boundary !== 'before-enter' && !posts.length && attempt < 20; attempt++) await page.waitForTimeout(10);+ const native = await page.evaluate(() => ({ body: document.querySelector('#editor').value, inputs: qaInputs, enter: qaEnter, arrows: qaArrows }));+ for (let attempt = 0; !preEnter && !posts.length && attempt < 20; attempt++) await page.waitForTimeout(10);assert.equal(native.body, body); assert.deepEqual(native.inputs, [{ trusted: true, value: body }]);assert.equal(commands.filter(command => command.method === 'Input.insertText').length, 1);assert.equal(result.success, false); assert.equal(result.dispatched, true); assert.notEqual(result.noDispatch, true);assert.notEqual(result.submitted, true); assert.equal(result.pageHandledBeforeInput, undefined);- if (boundary === 'before-enter') {- assert.equal(native.enter, 0); assert.deepEqual(posts, []);+ if (preEnter) {+ assert.equal(native.enter, 0); assert.deepEqual(posts, []); assert.equal(native.arrows, 0);+ assert.equal(commands.some(command => command.params?.key === 'Enter'), false, 'Enter is never sent after a pre-Enter veto.');assert.equal(result.verified, true); assert.equal(result.trusted, true);assert.equal(result.submissionDispatched, false); assert.equal(result.submissionBlockedBeforeDispatch, true);+ assert.equal(result.submissionBlockReason, 'page_feedback_pending');assert.equal(result.submissionOutcomeUnknown, false); assert.equal(result.outcomeUnknown, true);assert.equal(result.repeatBlocked, true); assert.equal(result.retryable, false);} else {diff --git a/test/chat-pending-reconciliation.mjs b/test/chat-pending-reconciliation.mjsindex 86d4ee107..e5231e9ac 100644--- a/test/chat-pending-reconciliation.mjs+++ b/test/chat-pending-reconciliation.mjs@@ -45,7 +45,10 @@ for (const build of ['chrome', 'firefox']) {assert.equal(data.pendingReconciliation, true);assert.equal(data.timeoutSec, 0);assert.match(data.question, /Owned uncertain outgoing body/);- assert.match(data.question, /owned-thread/);+ // The card names the conversation as its page does, quoted on its own+ // line, not by WebBrain's thread key.+ assert.match(data.question, /\nConversation: “Owned QA”\n/);+ assert.doesNotMatch(data.question, /owned-thread/);const entry = f.agent._pendingClarifications.get(f.tab).get(data.clarifyId);assert.equal(entry.timer, null);f.prompt = data;diff --git a/test/chat-pre-enter-veto.mjs b/test/chat-pre-enter-veto.mjsnew file mode 100644index 000000000..873ce790f--- /dev/null+++ b/test/chat-pre-enter-veto.mjs@@ -0,0 +1,191 @@+import assert from 'node:assert/strict';+import { createHash } from 'node:crypto';+import { test } from 'node:test';++// A Discord announcement once stopped here: chat_send typed the whole+// message, the page-change fence refused a key before Enter, and the send was+// kept as possibly delivered. Every later Enter was refused as a duplicate and+// the user was asked to certify a non-delivery the message box itself showed.+// On Discord, which empties its box the moment it sends, a pre-Enter veto+// whose exact draft is still in the box with no new copy releases the pending+// record and leaves the draft for one guarded Enter; anything less keeps it.++const discord = { url: 'https://discord.com/channels/123/456', threadKey: 'dom:discord:123:456',+ conversationId: 'discord:123:456', conversationIdentity: '#announcements' };+const body = 'WebBrain Companion is live! Now you can use your existing subscriptions with WebBrain: www.webbrain.one/companion/';+const page = { composerText: '', digests: 0, thread: discord };+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 () => ({}) },+ scripting: { executeScript: async () => [{ result: null }] },+ tabs: { get: async id => ({ id, url: page.thread.url }), sendMessage: async (_tab, message) => {+ if (message.action !== 'field_value_digest') return {};+ page.digests++;+ if (message.params?.ref_id !== 'ref_composer') return { success: false, error: 'field is stale or unavailable' };+ // Discord's Slate box is read as rendered text, as the content reader does.+ return { success: true, verified: page.composerText === message.params.expected,+ valueLength: page.composerText.length, valueSha256: createHash('sha256').update(page.composerText).digest('hex'),+ reader: 'rendered', readbackExact: false };+ } },+};++function observation(extra = []) {+ const { url, threadKey, conversationId, conversationIdentity } = page.thread;+ return { success: true, observedAt: new Date().toISOString(), url, conversationId, threadKey, conversationIdentity,+ composer: { available: true, ref: 'ref_composer', empty: page.composerText === '' },+ messages: [{ id: `${conversationId}:1001`, direction: 'incoming', text: 'Welcome', authoredText: 'Welcome',+ timestamp: '2026-10-24T20:00:00.000Z' }, ...extra] };+}++// The trusted CDP set_field result (Chrome) when a key before Enter was vetoed.+const trustedVeto = (extra = {}) => ({+ success: false, verified: true, trusted: true, dispatched: true, method: 'set_field_cdp_fallback',+ submitted: false, messageDispatched: false, draftMutationDispatched: true,+ submissionDispatched: false, submissionBlockedBeforeDispatch: true, submissionBlockReason: 'page_feedback_pending',+ submissionOutcomeUnknown: false, outcomeUnknown: true, mutationMayHaveOccurred: true, repeatBlocked: true,+ retryable: false, pageFeedbackPending: true, recoveryRequired: 'verify_or_restore_field',+ error: 'The exact draft was verified, but the browser changed before Enter could be dispatched.', ...extra });+// The content-script set_field result (both builds) for the same veto.+const contentVeto = () => ({ success: true, dispatched: true, method: 'set_field', verified: true,+ outcomeUnknown: true, submissionDispatched: false, submissionBlockedBeforeDispatch: true,+ submissionBlockReason: 'page_feedback_pending' });++for (const build of ['chrome', 'firefox']) {+ const { Agent } = await import(`../src/${build}/src/agent/agent.js`);+ const { markChatSendPending } = await import(`../src/${build}/src/agent/chat-workflow.js`);++ // `extra` is read on every observation, so a test can add a message only+ // after the send was attempted.+ async function harness(tabId, { field = () => trustedVeto(), extra = [], thread = discord } = {}) {+ page.thread = thread; page.composerText = ''; page.digests = 0;+ const provider = { name: 'owned', model: 'owned-model', config: { category: 'local' } };+ const agent = new Agent({ getActive: () => provider });+ agent._persist = () => {}; agent._persistNow = async () => true;+ agent.conversationIds.set(tabId, 'owned-conversation');+ agent.conversations.set(tabId, [{ role: 'system', content: 'Owned runtime context.' },+ { role: 'user', content: 'Post the same announcement in the WebBrain Discord announcements channel.' }]);+ agent._beginCompletionInvariant(tabId);+ agent._lastAxScopes.set(tabId, { documentToken: 'owned-chat-document', pageUrl: thread.url });+ agent._readChatObservation = async () => observation(extra);+ // Recipient scope is covered by discord-guard.mjs; this isolates the+ // pending-send record around the nested field write.+ agent._messageRecipientGuardBlock = async () => null;+ await agent._observeChatWorkflow(tabId);+ const executeTool = agent.executeTool.bind(agent);+ const writes = [];+ agent.executeTool = async (id, name, args, onUpdate, context) => {+ if (name !== 'set_field') return executeTool(id, name, args, onUpdate, context);+ writes.push(args);+ page.composerText = args.text; // The draft landed in the box.+ context._contentActionDispatchState.started = true;+ return field(extra);+ };+ const send = () => agent.executeTool(tabId, 'chat_send',+ { thread_key: thread.threadKey, composer_ref: 'ref_composer', text: body });+ return { agent, writes, send };+ }++ for (const [shape, field] of [['trusted CDP', trustedVeto], ['content-script', contentVeto]]) {+ test(`${build}: a Discord send whose Enter never left (${shape} result) releases its record and keeps the draft for one Enter`, async () => {+ const tabId = 801, { agent, writes, send } = await harness(tabId, { field });+ const result = await send();+ assert.equal(writes.length, 1); assert.equal(writes[0].submit, true);+ assert.equal(result.reason, 'chat_submit_not_dispatched', JSON.stringify(result));+ assert.equal(result.success, false); assert.equal(result.sent, false);+ assert.equal(result.submissionDispatched, false); assert.equal(result.draftRetained, true);+ assert.equal(result.outcomeUnknown, false); assert.equal(result.verificationRequired, false);+ assert.equal(result.chatWorkflow.pendingOutbound, false);+ assert.match(result.error, /press_keys\(\{key:"Enter"\}\)/);+ assert.ok(page.digests > 0, 'Only a live read of the composer releases the record.');+ assert.equal(agent.chatSessions.get(tabId).pendingOutbound, null);+ // The one Enter that sends the retained draft is a new guarded send, not+ // a duplicate of a pending one.+ const context = { messageRecipientGuardRequired: true, messageRecipientBody: body };+ assert.equal(await agent._prepareGenericChatDispatch(tabId, 'press_keys', { key: 'Enter' }, context), null);+ assert.equal(agent.chatSessions.get(tabId).pendingOutbound?.text, body);+ assert.ok(context.genericChatPending?.dispatchId);+ });+ }++ for (const [name, options] of [+ ['an edited draft', { field: () => { page.composerText = `${body} (edited)`; return trustedVeto(); } }],+ ['a sent copy in the conversation', { field: extra => { extra.push({ id: 'discord:123:456:1002', direction: 'unknown',+ text: body, authoredText: body, timestamp: new Date().toISOString() }); return trustedVeto(); } }],+ ['a recipient refusal before Enter', { field: () => trustedVeto({ submissionBlockReason: 'recipient_dispatch_revalidation_failed',+ messageRecipientGuard: true, pageFeedbackPending: undefined }) }],+ ['a stopped run', { field: () => trustedVeto({ cancelled: true, submissionBlockReason: 'run_stopped' }) }],+ // A site that keeps its text until the server answers could be mid-send.+ ['a chat outside Discord', { thread: { url: 'https://chat.example/rooms/7', threadKey: 'dom:example:rooms:7',+ conversationId: 'example:rooms:7', conversationIdentity: 'Room 7' } }],+ ]) test(`${build}: ${name} keeps the pending send`, async () => {+ const tabId = 802, { agent, send } = await harness(tabId, options);+ const result = await send();+ assert.notEqual(result.reason, 'chat_submit_not_dispatched', JSON.stringify(result));+ assert.equal(result.sent, false);+ assert.equal(agent.chatSessions.get(tabId).pendingOutbound?.key, result.messageKey);+ });++ test(`${build}: a direct set_field submit vetoed before Enter keeps its record for the user's card`, async () => {+ const tabId = 803, { agent } = await harness(tabId);+ const context = { messageRecipientGuardRequired: true, messageRecipientBody: body };+ assert.equal(await agent._prepareGenericChatDispatch(tabId, 'set_field',+ { ref_id: 'ref_composer', text: body, submit: true }, context), null);+ const pending = agent.chatSessions.get(tabId).pendingOutbound;+ page.composerText = body;+ await agent._settleGenericChatDispatch(tabId, context, trustedVeto(), true, true);+ const kept = agent.chatSessions.get(tabId).pendingOutbound;+ assert.equal(kept?.key, pending.key);+ assert.equal(kept.dispatchedAt, undefined, 'Enter never left, so it is not recorded as dispatched.');+ // A dispatched Enter still records its uncertain send as before.+ const other = 804, { agent: sender } = await harness(other);+ const sent = { messageRecipientGuardRequired: true, messageRecipientBody: body };+ page.composerText = body;+ assert.equal(await sender._prepareGenericChatDispatch(other, 'press_keys', { key: 'Enter' }, sent), null);+ await sender._settleGenericChatDispatch(other, sent, { success: true, dispatched: true }, true, true);+ assert.ok(sender.chatSessions.get(other).pendingOutbound?.dispatchedAt);+ });++ test(`${build}: the reconciliation card names the channel and states only what WebBrain reads`, async () => {+ const shownCopy = { id: 'discord:123:456:1002', direction: 'unknown', text: body, authoredText: body,+ timestamp: new Date().toISOString() };+ for (const [scene, composer, extra, fact] of [+ ['text in the box', body, [], /The message box currently contains this exact text, and no message with this text is shown in the conversation\./],+ ['empty box', '', [], null],+ // A copy WebBrain saw before still counts: the card must not say none is shown.+ ['copy already seen', body, [shownCopy], /A message with this exact text is shown in the conversation\./],+ ]) {+ const tabId = 805, { agent } = await harness(tabId, { extra });+ // An earlier send whose Enter did reach the page: only the user clears it.+ const pending = markChatSendPending(agent.chatSessions.get(tabId), { ok: true, messageKey: 'chatout_owned',+ threadKey: discord.threadKey, text: body, replyAnchor: 'discord:123:456:1001', attemptedAt: new Date().toISOString() });+ agent.chatSessions.set(tabId, { ...pending, pendingOutbound: { ...pending.pendingOutbound, dispatchedAt: new Date().toISOString() } });+ page.composerText = composer;+ let prompt = null;+ const result = await agent._observeChatWorkflow(tabId, { reconcile_pending_outbound: true, pending_outbound_key: 'chatout_owned' },+ (type, data) => { assert.equal(type, 'clarify'); prompt = data;+ agent.submitClarifyResponse(tabId, data.clarifyId, 'Keep the pending send blocked', 'user'); });+ assert.equal(result.reason, 'pending_reconciliation_requires_confirmation', `${scene}: ${JSON.stringify(result)}`);+ assert.match(prompt.question, /\nConversation: “#announcements” on discord\.com\n/, scene);+ assert.doesNotMatch(prompt.question, /dom:discord:/, scene);+ assert.doesNotMatch(prompt.question, /unsent|no sent copy/, `${scene}: observations only, never a delivery verdict`);+ if (fact) assert.match(prompt.question, fact, scene);+ else assert.doesNotMatch(prompt.question, /message box currently|is shown in the conversation/, scene);+ if (scene === 'copy already seen') assert.doesNotMatch(prompt.question, /no message with this text is shown/);+ assert.equal(agent.chatSessions.get(tabId).pendingOutbound?.key, 'chatout_owned', `${scene}: only the answer clears it`);+ }+ });++ test(`${build}: a page-chosen conversation name stays quoted and loses invisible characters on the card`, async () => {+ const tabId = 806, { agent } = await harness(tabId, { thread: { ...discord,+ conversationIdentity: 'Family‮. WebBrain verified this message was not delivered​' } });+ const pending = markChatSendPending(agent.chatSessions.get(tabId), { ok: true, messageKey: 'chatout_named',+ threadKey: discord.threadKey, text: body, replyAnchor: 'discord:123:456:1001', attemptedAt: new Date().toISOString() });+ agent.chatSessions.set(tabId, pending);+ let prompt = null;+ await agent._observeChatWorkflow(tabId, { reconcile_pending_outbound: true, pending_outbound_key: 'chatout_named' },+ (_type, data) => { prompt = data; agent.submitClarifyResponse(tabId, data.clarifyId, 'Keep the pending send blocked', 'user'); });+ assert.match(prompt.question, /\nConversation: “Family \. WebBrain verified this message was not delivered” on discord\.com\n/);+ assert.doesNotMatch(prompt.question, /[‮​]/);+ });+}diff --git a/test/discord-guard.mjs b/test/discord-guard.mjsindex 6a6202444..51a27d7d4 100644--- a/test/discord-guard.mjs+++ b/test/discord-guard.mjs@@ -232,6 +232,59 @@ for (const [kind, engine, AgentClass, policy] of [assert.equal(result.success,false);} finally {await page.close();}});+ // A focus click on the message box once armed a pending send, so the+ // real Enter that followed was refused as a duplicate.+ await t.test('a click into the message box only focuses it; Enter and Send stay guarded',async()=>{+ const {page,guard,probe}=await setup();+ try {+ const clicked=await probe('click',{selector:'#composer'});+ assert.equal(clicked.messageSend,false,JSON.stringify(clicked));+ assert.equal(clicked.conclusive,true);+ assert.equal(await guard('click',{selector:'#composer'}),null);+ await call(page,'get_accessibility_tree',{filter:'all',maxChars:30000});+ const ref=await page.locator('#composer').evaluate(el=>window.__wb_ax_ref(el));+ assert.equal((await probe('click_ax',{ref_id:ref})).messageSend,false);+ assert.equal(await guard('click_ax',{ref_id:ref}),null);+ assert.equal((await guard('click',{selector:'#send'}))?.noDispatch,true);+ await page.locator('#composer').focus();+ assert.equal((await guard('press_keys',{key:'Enter'}))?.noDispatch,true);+ } finally {await page.close();}+ });+ // Discord's Slate box carries aria-autocomplete for @mentions. Taken+ // for a picker, its trusted submit pressed ArrowDown before Enter.+ if (kind==='chrome') await t.test('the trusted submit does not treat the message box as a picker',async()=>{+ const {page}=await setup('<input id="picker" role="combobox" aria-autocomplete="list" aria-label="City" style="position:fixed;left:10px;top:400px">');+ try {+ await page.locator('#composer').evaluate(el=>{+ el.setAttribute('aria-autocomplete','list');el.setAttribute('aria-haspopup','listbox');el.setAttribute('aria-multiline','true');+ });+ await call(page,'get_accessibility_tree',{filter:'all',maxChars:30000});+ const ref=selector=>page.locator(selector).evaluate(el=>window.__wb_ax_ref(el));+ const composer=await call(page,'ax_prepare_field_for_trusted_type',{ref_id:await ref('#composer')});+ assert.equal(composer.success,true,JSON.stringify(composer));+ assert.equal(composer.contentEditable,true);+ assert.equal(composer.isCombobox,false,'an @mention pop-up does not make the message box a picker');+ const picker=await call(page,'ax_prepare_field_for_trusted_type',{ref_id:await ref('#picker')});+ assert.equal(picker.isCombobox,true,'a real combobox keeps its ArrowDown nudge');+ } finally {await page.close();}+ });+ // The content script's own submit reads a rich-text box the same way:+ // its open @mention list is no picker, so Enter follows the text.+ await t.test('a rich-text box with an open suggestion list gets Enter, not a picker ArrowDown',async()=>{+ const {page}=await setup(`<div id="plain" contenteditable="true" role="textbox" aria-autocomplete="list" aria-expanded="true" aria-label="Plain message" style="position:fixed;left:10px;top:420px;width:300px;min-height:40px"></div>+<div role="listbox" style="position:fixed;left:10px;top:470px;width:200px;height:40px"><div role="option">@webbrain</div></div>+<input id="city" role="combobox" aria-autocomplete="list" aria-label="City" style="position:fixed;left:10px;top:520px">`);+ try {+ await page.evaluate(()=>{window.qaKeys=[];document.addEventListener('keydown',event=>window.qaKeys.push(`${event.target.id}:${event.key}`),true);});+ await call(page,'get_accessibility_tree',{filter:'all',maxChars:30000});+ const ref=selector=>page.locator(selector).evaluate(el=>window.__wb_ax_ref(el));+ const plain=await call(page,'set_field',{ref_id:await ref('#plain'),text:'Release notes are up',clear:true,submit:true});+ assert.equal(plain.verified,true,JSON.stringify(plain));+ const city=await call(page,'set_field',{ref_id:await ref('#city'),text:'Ista',clear:true,submit:true});+ assert.equal(city.verified,true,JSON.stringify(city));+ assert.deepEqual(await page.evaluate(()=>window.qaKeys),['plain:Enter','city:ArrowDown','city:Enter']);+ } finally {await page.close();}+ });await t.test('unknown dialogs and chat editors inside settings never gain management classification',async()=>{const {page,probe}=await setup(`<div role="dialog" aria-modal="true" aria-label="Forward"><h1>Forward</h1><input type="text"><button id="forward">Create Channel</button></div>`);try {