fix(cursor): map composers to workspace via composer.composerHeaders

Recent Cursor builds renamed the per-workspace composer list from
ItemTable['composer.composerData'] to 'composer.composerHeaders' (identical
{ allComposers: [{ composerId }] } shape). loadWorkspaceMap only read the old
key, so on these builds the composer->workspace map came back empty and every
composer fell through to the 'cursor' orphan bucket, losing per-project
attribution.

Read both keys and merge their allComposers lists (backward compatible with
older installs). Add a regression test covering the new composer.composerHeaders
key and the legacy composer.composerData key.

Verified against a real workspace state.vscdb: composer.composerData absent,
composer.composerHeaders present with composerIds matching the bubbleId/
composerData rows; 21/22 calls now attribute to the real workspace instead of
the 'cursor' orphan bucket.

AI-Origin: human
This commit is contained in:
Andrew Lee 2026-07-02 17:51:23 +00:00
parent 174193d503
commit 400ca083a2
2 changed files with 104 additions and 13 deletions

View file

@ -193,22 +193,31 @@ function loadWorkspaceMap(workspaceStorageDir: string): WorkspaceMapping {
continue
}
try {
// Cursor renamed the per-workspace composer list from
// 'composer.composerData' to 'composer.composerHeaders' in newer builds
// (identical { allComposers: [{ composerId }] } shape). Read both keys
// and merge so the composer -> workspace mapping keeps working across
// Cursor versions. Without this, on builds that only write
// 'composer.composerHeaders' every composer falls through to the
// 'cursor' orphan bucket and per-project attribution is lost.
const rows = db.query<{ value: string }>(
"SELECT value FROM ItemTable WHERE key='composer.composerData'",
"SELECT value FROM ItemTable WHERE key IN ('composer.composerData', 'composer.composerHeaders')",
)
if (rows.length === 0) continue
let parsed: { allComposers?: Array<{ composerId?: string }> }
try {
parsed = JSON.parse(rows[0]!.value)
} catch {
continue
}
const project = sanitizeWorkspaceUri(folder)
let added = 0
for (const c of parsed.allComposers ?? []) {
if (typeof c.composerId === 'string') {
result.composerToWorkspace.set(c.composerId, folder)
added += 1
for (const row of rows) {
let parsed: { allComposers?: Array<{ composerId?: string }> }
try {
parsed = JSON.parse(row.value)
} catch {
continue
}
for (const c of parsed.allComposers ?? []) {
if (typeof c.composerId === 'string') {
result.composerToWorkspace.set(c.composerId, folder)
added += 1
}
}
}
if (added > 0) {