khairold
← Back to Work

PiBun

A native desktop GUI for the Pi coding agent — chat, terminal, git, plugins, themes — built with Electrobun, React, and Bun. Open source.

March 2026
ElectrobunReactBunTypeScriptPiWebSocketOpen Source

Why

I use Pi as my primary coding agent. It’s fast, extensible, and gets out of the way. But I was spending all day in a terminal — scrolling back through long conversations, losing context when tool output flew past, restarting processes to switch sessions. The terminal is great for the agent. It’s not great for the human watching the agent.

I wanted a proper window: see the conversation, see the tool calls, see the git diff, open a terminal, switch between projects — without leaving the app. Something native and fast, not a bloated Electron wrapper.

Nothing like that existed for Pi. So I built it.

The Problem

Pi is a powerful CLI coding agent, but terminals have limits. Long conversations scroll off-screen. Tool output — diffs, syntax-highlighted code, bash results — deserves better than monospace. Session management means restarting processes. There’s no way to glance at what the agent is doing without alt-tabbing into a terminal.

The Solution

PiBun gives Pi a visual interface — streaming conversations, tool call cards, thinking blocks, session controls, model switching — all in a native desktop app that’s 20MB and launches instantly.

The server spawns pi --mode rpc as a subprocess and bridges JSONL events over WebSocket to a React UI. Electrobun wraps everything into a native app using the OS’s webview — no bundled Chromium.

Architecture

┌──────────────┐     WebSocket       ┌──────────────┐     stdio/JSONL     ┌──────────┐
│  React UI    │ ◄──────────────────►│  Bun Server  │ ◄──────────────────►│ pi --rpc │
│  (Vite)      │                     │              │                     │          │
│  Chat, Tools │                     │  Bridge      │                     │ LLM API  │
│  Sessions    │                     │              │                     │ Tools    │
└──────────────┘                     └──────────────┘                     └──────────┘
         ▲                                  ▲
         └──────── Electrobun webview ──────┘

Core principle: Pi handles state. The server is a thin bridge. Don’t reimplement what Pi already does.

Features

  • Streaming chat — text deltas rendered in real-time with Markdown and syntax highlighting
  • Tool call cards — bash output as terminal blocks, file reads as highlighted code, edits as diff views
  • Thinking blocks — collapsible, streaming reasoning from Claude
  • Projects — organize work by project, switch between them, browse past sessions
  • Built-in terminal — full PTY terminal tabs alongside chat, scoped to each project
  • Git integration — branch, status, changed files, inline diffs with syntax highlighting
  • Session export — save conversations as HTML, Markdown, or JSON
  • Themes — 5 built-in themes, follows system dark/light preference
  • Plugins — sandboxed iframe plugin system with a postMessage bridge
  • Model switching — any model Pi supports, adjustable thinking level on the fly
  • Image paste — screenshot-driven debugging via the composer

How It Was Built

The entire codebase was built by AI coding agents using the .plan/ protocol — phased planning with autonomous execution. 166 items across 120 agent sessions, each verified before moving on.

The codebase follows an agent-first architecture: deep modules over small files, minimal cross-file dependencies, self-contained domains. Optimized for how AI agents read and edit code, not for human IDE navigation.

Status

v0.1.0 shippedopen source on GitHub, macOS (Apple Silicon) DMG available.

Stack

ComponentTechnology
RuntimeBun
ServerBun HTTP + WebSocket
WebReact 19 + Vite + Zustand + Tailwind v4
DesktopElectrobun (native webview)
TypesTypeScript (strict)
SyntaxShiki
BuildTurbo (monorepo)
AgentPi (RPC mode, JSONL over stdio)