Title: fix(mothership): leave desktop tool calls to the desktop app in other clients by waleedlatif1 · Pull Request #8562 · simstudioai/sim · GitHub
Open Graph Title: fix(mothership): leave desktop tool calls to the desktop app in other clients by waleedlatif1 · Pull Request #8562 · simstudioai/sim
X Title: fix(mothership): leave desktop tool calls to the desktop app in other clients by waleedlatif1 · Pull Request #8562 · simstudioai/sim
Description: Summary A Chat open in the desktop app and in a web tab at the same time could lose a browser or terminal tool's real result: the agent got an error instead Every client tailing a chat starts each client-executed call it sees. A web tab has no desktop bridge, so for a desktop tool it fails at once and posts an error to /api/copilot/confirm. The confirm route takes a pre-claim error while the call is still pending, so the web tab's error usually lands before the desktop claims the call (the desktop restores its browser scope first). The desktop's claim then 404s, and its retried reports 404 too Fix: the stream tool-event handler starts a desktop-only tool (agent browser, terminal, local files) only in the desktop app. Any other client leaves the call pending for the desktop, which claims it atomically through /api/desktop/tool/authorize as before isDesktopExecutedToolCall now names that set in client-executed-tools.ts, and isClientExecutedToolCall is built from it, so the gate and the client-executed set can't drift apart Workflow tools are unchanged: they still start in any client, and their claim settles who runs them Design notes Rejected: a server-side owner check on confirm. Native claims record a constant owner (desktop-browser/desktop-terminal), not which client holds them, and the desktop renderer's pre-claim errors (stale event, closed session, replay-guard limits) need the pre-claim path. Telling the web tab and the desktop apart would mean trusting a client header, or adding a per-client claim token across Electron main, the renderer and the server, which old desktop builds don't send Rejected: changing the 404 on a late confirm for an already-finished native call to a 200 or 409. With this fix that 404 no longer happens in this scenario. A native confirm carries no executor identity, so a 200 would tell a client its result was accepted when it was thrown away Behavior changes Web only (no desktop app): no change. The server offers browser, terminal and local-file tools only when the request reports desktop capabilities, so a web-only turn never gets these calls Desktop and a web tab open together: the desktop's result reaches the agent. The web tab shows the call as running until the result streams in Desktop app (any shell version): no change. The renderer is served by Sim, and every shell injects the bridge the gate checks If the desktop app quits for good while a web tab stays open, and the agent then issues a desktop tool, the call is no longer failed right away with a misleading "no active browser session" error from the web tab. It now ends on the worker's deferred-call timeout, the same as when no web tab is open. A desktop that exits mid-action still reports through its page-exit path, as before Not covered here: two desktop windows on the same chat both try the call. The losing window's rejected claim is still reported as an error. This predates this PR and is unchanged by it. Fixing it needs a per-window claim identity Type of Change Bug fix Testing New lib/mothership/tools/client/desktop-tool-executor.integration.ts runs against real Postgres and Redis. A web tab runs the production stream handler and client executors. The desktop claims through the real authorize route and reports through the real confirm route. The server-side waiter shows what the agent receives. Covers browser_find and terminal Red on origin/staging: the desktop's claim gets 404 and the agent receives the web tab's error Green with the fix: the claim returns 200, the confirm returns 200, the agent receives success, and the row is completed handle-tool-event.test.ts: the existing desktop routing tests now set the desktop bridge explicitly Reverting the gate turns the integration test red again bun run lint, bun run type-check (apps/sim), bun run check:audits, docs-manifest:check, block-registry check, root bun run test Checklist Code follows project style guidelines Self-reviewed my changes Tests added/updated and passing (new tests pass the test-audit authoring gate) No new warnings introduced I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)
Open Graph Description: Summary A Chat open in the desktop app and in a web tab at the same time could lose a browser or terminal tool's real result: the agent got an error instead Every client tailing a chat starts ...
X Description: Summary A Chat open in the desktop app and in a web tab at the same time could lose a browser or terminal tool's real result: the agent got an error instead Every client tailing a chat sta...
Opengraph URL: https://github.com/simstudioai/sim/pull/8562
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:0a0d2258-a25d-e9e2-5b01-51b0ddc837bf |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | BBEC:2833F1:AFC558:F13999:6AFB51A5 |
| html-safe-nonce | 4cd6b4746c67a6720479fcea5de2c0419ef28e89b8835561aa399c4726b6c771 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQkVDOjI4MzNGMTpBRkM1NTg6RjEzOTk5OjZBRkI1MUE1IiwidmlzaXRvcl9pZCI6IjE0MzYzNTk4NzE1NzcxNDk4NjEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 99d6e3f4d229838a9e088815ae1c0127017ceb5c57718af4a311f1f9a0266814 |
| hovercard-subject-tag | pull_request:4714110640 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/8562/files |
| twitter:image | https://avatars.githubusercontent.com/u/40672544?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/40672544?s=400&v=4 |
| og:image:alt | Summary A Chat open in the desktop app and in a web tab at the same time could lose a browser or terminal tool's real result: the agent got an error instead Every client tailing a chat starts ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7122bb414b542dba14d71a3f0b9f6fd2abce715b9f5912d082800563e6c806d1 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/simstudioai/sim git https://github.com/simstudioai/sim.git |
| octolytics-dimension-user_id | 199344406 |
| octolytics-dimension-user_login | simstudioai |
| octolytics-dimension-repository_id | 912559512 |
| octolytics-dimension-repository_nwo | simstudioai/sim |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 912559512 |
| octolytics-dimension-repository_network_root_nwo | simstudioai/sim |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | cbf66c024bb6d10e6955baa7413c54cf13a201bb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width