feat: drag-and-drop a folder to open it as a project - #51
Conversation
Drop a directory onto the window to create/switch a workspace at that path (same flow as File → Open Project). Overlay feedback while dragging; non-folder drops are ignored. Path resolved via webUtils in preload; directory check in main.
|
I'll take a look here later. |
|
Typecheck, lint, and the full test suite all pass on my end. I did hit one state bug while poking at it though. If you drop a folder that already has a workspace while a different workspace is active, the app ends up in a stale state. Here's the chain:
File > Open Project is affected too now that it shares this code path. It used to always go through The fix is small: check whether the dropped path was already the active workspace before calling const active = get().activeWorkspace
const wasAlreadyActive = active ? pathsEqual(active.path, trimmed) : false
await get().createWorkspace(name, trimmed)
const ws = get().workspaces.find((w) => pathsEqual(w.path, trimmed))
if (!ws) return false
if (wasAlreadyActive) {
get().setCurrentView('chat')
if (get().piStatus !== 'running') await get().startPi()
return true
}
const switched = await get().switchWorkspace(ws.id)
if (switched) get().setCurrentView('chat')
return switchedThe first-workspace case then flows through A store test for the "existing workspace, different one active" drop would be worth adding, since the current test plan only covers re-dropping the folder of the workspace you're already in. |
…active shortcut Main activates a duplicate path inside createWorkspace, so checking activeWorkspace after create wrongly skipped switchWorkspace. Snapshot whether the path was already active before create. Add regression tests.
|
Addressed the stale-state bug on opening an existing workspace that is not currently active:
|
Summary
openFolderAsWorkspacesystem:path-kind); path from drop via preloadwebUtils.getPathForFileTest plan
npm run typecheck&&npm run lint&&npx tsx --test src/shared/folder-drop.test.ts