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
Count a card's own timeout as held time, not only the user's answer
Claudef3078205bd5a
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.jsindex 5251529e3..fec227051 100644--- a/src/chrome/src/agent/agent.js+++ b/src/chrome/src/agent/agent.js@@ -21738,7 +21738,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dif (!entry) return false;// The time the user took to answer one of WebBrain's own cards does not// age the page observation the pending action was decided on.- if (!entry.settled && Number.isFinite(entry.ts)) this._notePageFeedbackUserDecision?.(tabId, Date.now() - entry.ts);+ this._noteClarifyHeld(tabId, entry);this._settleClarification(entry, { answer, source });return true;}@@ -22146,6 +22146,14 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dentry.timer = null;}+ // The time a card waited, whether the user answered or its own timeout chose,+ // does not age the page observation the pending action was decided on.+ _noteClarifyHeld(tabId, entry) {+ if (tabId != null && entry && !entry.settled && Number.isFinite(entry.ts)) {+ this._notePageFeedbackUserDecision?.(tabId, Date.now() - entry.ts);+ }+ }+/*** Resolve a pending clarify entry exactly once and clear its auto-timeout.*/@@ -31896,6 +31904,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dentry.timer = null;try { onUpdate('clarify_auto', { clarifyId, answer: timedAnswer, source, timeoutSec: waitSec }); }catch { /* UI emit must never break the run */ }+ this._noteClarifyHeld(tabId, entry);this._settleClarification(entry, { answer: timedAnswer, source });};if (timeoutSec === 0) {@@ -45213,6 +45222,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d});}} catch { /* UI emit must never break the run */ }+ this._noteClarifyHeld(tabId, entry);this._settleClarification(entry, { answer, source: autoSource });};entry.restartTimeout = () => {diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.jsindex a0a767d1c..5b7fcec72 100644--- a/src/firefox/src/agent/agent.js+++ b/src/firefox/src/agent/agent.js@@ -18778,7 +18778,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dif (!entry) return false;// The time the user took to answer one of WebBrain's own cards does not// age the page observation the pending action was decided on.- if (!entry.settled && Number.isFinite(entry.ts)) this._notePageFeedbackUserDecision?.(tabId, Date.now() - entry.ts);+ this._noteClarifyHeld(tabId, entry);this._settleClarification(entry, { answer, source });return true;}@@ -19186,6 +19186,14 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dentry.timer = null;}+ // The time a card waited, whether the user answered or its own timeout chose,+ // does not age the page observation the pending action was decided on.+ _noteClarifyHeld(tabId, entry) {+ if (tabId != null && entry && !entry.settled && Number.isFinite(entry.ts)) {+ this._notePageFeedbackUserDecision?.(tabId, Date.now() - entry.ts);+ }+ }+/*** Resolve a pending clarify entry exactly once and clear its auto-timeout.*/@@ -28883,6 +28891,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dentry.timer = null;try { onUpdate('clarify_auto', { clarifyId, answer: timedAnswer, source, timeoutSec: waitSec }); }catch { /* UI emit must never break the run */ }+ this._noteClarifyHeld(tabId, entry);this._settleClarification(entry, { answer: timedAnswer, source });};if (timeoutSec === 0) {@@ -40954,6 +40963,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d});}} catch { /* UI emit must never break the run */ }+ this._noteClarifyHeld(tabId, entry);this._settleClarification(entry, { answer, source: autoSource });};entry.restartTimeout = () => {diff --git a/test/page-feedback-held-time.mjs b/test/page-feedback-held-time.mjsindex 152ca900a..9a7f31a47 100644--- a/test/page-feedback-held-time.mjs+++ b/test/page-feedback-held-time.mjs@@ -65,6 +65,15 @@ for (const build of ['chrome', 'firefox']) {assert.equal(agent._pageFeedbackModelHeldMs(state), 158000);}));+ test(`${build}: a card its own timeout settles is reported as held time too`, () => withClock(async advance => {+ const { agent, tab, state } = watched();+ agent.clarifyTimeoutSec = 0; // the automatic choice fires on the next timer tick+ const pending = agent._promptUnverifiedStepConfirmation(tab, {}, () => {});+ advance(150000); // the card was on screen for two and a half minutes+ await pending;+ assert.equal(agent._pageFeedbackModelHeldMs(state), 150000);+ }));+test(`${build}: every check of the pre-inference certificate carries the held time`, () => withClock(async advance => {const { agent, tab, state } = watched();advance(46000);