Skip to content

[Bug][Storage] Sessions created before the JSONL→SQLite cutover disappear from the UI after updating — legacy JSONL transcripts are never imported #2260

Description

@cat0825

What happened

After updating Maka to the build where SQLite became the sole operational
session store, every session created before the cutover disappeared from the
UI. The session list only shows sessions created after the update.

The old data is not deleted — the legacy transcript files are still on
disk, byte-for-byte intact. The new storage layer simply never reads them.

Evidence (data layer, from a real upgrade on macOS)

  1. Legacy transcript file still exists, intact:
    ~/Library/Application Support/Maka/workspaces/default/sessions/b156d249-dbd1-4ddb-ae16-a801a9fe9526/session.jsonl
    schemaVersion: 1, opens with a legacy-header record, then user/turn
    message records. (In the affected install it contains a full turn: user
    message, turn_state, token_usage, system_note.)

  2. But the session is absent from the new SQLite store:
    runtime.sqlitesession_messages returns 0 rows for that
    session_id; the id appears in neither session_metadata nor
    session_catalog_projection. The UI therefore has nothing to list.

  3. Schema migrations ran on first launch, but imported nothing:
    operational_schema_migrations (runtime|9, session_metadata|21, …) all
    applied at 1785904471629, which is exactly the first launch after the
    update. The migration machinery ran; no legacy-session import was part of
    it.

Root cause (source layer)

  • refactor(storage): make SQLite the sole operational authority #1994 refactor(storage): make SQLite the sole operational authority
    made SQLite the only session store. Its README documents that several
    legacy file stores are not imported (e.g. pre-existing Electron
    safeStorage credential files "are not imported; affected users must
    re-authenticate"), but for session transcripts it removes the JSONL path
    without adding a one-time JSONL→SQLite importer.
  • fix(scripts): drop session-bundle imports deleted with the JSONL session tree #2029 fix(scripts): drop session-bundle imports deleted with the JSONL session tree explicitly deletes the remaining JSONL-session import
    code
    rather than replacing it with a migration.
  • In the shipped 0.1.5 bundle (dist/main/), grepping for jsonl finds no
    session-transcript reading code at all — the new store only reads SQLite.
  • Startup (app-lifecycle.ts) calls backfillSessionProjects, but that only
    backfills project grouping for sessions that already exist in SQLite; it
    never scans sessions/b156d249-dbd1-4ddb-ae16-a801a9fe9526/session.jsonl.
  • The only remaining JSONL handling is packages/core/src/foreign-session.ts
    / packages/storage/src/foreign-session-store.ts (importing Claude Code
    / Codex
    external transcripts) — not Maka's own legacy transcripts.

So the upgrade path is: JSONL tree → (nothing) → SQLite. Silent invisibility
of intact user data.

Expected behavior

On upgrade, legacy schemaVersion: 1 JSONL sessions should be migrated into
SQLite (session_metadata + session_messages) so they stay visible — or at
minimum surfaced with an explicit import path / notice. Intact data must not
become silently invisible.

Suggested fix (any of)

  1. One-time importer at first launch after cutover: scan
    sessions/*/session.jsonl, parse legacy-header + message records,
    insert into session_metadata / session_messages, and mark the
    migration done (schema-version bump or a durable one-time flag) so it runs
    exactly once and is idempotent.
  2. If full transcript import is too risky, import at least the session
    metadata + last message so the session appears in the list and can be
    opened/exported.
  3. Add a "import legacy sessions" action / notice for installs that still
    carry a sessions/ tree.

Repro / verification commands (maintainers)

# 1. Legacy transcript still on disk, intact
ls "~/Library/Application Support/Maka/workspaces/default/sessions/"
head -1 "~/Library/Application Support/Maka/workspaces/default/sessions/b156d249-dbd1-4ddb-ae16-a801a9fe9526/session.jsonl"

# 2. But the new store does not contain it
sqlite3 "~/Library/Application Support/Maka/workspaces/default/runtime.sqlite" \
  "SELECT COUNT(*) FROM session_messages WHERE session_id='b156d249-dbd1-4ddb-ae16-a801a9fe9526';"      # → 0
sqlite3 "~/Library/Application Support/Maka/workspaces/default/runtime.sqlite" \
  "SELECT COUNT(*) FROM session_metadata WHERE session_id='b156d249-dbd1-4ddb-ae16-a801a9fe9526';"      # → 0

# 3. Migrations ran on first launch, none imported the legacy tree
sqlite3 "~/Library/Application Support/Maka/workspaces/default/runtime.sqlite" \
  "SELECT * FROM operational_schema_migrations;"                        # all applied_at ≈ first launch after update

Environment

  • Maka version: 0.1.5 (desktop, CFBundleShortVersionString = 0.1.5; also
    reproduced from source at upstream/main HEAD 07c1e680)
  • OS: macOS, Apple Silicon (arm64)
  • Updated via auto-updater from an earlier 0.1.x build

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions