Skip to content

Add Tauri commands and xterm.js terminal UI for PTY agent sessions #1120

Closed

Description

@malibio

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.svelte renders a list of available agents (from ListSessions / agent catalog), a text input for the initial prompt, and a "Launch" button
  • Clicking "Launch" calls LaunchSession via Tauri command and opens a terminal pane
  • PtyTerminal.svelte renders xterm.js and streams output received from StreamOutput
  • 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 wrapper
  • packages/desktop-app/src/lib/components/agent/AgentLaunchPanel.svelte — launch UI
  • packages/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

Dependencies

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

  1. malibio commented on May 18, 2026

    @malibio
    CollaboratorAuthor

    Frontend baseline: 128 files, 3916 tests passed

  2. self-assigned this
    on May 18, 2026
  3. added a commit that references this issue on May 18, 2026
    637d3c1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions