fix(projects): allow removing manually added projects#620
fix(projects): allow removing manually added projects#620Steve-Rye wants to merge 1 commit intositeboon:mainfrom
Conversation
📝 WalkthroughWalkthroughThis pull request introduces a "remove project" feature distinct from deletion. Manually added projects can now be removed from the project list without deleting their local Claude history or sessions. The backend adds a new REST endpoint, the frontend differentiates between remove and delete actions with separate UI and messaging, and internationalization strings are added across all supported languages. Changes
Suggested reviewers
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🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/components/sidebar/view/subcomponents/SidebarModals.tsx (1)
108-113: Consider using neutral styling for the remove icon container.The icon container uses
bg-red-100 dark:bg-red-900/30even for remove confirmations, but remove is a non-destructive action. Consider making the container styling conditional as well for visual consistency.♻️ Proposed optional change
- <div className="flex h-12 w-12 flex-shrink-0 items-center justify-center rounded-full bg-red-100 dark:bg-red-900/30"> + <div className={cn( + "flex h-12 w-12 flex-shrink-0 items-center justify-center rounded-full", + isRemoveConfirmation + ? "bg-muted" + : "bg-red-100 dark:bg-red-900/30" + )}> {isRemoveConfirmation ? ( <X className="h-6 w-6 text-muted-foreground" /> ) : ( <AlertTriangle className="h-6 w-6 text-red-600 dark:text-red-400" /> )} </div>Note: You'll need to import
cnif not already available in this file.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/components/sidebar/view/subcomponents/SidebarModals.tsx` around lines 108 - 113, The icon container always uses the destructive classes "bg-red-100 dark:bg-red-900/30" even when isRemoveConfirmation is true (remove is non-destructive); update the container div rendering in SidebarModals so its className is conditional based on isRemoveConfirmation (e.g., use a neutral bg when isRemoveConfirmation is true and the red bg only for destructive alerts) and use the shared cn utility to compose classes (import cn if not present); adjust the inner icon rendering to remain the same but ensure the container classes reflect the non-destructive state.server/projects.remove-project.test.mjs (1)
9-21: Consider Windows compatibility for the HOME override.
process.env.HOMEworks on Unix-like systems, but Windows usesUSERPROFILE. Since the code callsos.homedir(), which is platform-aware, the test environment override will only affect Unix systems. If this test needs to run on Windows, override both environment variables.♻️ Proposed optional change for cross-platform support
async function withTempHome(fn) { const originalHome = process.env.HOME; + const originalUserProfile = process.env.USERPROFILE; const tempHome = await mkdtemp(path.join(os.tmpdir(), 'claudecodeui-home-')); process.env.HOME = tempHome; + process.env.USERPROFILE = tempHome; try { return await fn(tempHome); } finally { process.env.HOME = originalHome; + process.env.USERPROFILE = originalUserProfile; await rm(tempHome, { recursive: true, force: true }); } }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@server/projects.remove-project.test.mjs` around lines 9 - 21, The test helper withTempHome overrides only process.env.HOME which breaks on Windows; update withTempHome to save both originalHome = process.env.HOME and originalUserProfile = process.env.USERPROFILE, set both process.env.HOME and process.env.USERPROFILE to the tempHome before calling fn(tempHome), and restore both originals in the finally block (handling undefined values) so os.homedir() and other platform-aware calls see the temp directory on Windows and Unix.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@server/projects.remove-project.test.mjs`:
- Around line 9-21: The test helper withTempHome overrides only process.env.HOME
which breaks on Windows; update withTempHome to save both originalHome =
process.env.HOME and originalUserProfile = process.env.USERPROFILE, set both
process.env.HOME and process.env.USERPROFILE to the tempHome before calling
fn(tempHome), and restore both originals in the finally block (handling
undefined values) so os.homedir() and other platform-aware calls see the temp
directory on Windows and Unix.
In `@src/components/sidebar/view/subcomponents/SidebarModals.tsx`:
- Around line 108-113: The icon container always uses the destructive classes
"bg-red-100 dark:bg-red-900/30" even when isRemoveConfirmation is true (remove
is non-destructive); update the container div rendering in SidebarModals so its
className is conditional based on isRemoveConfirmation (e.g., use a neutral bg
when isRemoveConfirmation is true and the red bg only for destructive alerts)
and use the shared cn utility to compose classes (import cn if not present);
adjust the inner icon rendering to remain the same but ensure the container
classes reflect the non-destructive state.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 5aaa8fb9-d66d-4d30-9941-37c1ecf04249
📒 Files selected for processing (15)
server/index.jsserver/projects.jsserver/projects.remove-project.test.mjssrc/components/sidebar/hooks/useSidebarController.tssrc/components/sidebar/types/types.tssrc/components/sidebar/view/subcomponents/SidebarModals.tsxsrc/components/sidebar/view/subcomponents/SidebarProjectItem.tsxsrc/i18n/locales/de/sidebar.jsonsrc/i18n/locales/en/sidebar.jsonsrc/i18n/locales/ja/sidebar.jsonsrc/i18n/locales/ko/sidebar.jsonsrc/i18n/locales/ru/sidebar.jsonsrc/i18n/locales/zh-CN/sidebar.jsonsrc/types/app.tssrc/utils/api.js
Summary
This PR adds a safe
Removeflow for manually added projects so they can be removed from the sidebar without deleting the underlying project directory or related session data.What changed
DELETE /api/projects/:projectName/removefor eligible manually added projectsDelete Projectbehavior unchanged for projects with local Claude historyRemoveinstead ofDeletefor manually added sidebar-only projectsremoveProjectFromListWhy
Users can add existing workspaces to the project list, but the reverse action was missing. The only available action was
Delete Project, which is much heavier and can delete local data. For manually added projects that only exist as sidebar entries, users need a way to remove them from the list without treating them as disposable data.Scope
This PR intentionally only adds
Removefor projects that are:~/.claude/projectsProjects with local Claude history still use the existing delete flow because they are auto-discovered again from disk and cannot be truly hidden by removing config alone.
Testing
node --test server/projects.remove-project.test.mjsnpm run typechecknpm run buildRelated
Summary by CodeRabbit
New Features
Tests