← Back to Pull requests

feat(storage): import Cursor sessions via the state.vscdb adapter #6039

Open
unknown opened this pull request with 379 lines diff across 4 files
View on GitHub
unknown unknown commented on Oct 10, 2026 02:45 UTC
Author

Summary

Adds a fourth external-session adapter that imports Cursor conversations from the local state.vscdb SQLite database, per #5964's design sketch. The adapter follows the same contract and hardening rules as the existing Codex, Claude Code, and OpenCode adapters: read-only node:sqlite access, all five limit kinds active, sanitized titles, and error messages that carry no source paths or transcript content.

Shape notes from the real database (macOS, _v 10 through 14):

  • composerData:<id> holds the display name, epoch-millis stamps, and the ordered fullConversationHeadersOnly index; bubbleId:<composerId>:<bubbleId> holds one message body (bubble type 1 = user, 2 = assistant).

  • Assistant bubbles carry an optional toolFormerData; completed and error convert to paired tool results, cancelled calls stay unanswered and mark the turn aborted.

  • Headers whose bubble rows the source pruned, and bubble rows whose JSON this build cannot decode, are gaps the import skips rather than errors.

  • Catalog metadata the source does not expose is absent rather than invented: Cursor composers carry no working directory, so sessions import with an empty cwd, and archived filtering (which lives in the separate composerHeaders table) is left as a natural follow-up.
  • The maintainer questions on the issue are answered by proceeding the way its author proposed: the format is non-public like the three sources already imported, and the import page enumerates registry adapters, so no desktop UI change is included.

    Fixes #5964

    Verification

    | Check | Result |
    | --- | --- |
    | New fixture suite (in-code state.vscdb) | 14/14 green (detect/catalog/paging/full mapping/pruned+corrupt gaps/not-found/hostile id/all five limit kinds/path-free errors/title sanitize/registry) |
    | Adjacent adapters + importer suites | 114/114 green (registry change breaks nothing) |
    | Real database smoke (1.3 GB, _v up to 14) | detect true; catalog lists; one session read end-to-end: 925 messages = 5 user, 182 assistant, 368 tool calls, 365 paired results (the 3 unpaired are the source's cancelled tools) |
    | biome check on touched files | clean |
    | npm run check:asf-headers | green (4242 files audited) |
    | protocol-epoch-check --base 1e80e3b88 | no protocol changes (epoch 202) |
    | Not run locally | Windows/Linux behavior of node:sqlite on the spaced path (opened through the driver only, per the Codex adapter precedent); CI will cover |

    AI use

    Generated with an AI coding assistant (ZCode / GLM-5.3-Flash) under human direction; the design, schema measurements, and verification runs against a real database are recorded in the issue and this PR.

    Checklist

  • No protocol or storage-schema changes (read-only over existing on-disk data)

  • All five external-session limit kinds active and tested

  • Error messages and ids carry no source paths or transcript content

  • Fixture tests fail against the absent adapter by construction (the type and registry entry did not exist)
  • Diff: 379 lines (+284 / -95) across 4 files Reviewer: ggbdpq Review duration: 5234m
    All Vouch review confidence checks passed
    Residual risk 0.27 = Change Risk (0.48) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 379 lines diff across 4 files
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.355
    Shallow Review Depth shallow_review_depth
    0.344
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #6039"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 47.9% (MEDIUM) · Higher = larger blast radius
    47.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 43.0% · Lower = rushed or shallow review
    43.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 27.3% · Safe to merge
    27.3%
    Repository