Add project deletion from sidebar context menu #50
Mergedjuliusmarmingemerged 3 commits into
main fromcodething/9493a863merged by juliusmarminge View on GitHub- @@ -322,3 +322,19 @@322322 [api, dispatch, removeWorktreeMutation, state.projects, state.threads],323323 );324324325+ const handleProjectContextMenu = useCallback(326+ async (projectId: string, position: { x: number; y: number }) => {327+ if (!api) return;328+ const clicked = await api.contextMenu.show([{ id: "delete", label: "Delete" }], position);329+ if (clicked !== "delete") return;330+331+ const project = state.projects.find((entry) => entry.id === projectId);332+ if (!project) return;333+334+ if (isElectron) {335+ try {336+ await api.projects.remove({ id: projectId });337+ } catch {338+ return;339+ }340+ }
- apps/web/src/components/Sidebar.tsx lines 337 to 380Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -324,0 +349,21 @@349+ });350+ } catch {351+ // Session may already be stopped352+ }353+ }354+355+ try {356+ await api.terminal.close({357+ threadId: thread.id,358+ deleteHistory: true,359+ });360+ } catch {361+ // Terminal may already be closed362+ }363+ }),364+ );365+366+ dispatch({ type: "DELETE_PROJECT", projectId });367+ },368+ [api, dispatch, state.projects, state.threads],369+ );apps/web/src/components/Sidebar.tsx lines 361 to 375Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -322,3 +322,19 @@322322 [api, dispatch, removeWorktreeMutation, state.projects, state.threads],323323 );324324325+ const handleProjectContextMenu = useCallback(326+ async (projectId: string, position: { x: number; y: number }) => {327+ if (!api) return;328+ const clicked = await api.contextMenu.show([{ id: "delete", label: "Delete" }], position);329+ if (clicked !== "delete") return;330+331+ const project = state.projects.find((entry) => entry.id === projectId);332+ if (!project) return;333+334+ if (isElectron) {335+ try {336+ await api.projects.remove({ id: projectId });337+ } catch {338+ return;339+ }340+ }
juliusmarminge merged this748ea2a
juliusmarminge closed this
Sign in to join this conversation.
No actionable comments were generated in the recent review. 🎉
Walkthrough#
Adds a project-level right-click context menu that confirms and invokes project deletion via the Electron API, prevents deleting projects that still have threads, shows toasts for warnings/errors, and dispatches a new
DELETE_PROJECTaction; the reducer removes the project and its threads and updatesactiveThreadId.Changes#
apps/web/src/store.tsDELETE_PROJECTaction type and reducer case to remove the specified project, delete threads with matchingprojectId, and setactiveThreadIdto an existing thread ornull.apps/web/src/components/Sidebar.tsxhandleProjectContextMenu(useCallback) wired to project headeronContextMenu: prevents default menu, checks for threads (warning toast if non-empty), confirms deletion, callsapi.projects.remove, logs/shows error on failure, and dispatchesDELETE_PROJECTon success.apps/web/src/store.test.tsactiveThreadIdupdate.Sequence Diagram(s)#
Estimated code review effort#
🎯 3 (Moderate) | ⏱️ ~25 minutes
🚥 Pre-merge checks | ✅ 3 | ❌ 1
❌ Failed checks (1 warning)#
✅ Passed checks (3 passed)
main✨ Finishing touches
🧪 Generate unit tests (beta)
Comment `@coderabbitai help` to get the list of available commands and usage tips.