forked from anomalyco/opencode
-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
Problem
Current binary is ~95MB and feels sluggish. The TUI uses Ink (React-based terminal UI) which adds significant overhead.
Research Direction
Explore replacing the React/Ink TUI with a lightweight raw ANSI implementation.
Proposed Architecture
┌─────────────────────────────────────────────────────┐
│ claude-sonnet-4-20250514 · build │ ← sticky header
├─────────────────────────────────────────────────────┤
│ │
│ ... chat content with syntax highlighting ... │ ← scrollable
│ │
├─────────────────────────────────────────────────────┤
│ ⏳ explore (12s) │ ⏳ websearch (3s) │ ✓ grep │ ← sticky jobs bar
├─────────────────────────────────────────────────────┤
│ > _ │ ← input
└─────────────────────────────────────────────────────┘
Library Comparison
| Library | Sticky regions | Syntax HL | Size | Speed |
|---|---|---|---|---|
| terminal-kit | ✓ screenBuffer | External | ~150KB | Fast |
| blessed | ✓ boxes | External | ~200KB | Medium |
| Raw ANSI | Manual cursor | External | 0 | ⚡ Fastest |
| ink (current) | ✓ (React) | External | ~200KB+ | Slower |
Recommendation: Raw ANSI + cli-highlight
- Zero framework overhead
- ~550 lines total code
- Dependencies: picocolors (~5KB), cli-highlight (~30KB)
Core Components Needed
terminal.ts(~150 lines) - Region management, cursor controlmain.ts(~300 lines) - Event loop, commandsformat.ts(~100 lines) - Markdown, code highlighting
Key Features
- Sticky header (model/agent)
- Scrollable chat region
- Sticky jobs bar with live timers
- Input line with cursor
Integration with Background Tasks
Jobs bar would show running background tasks with elapsed time, updating every second.
Research Questions
- What's the actual size breakdown of current binary? (Bun runtime vs app code vs deps)
- Can we achieve <20MB binary with raw ANSI approach?
- What TUI features would we lose? Are they essential?
- How much of packages/opencode/src/cli/cmd/tui/ can be deleted?
Out of Scope (for now)
- Mouse support
- Complex layouts
- Rich widgets
Acceptance Criteria
- Research current binary size breakdown
- Prototype raw ANSI terminal abstraction
- Measure performance difference
- Document trade-offs
- Decision: migrate or keep Ink
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels