projects / anvil

Source Tools 2026

Anvil

A tiling canvas of terminals per project. Wails v2 shell, Svelte 5 frontend, Go PTY backend, one ~25 MB binary.

Anvil canvas with tiled terminal sessions and a minimap
  • ~25 MB Single Wails binary Release build
  • 16 ms Output batch window, 64 KB cap PTY batcher
  • 50 ms Resize debounce for ConPTY PTY manager

Overview

Problem

Terminal output arrives in many small reads, and forwarding each one through the webview JSON channel freezes the UI the moment a shell gets chatty.

Approach

A Go PTY backend coalesces output per session and flushes every 16 ms or 64 KB, then sends one base64-framed event across the Wails bridge to a Svelte 5 frontend.

Result

Same bytes, one event per flush instead of one per read, and no jank, in a single binary built for Windows, macOS and Linux.

Keybindings persist as diffs against defaults, so shipping a new default never requires a migration script.

On settings

Decisions · why this stack

  1. Batch PTY output

    A per-session batcher flushes every 16 ms or 64 KB and emits one event per flush, so cat on a large file or npm install never wedges the webview.

  2. Base64 for keystrokes

    Wails serialises IPC payloads as JSON, which mangles arrow keys, Alt sequences and paste markers, so keystrokes travel base64-encoded.

  3. Runes as app state

    Five .svelte.ts modules own the client with $state and $derived. No store library, and the palette and shortcuts share one keybinding registry.

  4. Atomic persistence

    Writes go to a .tmp sibling and rename into place, so a crash cannot leave an empty file, and a stale reorder never drops projects.

  5. One artifact everywhere

    The frontend is embedded with go:embed and go-pty picks ConPTY or a native PTY, so the same Session API runs on every platform.

Stack

  • Go
  • go-pty
  • Wails v2
  • Svelte 5
  • TypeScript
  • xterm.js
  • Vite
  • ConPTY

Architecture

§ System Architecture

One window. One binary. Three runtimes humming in lockstep.

Wails wraps a Svelte 5 (runes) frontend and a Go PTY backend into a single ~25 MB binary. The non-trivial piece is the seam between them: a coalesced event-bus that keeps the webview alive under high-throughput shell output.

Anvil architecture: Wails v2 shell with Svelte 5 frontend, Wails IPC event bus, Go PTY backend (output batcher, pty.Manager, projects store), go-pty bridge to ConPTY/Unix PTY, atomic JSON store at ~/.config/anvil/
FIG 01 Wails IPC · PTY pipeline · persistent store

Demo

Numbers

By the numbers

  • 64 KB Batch flush threshold PTY backend
  • 32 KB Read buffer per session PTY backend
  • 5 Runes state modules Frontend
  • 6 Shells auto-detected on PATH Shell picker