feat: Add projectFolder to user preferences#669
Conversation
Adds `projectFolder` as a key to user preferences, stores the location of the most recently opened project, and prefills it in the next File → Open action. Mirrors the pattern from siddharthvaddem#512 (`exportFolder`). Closes siddharthvaddem#668
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThreads an optional projectFolder from UI through preload, IPC, native bridge, and ProjectService; validates it for dialog prefill, and persists the parent folder in user preferences for future dialog defaults. ChangesRemember Last Project Folder
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Resolves conflicts in userPreferences.ts and userPreferences.test.ts by combining the projectFolder feature with upstream's trayLayout addition.
Resolved conflicts: - LaunchWindow.tsx: kept upstream's removal of openVideoFile/openProjectFile (moved to Studio Dashboard) - VideoEditor.tsx: used upstream's doLoadProject rename while preserving getProjectFolder() arg
The Studio Dashboard's Load Project button was calling loadProjectFile() without the remembered folder, always defaulting to RECORDINGS_DIR. Also save projectFolder preference after a successful load from this path.
Description
Adds
projectFolderas a key to user preferences, stores the location of the most recently opened project, and prefills it in the next File → Open action.Direct mirror of the pattern introduced by #512 for the export dialog. Reuses the existing
parentDirectoryOfhelper (which already handles POSIX and Windows roots after the codex-bot / coderabbit feedback on #512) and the same localStorage-backed preferences module.Type of Change
Related Issue(s)
Closes #668. Inspired by #503 / #512.
What changed
src/lib/userPreferences.ts— addedprojectFolder: string \| nulltoUserPreferencesandDEFAULT_PREFS, hydrate inloadUserPreferences, addedgetProjectFolder()helper.src/lib/userPreferences.test.ts— round-trip tests for the new field, default / invalid / empty hydration, independence fromexportFolder. Tests use an in-memorylocalStoragestub since the jsdom global isn't exposed in this vitest setup.electron/ipc/handlers.ts—loadProjectFilenow acceptsprojectFolder?: string, stats it, falls back toRECORDINGS_DIRwith a warn log if it's gone or unreadable. Mirrors thesave-exported-videopath validation pattern from feat: Add exportFolder to user preferences #512.electron/preload.ts+electron/electron-env.d.ts— threadprojectFolder?: stringthrough the bridge.electron/ipc/nativeBridge.ts+electron/native-bridge/services/projectService.ts— extend the bridge dispatch + service signature to forward the param.src/native/contracts.ts+src/native/client.ts— payload on theloadProjectFileaction carriesprojectFolder?: string.src/components/video-editor/VideoEditor.tsxandsrc/components/launch/LaunchWindow.tsx— both open-project entry points readgetProjectFolder()before calling the bridge, and on success persistparentDirectoryOf(result.path)back to preferences.Testing
RECORDINGS_DIR) and open an.openscreenproject.localStorage).RECORDINGS_DIRwithout erroring (warning logged to the main-process console).Unit tests (
src/lib/userPreferences.test.ts) cover the load/save round-trip, default fallback, invalid-type rejection, empty-string rejection, and independence fromexportFolder.Checklist
npm test,npx tsc --noEmit, andnpx biome check .all pass locally.Summary by CodeRabbit
New Features
Tests