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
Reconnect the side panel's presence port at once after a background restart
Claude463f84a9b5a0
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 765700c9d..a7eed40ed 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -10,7 +10,7 @@ This changelog was generated from the repository Git history and release tags. V- Selecting text on a page now shows a small bar, **Translate | Explain | Proofread | More…**, instead of the single `?` button. Translate, Explain and Proofread answer in a card next to the selection: Translate shows the detected source language, the original text and a target-language picker, and every card has an "Ask a follow-up" box that, once the answer is there, continues in the side panel with the card's answer as context. **More…** opens the same popup the `?` button opened (Summarize, Quiz me, Humanize, a question box and Hide this; Translate, Explain and Proofread are on the bar, so they are not repeated there). A card sends the selected text to your configured model provider, like any other selection action; selections over 4,000 characters go to the side panel instead of a card. A card answer that reaches the model's output limit says it was cut off and offers to continue in the side panel, which picks up from the unfinished text instead of starting over (a side-panel reply that is cut off again says so, including when an OpenAI Responses model reports the limit as an error, in which case the text it wrote is kept), and closing or redoing a card cancels the request it no longer needs. Chrome and Firefox.### Fixed-- Chrome: sending a follow-up or a selection action to WebBrain while the side panel is already open no longer closes it. Each side panel now tells the background whether it is on screen, and the background skips re-opening a panel that is already showing and hands it the prompt directly.+- Chrome: sending a follow-up or a selection action to WebBrain while the side panel is already open no longer closes it. Each side panel now tells the background whether it is on screen, and the background skips re-opening a panel that is already showing and hands it the prompt directly A panel that was open while the background restarted tells the new worker about itself at once instead of after a delay, so a request in that moment does not close it.- Stopping a task while WebBrain was waiting for page navigation to settle now stops it immediately. The pending settle step previously kept waiting and could let the run continue after you chose Stop.- Mastodon: replying to toots in a narrow window no longer posts the same reply several times and stops before the next toot. There, a toot's Reply button opens the composer at /publish, and after posting Mastodon goes back to the previous column by itself. WebBrain took both page changes for something you did, so it reported each click's outcome as unknown; the agent then concluded its reply had not been posted, wrote it again, and never reached the next toot. In Chrome, a page's own Back is now told apart from your browser's Back button: the page a click opens counts as that click's verified effect, and a click after which the page goes back by itself counts as delivered, to be checked on the page. The Mastodon notes now cover replies (start with the prefilled @mentions once, check the reply under the toot before any retry) and stay active on Favourites, Bookmarks and the other columns. Firefox still treats a page's own Back as yours until its Back button reporting is verified.- Finishing a form you asked WebBrain not to submit no longer takes most of a minute. The completion check removed every line that mentioned a password, so "fill out this form with a random password … don't submit" reached its judge as "[credential omitted]", and so did the approved plan and the agent's summary. Seeing only an unsubmitted signup form, the judge answered "pending" again and again; in the trace it took four attempts and about 50 seconds, ending only when a slow screenshot check ran out of time. The active model's check, which already holds these texts in the conversation, now receives every line of them, with only addresses shortened and bearer tokens and entered passwords hidden, as in all judge evidence. A decision model on this device, or WebBrain Cloud's own while WebBrain Cloud is also your provider, receives that same copy; any other decision model keeps whole-line redaction, and when that leaves it without the task, it is no longer asked while the active model can judge. A password WebBrain typed into a password field during the run is now hidden in the text judges receive, such as the agent's summary or a field a "show password" control revealed, unless the typing tool could not tell what kind of field it was; other entered values stay visible, so a judge can still catch a mistyped one. The judges are told that a task asking not to submit is complete once the staged values match, that a hidden value neither proves nor disproves an entry, and, for each recorded entry, whether its field read back what was entered, whether it is a credential field and which field it targeted; a credential field's line in the page evidence keeps its role and reference. Staged field edits are judged from the accessibility tree first: a screenshot shows passwords only as dots, and the focused field's blinking caret made each one stale before its verdict returned.diff --git a/docs/architecture.md b/docs/architecture.mdindex b93c9aae7..500c91b0e 100644--- a/docs/architecture.md+++ b/docs/architecture.md@@ -547,7 +547,9 @@ continues in the side panel as a custom question. In Chrome the background opensonly when none is showing in that window: re-running `sidePanel.setOptions()` + `open()` on anopen panel closes it, so each panel reports its visibility over a long-lived port(`sidepanel-presence.js`) and the background reads that synchronously, before the user-gesture can lapse, then hands an already-open panel the prompt by message. The card's+gesture can lapse, then hands an already-open panel the prompt by message. A panel whose port+was dropped by a background restart reconnects at once (only a port that is refused straight+away backs off), so the restarted worker is not left unaware of a panel that is still showing. The card'sanswer travels inside the selection's untrusted boundary, labelled as an earlier answer thatmay contain mistakes andcapped at 6,000 characters, so model output derived from page text never becomes trusteddiff --git a/src/chrome/src/sidepanel-presence.js b/src/chrome/src/sidepanel-presence.jsindex b2d5a5e1f..19bbdee48 100644--- a/src/chrome/src/sidepanel-presence.js+++ b/src/chrome/src/sidepanel-presence.js@@ -91,7 +91,12 @@ export function reportSidePanelPresence({void runtime.lastError;if (port === next) port = null;quickCloses = now() - openedAt < QUICK_CLOSE_MS ? quickCloses + 1 : 0;- const delay = Math.min(RECONNECT_MAX_MS, RECONNECT_BASE_MS * 2 ** quickCloses);+ // A port that lived was dropped because the background worker restarted, which+ // leaves it knowing of no panel until this one reports again, so come back at+ // once. Only a port that is refused straight away backs off.+ const delay = quickCloses === 0+ ? 0+ : Math.min(RECONNECT_MAX_MS, RECONNECT_BASE_MS * 2 ** (quickCloses - 1));schedule(connect, delay);});report();diff --git a/test/run.js b/test/run.jsindex 602425a5e..bb22cf2a6 100644--- a/test/run.js+++ b/test/run.js@@ -52684,30 +52684,37 @@ test('side panel presence: the background learns which windows show a panel, andclock = 60_000;connections[0].drop();assert.equal(timers.length, 1);- assert.equal(timers[0].delay, 500);+ assert.equal(timers[0].delay, 0, 'a restarted background is told about the panel again at once, not after a gap in which it would reopen it');timers.shift().callback();assert.equal(connections.length, 2, 'the panel reopens its port');assert.deepEqual(posted.at(-1), { visible: true, windowId: 5 });// A port that keeps being refused backs off instead of spinning.connections[1].drop();- assert.equal(timers[0].delay, 1_000);+ assert.equal(timers[0].delay, 500);timers.shift().callback();connections[2].drop();- assert.equal(timers[0].delay, 2_000);+ assert.equal(timers[0].delay, 1_000);timers.shift().callback();assert.equal(connections.length, 4);+ // One that lived again after a refusal goes back to reconnecting at once.+ clock = 120_000;+ connections[3].drop();+ assert.equal(timers[0].delay, 0);+ timers.shift().callback();+ assert.equal(connections.length, 5);+reporter.stop();assert.equal(connections.at(-1).disconnected, true);assert.equal(doc.listeners.length, 0);connections.at(-1).drop();timers.splice(0).forEach(timer => timer.callback());- assert.equal(connections.length, 4, 'a stopped reporter does not reconnect');+ assert.equal(connections.length, 5, 'a stopped reporter does not reconnect');// Without a window it reports nothing, which keeps the old always-open behaviour.const anonymous = reportSidePanelPresence({ runtime, doc, windowId: null });- assert.equal(connections.length, 4);+ assert.equal(connections.length, 5);anonymous.stop();});