Skip to content

Grok 1.0.13 moved session storage to SQLite — file-based discovery and transcript backfill are dead #331

Description

@wxtsky

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 --versiongrok 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, so findActiveGrokSessions returns nothing and matchGrokSessionsToProcesses has nothing to match.
  • grokEncodedCwd — 1.0.13 stores the plain path in a column; the percent-encoded directory name no longer exists.
  • transcriptPath points at chat_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_docs has no created_at, only updated_at. grokSessionProcessMatchScore leans on createdAt for its ±120s window and for the resumed-session branch, so the scoring needs rethinking rather than a straight port.
  • content is 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions