A practical guide to building, running, and operating ai-viewer on your workstation. ai-viewer is localhost-only and read-only on your agent session files (see SECURITY.md).
Two binaries share one SQLite database:
ai-viewer-ingest— watches your AI-agent session directories, parses each snapshot, and writes normalized rows into the database.ai-viewer-serve— serves the web UI plus a REST + SSE API athttp://127.0.0.1:7710, reading from that same database.
git clone https://github.com/netdata/ai-viewer ~/src/ai-viewer.git
cd ~/src/ai-viewer.git
./scripts/build.shscripts/build.sh builds the React UI, embeds it into ai-viewer-serve, and
produces both binaries in bin/. The single ai-viewer-serve binary serves the
UI itself — there is no separate web server or Node runtime at run time.
# 1. Ingest your sessions into the database (Ctrl-C to stop; it tails for new ones).
bin/ai-viewer-ingest
# 2. In another terminal, serve the UI + API.
bin/ai-viewer-serve
# 3. Open the UI.
xdg-open http://127.0.0.1:7710By default both use ~/.local/share/ai-viewer/index.db. The ingester
auto-discovers ai-agent v2/v3 (~/.ai-agent/sessions), claude-code, codex, and
opencode sources when their default directories exist. To ingest a specific
source explicitly, pass --source format:location (e.g.
--source aiagent_v3:~/.ai-agent/sessions) — any explicit --source flag
replaces auto-discovery. Override the DB path with --db, the state dir with
--state-dir, and (serve only) the bind with --bind 127.0.0.1:<port>. Run
either binary with --help for all flags.
If you start
ai-viewer-servebefore the ingester has created the database, it exits with a schema error — start the ingester first (or use the systemd units below, which retry automatically).
scripts/install-systemd-user.sh # build + install binaries and USER units
systemctl --user enable --now ai-viewer-ingest.service ai-viewer-serve.serviceinstall rebuilds from source, copies the binaries to ~/.local/bin/ and the
USER units to ~/.config/systemd/user/, reloads systemd, and prints the
enable --now command for you to run (it does not start services itself). No
root is needed. ai-viewer-serve.service is ordered After= the ingester and
restarts on failure, so on first run it retries until the database schema
exists.
scripts/install-systemd-user.sh status # systemctl --user status for both
scripts/install-systemd-user.sh uninstall # stop + remove the units (keeps binaries + data)/— the sessions list (root sessions: agent, model, start, duration, status, turns, ops, tokens, cost, failures). A child-count cell links to a session whose Overview lists its sub-sessions. "Load more" pages older sessions. The list refreshes live as new sessions are ingested./sessions/:id— session detail. Overview (per-session aggregates + a tools-used summary + a child-sessions table), Trace (APM views of the op tree: waterfall / flame-graph / event-list, with a shared span-detail drawer), Topology (per-session actor graph of the agents and tools that participated, node size/color encoding a selectable metric), Timeline (video-editor lanes — one per session, spans drawn on a shared time axis), and Logs (severity-filter + paging). Deep-linking / reloading this URL works./topology— cross-session topology: the actor graph aggregated across all sessions in the current timeframe + filters./sources— per-source lifecycle/read-model status, Tail heartbeat or failure evidence, parse-error counts, progress timestamp, and an overall health badge.- Theme — Auto (follows your OS) / Dark / Light, in the header; your choice persists.
cd ~/src/ai-viewer.git
git pull
scripts/install-systemd-user.sh install # rebuilds + reinstalls to ~/.local/bin
systemctl --user restart ai-viewer-ingest.service ai-viewer-serve.serviceThe schema migrates automatically on ingester startup. (For a manual install,
re-run ./scripts/build.sh and restart the binaries.)
| Path | What |
|---|---|
~/.local/share/ai-viewer/index.db |
the SQLite database (delete to reset; it rebuilds on next ingest) |
~/.local/bin/ai-viewer-{ingest,serve} |
installed binaries (systemd install) |
~/.config/systemd/user/ai-viewer-*.service |
the USER units |
source dirs (~/.ai-agent, ~/.claude, …) |
your agents' session files — read only, never modified |
/sourcesshows parse errors or a "degraded"/"down" health badge — a source file failed to parse, a source is still scanning too long, Tail failed or became stale, read-model repair is pending/failed, or the DB/schema is unavailable. Check/api/health, then the ingester logs (scripts/install-systemd-user.sh status, or the manual ingester's output). Parse errors, lifecycle failures, and read-model repair failures are surfaced per source, never hidden.- No sources configured/discovered —
/api/healthreturnsstatus="degraded"withstatus_detail="no_sources_configured". Start the ingester with explicit--source format:pathflags or restore the expected default source directories. - The UI says "UI not built" — you ran
ai-viewer-servewithout building the frontend. Run./scripts/build.shand restart. ai-viewer-serveexits with a schema error — the log line isai-viewer-serve: schema version mismatch, usually withschema_meta.version row missingorschema_meta.version is <got>, want 14. Stop serve, checkjournalctl --user -u ai-viewer-ingest.servicefor the migration failure, start/restartai-viewer-ingestso it applies migration 0014, then start/restart serve. The systemd units handle this ordering with auto-restart. Migration 0014 clears the derivedfts_ops/fts_logssearch indexes when upgrading old stores; source repair orrollups-backfillrepopulates them from primary rows.- Do not run SQLite
VACUUMon the ingest database while ai-viewer is running.fts_opsusesops.rowidas an internal maintenance docid, and SQLite can rewrite implicit rowids duringVACUUM. If external maintenance has vacuumed or rebuilt the DB, stop the service and runai-viewer-ingest rollups-backfill --db <index.db>(or let daemon startup complete its retained full read-model reconciliation) before trusting search. - Reset everything — stop the services,
rm -rf ~/.local/share/ai-viewer, and re-run the ingester; it re-reads your sources from scratch.
ai-viewer never modifies your source files, never makes a network call, and binds only localhost. See SECURITY.md and docs/architecture-overview.md.