-- Open chat with persona — file-anchored insight chat is keyed by -- (library_id, file_path). The open chat is keyed by (user_id, persona_id) -- with a single rolling transcript per pair. No tree branching in v1 -- (matches the locked-in "single rolling conversation per persona" scope); -- a flat JSON blob is enough and avoids forcing a tree shape onto a -- surface that's intentionally linear. -- -- `messages_json` is the same `Vec` shape the file-anchored -- chat persists, so the SSE replay / UI rendering on the mobile client -- can reuse the same parser without a second schema. CREATE TABLE persona_chat_conversations ( user_id INTEGER NOT NULL, persona_id TEXT NOT NULL, messages_json TEXT NOT NULL DEFAULT '[]', turn_count INTEGER NOT NULL DEFAULT 0, updated_at BIGINT NOT NULL, PRIMARY KEY (user_id, persona_id) ); CREATE INDEX idx_persona_chat_updated ON persona_chat_conversations (user_id, updated_at DESC);