Skip to content

fix(parsers): import Cursor desktop sessions - #1200

Closed
Cuinnchen wants to merge 1 commit into
spacering-net:mainfrom
Cuinnchen:fix/cursor-desktop-session-import
Closed

Cuinnchen wants to merge 1 commit into
spacering-net:mainfrom
Cuinnchen:fix/cursor-desktop-session-import

Conversation

@Cuinnchen

Copy link
Copy Markdown
Contributor

Summary

  • Discover and read Cursor desktop composer history from global and per-workspace state.vscdb stores.
  • Support inline, chunked, header-only, and unindexed records, including workspace-path resolution and TEXT/BLOB payloads.
  • Decode messages, thinking, tools, usage, and timestamps; skip empty drafts and preserve nonzero tool exits.
  • Keep all access read-only and use indexed range queries plus a constant-row readiness probe.

Verification

  • cargo test --no-default-features --features server-bin --bin codeg-server --lib parsers::cursor::tests -- --test-threads=1 — 37 passed.
  • cargo check --no-default-features --features server-bin --bin codeg-server — passed.
  • cargo clippy --no-default-features --features server-bin --bin codeg-server --lib -- -D warnings — passed.
  • Real local Cursor data: 215 conversations discovered; a chunked _v18 session decoded 1354 turns and an older _v14 workspace-mapped session decoded 12 turns in about 2 seconds.
  • Full server suite: 7015 passed, 27 failed, 6 ignored. All 27 failures are in unrelated delegation/scratch tests during /tmp temporary-directory creation or socket binding; no Cursor tests failed.

Review

  • Independent read-only review completed. All four initial Important findings were fixed and the follow-up verdict was ready to merge.

@xintaofei

Copy link
Copy Markdown
Collaborator

Thanks for the detailed work. Decoding state.vscdb across inline, chunked, header-only and unindexed records is careful. I don't think this should merge in its current shape, though. The problem is the approach, not individual lines.

Main concern: these conversations can't be continued. CursorParser now returns IDE composers as ordinary AgentType::Cursor conversations (src-tauri/src/parsers/cursor.rs:296, :301). They are imported with the composer ID as external_id. The agent codeg actually drives is cursor-agent acp, and its session/load only opens ~/.cursor/acp-sessions/<id>/store.db. For a desktop composer it answers Session "<id>" not found.

That message doesn't match codeg's session-gone markers (src-tauri/src/acp/connection.rs:14319), so the connection falls back to session/new. bind_external_id then re-points the open row to a new, empty CLI session and moves the desktop history to a separate sidebar row (src-tauri/src/db/service/conversation_service.rs:827). So a user who opens an imported desktop chat and replies gets an agent with no memory of it, and the conversation silently splits in two.

Codeg's other parsers deliberately read only the store of the agent codeg drives. kiro.rs reads only sessions/cli/, and antigravity.rs reads only the antigravity-acp/ subtree. Supporting another product's history needs a decision first: either view-only imports with no composer, or a separate source that is clearly labeled as not resumable. That is a different design rather than a fix to this one, so I haven't pushed any changes.

Other issues found along the way (worth fixing if the feature is redesigned):

  • No caching: every parser-backed scan (import, local list/folder/stats) reads each composer's full composerData and probes bubbles until one decodes (cursor_desktop.rs:64-93).
  • CURSOR_DESKTOP_USER_DIR (cursor_desktop.rs:193) is a made-up variable read from the agent's launch env. It works as a test hook, not a real Cursor setting.
  • Existing tests that build CursorParser::for_env without that override now scan the real user's Cursor data dir, e.g. for_env_reads_the_config_dir_of_the_launch_env.
  • The unindexed fallback orders bubbles by rowid (cursor_desktop.rs:405). cursorDiskKV is UNIQUE ON CONFLICT REPLACE, so a rewritten bubble moves to the end.
  • started_at falls back to Utc::now() (cursor_desktop.rs:490).
  • About 20 rustfmt-only hunks in cursor.rs inflate the diff.

How this was checked: I read the diff against the codeg import, load and bind code paths. A second reviewer checked the verdict independently and inspected the pinned cursor-agent bundle's session/load. I didn't build or run the tests.

If the maintainers want IDE history in codeg, a view-only import path would be the way to go; this decoder could mostly be reused there.


🤖 Generated with Codeg

@Cuinnchen Cuinnchen closed this Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants