Skip to content

Feature: TerminalGrid — Layout manager for tabs, splits, and state-aware styling #28

@holiber

Description

@holiber

Summary

Add a TerminalGrid component (or similar high-level layout manager) that sits on top of <JabTerm> and provides:

  1. Tabbed terminals — Create, close, and switch between multiple terminal sessions via a tab bar.
  2. Split panes — Split any terminal horizontally or vertically to view multiple sessions side-by-side (VS Code / tmux style).
  3. State-aware tab colors — Each tab automatically reflects the terminal's current state through color coding:
    • 🔵 Blue — Idle, waiting for user input
    • 🟢 Green / Lime — Process is running
    • 🟠 Orange — Errors detected in stderr
    • Gray — Disconnected / closed

Motivation

When embedding terminals in web applications (dashboards, AI agent UIs, DevOps panels), users almost always need multiple terminals with a way to organize them visually. Currently each <JabTerm> is independent, so the consuming app has to build its own tab bar, split logic, and state detection from scratch.

A first-party layout manager would make JabTerm a drop-in replacement for a full terminal experience.

Proposed API (rough sketch)

import { TerminalGrid } from 'jabterm/react';

<TerminalGrid
  wsUrl="ws://localhost:3223"
  defaultLayout={{
    type: 'tabs',
    children: [
      { id: 'main', title: 'Main' },
      { id: 'build', title: 'Build' },
      {
        type: 'split-h',
        children: [
          { id: 'logs', title: 'Logs' },
          { id: 'tests', title: 'Tests' },
        ],
      },
    ],
  }}
  tabColors={{
    idle: '#6366f1',      // indigo/blue
    running: '#84cc16',   // lime/green
    error: '#f97316',     // orange
    disconnected: '#6b7280', // gray
  }}
  onLayoutChange={(layout) => saveToLocalStorage(layout)}
/>

State detection approach

Terminal state could be inferred by combining:

  • data-jabterm-state (already exists: connecting | open | closed) → maps to disconnected
  • PTY child-process activity (server-side: is the foreground process running?) → running vs idle
  • stderr marker detection (opt-in, via ANSI escape or heuristic) → error

Scope

  • TerminalGrid React component with tab bar
  • Horizontal and vertical split support (draggable dividers)
  • State-aware tab styling (color + optional icon/badge)
  • Keyboard shortcuts (e.g. Cmd+T new tab, Cmd+D split, Cmd+W close)
  • Persistent layout via onLayoutChange callback
  • Server-side: expose process state per terminal session (new WS message or REST endpoint)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions