Open the thread's simulator tab when its agent starts driving (opt-in) - #4
Open the thread's simulator tab when its agent starts driving (opt-in)#4dhiyaancnirmal wants to merge 1 commit into
Conversation
A new boolean setting, openSimulatorOnDrive, off by default and also offered in the panel's gear menu. When it is on and a thread takes the simulator lease through the agent tools or the CLI, the server publishes a simulator-driven signal naming that thread, and the thread's composer opens the simulator threadPanelAction in its own side panel. A driving session, not a lease, is what gets announced: every tool call takes and releases the lease, so DriveAnnouncer collapses acquisitions by one thread with no gap longer than 90s into one announcement at the start. A tab the person closes therefore stays closed until the agent has been quiet and comes back, rather than reopening on the next gesture. The signal rides its own channel so the panels that refetch on every simulator-changed signal do not pay for one that is not about state.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f9de3404c5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (outcome.ok && threadId !== null && device !== null && drives.touch(threadId)) { | ||
| if (settings.openSimulatorOnDrive) { |
There was a problem hiding this comment.
Reset session tracking when enabling auto-open
When openSimulatorOnDrive is disabled, every successful acquisition still calls drives.touch(threadId) and advances the session window. If a user enables the option within 90 seconds of such an acquisition, the agent's next drive returns false from touch, so no signal is published and the newly enabled setting appears ineffective until the thread has been quiet for the full window. Only record touches while the option is enabled, or forget existing sessions when it transitions from off to on.
Useful? React with 👍 / 👎.
What
A new boolean setting,
openSimulatorOnDrive, off by default. When it is on and a thread takes the simulator lease through the agent tools or the CLI, its simulator tab opens in that thread's side panel — so you watch what the agent does without going looking for it.Also offered in the panel's gear menu, since it is presentation only: the worst a same-user caller can do by flipping it is open a panel.
allowAgentCapturestays where it is.How
src/sim/wire.ts): theleases.acquirewrapper already knows the invoking thread. On a successful acquisition by a thread (not the panel'snull), with a live device and the setting on, it publishes{ threadId, deviceUdid }on a newsimulator-drivenchannel. Separate fromsimulator-changedso the panels that refetch on every state signal do not pay for one that is not about state.src/sim/announce.ts): every tool call takes and releases the lease, so announcing per acquisition would reopen the tab on every gesture — including a tab the person had just closed.DriveAnnouncercollapses acquisitions by one thread with no gap longer than 90s (the lease TTL) into one announcement at the start. A closed tab stays closed until the agent has been quiet and comes back.app/sim/useOpenOnDrive.ts): a hook on the composer banner, which is the one per-thread surface with the thread id and navigation in scope. On a signal naming its thread it callsopenThreadPanel({ actionId: "simulator" }). Opening the same action twice focuses the existing tab. No params: the thread panel already mirrors the live device, which is the one being driven.Tests
test/sim/announce.test.ts— session window semantics (first touch, sliding window, exact boundary, per-thread independence, forget).test/sim/options.test.ts— the new key is in both the allowlist and the presentation enumeration.npm run checkpasses.I did not add a server-level test for the publish itself: the wrapper only announces with a live device, and the server harness has no way to fake one. The wrapper is six lines; happy to add a seam if you'd like one.
Verified
On bb 0.41.0 / macOS 26.5 / Xcode 27 beta: with the setting on,
bb xcode sim drive "tap 0.5,0.5"from a thread opens that thread's simulator tab. With it off, nothing changes.Note: on a git install this needs #3 to get past the doctor at all; the branches are independent.