Repository navigation
Commit d4d16a0
authored
feat(desktop): keep the machine awake for background chats and yield the page to the user (#8671)
* feat(desktop): keep the machine awake for background chats and yield 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.
* fix(desktop): give the page back to the user mid-action
- 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.
* test(desktop): read the blockers the OS holds instead of asserting the mock was called
* fix(desktop): yield the page only for background calls that act on it
- 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.
* test(desktop): give the notification tests the prevent-sleep setter the settings service now requires
* test(desktop): show the prevent-sleep switch only on a device that runs chats in the background1 parent 0d74834 commit d4d16a0
20 files changed
Lines changed: 693 additions & 44 deletions
File tree
- apps
- desktop
- e2e
- src
- main
- browser-agent
- desktop-executor
- preload
- sim
- app/workspace/[workspaceId]/settings/components/desktop
- lib/mothership/tools/client
- packages
- browser-protocol/src
- desktop-bridge/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
359 | 359 | | |
360 | 360 | | |
361 | 361 | | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
362 | 367 | | |
363 | 368 | | |
364 | 369 | | |
| |||
730 | 735 | | |
731 | 736 | | |
732 | 737 | | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
733 | 848 | | |
734 | 849 | | |
735 | 850 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
82 | 178 | | |
83 | 179 | | |
84 | 180 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
35 | | - | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
5094 | 5095 | | |
5095 | 5096 | | |
5096 | 5097 | | |
| 5098 | + | |
| 5099 | + | |
| 5100 | + | |
| 5101 | + | |
| 5102 | + | |
| 5103 | + | |
| 5104 | + | |
| 5105 | + | |
| 5106 | + | |
| 5107 | + | |
| 5108 | + | |
| 5109 | + | |
| 5110 | + | |
| 5111 | + | |
| 5112 | + | |
| 5113 | + | |
| 5114 | + | |
| 5115 | + | |
| 5116 | + | |
| 5117 | + | |
| 5118 | + | |
| 5119 | + | |
| 5120 | + | |
| 5121 | + | |
| 5122 | + | |
| 5123 | + | |
| 5124 | + | |
| 5125 | + | |
| 5126 | + | |
| 5127 | + | |
| 5128 | + | |
| 5129 | + | |
| 5130 | + | |
| 5131 | + | |
| 5132 | + | |
| 5133 | + | |
| 5134 | + | |
| 5135 | + | |
| 5136 | + | |
| 5137 | + | |
| 5138 | + | |
| 5139 | + | |
| 5140 | + | |
| 5141 | + | |
| 5142 | + | |
| 5143 | + | |
| 5144 | + | |
| 5145 | + | |
| 5146 | + | |
| 5147 | + | |
| 5148 | + | |
5097 | 5149 | | |
5098 | 5150 | | |
5099 | 5151 | | |
5100 | 5152 | | |
5101 | 5153 | | |
5102 | | - | |
| 5154 | + | |
| 5155 | + | |
5103 | 5156 | | |
5104 | 5157 | | |
5105 | 5158 | | |
| |||
5190 | 5243 | | |
5191 | 5244 | | |
5192 | 5245 | | |
| 5246 | + | |
| 5247 | + | |
| 5248 | + | |
| 5249 | + | |
| 5250 | + | |
| 5251 | + | |
| 5252 | + | |
| 5253 | + | |
| 5254 | + | |
| 5255 | + | |
| 5256 | + | |
| 5257 | + | |
| 5258 | + | |
| 5259 | + | |
| 5260 | + | |
5193 | 5261 | | |
5194 | 5262 | | |
5195 | 5263 | | |
5196 | 5264 | | |
5197 | 5265 | | |
5198 | | - | |
5199 | 5266 | | |
| 5267 | + | |
| 5268 | + | |
5200 | 5269 | | |
5201 | 5270 | | |
5202 | 5271 | | |
5203 | 5272 | | |
| 5273 | + | |
| 5274 | + | |
| 5275 | + | |
5204 | 5276 | | |
5205 | 5277 | | |
5206 | 5278 | | |
| |||
0 commit comments