GeezerVison is showing github.com — feat: agents can run app commands in the user's window by batchema · Pull Request #7 · batchema/t3code
Conversation
batchema
commented
Nov 13, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Part of #5 (step 2: app commands).
Agents could change settings and keyboard shortcuts (#4), but couldn't act on the app itself, such as opening the terminal or a panel. Now an agent can run any shortcut command in the window you used most recently, as if you'd pressed the shortcut.
What changed
t3_app_command({ command }) takes a command id from t3_keybindings_read, such as terminal.toggle or sidebar.toggle. It returns { ran: true } once the window ran it. Otherwise it fails with a clear reason: no window is open, the window didn't answer, or nothing on screen handles that command right now (such as a thread command outside a thread). It has the same access rule as other environment writes: a live full-access or default caller thread.
- User-only commands. Commands that send or dictate in your composer (
composer.send*, composer.dictation, thread.steerQueuedMessage) are refused, so an agent can't send words you haven't sent. Commands that pick work that may belong to another environment are refused as well: thread.undo, view.reopenClosed, composer.cycleHost, and the new-thread commands. Agents start threads with t3_thread_launch.
- Environment guard.
- View-only commands run on any screen: sidebar, back and forward, focus, palette, theme, usage, and switching threads.
- Every other command runs only while the window shows a thread or draft from the agent's own environment. Screens with no single environment, such as the pull requests page, refuse them.
- This keeps an agent from acting, through your window, on an environment it has no access to.
- Server:
AppControl service. Each window subscribes over WebSocket (subscribeAppControl) and says whether it is focused at that moment. Windows are keyed per socket, because tabs share a session. After that, the focus reports windows already send (server.reportClientActivity) pick the target, so a window reconnecting in the background doesn't take over. The window answers through appControl.respond, which only that window's session can answer.
- Web:
runCommand(id) in the shortcut dispatcher. It runs a command through the same handlers as its shortcut, without a key press. Some views match their own keys outside the dispatcher, so they register a runner the dispatcher also tries: the chat, the sidebar toggle, thread switching, a new right-panel tab, the usage page, and the pull request detail panel. Commands that only act inside an open popup, such as the model picker, answer "not handled".
- Surfaces:
- Desktop gets this through the web app.
- Mobile doesn't subscribe, so agents get "no window" when only a phone is connected.
- A command goes to windows connected to the agent's own environment.
Validation
vp run check:changed passes: format, lint, knip, typecheck (37 packages), and tests next to the changes.
- Tests:
- Service: the target is the window used most recently, another session can't answer for it, and there are failures for no window and no answer.
- Tool: unknown commands and user-only commands are refused; "not handled" and "no window" each come back as a failure.
- Dispatcher: the existing fall-through test now also runs through
runCommand.
- End to end on a dev server with copied data: a real Codex (Luna) agent turn called
t3_app_command. A headless Chromium window on a thread opened its terminal, and a second turn hid the sidebar. Both returned {"ran":true}.



- Eval case
open-panel-uses-app-command added. It passes a dry run; I didn't run it against live models.
- The agent context budget grows by 445 bytes, to 50,094.
Built with Claude Opus 5.5 in Claude Code. Codex GPT-6.1 Sol (xhigh) reviewed it.
🤖 Generated with Claude Code
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Agents could change settings and shortcuts but could not act on the app
itself, such as opening the terminal or a panel. A new `t3_app_command`
tool runs a shortcut command in the window the user used most recently.
Windows subscribe to app commands over WebSocket; the focus reports they
already send pick the target. The window runs the command through the
shortcut dispatcher and answers whether anything handled it. The chat,
sidebar toggle, and thread switching match their own shortcuts, so they
register runners the dispatcher also tries. Commands that send or dictate
in the user's composer stay user-only. Mobile apps don't subscribe.
- Key windows by socket, since tabs sharing a session also share RPC
client ids.
- A window says whether it is focused when it subscribes, so a background
reconnect no longer takes commands from the window in use.
- A window refuses commands from an environment other than the one it
shows, so an agent can't act on a thread it has no access to.
- The usage page, reopen closed view, new right panel tab, pull request
panels, and thread undo register command runners too.
- A timeout tells the agent the command may still run, so it checks
before retrying.
- A window showing a draft refuses commands from environments other than
the draft's, as it already did for server threads.
- `thread.undo` is user-only: an undo notice can hold actions from other
environments, so an agent can't replay them.
Patching each screen's environment one by one kept missing paths, so the
rule is now positive. View-only commands (sidebar, navigation, palette,
theme, usage, thread switching) run on any screen. The rest run only while
the window shows a thread or draft from the agent's environment, so pages
with no single environment, such as pull requests, refuse them.
Commands that pick work from another environment become user-only: new
threads, host cycling, and reopening closed views. Agents start threads
with t3_thread_launch.
This was referenced Nov 13, 2026
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|