fix(cursor): verify Cursor installation on Linux before auto-import

On Linux, verify that Cursor IDE is actually installed before importing
tokens. Previously, leftover config files from a removed Cursor installation
would trigger a false positive, creating a phantom Cursor provider connection.

The check uses `which cursor` and falls back to checking for a .desktop file
in ~/.local/share/applications/

Fixes #313

Co-authored-by: Ibrahim Ryan <ryan@nuevanext.com>
Made-with: Cursor
This commit is contained in:
Ibrahim Ryan
2026-03-23 10:31:29 +07:00
committed by decolua
parent 97f2a00e74
commit 8312af79a4

View File

@@ -156,6 +156,27 @@ export async function GET() {
});
}
// On Linux, verify Cursor is actually installed (not just leftover config)
if (platform === "linux") {
let cursorInstalled = false;
try {
await execFileAsync("which", ["cursor"], { timeout: 5000 });
cursorInstalled = true;
} catch {
try {
const desktopFile = join(homedir(), ".local/share/applications/cursor.desktop");
await access(desktopFile, constants.R_OK);
cursorInstalled = true;
} catch { /* not found */ }
}
if (!cursorInstalled) {
return NextResponse.json({
found: false,
error: "Cursor config files found but Cursor IDE does not appear to be installed. Skipping auto-import.",
});
}
}
// Strategy 1: sqlite3 CLI
try {
const tokens = await extractTokensViaCLI(dbPath);