Skip to content

feat(worktree): rich delete confirmation dialog with dirty-file status - #11

Merged
JeanBaptisteRenard merged 1 commit into
mainfrom
feat/pr49-delete-worktree-dialog
May 23, 2026
Merged

JeanBaptisteRenard merged 1 commit into
mainfrom
feat/pr49-delete-worktree-dialog

Conversation

@JeanBaptisteRenard

Copy link
Copy Markdown
Collaborator

Closes the UX gap flagged in PR#49 review: the old confirm() hid the destructive consequence of -f (untracked/uncommitted files lost forever).

Changes

main.js — new worktree-status IPC handler

  • Runs git -C <parentRepo> -C <worktreePath> status --porcelain
  • Uses the same WORKTREE_PATH_RE path-validation already in delete-worktree
  • Returns { ok: true, dirty: string[], total: number } or { ok: false, error }

preload.js — expose window.api.worktreeStatus(path)

public/sidebar.js — replace bare confirm() with showDeleteWorktreeDialog()

  • Fetches git status async while the modal is already visible
  • Title: "Delete worktree <name>?"
  • Red warning banner: "Any uncommitted changes in this worktree will be permanently lost."
  • Status section: loading spinner → green clean message / amber dirty-file list (first 10, + N more) / red error message
  • Buttons: Cancel (neutral) / Delete anyway (red destructive); Escape key and overlay-click cancel

public/style.css.delete-worktree-dialog, .delete-worktree-warning, .delete-worktree-status, .dwt-* classes matching existing dark theme

Tests

  • 38/38 pass, 0 errors from npm run lint

🤖 Generated with Claude Code

- Add worktree-status IPC in main.js: runs git status --porcelain
  for the worktree path, returns { ok, dirty, total }
- Expose as window.api.worktreeStatus() in preload.js
- Replace bare confirm() in sidebar.js with showDeleteWorktreeDialog():
  - Modal shows worktree name, permanent-loss warning, and dirty-file list
  - Fetches git status asynchronously while modal is open
  - Lists first 10 dirty files in <pre>, '+ N more' if truncated
  - Clean worktree shows green 'no uncommitted changes' message
  - IPC error shows red 'Unable to read worktree status' message
  - Cancel / Delete anyway buttons; Escape key closes; overlay click cancels
- Add CSS for .delete-worktree-dialog, .delete-worktree-warning,
  .delete-worktree-status, .dwt-* classes matching existing dark theme
@JeanBaptisteRenard
JeanBaptisteRenard merged commit 2203596 into main May 23, 2026
7 checks passed
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