From e117cfdff08b7e43b7d0b7f7e661be7b710e7a4f Mon Sep 17 00:00:00 2001 From: Brooklyn Nicholson Date: Sun, 28 Jun 2026 21:15:14 -0500 Subject: [PATCH] feat(desktop): live agent terminals + agent-driven tab close MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make the read-only agent terminal mirrors stream in real time and give the agent a desktop-only way to dismiss its own tabs. - Stream background output live: the local reader used a blocking read(4096) that buffered small periodic output until EOF, so agent tabs only "filled in" at process exit. Switch to buffer.read1(4096) (decoded) for incremental chunks. - Route agent.terminal.output / terminal.close to the window that owns the process (its gateway session) instead of an empty session id, so events actually reach the desktop renderer. - Add close_terminal: a HERMES_DESKTOP-gated tool (sibling of read_terminal) that drops a process's read-only tab WITHOUT killing it via process_registry.on_close; output keeps buffering and the user can reopen from the status stack. - ⌘W now closes a focused agent tab: mark the agent instance data-terminal and focus it on activation so isFocusWithin routes there. - ensureTerminal() no longer spawns an extra user shell when a tab already exists (e.g. opening a background task from the status stack). --- .../app/right-sidebar/terminal/instance.tsx | 7 +- .../src/app/right-sidebar/terminal/rail.tsx | 7 +- .../app/right-sidebar/terminal/terminals.ts | 24 +++- .../terminal/use-agent-terminal.ts | 4 + .../app/session/hooks/use-message-stream.ts | 5 + tests/tools/test_process_registry.py | 112 ++++++++++++++++++ tools/close_terminal_tool.py | 69 +++++++++++ tools/process_registry.py | 64 +++++++++- toolsets.py | 9 +- tui_gateway/server.py | 41 +++++-- 10 files changed, 320 insertions(+), 22 deletions(-) create mode 100644 tools/close_terminal_tool.py diff --git a/apps/desktop/src/app/right-sidebar/terminal/instance.tsx b/apps/desktop/src/app/right-sidebar/terminal/instance.tsx index 23d905f0503..5e32c98710f 100644 --- a/apps/desktop/src/app/right-sidebar/terminal/instance.tsx +++ b/apps/desktop/src/app/right-sidebar/terminal/instance.tsx @@ -84,7 +84,12 @@ export function AgentTerminalInstance({ active, procId }: AgentTerminalInstanceP const { hostRef } = useAgentTerminal({ active, procId }) return ( -
+
  • {active && ( -