Session Diff
OpenCode sidebar panel listing the current session's file changes (±line counts)
0
365
365 in 7 days
35.7
Multi-signal model
4 hours ago
2026-10-21
Install and configure
opencode.jsonWrites to this project's opencode.json — applies to this repository only.
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-session-diff@0.1.1"]
}Writes to ~/.config/opencode/opencode.json — applies to every project.
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-session-diff@0.1.1"]
}If you want to modify the plugin locally, install it into the project and reference the local path.
shell
pnpm add -D opencode-session-diffOpenCode loads npm dependencies through its embedded runtime on startup and caches them locally — no manual global install needed.
Not an official OpenCode / SST product. This is a community plugin, not affiliated with or endorsed by OpenCode.
English | 简体中文
Changes sidebar panel for OpenCode — see every file the current session touched, at a glance.
A TUI plugin for OpenCode that adds a Changes section to the session sidebar. It lists every file the current session modified, added, or deleted, with ± line counts, highlights the file being edited right now, and click-through to the built-in diff viewer.
▼ Changes (4) +154 −18
• src/agent/loop.ts +28 −9
• src/tools/fs.ts +110 −3
• test/loop.test.ts +13
• src/legacy/runner.ts −6
Features
- Session-scoped: exactly what this conversation changed — powered by the server's
session.diffsnapshot, not a client-side guess. - Added / modified / deleted with per-file
+additions −deletionscounters, right-aligned. - Live-edit highlight: the file being edited turns warning-colored for a few seconds (
session.tool.*events; filesystem watcher as fallback). - Click to review: opens the official diff viewer, already scoped to this session's changes.
- Events, not polling: refreshes on round completion and
/undo; no timers in the background. - Theme-aware: all colors come from the host theme (dark/light/custom).
- Zero config.
Install
opencode plugin add opencode-session-diff@latest
Recommended host setting so the diff viewer opens on the session's own changes rather than the git branch:
// ~/.config/opencode/cli.json
{
"diffs": { "source": "turn" }
}
The sidebar shows when space allows (session.sidebar: "auto"). Toggle it with Ctrl+X then B.
Usage
| Action | Result |
|---|---|
| Click the Changes title | Collapse / expand the section |
| Click a file row | Open the diff viewer (session source) |
Ctrl+P → Toggle collapse (Changes group) |
Same collapse, keyboard-only |
Collapse state is persisted per TUI instance.
Requirements
- OpenCode ≥ 2.0.x (V2 plugin API,
@opencode/plugin/tui) - A git repository is not required; the panel is driven by the session snapshot
How it works
- The plugin registers a
sidebar.content-anchored claim (afterthe content boundary, below other sections, above the footer) with@opencode/plugin'sui.slot. - It fetches
client.session.diff({ sessionID })and classifies eachFileDiff.Infoby its authoritativestatus(added/deleted/modified), falling back to ± counts ifstatusis absent. - Refreshes are debounced 500 ms and triggered by
session.execution.succeeded,session.idle, andsession.revert.*events. - The host paints only the synchronous snapshot returned by the slot render, so any state change re-registers the claim (documented in
docs/DEVELOPMENT.md).
Limitations
- The official diff viewer cannot focus a single file from the API; clicking opens the whole session diff (navigate files with
n/pinside it). - The plugin is TUI-only (V2). It ships a no-op server stub because the host loader requires one.
Development
bun install
bun run build # dist/index.js + dist/tui.js (host deps stay external)
bun test # 34 unit tests
bun run typecheck
Deeper notes, verified API contracts, and edge cases live in docs/DEVELOPMENT.md.
License
Similar plugins
Fold Diffs
opencode-fold-diffs
OpenCode TUI plugin: write, edit, apply_patch and long bash commands render folded to their title line, click or ctrl+o to open them.
Review
@opencode-cockpit/review
A pull request in the terminal: read the diff, hold your notes, send one review
Fork Lane
@bojackduy/opencode-fork-lane
Fork-lane for OpenCode — lane-inspired copy-on-write git worktrees + session fork. /fork-lane (/lane) creates a new branch + worktree (reflink for ignored files) and forks the session into it. Agent-callable via fork_lane tool (alias lane).