Skip to content

improve delete worktree failure diagnostics#302

Open
VooDisss wants to merge 1 commit intoNeuralNomadsAI:devfrom
VooDisss:worktree-checks
Open

improve delete worktree failure diagnostics#302
VooDisss wants to merge 1 commit intoNeuralNomadsAI:devfrom
VooDisss:worktree-checks

Conversation

@VooDisss
Copy link
Copy Markdown
Contributor

@VooDisss VooDisss commented Apr 9, 2026

Summary

  • move delete-worktree failures out of transient toast-only UX and keep them inline in the delete modal
  • add parsed diagnostics for common failure modes, including a short summary, likely cause, and suggested next step
  • make the raw error easier to review and share with raw and sanitized copy actions

Closes #301.

BEFORE:

image

AFTER:

image

Problem

Before this change, delete-worktree failures were difficult to work with:

  1. The failure message was effectively raw backend or git output.
  2. Users had to infer the meaning of the error themselves.
  3. The UI did not explain what likely went wrong or what to do next.
  4. Sharing the error for debugging was awkward when it included machine-local absolute paths.
  5. The confirmation modal was not being used as the primary diagnostic surface for a destructive action that frequently fails for understandable reasons.

This was especially frustrating for common cases such as:

  • modified or untracked files in the worktree
  • a process still using the worktree directory
  • permission errors on Windows
  • missing worktree directories or stale worktree records

What changed

Modal failure UX

  • keep delete failures inline inside packages/ui/src/components/worktree-selector.tsx
  • clear modal-local error state when opening or closing the dialog
  • keep the success toast on successful deletion, but use the modal itself for failure presentation

Human-readable diagnostics

  • parse JSON-shaped backend error payloads such as {"error":"..."} before classification
  • classify common delete failure patterns into:
    • localChanges
    • inUse
    • notFound
    • permissionDenied
    • unknown
  • render three user-facing lines above the raw error:
    • summary
    • likely cause
    • suggested next step

Copy flows

  • add Copy error for the original failure text
  • add Copy sanitized to redact common absolute path and username patterns before copying

Modal content and sizing

  • present the target worktree in a simpler two-line summary block
  • update the delete description text to plain English: Deletes this branch worktree and its local folder.
  • size the delete modal deliberately for desktop use while allowing vertical expansion to the viewport limit before scrolling

i18n coverage

  • add the new delete diagnostic strings across all currently supported locales touched by this area:
    • en
    • es
    • fr
    • he
    • ja
    • ru
    • zh-Hans

Why this approach

  • It keeps the backend contract unchanged and solves the UX problem where it occurs.
  • It preserves access to the raw failure text instead of hiding implementation detail entirely.
  • It gives users immediate guidance without forcing them to translate git errors into next actions.
  • It improves bug reporting without requiring a separate logging or export workflow.

Not included

  • server-side preflight guards that block delete when the worktree is still assigned or in use
  • process-aware worktree locking detection
  • automatic retry or force-delete-and-retry flows

Those are useful follow-ups, but this PR is intentionally scoped to failure presentation and debuggability.

Files changed

  • packages/ui/src/components/worktree-selector.tsx
  • packages/ui/src/lib/i18n/messages/en/instance.ts
  • packages/ui/src/lib/i18n/messages/es/instance.ts
  • packages/ui/src/lib/i18n/messages/fr/instance.ts
  • packages/ui/src/lib/i18n/messages/he/instance.ts
  • packages/ui/src/lib/i18n/messages/ja/instance.ts
  • packages/ui/src/lib/i18n/messages/ru/instance.ts
  • packages/ui/src/lib/i18n/messages/zh-Hans/instance.ts

Validation

  • npm run typecheck --workspace @codenomad/ui
  • npm run build --workspace @codenomad/ui
  • npm run typecheck --workspace @neuralnomads/codenomad-electron-app

Notes for reviewers

  • The error classifier is intentionally heuristic and string-based. It is meant to improve the common cases without increasing backend coupling.
  • The sanitized copy flow is conservative and focused on path and username redaction, not full structured log scrubbing.

Move delete-worktree failures out of transient toast-only feedback and into the confirmation modal so the error stays visible, selectable, and easier to copy when deletion fails. The modal now keeps the raw backend/git error inline, offers raw and sanitized copy actions, and presents a clearer two-line worktree summary instead of pushing users to capture a disappearing notification.

Add lightweight error parsing and classification in the UI so common failure modes such as local changes, in-use directories, missing worktrees, and permission issues get a short summary, likely-cause label, and suggested next step. This keeps the backend contract unchanged while making the delete flow much easier to understand and debug without losing access to the original raw error text.

Also tune the delete dialog layout so it uses a deliberate desktop-sized modal, allows the content to expand vertically to the viewport, and keeps the copy actions compact. Matching i18n strings were added for all supported locales so the new diagnostics remain wired through the existing translation layer instead of hardcoding English-only UI text.
@shantur
Copy link
Copy Markdown
Collaborator

shantur commented Apr 11, 2026

@CodeNomadBot

I want you to perform the gatekeeper checks for latest PR state

check for regressions
check for better possible implementations
Be the PR gatekeeper
Be ruthless about code quality

@codenomadbot
Copy link
Copy Markdown
Contributor

codenomadbot bot commented Apr 11, 2026

Gatekeeper review for the latest PR state. I reviewed the current diff for regressions and stronger implementation options.

Findings:

  1. packages/ui/src/components/worktree-selector.tsx:214-217
    Copy sanitized does not actually sanitize Linux home-directory paths. The new redaction logic covers macOS /Users/... and Windows Users\..., but CodeNomad supports Linux too, so errors containing paths like /home/alice/project/... will still leak the username and absolute path verbatim. That breaks the main privacy/safe-sharing promise of the feature on one of the supported platforms.

  2. packages/ui/src/components/worktree-selector.tsx:75-88, packages/ui/src/components/worktree-selector.tsx:247-248, packages/ui/src/components/worktree-selector.tsx:590
    The PR parses JSON-shaped backend errors for classification, but the modal still renders the unparsed payload in the visible error block. For the common {"error":"..."} response shape, users will still see noisy JSON instead of the actual git/backend message. That undercuts the stated goal of making the error easier to review in the modal. A cleaner implementation would render extractDeleteErrorMessage(raw) in the UI and keep the true raw payload only for the Copy error action.

Validation:

  • npm run typecheck --workspace @codenomad/ui could not be executed meaningfully in this workspace because required dependencies are not installed here (solid-js, zod, etc. were unresolved immediately), so I could not use typecheck/build as a merge signal from this environment.

--
Yours,
CodeNomadBot

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.

Delete worktree failures are hard to understand and share

2 participants