NyaTerm Documentation

repository·main·Indexed 21 days ago

https://github.com/nyakang/nyaterm

A modern, high-performance remote terminal workspace built with Tauri, React, and Rust. NyaTerm supports SSH, SFTP, Telnet, and Serial devices, featuring a tabbed interface with pane splits, an integrated AI assistant for command generation and error analysis, and encrypted configuration sync. It includes a built-in SFTP browser with a local-edit-then-upload workflow and real-time remote monitoring for resource usage, NVIDIA GPU metrics, and Docker management.

Tokens
63.9K
Snippets
182
Records
351
Agent score
73%

What's inside NyaTerm

  1. What is NyaTerm and its core capabilities

    main

    NyaTerm is a modern desktop client designed for SSH-centric operations and mixed terminal workflows. It is built with Tauri, React, and Rust.

    Key Capabilities:

    • Session Support: Connects to SSH, Local Shells, Telnet, and Serial devices. It is a client for these protocols, not a shell replacement.
    • Workspace Management: Provides a tabbed interface with horizontal and vertical pane splits, tab docking, and layout restoration.
    • SFTP Integration: Includes a built-in SFTP browser for remote file management and a transfer queue.
    • AI Assistance: Features an integrated AI panel for command generation, error analysis, and multi-step terminal workflows.
    • Security: Offers credential management, OTP (TOTP/HOTP) support, and encrypted sync/backup.
    • Remote Monitoring: Provides real-time monitoring for SSH sessions, including resource usage, NVIDIA GPU metrics, process management, and Docker management.
  2. Overview of NyaTerm capabilities

    main

    NyaTerm is a modern remote terminal workspace built with Tauri, React, and Rust. It is designed for SSH operations, DevOps, and hybrid terminal workflows. It provides a unified desktop client to manage multiple connection types and workflows in a single workspace.

    Core Capabilities:

    • Session Management: Supports SSH, local Shell, Telnet, and Serial (UART) sessions.
    • Workspace Organization: Uses tabs with support for horizontal/vertical splitting, tab docking, and layout recovery.
    • SFTP & File Workflows: Integrated SFTP browser with a transfer queue and a "local edit and upload" workflow.
    • AI Assistance: Built-in AI panel for command generation, error analysis, and multi-step agentic tasks.
    • Security & Networking: Manages credentials, private keys, OTP (TOTP/HOTP), SSH tunnels (local/remote/dynamic), jump hosts, and proxies (SOCKS5/HTTP).
    • Sync & Backup: Encrypted configuration synchronization via WebDAV, S3-compatible storage, or GitHub Gist.
  3. Understand the NyaTerm Architecture

    main

    NyaTerm is a desktop application built on Tauri 2. It follows a split architecture where the frontend and backend communicate via Tauri commands and events.

    Frontend (React / TypeScript)

    • Main Window: Uses AppProvider and App.tsx to manage the primary workspace.
    • Child Windows: Uses ChildAppProvider and ChildWindowRouter for specialized tasks like settings, new connections, or command editing.
    • Communication: Uses an invoke wrapper for commands and Tauri event listeners for backend-to-frontend updates.

    Backend (Rust)

    • Core Managers: Handles sessions (SessionManager), tunnels (TunnelManager), recordings (RecordingManager), authentication (PendingAuthManager), and cloud synchronization (CloudSyncManager).
    • Capabilities: Provides SSH, SFTP, local PTY, Telnet, Serial, file watching, session importing (Xshell/MobaXterm/WindTerm), and AI integration.
    • Persistence: Uses redb for high-performance storage and encrypted credential management.
  4. Navigate the Frontend Directory Structure

    main

    The src/ directory is organized as follows:

    • components/: UI components, subdivided into dialog/, panel/, terminal/, layout/, and ui/ (shadcn/ui).
    • context/: React Context providers for state management.
    • hooks/: Custom React hooks.
    • i18n/: Internationalization files.
    • lib/: Core utilities including invoke wrappers, window management, and the workspace model.
    • pages/: Page components for child windows.
    • types/: TypeScript type definitions.
    • App.tsx: The main application shell.
    • main.tsx: The frontend entry point.
  5. Use SSH Multiplexing

    main

    NyaTerm supports SSH multiplexing, allowing multiple terminal sessions to run over a single established SSH connection. When opening a new terminal to the same host, NyaTerm reuses the existing authenticated connection.

    Benefits:

    • Faster new terminal startup.
    • Fewer authentication prompts or OTP entries.
    • Reduced load on the server.
  6. Understand the NyaTerm Frontend Entry and Window Model

    main

    The frontend is built with React 19 and TypeScript, located in src/. The entry point src/main.tsx determines which application set to load based on the ?window= URL parameter:

    • Main Window: Uses AppProvider and App.tsx.
    • Child Windows: Uses ChildAppProvider and ChildWindowRouter.tsx.

    Common child windows include:

    • settings
    • new-session
    • quick-command
    • auto-upload

    If you need to modify the window loading logic, refer to src/main.tsx, src/ChildWindowRouter.tsx, or src/lib/windowManager.ts.

  7. Handle interactive authentication requests

    main

    When a server requires additional keyboard interaction, OTP, or re-authentication, NyaTerm uses a dedicated SSH authentication request window. This prevents prompts from being mixed into the standard terminal output, allowing you to clearly distinguish between:

    • Standard password/private key authentication
    • Keyboard-interactive authentication
    • OTP or second-factor confirmation prompts
    • Authentication flows that require a restart
  8. Understand NyaTerm data storage and encryption

    main

    Data is persisted in ~/.nyaterm/nyaterm.redb and managed by src-tauri/src/storage.rs and src-tauri/src/config/.

    Redb Document Types

    • JSON Documents: settings, sessions, keys, passwords, otp, quick-command, tunnels, proxies, history, cloud-sync, cloud-sync-state, ai-history, ai-audit.
    • Text Documents: known_hosts, master.key.

    Security

    Sensitive fields are encrypted before being written to disk. When adding new configuration items, developers must determine if they fall within the sensitive data boundary requiring encryption.

  9. Use the NyaTerm AI Assistant modes: Ask and Agent

    main

    The NyaTerm AI Assistant operates in two distinct modes depending on your goal:

    1. Ask Mode (Default): Best for single-turn interactions. Use this to:

      • Generate commands.
      • Explain terminal output.
      • Analyze errors.
      • Derive fix commands from selected text.
      • Commands are returned as structured cards with risk level annotations.
    2. Agent Mode: Best for multi-step autonomous tasks. It uses a ReAct loop (Observe $\rightarrow$ Decide $\rightarrow$ Execute $\rightarrow$ Observe) to complete complex tasks like troubleshooting, building, or deployment checks.

      • Requires an active terminal session.
      • Displays execution status for every step (Running, Completed, Failed, Timed Out, Needs Approval, or Blocked by Security Policy).
      • Commands are executed in the terminal, and the Agent provides a final summary via a dedicated tool rather than mixing it with command output.

    Configuration: You can configure maximum steps and single-step timeouts in Settings $\rightarrow$ AI $\rightarrow$ Agent Settings.

    // Agent Mode Workflow Example:
    1. Agent proposes command
    2. Command passes risk/policy check
    3. Command executes in terminal
    4. Agent observes output
    5. Agent provides 'Final Answer' summary
  10. How OTP relates to Passwords and Private Keys

    main

    OTP is not a replacement for passwords or private keys; it is a secondary factor used in combination with them. NyaTerm supports the following authentication patterns:

    • Password + OTP
    • Private Key + OTP

    Best Practice: Organize your credentials in the Security/Auth panel first (separately managing passwords, private keys, and OTPs), then bind them to specific SSH connections. This keeps connection configurations clean and allows for easier bulk updates to authentication materials.

  11. How to resolve Cloud Sync conflicts

    main

    A conflict occurs when both the local state and the remote state have changed since the last synchronization. NyaTerm provides a conflict preview showing the local snapshot hash, remote revision, and remote device info.

    Because NyaTerm performs snapshot-level synchronization rather than field-level merging, you must choose one of two resolutions:

    1. Download Remote Version: Overwrites your local configuration with the version from the cloud. Use this if the cloud version is the correct one and you want to discard local changes.
    2. Upload Local Version: Forces your current local snapshot to overwrite the remote state. Use this if your local configuration is the most up-to-date and you want other devices to follow it.