-
Notifications
You must be signed in to change notification settings - Fork 280
feat: Add project reset functionality #4
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
base: master
Are you sure you want to change the base?
Conversation
Allow users to reset a project to its initial state without having to
re-register it. This is useful when a project initialization fails or
when users want to start fresh.
Changes:
- Add POST /api/projects/{name}/reset endpoint
- Add ResetProjectModal component with confirmation dialog
- Add useResetProject hook for React Query integration
- Add Reset button in header (keyboard shortcut: R)
- Disable reset while agent is running
The reset clears features.db, assistant.db, and settings files while
preserving the prompts directory with app_spec.txt and templates.
- Backend: Add full_reset query parameter to POST /api/projects/{name}/reset
- When full_reset=true, also deletes prompts/ directory
- Allows starting completely fresh with setup wizard
- Frontend: Enhanced ResetProjectModal with two options:
- Quick Reset: Clear features/history, keep prompts
- Full Reset: Delete everything including prompts
- Removed R keyboard shortcut for reset modal
- Updated API client and hooks to support fullReset parameter
The script was failing with 'ModuleNotFoundError: No module named dotenv' because it wasn't activating the virtual environment before running Python. Now checks for and activates venv/bin/activate if the venv directory exists.
When a project's spec files are deleted via full reset, the UI now displays the ProjectSetupRequired component which offers: - "Create with Claude" for interactive spec generation - "Edit Templates Manually" for direct file editing Changes: - Add ProjectSetupRequired component for projects without specs - Update App.tsx to check has_spec and conditionally render setup UI - Refetch projects after setup completes to update UI state
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
📝 WalkthroughWalkthroughThis PR introduces a project reset feature enabling users to clear project state selectively. It adds a backend POST endpoint for project reset with file deletion logic, new frontend components for reset modals and setup prompts, integrates reset-related hooks and API calls, and activates virtual environment support in the startup script. Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant App as App.tsx
participant Modal as ResetProjectModal
participant Hook as useResetProject
participant API as api.ts
participant Backend as /projects/{name}/reset
participant FS as Filesystem
User->>App: Click Reset Button
App->>App: Show Reset Modal
activate Modal
User->>Modal: Select Reset Type & Confirm
Modal->>Hook: mutate(projectName, fullReset)
activate Hook
Hook->>API: resetProject(name, fullReset)
activate API
API->>Backend: POST /projects/{name}/reset
deactivate API
activate Backend
Backend->>Backend: Validate project exists
Backend->>Backend: Check agent not running
Backend->>FS: Delete features.db, assistant.db, settings
Backend->>FS: Delete prompts/ if fullReset=true
FS-->>Backend: Deletion complete
Backend-->>Backend: Aggregate results
Backend-->>API: ResetProjectResponse
deactivate Backend
activate API
API-->>Hook: Response
deactivate API
Hook->>Hook: Invalidate queries
Hook-->>Modal: Success
deactivate Hook
Modal->>App: onClose & onReset callbacks
deactivate Modal
App->>App: Update state, refresh UI
User->>User: Project reset complete
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (5)
start_ui.sh (1)
14-18: Consider adding error handling for activation failure.While the venv activation is a good addition, consider adding error handling in case the activation fails:
# Activate virtual environment if it exists if [ -d "$SCRIPT_DIR/venv" ]; then echo "Activating virtual environment..." - source "$SCRIPT_DIR/venv/bin/activate" + if ! source "$SCRIPT_DIR/venv/bin/activate"; then + echo "WARNING: Failed to activate virtual environment" + echo "Continuing with system Python..." + fi fiThis ensures the script continues gracefully if activation fails for any reason.
ui/src/hooks/useProjects.ts (1)
51-64: Consider invalidating agent status query.The invalidation strategy covers the main affected queries. However, since the reset operation might affect the agent's state (especially in a full reset), consider also invalidating the agent status query:
onSuccess: (_, { name }) => { // Invalidate both projects and features queries queryClient.invalidateQueries({ queryKey: ['projects'] }) queryClient.invalidateQueries({ queryKey: ['features', name] }) queryClient.invalidateQueries({ queryKey: ['project', name] }) + queryClient.invalidateQueries({ queryKey: ['agent-status', name] }) },This ensures the UI reflects any agent state changes that occur during reset.
server/routers/projects.py (2)
262-264: Remove unused ResetOptions class.The
ResetOptionsclass is defined but never instantiated or used. The endpoint uses thefull_resetparameter directly instead of this class.🧹 Proposed fix
-class ResetOptions: - """Options for project reset.""" - delete_prompts: bool = False - - @router.post("/{name}/reset")
300-301: Remove unnecessary f-string prefix.The f-string on Line 301 contains no placeholders.
📝 Proposed fix
- if not project_dir.exists(): - raise HTTPException(status_code=404, detail=f"Project directory not found") + if not project_dir.exists(): + raise HTTPException(status_code=404, detail="Project directory not found")ui/src/App.tsx (1)
123-123: Consider removingwsState.agentStatusfrom dependencies.The
wsState.agentStatusvalue is not used in the keyboard handler (lines 80-119). Including it in the dependencies will cause the effect to re-register event listeners whenever the agent status changes, which is unnecessary.♻️ Proposed fix
- }, [selectedProject, showAddFeature, selectedFeature, debugOpen, assistantOpen, showResetModal, wsState.agentStatus]) + }, [selectedProject, showAddFeature, selectedFeature, debugOpen, assistantOpen, showResetModal])
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
server/routers/projects.pystart_ui.shui/src/App.tsxui/src/components/ProjectSetupRequired.tsxui/src/components/ResetProjectModal.tsxui/src/hooks/useProjects.tsui/src/lib/api.tsui/tsconfig.tsbuildinfo
🧰 Additional context used
🧬 Code graph analysis (3)
ui/src/components/ResetProjectModal.tsx (2)
ui/src/lib/api.ts (1)
resetProject(76-81)ui/src/hooks/useProjects.ts (1)
useResetProject(51-64)
server/routers/projects.py (5)
registry.py (1)
get_project_path(195-213)server/routers/spec_creation.py (1)
validate_project_name(46-48)server/routers/agent.py (1)
validate_project_name(35-42)server/routers/features.py (1)
validate_project_name(57-64)server/websocket.py (1)
validate_project_name(107-109)
ui/src/App.tsx (4)
ui/src/hooks/useProjects.ts (3)
useProjects(13-18)useFeatures(70-77)useAgentStatus(116-123)ui/src/hooks/useWebSocket.ts (1)
useProjectWebSocket(22-163)ui/src/components/ProjectSetupRequired.tsx (1)
ProjectSetupRequired(20-175)ui/src/components/ResetProjectModal.tsx (1)
ResetProjectModal(11-175)
🪛 Ruff (0.14.10)
server/routers/projects.py
301-301: f-string without any placeholders
Remove extraneous f prefix
(F541)
328-328: Do not catch blind exception: Exception
(BLE001)
338-338: Do not catch blind exception: Exception
(BLE001)
🔇 Additional comments (21)
ui/src/components/ProjectSetupRequired.tsx (6)
36-46: LGTM! Clean async error handling.The function correctly manages state transitions and error handling for the agent initialization flow.
63-77: LGTM! Clean full-screen overlay pattern.The chat overlay is properly structured with appropriate z-index and callbacks.
79-152: LGTM! Well-structured UI with clear options.The two-option layout is clear and accessible. The visual design aligns with the neo-brutalism theme used throughout the app.
154-172: LGTM! Clear status feedback.The loading and error states provide good user feedback with appropriate retry functionality.
24-24: LGTM! State correctly preserves yolo mode for retry.The
yoloModeSelectedstate ensures retry attempts use the same mode as the original request.
48-52: No action needed — retry logic is correct.
handleSpecCompleteonly retries thestartAgentcall, which is appropriate. Spec creation happens within theSpecCreationChatcomponent and completes beforehandleSpecCompleteis invoked. Spec creation errors are handled bySpecCreationChatitself, not by this retry mechanism.ui/src/lib/api.ts (2)
69-74: LGTM! Well-structured response type.The interface clearly communicates the reset operation results, including which files were deleted.
76-81: LGTM! Safe defaults and proper encoding.The function correctly defaults to a non-destructive quick reset and properly encodes the project name.
ui/tsconfig.tsbuildinfo (1)
1-1: Build metadata correctly updated.This generated file reflects the addition of the new
resetprojectmodal.tsxcomponent.server/routers/projects.py (4)
303-309: LGTM! Proper concurrency control.The lock file check correctly prevents project reset while the agent is running, avoiding potential data corruption or race conditions.
311-330: LGTM! Good error collection pattern.The deletion loop properly collects all errors before reporting them, which provides better user feedback than failing on the first error. The broad exception catching here is appropriate for error collection.
331-339: LGTM! Full reset logic is correct.The prompts directory deletion is properly conditional on
full_reset=True, and the error handling follows the same collection pattern as file deletions. The prompts are intentionally not re-scaffolded here, as the setup wizard handles that flow.
341-353: LGTM! Comprehensive response structure.The error handling properly aggregates deletion failures and returns a 500 status with details. The success response provides useful feedback including the list of deleted files and reset type.
ui/src/App.tsx (4)
19-21: LGTM! Clean state and hook integration.The new imports, state management, and
needsSetupcomputation are properly integrated. Therefetchcapability fromuseProjectswill correctly update the project list after setup completion.Also applies to: 39-39, 41-41, 46-50
107-109: LGTM! Correct Escape key priority.The reset modal is properly prioritized as the first modal to close on Escape, which prevents unintended dismissal of other UI elements when the user wants to cancel the reset operation.
174-182: LGTM! Proper button state management.The Reset button correctly disables when the agent is running, preventing concurrent operations and matching the backend's lock file check. The visual styling and placement are appropriate.
210-217: LGTM! Correct conditional rendering flow.The setup wizard properly displays when
needsSetupis true, and the refetch callback ensures the project list updates after setup completion. The reset modal rendering is properly gated by bothshowResetModalandselectedProject.Also applies to: 277-283
ui/src/components/ResetProjectModal.tsx (4)
1-14: LGTM! Well-structured component setup.The imports, props interface, and state management are clean and appropriate. The
onResetcallback is optional, allowing flexibility in how parent components respond to reset completion.
16-25: LGTM! Robust error handling and callback flow.The
handleResetfunction properly clears errors before attempting the reset, awaits the mutation, and calls callbacks in the correct order. Error handling gracefully sets local state for user feedback.
27-109: LGTM! Excellent UX with clear visual distinction.The modal structure properly handles click propagation to prevent accidental closure. The reset type toggle provides clear visual feedback with appropriate color coding: Quick Reset uses the progress color while Full Reset uses the danger color, helping users understand the severity of each option.
111-170: LGTM! Transparent and informative user interface.The deletion and preservation lists clearly communicate what will happen during the reset, with content dynamically adapting to the selected reset type. The color-coded sections (warning for deletions, success for preservation) and the contextual note about the setup wizard provide excellent transparency for users making this decision.
- Add users table schema with id, username, passwordHash, email, role fields - Add tokens table schema for session management - Create UserRepository with login, create, getByUsername methods - Add authentication error types (InvalidCredentialsError, UserNotFoundError, UserAlreadyExistsError) - Implement POST /api/auth/login endpoint with username/password validation - Implement POST /api/auth/register endpoint for user registration - Password hashing with SHA-256 + salt - Token generation for authenticated sessions Tested via browser automation: - User registration: 201 Created with user data - Login with valid credentials: 200 OK with user + token - Login with invalid credentials: 401 Unauthorized Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary
ResetProjectModalwith two reset options:ProjectSetupRequiredcomponent shown after full reset whenhas_spec === falsePOST /api/projects/{name}/reset?full_reset=trueendpointFeatures
Test plan
Summary by CodeRabbit
Release Notes
✏️ Tip: You can customize this high-level summary in your review settings.