Wave Terminal

repository·main·Indexed 12 days ago

https://github.com/wavetermdev/waveterm

An open-source, AI-integrated terminal for macOS, Linux, and Windows. It features a block-based UI, durable SSH sessions, and Wave AI, a context-aware assistant supporting local models (Ollama, LM Studio) and providers like OpenAI, Claude, Gemini, and Azure. Includes the `wsh` command system for workspace management and AI integration.

Tokens
126.1K
Snippets
366
Records
555
Agent score
94%

What's inside Wave Terminal

  1. Overview of Wave Terminal

    main

    Wave Terminal is an open-source, AI-integrated terminal designed for macOS, Linux, and Windows. It features context-aware AI assistance, durable SSH sessions that persist through network interruptions or restarts, and a drag-and-drop interface for managing terminal blocks, editors, web browsers, and AI assistants. Key capabilities include:

    • Wave AI: A terminal assistant that understands terminal output, widgets, and can perform file operations (with user approval).
    • Durable SSH: Automatic reconnection and session persistence during network changes or application restarts.
    • Integrated Editor & Preview: Built-in editor for remote file editing and a rich preview system for Markdown, images, videos, PDF, CSV, and directories.
    • Command Blocks: Individual command isolation and monitoring.
    • WSH (Wave Shell): A powerful CLI system (wsh) for controlling workspaces, sharing data between sessions, and managing files via wsh file (copying/syncing between local and remote hosts).
    • Secure Secrets: Local storage of API keys and credentials using native system backends.
  2. Overview of the wsh command

    main

    The wsh command is Wave Terminal's core CLI. It enables interaction between terminal commands and Wave's graphical elements (blocks). Key capabilities include:

    • Controlling graphical widgets from the CLI.
    • Sharing data between terminal sessions and GUI components.
    • Managing workspaces programmatically.
    • Connecting local and remote environments.
    • Sending CLI output and files directly to AI conversations.
    • Running commands in isolated blocks.
  3. Understand the Tsunami AI Builder UI Layout

    main

    The Tsunami AI Builder uses a split-screen interface to facilitate iterative app development via AI chat:

    Left Panel

    • Chat: The primary interface for communicating with the AI to describe desired changes.

    Right Panel

    Top Section (Tabs):

    • Preview (Default): A live, auto-updating view of the running Tsunami application.
    • Code: A Monaco editor for manual editing of the app.go file.
    • Files: A browser for managing static assets (images, etc.).

    Bottom Section:

    • Build Panel: A closable panel showing compilation status, success messages, or detailed error messages with line numbers. It auto-runs after AI edits or manual code changes.
  4. What is UIMessage and how does it differ from ModelMessage?

    main

    A UIMessage is the source of truth for your application's UI state. It represents the complete message history, including metadata, data parts, and all contextual information required for rendering the UI and managing client-side functionality.

    Key Distinction:

    • ModelMessage: Represents the state or context passed specifically to the AI model.
    • UIMessage: Contains the full application state needed for the user interface.
  5. What is WSH (Wave Shell Extensions)?

    main

    WSH (wsh) is a cross-platform Go binary that runs on remote hosts to provide RPC services to Wave Terminal. It enables advanced features like file synchronization and deep shell integration.

    Key Components:

    • wsh version: Checks the installed version.
    • wsh connserver: A long-running RPC server that handles file operations, command execution, and remote state information via a domain socket.

    Installation Process: If WSH is missing or outdated, Wave Terminal will:

    1. Detect the remote platform using uname -sm.
    2. (Optional) Prompt the user for permission.
    3. Copy the appropriate binary to ~/.waveterm/bin/wsh on the remote host.
    4. Set executable permissions and restart the connection process.

    Modes of Operation:

    • With WSH: Full RPC support, file sync, and enhanced integration.
    • Without WSH: Fallback mode providing basic shell access only.
  6. How Claude Code badges work in Wave

    main

    Wave uses the wsh badge command to set or clear visual indicators on the current block or tab.

    Key Behaviors:

    • Auto-clear: Badges automatically disappear when you focus the block (click into it). They serve as transient "look here" signals.
    • Badge Rollup: If a tab contains multiple terminals (blocks), Wave displays the badge with the highest priority on the tab header. If priorities are tied, the earliest badge set is shown.
    • Priority Levels: Higher numbers take precedence. It is recommended to use high priorities (15–25) for permission-blocking signals and low priorities (5–10) for informational signals.

    Customization:

    • Icons: Use Font Awesome icon names (excluding the fa- prefix).
    • Colors: Use any valid CSS color (hex, named colors, etc.).
  7. Use Wave AI with terminal context and CLI

    main

    Wave AI is a context-aware assistant that can access your workspace to assist with debugging and file operations.

    Capabilities

    • Terminal Context: Reads terminal output and scrollback for analysis.
    • File Operations: Can read, write, and edit files (requires user approval and includes automatic backups).
    • Local Models: Supports Ollama, LM Studio, and other OpenAI-compatible providers.
    • BYOK: Supports OpenAI, Claude, Gemini, Azure, and Perplexity.

    CLI Integration

    You can use the wsh ai command to pipe output or attach files directly from the command line to the AI assistant. For more detailed usage, refer to the Wave AI documentation.

  8. How the Tab Layout System works

    main

    Wave Terminal uses a tiling layout system that emulates CSS Flexbox. A tab is composed of a tree of nodes (an n-tree) where each node is either a single Block (a leaf containing a widget) or an ordered list of nodes.

    Layout Mechanics

    • Tiling Direction: The system alternates tiling directions by level. Level 1 tiles as a row, Level 2 as a column, Level 3 as a row, and so on.
    • Node Structure: A node defines a tiling direction and a unitless size. The ratio of node sizes at a given level determines their displacement.
    • Automatic Placement: When adding new blocks (via the right sidebar), they are added to the right of existing blocks in a row. Once a node reaches 5 children, new blocks are added below existing ones, converting the node into a list node and moving the existing block one level deeper in the tree.
    • Performance: While there is no hard limit on blocks, performance may degrade beyond approximately 25 blocks per tab.
  9. How the Wave Terminal Focus System works

    main

    Wave Terminal uses a multi-layered focus system to coordinate visual feedback, layout state, and actual browser interaction. It separates concerns into four distinct layers:

    1. Layout Focus State: Managed via Jotai atoms (e.g., nodeModel.isFocused) to track which block is logically focused.
    2. Visual Focus Ring: CSS styling that provides immediate feedback to the user.
    3. DOM Focus: The actual browser focus on interactive elements (like an input or terminal).
    4. View-Specific Focus: Custom logic implemented by view models (e.g., XTerm terminal focus) to handle specialized input requirements.

    This separation allows the UI to show a focus ring immediately on mousedown (Visual Focus) while deferring the actual DOM focus until the click interaction is complete, preventing the disruption of text selections.

  10. Calculate total input tokens for billing

    main

    Anthropic's API bills and rate-limits based on token counts. When calculating total input tokens for a request, you must sum the following three fields from the usage object:

    1. input_tokens
    2. cache_creation_input_tokens
    3. cache_read_input_tokens

    Note that output_tokens will be non-zero even for an empty string response due to internal API transformations.