Repository navigation
feat(desktop): keep the machine awake for background chats and yield the page to the user - #8671
waleedlatif1 wants to merge 4 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
|
8c2b3fd to
de04c40
Compare
0d8b513 to
4024e1f
Compare
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 16 files
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Turn on auto-fix | Re-trigger cubic
de04c40 to
93a0f75
Compare
4024e1f to
ccdaab7
Compare
ccdaab7 to
d23e403
Compare
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
9a69412 to
13848af
Compare
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
This comment has been minimized.
This comment has been minimized.
13848af to
808259c
Compare
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
808259c to
ede95e9
Compare
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
…the page to the user - Prevent sleep: while any chat has desktop work claimed on this machine, the app holds a prevent-app-suspension power blocker, released as soon as the last result is delivered. On by default, with a switch in Desktop settings that notes a closed lid still sleeps the computer. The switch is a new optional bridge method, so older shells simply do not show it. - Takeover: when the user clicks, scrolls or types in the page an agent drives, that chat's next browser action waits, marked as needing attention, until the user has left the page alone for a few seconds, then resumes in the same page. A Stop still cancels it while it waits.
- A browser action now rechecks, right before each input it sends, whether the user is working in the page. Between a batch's steps or during a click's target probes, the user wins and the action stops before its next input. - The wait for the user is bounded inside the action's own deadline. A user who keeps working gets the model a clear "not run" instead of a timeout with an unknown outcome. - The user's activity belongs to the tab they acted in. Once the agent drives another tab (the old one closed or replaced, the session reopened), that activity no longer holds anything up. - `createSleepBlocker` is documented.
…e mock was called
- Only a call from the background executor yields the page to the user. A call from the chat view the user is watching acts exactly as before: there the user steers the agent directly. - A background call that only reads the page (snapshot, read text, list tabs) never waits for the user, since it cannot collide with their input. - Which browser tools only observe the page now lives in @sim/browser-protocol, shared by the chat view's replay policy and the driver. - The prevent-sleep switch shows only when Sim runs chats on this device in the background. - Tests: a chat-view call acts at once under user input; a background call waits, and a background read does not; a user who starts working mid-action stops it before its next input; sign-out releases the sleep blocker while a call is still running.
ede95e9 to
4fda09e
Compare
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
Summary
Phase 2c of the desktop background executor. Stacked on #8668.
Prevent sleep while a chat is running
prevent-app-suspensionpower blocker. It releases the blocker as soon as the last result is delivered. It never holds one while idle.settings.setPreventSleepWhileRunning, so older desktop builds don't show it.The agent yields the page to the user (takeover)
browser_request_takeoverkeeps its own explicit hand-back flow.Not in this PR: a background chat's page dialog can still take focus
A page in a hidden chat that calls
confirm()oralert()still takes focus from the user's window. Electron shows its native message box before the driver's CDP handler answers the dialog. This happens whether or not the executor runs the chat, and it overlaps with #8432's dialog work. Suppressing native dialogs (disableDialogs) would also break the agent'sdialog: {accept: true}answers. I reproduced it in a packaged-app E2E and left it out of this PR so it can be decided with #8432.Test plan
Unit tests (
sleep-blocker.test.ts):Packaged-app E2E (
background-executor.spec.ts):browser_clickuntil 4 s of quiet. The click then runs exactly once.Both fail with the change reverted (mutation-checked). The full suite, A to J, passes in 1.1 min.
type-check,check:audits,check:desktop-ipc,check:desktop-bridge, and the desktop Vitest suite (931 tests).