Skip to content

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

avoid idle waits on automatic scroll events

Barack Sokullu2c44731380ac
diff --git a/src/chrome/src/agent/page-feedback.js b/src/chrome/src/agent/page-feedback.js
index db7b32e06..af5bb0ae1 100644
--- a/src/chrome/src/agent/page-feedback.js
+++ b/src/chrome/src/agent/page-feedback.js
@@ -179,7 +179,7 @@ export const pageFeedbackMethods = {
// A physical interaction supersedes an expected agent navigation.
run.navigation = null;
}
- if (feedback.kind !== 'dom' && (feedback.source === 'user' || feedback.kind === 'scroll'
+ if (feedback.kind !== 'dom' && (feedback.source === 'user'
|| (feedback.kind === 'resize' && feedback.source !== 'page'))) run.lastActivityAt = Date.now();
this._queuePageFeedback(tabId, item);
return { accepted: true };
diff --git a/src/firefox/src/agent/page-feedback.js b/src/firefox/src/agent/page-feedback.js
index db7b32e06..af5bb0ae1 100644
--- a/src/firefox/src/agent/page-feedback.js
+++ b/src/firefox/src/agent/page-feedback.js
@@ -179,7 +179,7 @@ export const pageFeedbackMethods = {
// A physical interaction supersedes an expected agent navigation.
run.navigation = null;
}
- if (feedback.kind !== 'dom' && (feedback.source === 'user' || feedback.kind === 'scroll'
+ if (feedback.kind !== 'dom' && (feedback.source === 'user'
|| (feedback.kind === 'resize' && feedback.source !== 'page'))) run.lastActivityAt = Date.now();
this._queuePageFeedback(tabId, item);
return { accepted: true };
diff --git a/test/page-feedback.mjs b/test/page-feedback.mjs
index 9eb6e9aaf..fa0c2eb26 100644
--- a/test/page-feedback.mjs
+++ b/test/page-feedback.mjs
@@ -344,10 +344,17 @@ for (const build of ['chrome', 'firefox']) {
const started = Date.now();
await agent._waitForPageFeedbackIdle(tab);
assert.ok(Date.now() - started >= 30);
- binding.send({ kind: 'scroll', source: 'unknown' });
+ binding.send({ kind: 'scroll', source: 'user' });
const externalScrollAt = Date.now();
await agent._waitForPageFeedbackIdle(tab);
- assert.ok(Date.now() - externalScrollAt >= 30, 'Unattributed scrollbar/page scroll also gets the idle gate');
+ assert.ok(Date.now() - externalScrollAt >= 30, 'A physical scroll receives the idle gate');
+ binding.send({ kind: 'click', source: 'user' });
+ const automaticScrollAt = Date.now();
+ const ticker = setInterval(() => binding.send({ kind: 'scroll', source: 'unknown' }), 5);
+ try { await agent._waitForPageFeedbackIdle(tab); }
+ finally { clearInterval(ticker); }
+ assert.ok(Date.now() - automaticScrollAt >= 30 && Date.now() - automaticScrollAt < 100,
+ 'Repeated unattributed scroll events must not restart the physical-input idle deadline');
binding.send({ kind: 'activity', interacting: true });
const waiting = agent._waitForPageFeedbackIdle(tab);
agent.abort(tab);