Atuin Desktop Documentation

repository·main·Indexed 25 days ago

https://github.com/atuinsh/desktop

Atuin Desktop is a local-first, executable runbook editor for terminal-heavy workflows. It transforms static documentation into actionable workflows by allowing users to chain shell commands, database queries, and API requests. Key features include executable blocks (Directory, Kubernetes, Script, Terminal, etc.), monitoring blocks for Prometheus metrics, network blocks for HTTP and SSH, and a CRDT-powered architecture that syncs via Atuin Hub.

Tokens
56K
Snippets
115
Records
327
Agent score
81%

What's inside Atuin Desktop

  1. What is Atuin Desktop?

    main

    Atuin Desktop is a local-first, executable runbook editor designed for terminal-heavy workflows. It bridges the gap between static documentation and automation by allowing users to create executable runbooks.

    Core Concepts

    • Executable Runbooks: Instead of just reading instructions, you can execute shell commands, database queries, and HTTP requests directly within the document.
    • Embedded Execution: The interface includes terminal blocks for direct execution, database clients for live queries, and integrations for monitoring tools like Prometheus.
    • Dynamic Templating: Uses Jinja-style templating to allow for variable substitution, conditional logic, and parameterized workflows (e.g., switching between staging and production environments).
    • Local-First & Sync: Built with a CRDT-powered architecture, it works offline and synchronizes with Atuin Hub when connected, enabling collaborative runbook management.
  2. Overview of Atuin Desktop features

    main

    Atuin Desktop is a collaborative, block-based editor designed to transform operational workflows into executable runbooks. Instead of static documentation, users create runbooks that combine rich text with live automation components.

    Key capabilities include:

    • Executable Blocks: Run scripts, execute terminal commands, and automate workflows.
    • Database Blocks: Connect to and query MySQL, PostgreSQL, ClickHouse, and SQLite.
    • Dynamic Templating: Use variables to create reusable runbooks.
    • Real-time Collaboration: Work with teams on incident response and deployments via the Atuin Hub.
    • AI Assistant: Use natural language to create and edit runbooks.
  3. Use Network Blocks to interact with remote services

    main

    Network blocks allow you to explore and interact with external systems, APIs, and remote servers. They are primarily used for API testing, system monitoring, and performing remote operations directly from the Atuin Desktop environment.

    There are two main types of network blocks available:

    1. HTTP: Used to make HTTP requests to APIs and web services. This block provides full control over request methods (GET, POST, etc.) and headers.
    2. SSH: Used to execute commands on remote systems securely via SSH connections.
  4. Use Database Blocks in Runbooks

    main
    Database blocks allow you to integrate database querying directly into your Atuin runbooks. You can connect to several database types to perform analytics, OLAP queries, or lightweight local operations. All input fields in these blocks are processed through the Atuin templating system, allowing you to parameterize queries using variables.
  5. Use Monitoring Blocks for real-time system insights

    main
    Monitoring Blocks allow you to observe system health and performance metrics directly within your runbooks. They enable you to keep track of system status while simultaneously executing queries and commands. Currently, the available monitoring capabilities focus on querying metrics and creating custom dashboards.
  6. Understand why scripts might fail in Atuin Desktop

    main

    Script blocks in Atuin Desktop run as non-interactive shells. Unlike the interactive shell you use in a terminal emulator, non-interactive shells do not load your full shell configuration (like .zshrc or .bashrc).

    If a command works in your terminal but fails in an Atuin script block, it is likely because the command's location (its PATH) or its environment variables are defined in a configuration file that is only loaded for interactive shells.

  7. Use Online Workspaces for collaboration

    main

    Online workspaces are synced to the Atuin Hub.

    Key Characteristics:

    • Automatic Sync: All runbooks added to an online workspace are automatically saved to the Hub.
    • Requirements: You must be online and logged in to the Hub to create or edit these workspaces.
    • Collaboration: Multiple collaborators or team members can edit runbooks within an online workspace simultaneously.
  8. Identify and use Execution vs. Context blocks

    main

    Blocks in Atuin Desktop are categorized by their primary function: performing work or modifying the environment.

    Execution Blocks

    These blocks perform active tasks such as running commands, making network requests, or querying data:

    • Script: Executes shell commands.
    • Terminal: Starts interactive terminal sessions.
    • Http: Performs HTTP requests.
    • Postgres, MySQL, SQLite, Clickhouse: Executes database queries.
    • Prometheus: Performs metrics queries.

    Context Blocks

    These blocks modify the execution environment for all subsequent blocks in the runbook using the passive_context method:

    • Directory: Changes the working directory.
    • LocalDirectory: Changes the working directory (note: this change is not persisted in the Runbook).
    • Environment: Sets environment variables.
    • Host: Selects a host for SSH connections.
    • SshConnect: Configures SSH connection settings.
    • Var: Sets document-level variables.
    • LocalVar: Sets a variable (note: this change is not persisted in the Runbook).
  9. Markdown Render block features

    main

    The Markdown Render block includes several interactive features:

    • Collapse/Expand: Toggle between a compact view and a full expanded view. A gradient fade indicates additional content when collapsed.
    • Fullscreen Mode: Open the content in a fullscreen modal for better readability. Press Escape or click outside to close.
    • Selectable Text: All rendered content is fully selectable and copyable.
    • View Mode vs Edit Mode: In edit mode, you can configure settings like the variable name and line count. In view mode (during runbook execution), only the variable name and the rendered content are visible.
  10. Work with Blocks in Atuin Desktop

    main

    Blocks are interactive components that execute commands, query databases, or make network requests. They are the core automation unit of a runbook.

    To create a block, type / anywhere in your runbook to open the block picker. Blocks are categorized into:

    • Executable: Scripts, terminals, and command execution.
    • Databases: Query MySQL, PostgreSQL, ClickHouse, SQLite.
    • Network: HTTP requests, SSH connections.
    • Monitoring: Prometheus metrics and system monitoring.
  11. Architecture of the Grand Central Event System

    main

    The Grand Central (GC) event system is a robust, type-safe foundation for event-driven communication in Atuin Desktop. It facilitates communication between the backend (Rust) and the frontend (TypeScript) while maintaining strict architectural boundaries.

    Key Architectural Benefits

    • Boundary Preservation: The runtime layer maintains zero Tauri dependencies and uses clean interfaces (event emission through traits rather than concrete types) to ensure isolation.
    • Type Safety: The system uses ts-rs to ensure that frontend TypeScript types match backend Rust types, providing compile-time guarantees and full IDE autocomplete.
    • Performance: Events are emitted asynchronously to prevent blocking execution. The system uses a single efficient transport channel and supports selective subscription so components only process relevant events.
    • Maintainability: All events are centralized in one system, making the system self-documenting and easy to extend without breaking changes.
    • Developer Experience: Provides a global instance for easy access, simple subscription patterns, and automatic lifecycle management (cleanup and error handling).
  12. Understand the Atuin Desktop Execution Flow

    main

    The execution system follows a specific lifecycle for managing runbooks (documents) and their constituent blocks:

    1. Document Opening: Triggered by open_document. The system creates a DocumentHandle, spawns a DocumentActor, parses blocks, loads active contexts from disk, and builds initial passive contexts.
    2. Document Updates: Triggered by update_document. The actor identifies changed blocks, determines the earliest index requiring a rebuild, and rebuilds passive contexts for affected blocks, sending updates to the frontend.
    3. Block Execution: Triggered by execute_block. The system creates an ExecutionContext using a ContextResolver (built from all blocks above the target), clears the block's active context, and calls block.execute(context).
    4. Async Execution: Blocks typically spawn background tasks (e.g., via tokio::spawn). During execution, blocks can update their active context with output variables and finally update their execution status.
    5. Handle Management: Execution handles are stored in state.block_executions to allow for task cancellation.
    #[tauri::command]
    pub async fn open_document(
        state: State<'_, AtuinState>,
        document_id: String,
        document: Vec<serde_json::Value>,
        document_bridge: Channel<DocumentBridgeMessage>,
    ) -> Result<(), String>