Skip to content
    ↑↓ select↵ openesc close
    imdlan

    Session Diff

    opencode-session-diff·v0.1.1·Git & VCS

    OpenCode sidebar panel listing the current session's file changes (±line counts)

    GitHub stars

    0

    Monthly installs

    365

    365 in 7 days

    Composite score

    35.7

    Multi-signal model

    Last commit

    4 hours ago

    2026-10-21

    Install and configure

    opencode.json

    Writes 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"]
    }

    OpenCode 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 | 简体中文

    npm version license

    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.diff snapshot, not a client-side guess.
    • Added / modified / deleted with per-file +additions −deletions counters, 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

    1. The plugin registers a sidebar.content-anchored claim (after the content boundary, below other sections, above the footer) with @opencode/plugin's ui.slot.
    2. It fetches client.session.diff({ sessionID }) and classifies each FileDiff.Info by its authoritative status (added / deleted / modified), falling back to ± counts if status is absent.
    3. Refreshes are debounced 500 ms and triggered by session.execution.succeeded, session.idle, and session.revert.* events.
    4. 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 / p inside 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

    MIT

    Similar plugins