Repository navigation
Closed as not planned
Closed as not planned
Copy link
Description
jcode session migrate: session storage migration & v2 sidecar fast-path for large sessions
Summary
Add a session-storage migration command (jcode session migrate [path] [--dry-run]) and a v2 sidecar format that pairs the existing JSONL log with an indexed SQLite sidecar so resume and /tree open large sessions in <100 ms. Mirrors pi migrate and pi_agent_rust's "Session Store V2 Sidecar".
Reference: pi_agent_rust Session Indexing and Session Store V2 Sidecar (Large Session Fast-Path).
Why
- jcode sessions can balloon past tens of thousands of entries (especially in self-dev). Resume time on those is currently O(N) read + parse.
- The session-tree issue introduces parent_id; rebuilding the tree on every open is wasteful without an index.
- A separate migration command lets users run it in CI before upgrading.
Current state in jcode
src/session_active_pids.rsandsrc/storage/exist; no v2 sidecar, no migration command.- Resume picker (
src/tui/session_picker/loading.rs) parses each JSONL on demand, which gets slow on large sessions.
Implementation checklist
1. v2 sidecar schema
- Per JSONL session file, an adjacent
.sqlite3sidecar with tables:entries(id PK, parent_id, ts, kind, branch_leaf_marker, byte_offset, byte_len)branches(leaf_id PK, name, labeled_at)metadata(key PK, value)
- Sidecar is regenerable from the JSONL at any time. Mismatched sidecar → treat as corrupt and rebuild.
2. Read path
- On open:
- mmap the JSONL.
- If sidecar exists and is up to date (mtime + size match metadata), use it for index queries.
- Otherwise, rebuild sidecar in the background while serving reads from the JSONL.
3. Write path
- Every appended entry updates the sidecar in the same transaction the JSONL is fsync'd in.
- Durability mode (see separate consideration):
strict(fsync every write),balanced(fsync every N entries or T seconds),throughput(fsync on flush only). Pi_agent_rust ships these as--session-durability.
4. CLI subcommand
-
jcode session migrate [path] [--dry-run] [--force]- Default
path:~/.jcode/sessions/recursively. --dry-run: print what would be migrated; no writes.--force: rebuild sidecars even when up to date.
- Default
- Subcommand also exposes
jcode session verify <path>to check sidecar/JSONL coherence.
5. Resume picker speedup
- When a sidecar is present, the picker reads metadata (name, last activity, message count, branch count) from the sidecar without parsing the JSONL.
6. Doctor integration
-
jcode doctor --only sessionsreports number of sessions, total size, sidecar coverage, last migrate time.
Testing
Unit
- Sidecar build is deterministic for a given JSONL.
- Corruption recovery: zero-out random bytes in the sidecar; on open, rebuild succeeds and JSONL data is intact.
- Durability mode crash test (using a fault-injecting writer):
strictmode survives a kill -9 between writes with no entry loss.
Bench
- Resume picker open time for a 100,000-entry session: <100 ms with sidecar, document baseline without.
Manual
- Convert a real long session and confirm
/treeopens fast.
Acceptance criteria
jcode session migrateis idempotent and lossless.- Sidecars are auto-rebuilt on detection of mismatch.
--dry-runpreviews accurately.- Durability modes are documented and selectable per-session.
- Resume picker shows the speed-up on the bench above.
References
pi_agent_rust: Session Indexing, Session Store V2 Sidecar, Subcommandpi migrate.- pi: Session format.
Metadata
Metadata
Assignees
Labels
No labels
Activity
quangdang46 commentedon May 21, 2026
Moving this issue to https://github.com/quangdang46/jcode at the repo owner's request. Closing here as not planned. The new location will be linked once re-created.