-
Notifications
You must be signed in to change notification settings - Fork 11
🤖 fix: expand tilde in project paths and validate existence #492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+593
−191
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When users input project paths with tilde (~), they were not being expanded correctly, causing all project operations to fail. This fix implements automatic tilde expansion and path validation. Changes: - Add pathUtils module with expandTilde() and validateProjectPath() - Update PROJECT_CREATE handler to validate and normalize paths - Update PROJECT_LIST_BRANCHES handler to handle tilde paths - Prevent adding non-existent paths as projects - Reject file paths (only directories are valid projects) - Normalize paths with .. to avoid duplicate entries Testing: - Unit tests for expandTilde() and validateProjectPath() - Integration tests for PROJECT_CREATE IPC handler covering: * Tilde expansion in project paths * Rejection of non-existent paths * Rejection of file paths (non-directories) * Path normalization with .. segments * Duplicate detection with normalized paths All tests pass. Linter and type checker satisfied. _Generated with `cmux`_
- Add .git directory validation to prevent non-git paths - Return normalized path from PROJECT_CREATE for frontend use - Fix duplicate detection using backend-normalized paths - Add proper error display with alert() in frontend - Update integration tests for new response format Fixes issues: - Projects showing in UI even when creation failed - Duplicate projects appearing due to path normalization mismatch - Missing git repository validation - Silent errors not shown to users
- Replace all alert() calls in useProjectManagement with proper error state - Add ProjectErrorModal component to display validation and create errors - Wire error state through AppContext to App component - Clean up unnecessary console.log statements in loadProjects - Add Storybook stories for ProjectErrorModal demonstrating all error types Error flow now properly blocks project creation in both native dialog and web versions without using alert(). Errors are displayed in a modal that must be dismissed before continuing. _Generated with `cmux`_
Remove native Electron file dialog in favor of web dialog for consistency: - Update useProjectManagement to dispatch directory-select-request event - Remove dialog IPC handler (DIALOG_SELECT_DIR) from ipcMain - Remove dialog API from IPCApi interface, preload, and browser API - Update App.stories.tsx mock to remove dialog API - Remove DIALOG_SELECT_DIR constant from ipc-constants Both native and web versions now use DirectorySelectModal for path input, providing consistent UX across deployment modes. _Generated with `cmux`_
Move error handling into DirectorySelectModal to keep modal open on error: - Modal now calls window.api.projects.create() directly - Backend validation errors displayed inline with path preserved - Duplicate project check moved to modal (using normalized path) - Remove ProjectErrorModal component (no longer needed) - Remove error state from useProjectManagement hook - Remove projectError/clearProjectError from AppContext - Add loading state with "Adding..." button text Modal stays open until project successfully created or user cancels. User can correct path without re-entering everything. _Generated with `cmux`_
Rename for better discoverability and clarity: - File: DirectorySelectModal.tsx → ProjectCreateModal.tsx - Component: DirectorySelectModal → ProjectCreateModal - Update imports in App.tsx - Update component documentation The modal now clearly indicates it handles project creation, not just directory selection. _Generated with `cmux`_
Replace custom event system with standard React props pattern: - ProjectCreateModal now accepts isOpen, onClose, onSuccess props - Remove event listener and promise-based communication - Update useProjectManagement.addProject to accept params directly - App.tsx manages projectCreateModalOpen state - Simpler flow: button click → setState(true) → modal opens Eliminates unnecessary indirection. Modal is just a normal React component controlled by parent state. _Generated with `cmux`_
Convert validateProjectPath from sync to async to avoid blocking IPC handlers: - Use fs/promises instead of sync fs methods - Update IPC handlers to await validation - Update all tests to handle async function - Better error handling with try/catch instead of existsSync Removes eslint-disable comments for sync fs methods. _Generated with `cmux`_
_Generated with `cmux`_
7dfd9de to
fc2dd04
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When users input project paths with tilde (~), they were not being expanded correctly, causing all project operations to fail. This fix implements automatic tilde expansion and path validation.
Changes
Testing
Unit tests (12 tests):
Integration tests (7 tests):
All tests pass. Linter and type checker satisfied.
Generated with
cmux