Terminals

Terminal & Message Bus

Terminal windows are project-aware command surfaces. The message bus lets terminals subscribe to named channels and execute commands broadcast by other terminals.

Terminal Model

TerminalManager owns open terminal objects, selected terminal state, chat messages, system metrics, and window creation. SwiftTerminal tracks terminal identity, name, project path, engine, session ID, command history, current path, status, terminal view mode, and message bus subscriptions.

The app also includes GhosttyTerminal, which bridges Ghostty terminal rendering into an AppKit view for a richer terminal experience.

Terminal Features

Message Bus Concepts

ConceptDescription
ChannelA named topic such as dev, test, or monitoring.
SubscriberA terminal registered to receive messages for a channel.
PublisherA terminal that sends a command to a channel.
ResponseCaptured output routed back to the originating terminal when response collection is enabled.

Basic Message Bus Workflow

  1. Open two or more terminal windows.
  2. Open the message bus panel from the terminal header.
  3. Subscribe receiving terminals to the same channel.
  4. Publish a command to that channel from a sender terminal.
  5. Subscriber terminals execute the command and send output back to the sender.

API Shape

// Terminal-level helpers
terminal.subscribeToChannel("dev")
terminal.unsubscribeFromChannel("dev")
terminal.publishCommand("git status", toChannel: "dev", expectResponse: true)

// Bus-level helpers
MessageBus.shared.getActiveChannels()
MessageBus.shared.getChannelInfo()

Practical Patterns

Monitoring

Subscribe several service terminals to monitoring, then broadcast uptime, pwd, or health commands.

Distributed Testing

Subscribe app, worker, and staging terminals to test, then broadcast test commands and compare responses.

Agent Coordination

Use channels to tell multiple project terminals to inspect status, branch state, or logs before assigning work.

Safety Notes

Message bus subscribers execute received commands automatically. Use explicit channel names and avoid subscribing terminals that point at production or sensitive directories unless command broadcast is intended.