Repository navigation
Description
Overview
Build the desktop UI surface for PTY agent sessions: Tauri command proxies that call AgentSessionService via gRPC, an xterm.js-powered PtyTerminal.svelte component that renders live terminal output, and an AgentLaunchPanel.svelte that lets users pick an agent, write a prompt, and start a session.
Problem Statement
After #1119, PTY sessions are accessible via gRPC but there is no way to interact with them from the desktop UI. Users need a terminal-like view that streams output in real time, accepts keyboard input, and supports resize — the same experience as a native terminal window, embedded in NodeSpace.
Proposed Solution
PtyTerminal.svelte wraps xterm.js and connects to a session's StreamOutput gRPC stream (bridged through a Tauri command). Keyboard events are forwarded to WriteInput. The terminal div's ResizeObserver fires ResizeTerminal calls. AgentLaunchPanel.svelte exposes agent selection, an optional initial prompt input, and a launch button that opens a PtyTerminal pane.
Acceptance Criteria
-
AgentLaunchPanel.svelterenders a list of available agents (fromListSessions/ agent catalog), a text input for the initial prompt, and a "Launch" button - Clicking "Launch" calls
LaunchSessionvia Tauri command and opens a terminal pane -
PtyTerminal.svelterendersxterm.jsand streams output received fromStreamOutput - Keyboard input in the terminal is forwarded to
WriteInput - Terminal resize (component resize / window resize) calls
ResizeTerminal - Sessions panel shows all active sessions from
ListSessions; each has a "Terminate" button - Terminating a session closes the terminal pane and cleans up
- xterm.js fits the parent container (no fixed width/height)
- All existing frontend tests pass (
bun run test:all) - Code passes
bun run quality:fix
Technical Specifications
New frontend files
packages/desktop-app/src/lib/components/agent/PtyTerminal.svelte— xterm.js wrapperpackages/desktop-app/src/lib/components/agent/AgentLaunchPanel.svelte— launch UIpackages/desktop-app/src/lib/components/agent/SessionsPanel.svelte— active sessions list
New Tauri command files
packages/desktop-app/src-tauri/src/commands/agent_session.rs— gRPC proxy commands:launch_session,write_input,resize_terminal,terminate_session,list_sessions- Output streaming is handled via a dedicated Tauri event channel (see below)
xterm.js dependency
// packages/desktop-app/package.json
"@xterm/xterm": "^5.5",
"@xterm/addon-fit": "^0.10"PtyTerminal.svelte structure
<script lang="ts">
import { Terminal } from '@xterm/xterm';
import { FitAddon } from '@xterm/addon-fit';
let { sessionId } = $props<{ sessionId: string }>();
// Mount xterm.js, subscribe to output events via Tauri listen(),
// forward keystrokes via invoke('write_input', { sessionId, data })
// FitAddon + ResizeObserver → invoke('resize_terminal', { sessionId, cols, rows })
</script>
<div bind:this={terminalEl} class="pty-terminal" />Output streaming bridge
Because gRPC server-streaming cannot be directly exposed as a Tauri command return value, the Tauri backend spawns a task per session that reads StreamOutput and emits Tauri events keyed by session ID:
// In launch_session command handler:
tokio::spawn(async move {
let mut stream = agent_client.stream_output(...).await?.into_inner();
while let Some(chunk) = stream.next().await {
app_handle.emit(&format!("pty-output-{}", session_id), chunk.data)?;
}
});The PtyTerminal.svelte component listens on pty-output-{sessionId} and writes to the xterm.js terminal.
Reference files
packages/daemon/proto/agent_session_service.proto— service interface (from Define protobuf schema and set up tonic/prost build pipeline for nodespaced #1111)packages/desktop-app/src-tauri/src/commands/nodes.rs— existing gRPC proxy command pattern (from Migrate Tauri command handlers to thin gRPC proxy wrappers #1113)packages/desktop-app/src/lib/components/— existing component patterns for structural reference
Dependencies
- Migrate Tauri command handlers to thin gRPC proxy wrappers #1113
- Implement AgentSessionService gRPC handler in nodespaced #1119
Non-Goals
- Session capture UI settings (separate issue)
- Agent binary detection / availability indicators (separate issue)
- Split-pane layout or multi-terminal tabs (future)
- Scrollback buffer persistence across app restarts (future)
Activity
malibio commentedon May 18, 2026
Frontend baseline: 128 files, 3916 tests passed
Add Tauri commands and xterm.js terminal UI for PTY agent sessions (c…
Add Tauri commands and xterm.js terminal UI for PTY agent sessions (#…