Show changed files with per-file +additions / -deletions in the
OpenCode session sidebar — a live git diff --stat for
whatever the agent (or you) changed.
Context
107,338 tokens
54% used
Changes +4 -4
…/indexing.twig +4 -4
- Per-file added/removed line counts, colored with the current OpenCode theme.
- Three scopes: the whole session (default), the current turn, or the VCS working tree.
- Live updates while the agent works — driven by server events with a 250 ms debounce, no polling.
- Totals in the header, long paths shortened, and a
maxcap so the sidebar stays readable. - Pure CLI/TUI plugin: renders in the terminal and works against local and remote servers.
- OpenCode v2 (the CLI/TUI).
- A Git worktree for file snapshots.
- For
scope: "session"/"turn": snapshots enabled (default). These read the same snapshot data/undouses. - For
scope: "working": any Git repository.
opencode plugin add opencode-session-changesPin a version with opencode-session-changes@1.0.0; opencode plugin check and
opencode plugin update keep it fresh.
opencode plugin add github:kdbsoft/opencode-session-changesBoth plugin add forms install the package and register it globally. Reload or
restart the TUI afterwards.
git clone https://github.com/kdbsoft/opencode-session-changes.git \
~/.config/opencode/plugins/session-changesOpenCode discovers directories under ~/.config/opencode/plugins/ (and
.opencode/plugins/) automatically; the plugin hot-reloads on file changes.
Clone the repository somewhere and reference it from
~/.config/opencode/cli.json. This keeps the plugin active even when the TUI is
connected to a remote server, and lets you pass options:
{
"$schema": "https://opencode.ai/v2/cli.json",
"plugins": [
{ "package": "./plugins/session-changes", "options": { "scope": "session", "max": 30 } }
]
}Options are passed through the plugin entry in cli.json:
{
"plugins": [
{ "package": "./plugins/session-changes", "options": { "scope": "working", "max": 15 } }
]
}| Option | Values | Default | Description |
|---|---|---|---|
scope |
"session" | "turn" | "working" |
"session" |
Which changes to list (see below). |
max |
number > 0 | 30 |
Maximum number of files rendered; the rest collapses into … N more. |
session— every file changed since the first prompt of the session. It diffs from the earliest recorded snapshot of the session, so the list keeps everything the session produced across turns.turn— only the current (latest) turn, resetting when you send a new prompt.working— the Git working tree,git status-style. Unlike the two snapshot scopes this also includes edits made outside OpenCode, and it keeps working after commits.
- The plugin claims the
sidebar.contentslot viacontext.ui.slot({ append: ... })and renders the list in the session sidebar. - Data comes from the OpenCode client:
session/turn:client.session.diff({ sessionID, from, context: 0 }); forsessionscopefromis the first user message of the session.working:client.vcs.status().
- Refresh triggers: server events (
filesystem.changed,session.step.ended,session.tool.*,session.revert.*,session.status, ...) debounced by 250 ms, plus session switches and the first user message arriving. index.tsis an intentionally empty server plugin: it makes OpenCode discover the directory and advertise the plugin'stuientrypoint to the CLI.
npm install
npm run typecheckEdit tui.tsx while OpenCode is running and the plugin hot-reloads — no restart
needed.