Skip to content

Latest commit

History

32 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

OpenCode UI

A clean, fast web dashboard for browsing, searching, and continuing your OpenCode chat sessions.

Screenshot

Features

Session Browser

  • Live Search — Instantly filter sessions by title, preview, or ID
  • Session List — See title, date, message count, and preview at a glance
  • New Session — Start a fresh OpenCode session in a terminal with one click

Chat Viewer

  • Chat-Style Layout — Messages rendered as bubbles (user / assistant), not raw markdown files
  • Rich Message Types — Text, reasoning/thinking blocks, and tool calls with expandable input/output
  • Markdown Rendering — Full markdown support with tables, lists, blockquotes, and syntax-highlighted code blocks
  • Copy Code — Hover any code block to copy with one click
  • Auto-Scroll — Jumps to the latest message when loading or sending

Continue Conversations

  • Send Messages — Type and send directly from the browser; spawns OpenCode in the background
  • Live Polling — Automatically refreshes the chat every 3 seconds to show the AI's response
  • Visual Feedback — Skeleton loaders while fetching, temporary message preview while sending

Terminal Integration

  • Open in OpenCode — Launch any session in gnome-terminal with the OpenCode CLI
  • Working Directory Aware — Opens in the session's original directory

Prerequisites

  • Node.js 18+
  • OpenCode CLI installed and on your $PATH
  • gnome-terminal (for the "Open in Terminal" feature)
  • Linux (tested on Ubuntu; macOS/Windows may need tweaks)

Installation

git clone https://github.com/dalpat/opencode-ui.git
cd opencode-ui
npm install

Usage

Start the server:

npm start

Open http://localhost:3457 in your browser.

Environment Variables

VariableDefaultDescription
PORT3457HTTP server port
SESSIONS_DIR../opencode-sessionsDirectory where exported .md session files are stored

Tech Stack

  • Backend: Express.js with a local read-optimized SQLite cache (better-sqlite3)
  • Frontend: Vanilla HTML/CSS/JS — no build step, no framework
  • Styling: Custom CSS with Inter + JetBrains Mono fonts
  • Markdown: Rendered client-side with marked.js

Architecture

The dashboard uses a local cache database for sub-millisecond queries instead of spawning a sqlite3 CLI process on every request.

┌─────────────┐ ┌──────────┐ ┌──────────┐ ┌────────┐
│ opencode.db │────▶│ sync │────▶│ cache.db │────▶│ API │
│ (source) │ │ (startup │ │ (cache) │ │(Express│
│ │ │ + watch) │ │ │ │ │
└─────────────┘ └──────────┘ └──────────┘ └────────┘
│
▼
┌──────────┐
│ FTS5 │
│part_fts │
└──────────┘

Data flow:

  1. On startup, the server copies all data from opencode.db into cache.db
  2. A file watcher monitors opencode.db for changes and incrementally syncs new data
  3. All API endpoints read from cache.db via better-sqlite3 native bindings
  4. Full-text search uses the FTS5 virtual table part_fts for instant results

Cache Schema

The cache lives at ~/.local/share/opencode-dashboard/cache.db and mirrors opencode's core tables with denormalized fields and custom indexes.

TableColumnsIndexes / Notes
sessionid, title, directory, parent_id, time_created, time_updated, model, agentidx_session_time_updated DESC (sidebar ordering)
messageid, session_id, time_created, data, roleidx_message_session_time_created (session messages)
partid, message_id, time_created, data, text_contentidx_part_message_time_created (message parts)
part_ftstext_contentFTS5 virtual table for full-text search
_schema_versionversion, applied_atTracks applied migrations
sync_metadatatable_name, last_sync_timeTracks incremental sync state

FTS5 triggers (part_fts_insert, part_fts_delete, part_fts_update) keep the search index in sync automatically when rows are inserted, deleted, or updated in the part table.

Managing the Cache

Clear / rebuild the cache

If the cache becomes corrupt or you want to force a full refresh:

# Stop the server, then delete the cache file
rm ~/.local/share/opencode-dashboard/cache.db
# Restart the server — it will rebuild the cache from opencode.db on startup
npm start

The server also detects corruption automatically on startup and will rebuild the cache without manual intervention.

Project Structure

.
├── public/ # Static frontend
│ ├── index.html # App shell
│ ├── styles.css # Custom CSS design system
│ └── app.js # Vanilla JS app logic
├── server.js # Express API
├── session-persistence.js # Unified session persistence boundary (DB + filesystem)
├── process-runner.js # Terminal spawning and opencode process runner
├── export.js # CLI export script
├── session-persistence.test.js # Boundary tests
└── package.json

API Endpoints

MethodEndpointDescription
GET/api/sessionsList all sessions
GET/api/session/:idGet session details with structured messages
POST/api/session/:id/continueAppend user message and run OpenCode
POST/api/open/:idOpen session in a new terminal
POST/api/open-newStart a brand-new OpenCode session in a terminal

License

MIT

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages