Skip to content

Techie5879/opencode-smart-session-picker

Repository files navigation

opencode-smart-session-picker

Prototype OpenCode TUI plugin that replaces the built-in session picker opened with Ctrl-X then L.

It adds a smarter local search path for finding past OpenCode sessions while leaving your OpenCode sessions, config, and navigation in OpenCode itself. The local search index is disposable and can be rebuilt from OpenCode data.

image

Features

  • Replaces the normal OpenCode session picker shortcut: Ctrl-X then L.
  • Searches session titles, paths, and indexed transcript snippets.
  • Uses a local SQLite search index for fast keyword search.
  • Can use fzf for fuzzy ranking when requested.
  • Surfaces clear mode-unavailable messages when required dependencies are missing instead of silently falling back.
  • Shows non-blocking dependency status grouped by mode when indexing or optional dependencies are not available.
  • Includes an isolated dev launcher for trying the plugin without touching your real OpenCode config or state.

Requirements

  • Bun for installing dependencies and running checks.
  • OpenCode with TUI plugin support.
  • Optional: fzf for fzf search mode.
  • Optional: llama-server and a local embedding model for vector-search experiments.

Install

From this repo:

bun install

Add the plugin to ~/.config/opencode/tui.json, replacing the example path with the absolute path to your clone of this repo:

{
  "$schema": "https://opencode.ai/tui.json",
  "plugin": ["file:///absolute/path/to/opencode-smart-session-picker"]
}

Restart opencode, then press Ctrl-X followed by L.

Search Modes

The default mode is hybrid, which uses the local SQLite keyword index. If the sidecar index or other required dependencies are unavailable, the picker shows a clear status message instead of silently falling back to a different search.

Inside the smart session dialog, a status bar groups dependency chips by mode (hybrid and fzf). The active mode is marked with ; press Tab to switch. Each mode row shows its own dependencies as ready, missing, errored, or disabled.

To use another mode for a run:

OPENCODE_SMART_PICKER_SEARCH_MODE=fzf opencode /path/to/workspace

Available modes:

  • hybrid: default local search mode.
  • fzf: ranks sessions with an installed fzf executable.

Useful environment variables:

OPENCODE_SMART_PICKER_SEARCH_MODE=hybrid # or fzf
OPENCODE_SMART_PICKER_HYBRID_ALPHA=0.5
OPENCODE_SMART_PICKER_SEARCH_DB=/path/to/opencode-search.db
OPENCODE_SMART_PICKER_SOURCE_DB=/path/to/opencode.db
OPENCODE_SMART_PICKER_FZF_BIN=/path/to/fzf
OPENCODE_SMART_PICKER_EMBED_BASE_URL=http://127.0.0.1:8081
OPENCODE_SMART_PICKER_EMBED_MODEL=nomic-embed-text-v1.5
OPENCODE_SMART_PICKER_DISABLE_VECTOR=1
OPENCODE_SMART_PICKER_SQLITE_LIB=/opt/homebrew/opt/sqlite/lib/libsqlite3.dylib

OPENCODE_SMART_PICKER_HYBRID_ALPHA is a ranking weight between 0 and 1. Changing it does not rebuild the local index.

fzf Mode

Install fzf through your package manager:

brew install fzf

Check that it works:

fzf --version
printf 'alpha\nbeta\n' | fzf --filter a

Then run OpenCode with:

OPENCODE_SMART_PICKER_SEARCH_MODE=fzf opencode /path/to/workspace

Optional Local Embeddings

The picker does not require a local embedding server. For vector-search experiments, use a local llama-server embedding endpoint.

Recommended model: nomic-ai/nomic-embed-text-v1.5-GGUF.

Example download location:

mkdir -p "$HOME/.local/share/opencode-smart-session-picker/models"

huggingface-cli download \
  nomic-ai/nomic-embed-text-v1.5-GGUF \
  nomic-embed-text-v1.5.f16.gguf \
  --local-dir "$HOME/.local/share/opencode-smart-session-picker/models" \
  --local-dir-use-symlinks false

Start llama-server:

llama-server \
  -m "$HOME/.local/share/opencode-smart-session-picker/models/nomic-embed-text-v1.5.f16.gguf" \
  --embedding \
  --pooling mean \
  -c 8192 \
  -ub 8192 \
  --host 127.0.0.1 \
  --port 8081

Smoke test:

curl http://127.0.0.1:8081/health
curl http://127.0.0.1:8081/v1/embeddings \
  -H "Content-Type: application/json" \
  -d '{"input":"search_query: test","model":"nomic-embed-text-v1.5","encoding_format":"float"}'

Disposable Testing

Use the dev launcher to test against upstream OpenCode without changing your real OpenCode config, data, state, or cache:

bun install
bun install --cwd upstream/opencode
bun run dev:opencode -- <workspace>

Omit <workspace> to open OpenCode against this repo.

The dev launcher writes under .opencode-dev/ and uses an isolated OpenCode home. It intentionally will not show your real OpenCode sessions. The picker derives the isolated source DB from OpenCode's channel database convention, so local dev runs use .opencode-dev/xdg/data/opencode/opencode-local.db.

Checks

bun run typecheck
bun run test

bun run test runs the repo check suite. bunfig.toml scopes bare Bun test discovery away from the reference submodules in upstream/.

About

Better search over opencode sessions

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors