thomas-pedersen / cursor-chat-browser

A web application for browsing and managing chat histories from the Cursor editor's AI chat feature. View, search, and export your AI conversations in various formats.
28 stars 2 forks source link

Fix home directory path resolution on macOS #3

Open abakermi opened 5 days ago

abakermi commented 5 days ago

The current implementation uses a macOS-specific path with a tilde (~), which has two problems:

  1. The tilde isn't automatically expanded to the home directory in Node.js
  2. The path structure is specific to macOS and won't work on Windows

Current implementation:

const workspacePath = process.env.WORKSPACE_PATH || '~/Library/Application Support/Cursor/User/workspaceStorage' . This doesn't work correctly because Node.js doesn't automatically expand the tilde (~) to the user's home directory.

Current Behavior

Proposed Solution

Use os.homedir() and path.join() with platform-specific paths:

import os from 'os'
import path from 'path'
const defaultPath = process.platform === 'win32'
? path.join(os.homedir(), 'AppData/Roaming/Cursor/User/workspaceStorage')
: path.join(os.homedir(), 'Library/Application Support/Cursor/User/workspaceStorage')
const workspacePath = process.env.WORKSPACE_PATH || defaultPath

Benefits

Additional Notes

This issue affects all users who haven't set a custom WORKSPACE_PATH environment variable, particularly:

thomas-pedersen commented 4 days ago

Thanks for the feedback abakermi. I have only tried this in windows using WSL2, so wasn't sure it would work out of the box on other systems. Feel free to make a PR with a fix.

nsubordin81 commented 1 day ago

I put in some changes (with a lot of help from claude using cursor. barely understand what is being done, but it resolves the path correclty for me on a mac OS. not sure if there are differences in how cursor is storing things on a mac, but in my browser I'm seeing a bunch of 404s on attempts to access some of the directories within my workspaceStorage. So the UI is showing me chats from soem of these long hex-string dirs but not for others.

definitely not feeling comfortable putting up a PR at this point but wanted to validate the approach. if I make progress I'll fork and PR just to show it.