Repository navigation
Description
Found while investigating #318. Grok shipped 1.0.13 (from the 0.2.x line) and replaced its on-disk session layout. Everything in AppState that reads Grok sessions from the filesystem now finds nothing.
What changed
Before (0.2.x):
~/.grok/sessions/<percent-encoded-cwd>/<session-uuid>/
chat_history.jsonl
summary.json
events.jsonl
updates.jsonl
After (1.0.13) — the whole tree is gone, replaced by a single index:
~/.grok/sessions/session_search.sqlite
CREATE TABLE session_docs (
session_id TEXT PRIMARY KEY,
cwd TEXT NOT NULL, -- plain path, no percent-encoding
updated_at INTEGER NOT NULL, -- unix seconds
title TEXT NOT NULL,
content TEXT NOT NULL, -- flattened digest, not a transcript
content_hash TEXT NOT NULL
);plus an FTS5 mirror (session_docs_fts). meta holds session_search_schema_version = 4. The migration also drops empty ~/.grok/relocations/<session-id>.lock markers.
Verified locally: grok --version → grok 1.0.13 (5e9a58528b76) [stable], ~/.grok/sessions/ contains only the SQLite file, and find ~/.grok -name chat_history.jsonl returns nothing.
What breaks
All in Sources/CodeIsland/AppState.swift:
grokSessionCandidates(cwd:)walks~/.grok/sessions/<encoded-cwd>/→ always empty, sofindActiveGrokSessionsreturns nothing andmatchGrokSessionsToProcesseshas nothing to match.grokEncodedCwd— 1.0.13 stores the plain path in a column; the percent-encoded directory name no longer exists.transcriptPathpoints atchat_history.jsonl, so message backfill and the transcript tailer are dead.- The
("grok", "\(ConfigInstaller.grokHome())/sessions")watch now only fires when the SQLite index is rewritten.
Hooks are unaffected — they run out of ~/.grok/hooks/codeisland.json and don't touch session storage — so Grok cards still appear and still update. What's lost is everything discovery adds on top: recovering a session CodeIsland didn't see start, backfilling recent messages, and reattaching after a CodeIsland restart.
Notes for the fix
session_docshas nocreated_at, onlyupdated_at.grokSessionProcessMatchScoreleans oncreatedAtfor its ±120s window and for the resumed-session branch, so the scoring needs rethinking rather than a straight port.contentis a flattened digest (title + a run of text and tool names), not turn-structured — usable for a preview line, not as a transcript source.- Both layouts will be in the wild for a while, so detection should be by what's on disk (SQLite present vs. cwd directories present) rather than by a version probe.
- Reading the index while Grok is running means opening the SQLite read-only, and ideally in WAL-safe fashion, since Grok writes it live.
Filing rather than fixing because I have no live 1.0.13 session to verify against — the scoring change in particular needs a real session to test, and guessing at it risks hiding sessions that currently work via hooks.
Activity
fix(grok): read Grok's session search index next to session dirs (#331)
wxtsky commentedon Sep 23, 2026
Follow-up with a correction to my own premise, from a closer look (a copy of the index plus
stringson the 1.0.13 binary; Grok was not launched).The SQLite file isn't a replacement store.
session_search.sqliteis Grok's FTS5 search index, and 0.2.114 already had it: this machine'slast_bootstrap_atmatches the 0.2.114 launch inunified.jsonl. The 1.0.13 binary's own bundled docs and storage code still keep each session insessions/<encoded-cwd>/<id>/(summary.json,updates.jsonl,chat_history.jsonl): "JSONL is the source of truth; … additionally maintains a local SQLite FTS5 index". The session directories on this machine disappeared during that upgrade run, most likely an upgrade/relocation accident (30relocations/*.lockmarkers were written at the same moment) rather than a format change. Nothing else under~/.grokholds a transcript, and the index'scontentcolumn is a digest, not a transcript.Fixed on
main(e48c4a8), robust to both situations:session_search.sqliteis a read-only fallback, opened withoutimmutableso rows still sitting in Grok's live WAL are seen. An unexpected schema yields no rows rather than a guess. Sessions known only to the index are tracked without a transcript path.created_atin scoring. The scorer's rules are unchanged, and it still prefers not matching when unsure.chat_history.jsonlpath once the file exists. This also fixes a real bug: a path recorded before the file was created was marked attached, and the tailer never retried it.The same batch fixes #318 (a
/resumein the same TUI leaving two cards). Still to confirm on a real machine: that a new 1.0.13 session creates itssessions/<cwd>/<id>/directory. If it turns out it doesn't, that's a fresh issue with concrete evidence.