Skip to content

Terminal cards in the session view#95

Merged
stippi merged 55 commits intomainfrom
feature/terminal-cards
Mar 28, 2026
Merged

Terminal cards in the session view#95
stippi merged 55 commits intomainfrom
feature/terminal-cards

Conversation

@stippi
Copy link
Copy Markdown
Owner

@stippi stippi commented Mar 17, 2026

No description provided.

stippi added 30 commits March 11, 2026 18:39
Phase 1-3 of terminal cards implementation:

- terminal crate: Wraps alacritty_terminal (Apache-2.0) as a GPUI entity
  with PTY and display-only modes, event processing, content snapshots
- terminal_view crate: GPUI Element that renders the terminal cell grid
  with full ANSI color support, embedded/scrollable modes
- Integration: ExecuteCommandOutputRenderer feeds command output into a
  display-only terminal for rich rendering with colors

The renderer uses the existing ToolOutputRendererRegistry pattern,
creating display-only Terminal entities that process ANSI escape codes
via alacritty's VTE parser and render styled cells via GPUI's text system.

Branch: feature/terminal-cards
Replace DefaultCommandExecutor with GpuiTerminalCommandExecutor in the
GPUI UI so that execute_command tool invocations run inside real PTY
terminals. Terminal output appears as live cards in the chat with full
ANSI color rendering, a header showing the command and status, colored
borders (gray=running, green=success, red=error), and collapse/expand.

New files:
- terminal_pool.rs: global pool of Entity<Terminal> keyed by terminal_id
  with a (session_id, tool_id) -> terminal_id secondary index
- terminal_executor.rs: GpuiTerminalCommandExecutor using a worker/channel
  bridge to create PTY terminals on the GPUI foreground thread; each
  command runs as an independent task for concurrency; falls back to
  DefaultCommandExecutor if the worker is unavailable

Modified files:
- terminal_output_renderer.rs: rewritten to prefer live PTY terminals
  from the pool, falling back to display-only terminals for session
  restoration from persistence
- mod.rs: register terminal worker at startup, handle ToolTerminal
  fragments to store tool_id -> terminal_id mappings
- app/gpui.rs, backend.rs: inject GpuiTerminalCommandExecutor
- ui_events.rs: add ToolTerminalAttached event variant
- acp/ui.rs: handle new event variant (no-op for ACP)
…d state

- Switch font from Berkeley Mono to Menlo (system monospace, always
  available on macOS) — fixes wide character spacing
- Add Terminal::content_lines() that counts lines with actual content
  (cursor position + scrollback) instead of total grid rows
- Use content_lines() in TerminalView::content_mode() so cards grow
  dynamically as output appears rather than starting at max height
- Reduce max_lines_when_unfocused from 1000 to 50 for a reasonable
  card height that stays in Inline mode
- Fix UTF-8 panic in terminal_executor: switch delta tracking from
  byte offsets to character counts, avoiding slicing inside multi-byte
  characters when get_content_text() content shifts between reads
- Keep tools with custom output renderers (execute_command, spawn_agent)
  expanded after completion so terminal cards remain visible
- Remove the terminal card's own header and collapse toggle (the tool
  block already provides these)
- Remove the card border (tool block has its own visual framing)
- Make execute_command's command_line parameter full-width so long
  commands display properly instead of being truncated in the header
- Clean up dead code (collapse state, card helper functions, unused imports)
stippi added 25 commits March 26, 2026 22:55
Fixes fallback for detecting finished terminals via timeout
Fixes glaring markdown inline code spens
- inline tools not animating
- a bug when expanding thinking blocks (flashing at full height for one frame)
Replacement versus append. Fixes unified diffs in the new diff cards
@stippi stippi marked this pull request as ready for review March 28, 2026 19:07
@stippi stippi merged commit 9ffa9ab into main Mar 28, 2026
1 check passed
@stippi stippi deleted the feature/terminal-cards branch March 28, 2026 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant