Skip to content

About

A read-only OpenCode plugin that pins one coding session and streams a live progress dashboard to a separate terminal.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

28 Commits

Folders and files

Repository files navigation

Track Coding Session

License: MIT

A read-only OpenCode plugin that pins one coding session and streams a live progress dashboard to a separate terminal.

The dashboard shows what the agent is working on, what it just did, and whether it needs you, while you keep working in another window or another app.

Session Monitor · Build archive export
watching since 14:30 · q quit

14:32  Reading archive · src/archive — 3 files
14:33  Writing archive logic · src/archive — 2 files
14:34  Running tests · bun test — passed

[WORKING] Building archive creation
live · updated 2s ago · q quit · r resync

Completed steps are appended to the terminal log and never rewritten. Only the small live block at the bottom updates.

Why

An OpenCode session is a long-running process. Watching it means keeping the terminal in front of you, which defeats the point of delegating work. This plugin moves the progress view somewhere else:

  • one session is pinned as the subject;
  • a server-side observer turns the event stream into intent-level steps;
  • a standalone streaming dashboard appends completed steps to a terminal log and keeps a small live status block at the bottom;
  • alerts tell you when the session is waiting, stalled, or looping.

The monitor never writes to the session. It does not answer permissions, interrupt work, or send prompts.

Features

  • One pinned session. The pin is global and survives TUI restarts. Watching another session retargets the existing dashboard instead of opening a second one.
  • Intent-level timeline. Consecutive reads, edits, searches, commands, delegations, and skill calls collapse into meaningful steps, each with a plain-language label, a dim file or command hint, and an outcome.
  • A useful headline. A small model summarizes the current feature once a minute, with a deterministic fallback when the model is unavailable or no new activity warrants a call.
  • Attention states. The dashboard distinguishes working, idle, waiting for input, stalled, looping, ended, and disconnected.
  • Alerts that respect focus. Waiting, stall, and loop transitions raise one native notification each, suppressed while you are looking at the watched session or the dashboard.
  • A real separate process. The dashboard keeps updating while the session window is minimized or closed. If the connection drops, it says so instead of presenting a stale feed as live.
  • Log-like output. Finished steps are printed once and stay in terminal scrollback. Only the current status and in-flight steps update in place, so the screen does not rewrite itself.
  • Child activity is attributed. Work in delegated child sessions counts toward the pinned session and is marked as delegated. Pinning mid-run discovers active subagents and shows their work immediately.
  • Reasoning counts as activity. A session that is streaming model output stays WORKING instead of looking idle while no tool call is open.

Requirements

  • OpenCode 2.4.3 or newer, with the V2 plugin API.
  • Bun 1.3 or newer.
  • macOS with Terminal or iTerm, or Linux with x-terminal-emulator, for automatic window launching. Other terminals and platforms get the exact command to run instead.
  • Optional: access to a model provider for the written headline. The default is opencode/deepseek-v4.1-flash-free.

Install

Clone the repository and install its dependencies:

git clone https://github.com/ghostmeson/track-coding-session-opencode-plugin.git
cd track-coding-session-opencode-plugin
bun install

Add the plugin directory to your global or project opencode.json / opencode.jsonc:

{
  "$schema": "https://opencode.ai/config.json",
  "plugins": ["/absolute/path/to/track-coding-session-opencode-plugin"]
}

To set options, use the object form:

{
  "$schema": "https://opencode.ai/config.json",
  "plugins": [
    {
      "package": "/absolute/path/to/track-coding-session-opencode-plugin",
      "options": {
        "headlineModel": {
          "providerID": "opencode",
          "modelID": "deepseek-v4.1-flash-free"
        }
      }
    }
  ]
}

One plugin entry loads every part of the package: the server observer, the TUI commands, and the RPC contract.

OpenCode reloads plugin configuration live. If the plugin does not appear, restart OpenCode once.

The pin is stored in OpenCode plugin storage. The timeline is kept in memory for the current watch period only.

Use

Open an OpenCode session and run one of these commands from the command palette or as a slash command:

Command Slash What it does
Watch this session /watch-session Pins the current session and opens the dashboard. If a dashboard is already attached, it retargets that window.
Open monitor /monitor Opens the dashboard for the pinned session, or shows the empty state when nothing is pinned.
Stop watching /monitor-stop Clears the pin and resets the feed.

On macOS, the launcher opens a new Terminal or iTerm window. If it cannot, OpenCode shows a warning toast containing the exact command to run.

Dashboard keys

Key Action
q / Esc Quit the dashboard. This stops its alerts but keeps the pin.
r Resync from the server.

Completed steps stay in the terminal scrollback. Use the terminal's normal scrollback and search instead of an in-app pager.

The dashboard also reports terminal focus and sends a heartbeat every 10 seconds. Closing it releases the presence lease and stops alerts; the pin remains.

States and alerts

State Meaning
WORKING The session is running and has recent activity.
IDLE The session is not running and is not waiting on a request.
WAITING A permission request or form is pending, or the agent finished its turn and is waiting for you. Shows a one-line summary.
STALLED The session reports busy but no meaningful activity has arrived past the threshold. Long-running tools and in-flight model calls still read as running.
LOOPING The same failing action has repeated the configured number of times.
ENDED The watched session was deleted or can no longer be read.
DISCONNECTED The dashboard lost its connection to the server. The last feed is dimmed and labeled, not presented as live.

Alerts fire for WAITING, STALLED, and LOOPING only. Each transition raises at most one alert, and an alert is suppressed while either the watched session or the dashboard has focus. Notifications use osascript on macOS and notify-send on Linux, with a terminal bell in the dashboard when no notifier is available. Session focus detection is macOS-only; the dashboard's own input focus works everywhere.

Configuration

All options are optional.

Option Default Meaning
headlineModel { "providerID": "opencode", "modelID": "deepseek-v4.1-flash-free" } Model used for the written headline. Set to null to use only the deterministic headline.
headlineIntervalMs 60000 Minimum gap between model headline calls. A call is also skipped when the digest has not changed.
stallThresholdMs 180000 No-activity window before a busy session is labeled stalled.
loopThreshold 3 Consecutive identical failures before a loop is labeled. Values below 2 fall back to the default.
stepGapMs 90000 Inactivity gap that closes an intent-level step.
notifications true Enables native alerts while the dashboard is attached and neither the session nor the dashboard is focused.

Example with a different model:

{
  "plugins": [
    {
      "package": "/absolute/path/to/track-coding-session-opencode-plugin",
      "options": {
        "headlineModel": {
          "providerID": "opencode",
          "modelID": "deepseek-v4.1-flash-free"
        },
        "stallThresholdMs": 300000,
        "loopThreshold": 4,
        "notifications": true
      }
    }
  ]
}

To run without model calls:

{
  "plugins": [
    {
      "package": "/absolute/path/to/track-coding-session-opencode-plugin",
      "options": { "headlineModel": null }
    }
  ]
}

How it works

flowchart LR
  A[OpenCode session events] --> B[Monitor observer]
  B --> C[RPC feed and alert events]
  C --> D[Streaming dashboard]
  D --> E[Terminal UI and native alerts]
  D -->|attach, heartbeat, focus| C
Loading
  • src/index.ts is the server plugin. It subscribes to session events, owns the observer, registers the RPC surface, and forwards feed and alert events.
  • src/monitor/observer.ts is the brain: pin state, event routing, presence leases, attention, and alert policy.
  • src/monitor/step-grouper.ts and src/monitor/tool-classifier.ts turn raw tool calls into intent-level steps.
  • src/monitor/attention.ts and src/monitor/notify-policy.ts decide the current state and whether a transition should alert.
  • src/monitor/headline.ts calls the configured model with a digest, a 60-second cap, and a deterministic fallback.
  • src/tui.ts registers the commands, launches the terminal, and reports the current route and terminal focus.
  • src/dashboard/ is the standalone streaming dashboard, its RPC client, log formatting, and notification adapter.
  • src/rpc.ts is the typed contract shared by the server, TUI, and dashboard.

The server owns one observer for the whole OpenCode instance. The dashboard is a client: it attaches with a 30-second lease, sends a heartbeat every 10 seconds, and is the primary notifier while attached. A second dashboard cannot be opened by the TUI; the existing one is retargeted instead.

Privacy and safety

  • Read-only. The plugin never calls session write methods. It does not approve permissions, interrupt a turn, or send prompts.
  • No file contents in model prompts. The headline digest contains the session title, step labels, file paths, and a short assistant line. It does not include file contents or diffs.
  • Content stays local except model calls. The headline is generated through the configured provider. Set headlineModel to null to avoid model calls entirely.
  • No durable timeline. The feed lives in the observer's memory and resets when the watch changes or the plugin restarts. The pin itself is durable.

Run the dashboard directly

If the launcher cannot open a window, run the dashboard with Bun:

bun run /absolute/path/to/track-coding-session-opencode-plugin/src/dashboard/main.tsx --location /absolute/path/to/project

The dashboard discovers the shared OpenCode service and attaches to the current pin. --location is optional when only one project is open.

The TUI launcher runs that command with bun from PATH. Set OPENCODE_BUN_PATH when Bun is not on the session's PATH:

OPENCODE_BUN_PATH=/absolute/path/to/bun opencode

Troubleshooting

No dashboard window appears. macOS may have denied Automation permission for Terminal or iTerm. Allow it in System Settings, or copy the command from the warning toast and run it manually.

"The monitor is already open." A dashboard process is still holding its 30-second presence lease. Close the old window, or wait for the lease to expire, then run Open monitor again.

No alerts. Check that notifications is enabled, that the dashboard is attached, and that neither the session nor the dashboard is focused. On macOS, check notification permission for the terminal app.

The headline does not change. The model call is capped at one per minute and skipped when the digest is unchanged. Set headlineModel to null for deterministic narration, or wait for new activity.

The dashboard says disconnected. The OpenCode server is unavailable or the connection dropped. It reconnects automatically; the last feed is labeled as stale rather than shown as live.

No session is pinned. Run Watch this session first, or open an existing session from the dashboard after pinning.

Development

bun install
bun test
bun run typecheck
bun run demo

bun run demo renders every dashboard state from a fake feed without a live session. The test suite covers event ingestion, grouping, attention and alert policy, the headline cap and fallback, pin and presence behavior, the RPC contract, formatting, the dashboard client, the launcher, focus probes, and the TUI commands.

Current verification:

bun test        150 pass, 0 fail
tsc --noEmit    clean
bun run demo    all dashboard states render

Manual smoke check

The interactive path still needs to be exercised against a real OpenCode install:

  1. Install the plugin and open a session.
  2. Run Watch this session; confirm a new terminal opens, or the exact command is shown.
  3. Run Watch this session in a second session; confirm the same dashboard retargets and no second window opens.
  4. Minimize the session and switch to another app; confirm the dashboard keeps updating.
  5. Trigger a permission request while the watched session is still the TUI's active route but the terminal is unfocused; confirm one notification.
  6. Run a long command; confirm it reads as running, not stalled.
  7. Repeat a failing command three times; confirm one loop alert.
  8. Kill the OpenCode server; confirm the dashboard shows disconnected and does not present the last feed as live.
  9. Close and reopen the dashboard; confirm the pin survives and a held waiting state shows the badge without a catch-up alert.
  10. Run Stop watching; confirm the pin clears and the feed shows the empty state.

Limitations

  • Automatic window launching supports Terminal and iTerm on macOS and x-terminal-emulator on Linux. Other terminals use the printed command.
  • One session is pinned at a time for the whole OpenCode instance.
  • The timeline covers the current watch period only. It is not a durable or replayable history.
  • Session focus detection is macOS-only and works at the application level. Two windows or tabs of the same terminal are indistinguishable.
  • This is a local plugin, not an npm package. Install it from a clone.

Project layout

src/
  index.ts               server plugin: observer wiring, RPC handlers, event stream
  tui.ts                 TUI commands, launcher call, focus reporting
  rpc.ts                 typed RPC methods, events, and schemas
  launcher.ts            Terminal/iTerm launch and fallback command
  focus.ts               macOS frontmost-terminal probe
  applescript.ts         shared AppleScript string escaping
  monitor/
    observer.ts          pin, feed state, event routing, presence, alerts
    step-grouper.ts      intent-level grouping and timeline
    tool-classifier.ts   tool name/input to category and label
    attention.ts         waiting, stalled, and looping precedence
    headline.ts          capped model headline and deterministic fallback
    notify-policy.ts     one-alert-per-transition policy
    pin.ts               durable pin record
    feed.ts              empty feed factory
    prompt.ts            headline digest and prompt
  dashboard/
    main.tsx             standalone entrypoint
    stream.ts            streaming terminal renderer and input handling
    log.ts               completed-step log selection and formatting
    client.ts            service discovery, attach, heartbeat, reconnect
    format.ts            pure view model
    notify.ts            native notification and bell fallback
test/                    behavior, contract, and UI-format tests
scripts/demo-feed.ts     terminal preview for every dashboard state
docs/plans/              the implementation plan and verification contract

Status

v0.1.0. The code, unit tests, type check, and demo preview are complete. The interactive smoke check above is the remaining verification step before calling the plugin shipped.

License

MIT. See LICENSE.

You can use, copy, modify, merge, publish, distribute, sublicense, and sell copies of this plugin, provided the copyright notice and permission notice are retained. Forks and commercial use are welcome.


Built with Bun and the OpenCode plugin API.

About

A read-only OpenCode plugin that pins one coding session and streams a live progress dashboard to a separate terminal.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages