Skip to content

feat(desktop): allow force delete when teardown fails - #1370

Merged
Kitenite merged 1 commit into
mainfrom
kitenite/allow-delete-anyway-when-teardown-fails
Feb 10, 2026
Merged

Kitenite merged 1 commit into
mainfrom
kitenite/allow-delete-anyway-when-teardown-fails

Conversation

@Kitenite

@Kitenite Kitenite commented Feb 10, 2026 •

Copy link
Copy Markdown
Member

Summary

  • When teardown scripts fail during workspace/worktree deletion, users were previously blocked with no way to proceed
  • Now users can choose "Delete Anyway" to force-delete, skipping the failed teardown and continuing with cleanup

Changes

  • Backend (delete.ts): Added force parameter to both delete and deleteWorktree procedures — when true, logs the teardown failure as a warning and continues deletion
  • TeardownLogsDialog: Extended showTeardownLogs to accept an onDeleteAnyway callback; renders a "Delete Anyway" button in the dialog footer
  • DeleteWorkspaceDialog: Error toast now shows "Delete Anyway" (primary action) and "View Logs" (secondary) buttons
  • DeleteWorktreeDialog: Same force-delete flow for worktree deletion

Test Plan

  • Trigger a teardown failure during workspace deletion — verify toast shows both "Delete Anyway" and "View Logs" buttons
  • Click "Delete Anyway" on toast — verify workspace is force-deleted successfully
  • Click "View Logs" on toast — verify logs dialog opens with "Delete Anyway" button in footer
  • Click "Delete Anyway" in logs dialog — verify workspace is force-deleted and dialog closes
  • Repeat above for worktree deletion flow
  • Verify normal (non-failing teardown) deletion still works as before

Summary by CodeRabbit

  • New Features

    • Added a "Delete Anyway" / force-delete option when workspace or worktree teardown fails.
    • Improved teardown failure UI: view logs, a dedicated failure toast, and an inline force-delete flow with progress/result feedback.
  • Bug Fixes

    • Teardown errors can now be bypassed when forcing deletion; non-forced behavior unchanged.

@coderabbitai

coderabbitai Bot commented Feb 10, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This PR adds an optional force flag to workspace and worktree deletion procedures and updates UI flows to support a "Delete Anyway" / force-delete path: teardown failures can be bypassed when force is true, and the teardown logs dialog and toast UI now surface a callback to trigger forced deletion.

Changes

Cohort / File(s) Summary
Backend Delete Procedures
apps/desktop/src/lib/trpc/routers/workspaces/procedures/delete.ts
Add optional force to delete and deleteWorktree inputs. Teardown failures only abort when force is not set; when force is true the procedure logs warnings and proceeds with deletion.
Teardown Logs Dialog & Exports
apps/desktop/src/renderer/routes/_authenticated/components/TeardownLogsDialog/TeardownLogsDialog.tsx, apps/desktop/src/renderer/routes/_authenticated/components/TeardownLogsDialog/index.ts
Extend showTeardownLogs to accept options with onDeleteAnyway; add and export forceDeleteWithToast and showTeardownFailedToast; dialog stores onDeleteAnyway and conditionally renders "Delete Anyway".
Workspace Delete UI
apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/components/DeleteWorkspaceDialog/DeleteWorkspaceDialog.tsx
Replace inline teardown-failure toast with showTeardownFailedToast; add handleForceDelete that calls forceDeleteWithToast and invokes backend delete with force: true.
Worktree Delete UI
apps/desktop/src/renderer/screens/main/components/WorkspacesListView/WorkspaceRow/DeleteWorktreeDialog.tsx
On teardown failure, use showTeardownFailedToast and add handleForceDelete to call deleteWorktree with force: true via forceDeleteWithToast.

Sequence Diagram

sequenceDiagram
    actor User
    participant UI as Delete Dialog / Button
    participant Toast as Toast UI
    participant Logs as Teardown Logs Dialog
    participant TRPC as Delete Procedure (server)
    participant Teardown as Teardown Handler

    User->>UI: Click Delete
    UI->>TRPC: delete({ id, deleteLocalBranch?, force: false })
    TRPC->>Teardown: run teardown
    Teardown-->>TRPC: returns failure + logs
    TRPC-->>UI: error with teardown output
    UI->>Toast: show teardown-failed toast (with "View Logs" / "Delete Anyway")
    User->>Toast: Click "View Logs"
    Toast->>Logs: showTeardownLogs(output, { onDeleteAnyway })
    User->>Logs: Click "Delete Anyway"
    Logs->>TRPC: delete({ id, force: true })
    TRPC->>Teardown: run teardown (force mode)
    Teardown-->>TRPC: may fail (logged)
    TRPC-->>UI: success (deletion proceeds despite teardown failure)
    UI->>User: show success
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • #1277: Modifies delete procedures and teardown-log UI integration; this PR builds the force-delete flow on top of that work.
  • #1255: Earlier changes to delete procedures adding optional flags (e.g., deleteLocalBranch) affecting the same delete logic.
  • #1120: Adjusts teardown control flow in delete procedures; shares code-level overlap with force-aware teardown handling.

Poem

🐰 I nibbled logs in moonlit code,

When teardowns tripped on rocky road.
"Delete Anyway" — a brave hare said,
With force in paw and warnings spread,
We hop on, leaving traces logged and stowed.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main feature: allowing force deletion when teardown fails.
Description check ✅ Passed The description covers the problem, solution, implementation details, and includes a test plan. However, it does not follow the template structure with explicit sections like Related Issues or Type of Change.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch kitenite/allow-delete-anyway-when-teardown-fails

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
apps/desktop/src/renderer/routes/_authenticated/components/TeardownLogsDialog/TeardownLogsDialog.tsx (1)

23-38: showTeardownLogs uses positional parameters — consider an object parameter.

Per coding guidelines, functions with 2 or more parameters should use object parameters. Since this is an existing function being extended, this is a minor deviation, but it would be cleaner:

♻️ Suggested refactor
-export const showTeardownLogs = (
-	logs: string,
-	options?: { onDeleteAnyway?: () => void },
-) => {
+export const showTeardownLogs = ({
+	logs,
+	onDeleteAnyway,
+}: {
+	logs: string;
+	onDeleteAnyway?: () => void;
+}) => {
 	if (!showLogsFn) {
 		console.error(
 			"[teardown-logs] TeardownLogsDialog not mounted. Make sure to render <TeardownLogsDialog /> in your app",
 		);
 		return;
 	}
-	showLogsFn(logs, options);
+	showLogsFn(logs, { onDeleteAnyway });
 };

This would also require updating all call sites. As per coding guidelines, "Use object parameters for functions with 2 or more parameters instead of positional arguments".


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

When teardown scripts fail during workspace/worktree deletion, users
can now choose to "Delete Anyway" instead of being blocked. The option
is available both in the error toast and in the teardown logs dialog.
@Kitenite
Kitenite force-pushed the kitenite/allow-delete-anyway-when-teardown-fails branch from a2fbb3b to 83da352 Compare February 10, 2026 20:06
@Kitenite
Kitenite merged commit 99e3c25 into main Feb 10, 2026
6 checks passed
@Kitenite
Kitenite deleted the kitenite/allow-delete-anyway-when-teardown-fails branch February 10, 2026 21:50
@github-actions

Copy link
Copy Markdown
Contributor

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ⚠️ Neon database branch
  • ⚠️ Electric Fly.io app
  • ⚠️ Streams Fly.io app

Thank you for your contribution! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant