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.
- Replaces the normal OpenCode session picker shortcut:
Ctrl-XthenL. - Searches session titles, paths, and indexed transcript snippets.
- Uses a local SQLite search index for fast keyword search.
- Can use
fzffor 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.
- Bun for installing dependencies and running checks.
- OpenCode with TUI plugin support.
- Optional:
fzfforfzfsearch mode. - Optional:
llama-serverand a local embedding model for vector-search experiments.
From this repo:
bun installAdd 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.
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/workspaceAvailable modes:
hybrid: default local search mode.fzf: ranks sessions with an installedfzfexecutable.
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.dylibOPENCODE_SMART_PICKER_HYBRID_ALPHA is a ranking weight between 0 and 1.
Changing it does not rebuild the local index.
Install fzf through your package manager:
brew install fzfCheck that it works:
fzf --version
printf 'alpha\nbeta\n' | fzf --filter aThen run OpenCode with:
OPENCODE_SMART_PICKER_SEARCH_MODE=fzf opencode /path/to/workspaceThe 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 falseStart 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 8081Smoke 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"}'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.
bun run typecheck
bun run testbun run test runs the repo check suite. bunfig.toml scopes bare Bun test
discovery away from the reference submodules in upstream/.