Skip to content

feat: OpenCode chat support#4

Open
Ar9av wants to merge 1 commit into
mainfrom
feat/opencode-support
Open

feat: OpenCode chat support#4
Ar9av wants to merge 1 commit into
mainfrom
feat/opencode-support

Conversation

@Ar9av
Copy link
Copy Markdown
Owner

@Ar9av Ar9av commented May 21, 2026

Summary

Adds support for reading and displaying OpenCode chat sessions alongside Claude Code sessions throughout AgentTower.

  • lib/opencode-fs.ts — new module that reads ~/.local/share/opencode/opencode.db (SQLite, OpenCode v1.2.0+). Converts session, message, and part tables into AgentTower's ParsedMessage / SessionInfo / ProjectInfo types. Uses the built-in node:sqlite module (Node.js 22+); falls back gracefully when the DB doesn't exist.
  • typings/node-sqlite.d.ts — minimal TypeScript shim for node:sqlite (not yet in @types/node for this project's config).
  • lib/types.ts — added source?: 'claude' | 'opencode' to ProjectInfo and SessionInfo.
  • lib/claude-fs.ts — added source: 'claude' field to RecentSession type and all returned objects.
  • API routes (projects, sessions, recent-sessions, session, tail) — merged Claude + OpenCode data; opencode: prefix in the f/p params routes to the new module. The tail route returns an empty SSE stream for OpenCode sessions (they're static).
  • app/projects/page.tsx — merges both project lists, sorted by most-recently-active.
  • app/project/page.tsx — OpenCode projects render a read-only session list with a source badge; Claude projects render the existing full-featured view.
  • app/session/page.tsx — detects opencode: filepath prefix and reads from SQLite instead of JSONL.
  • components/LiveSession.tsx — new source prop; OpenCode sessions skip SSE connection, process polling, fork buttons, and the input bar (replaced by a "read-only" notice).

How it works

OpenCode session paths are encoded as opencode:<sessionId> (base64 in URLs). The existing routing, pagination, and session-viewer components work unchanged — they just receive pre-converted ParsedMessage[] from the new module.

Test plan

  • Start AgentTower with OpenCode installed — OpenCode projects appear in the /projects list with an opencode badge
  • Click an OpenCode project — shows its sessions with costs and timestamps
  • Open an OpenCode session — messages (text, tool calls, reasoning) render correctly; no input bar / process controls shown
  • Verify Claude sessions are unaffected (all existing features work)
  • With no OpenCode DB (~/.local/share/opencode/opencode.db absent) — app works normally with only Claude sessions

@vercel
Copy link
Copy Markdown

vercel Bot commented May 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agenttower Ready Ready Preview, Comment May 21, 2026 5:00am

Request Review

Read OpenCode sessions from ~/.local/share/opencode/opencode.db (SQLite,
v1.2.0+) and surface them alongside Claude Code sessions throughout the UI.

Changes:
- lib/opencode-fs.ts — new module; reads session/message/part tables and
  converts to AgentTower's ParsedMessage/SessionInfo/ProjectInfo types
- typings/node-sqlite.d.ts — minimal type shim for node:sqlite built-in
- lib/types.ts — add `source?: 'claude' | 'opencode'` to ProjectInfo,
  SessionInfo
- lib/claude-fs.ts — add `source: 'claude'` to RecentSession type and
  all returned objects
- API routes (projects, sessions, recent-sessions, session, tail) — merge
  Claude and OpenCode data; opencode: prefix routes to the new module
- app/projects/page.tsx — merge both project lists, sort by mtime
- app/project/page.tsx — OpenCode branch: read-only session list with
  source badge; Claude branch unchanged
- app/session/page.tsx — detect opencode: filepath prefix, parse from
  SQLite instead of JSONL
- components/LiveSession.tsx — new `source` prop; OpenCode sessions skip
  SSE tail, process polling, fork buttons, and the input bar (replaced by
  a read-only notice)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant