Skip to content

feat(tasks): add delete behavior setting#2535

Open
janburzinski wants to merge 2 commits into
mainfrom
jan/eng-1578-add-settings-for-task-delete-behavior
Open

feat(tasks): add delete behavior setting#2535
janburzinski wants to merge 2 commits into
mainfrom
jan/eng-1578-add-settings-for-task-delete-behavior

Conversation

@janburzinski

Copy link
Copy Markdown
Collaborator

Description

  • adds a setting for "deleting branch / delete worktree" or if you want to be asked every time

Screenshot/Recording (if applicable)

https://streamable.com/rzfsq6

Checklist
  • I kept this PR small and focused
  • I ran a self-review before opening this PR
  • I ran the relevant local checks or explained why not
  • I updated docs when behavior or setup changed
  • I added or updated tests when behavior changed, or explained why not
  • I only added comments where the logic is not obvious
  • I used Conventional Commits for commit
    messages and, when possible, the PR title

@greptile-apps

greptile-apps Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a new task delete behavior setting with two options: 'ask' (show the existing checkbox dialog each time) and 'delete-worktree-and-branch' (silently delete both without prompting). The setting is wired end-to-end through schema, defaults, settings UI, and the delete modal.

  • Schema & defaults: taskDeleteBehaviorSchema enum and deleteBehavior field added to taskSettingsSchema; the registry defaults to 'ask', keeping existing users in the familiar dialog flow.
  • Settings UI: A new TaskDeleteBehaviorRow using a <Select> is added to the General settings page, with a reset-to-default button.
  • Delete modal: In ask mode the existing checkboxes are shown; in delete-worktree-and-branch mode they are hidden and a scope notice + dirty-file warning are shown instead, before hard-coding deleteWorktree: true, deleteBranch: true on confirm.

Confidence Score: 4/5

Safe to merge with one concern: in 'ask' mode the branch checkbox now opens pre-checked, which silently changes the outcome for users who click through without inspecting the dialog.

The branch deletion checkbox changed from starting unchecked to starting checked in 'ask' mode. Users who habitually click Delete without examining the modal — including everyone on the default 'ask' setting after upgrading — will now have their branches deleted when they previously would not have. Everything else in the change (schema, defaults, settings UI, dirty-file warning, scope notice) is well-structured and correct.

apps/emdash-desktop/src/renderer/features/tasks/delete-task-modal.tsx — specifically the initial value of the deleteBranch state and when the scope notice is displayed.

Important Files Changed

Filename Overview
apps/emdash-desktop/src/renderer/features/tasks/delete-task-modal.tsx Integrates deleteBehavior setting; the branch checkbox is now pre-checked in 'ask' mode (changed from false→true), making branch deletion the implicit default when the user doesn't examine the dialog.
apps/emdash-desktop/src/main/core/tasks/operations/deleteTask.ts Default for deleteBranch changed from false to true; all current callers pass explicit values so no runtime regression, but the default is now more destructive.
apps/emdash-desktop/src/main/core/settings/schema.ts Adds taskDeleteBehaviorSchema enum and deleteBehavior field to taskSettingsSchema; looks correct.
apps/emdash-desktop/src/main/core/settings/settings-registry.ts Defaults deleteBehavior to 'ask', which is appropriate for safe upgrade behavior.
apps/emdash-desktop/src/renderer/features/settings/components/TaskSettingsRows.tsx Adds TaskDeleteBehaviorRow with Select UI wired to useTaskSettings; implementation looks correct.
apps/emdash-desktop/src/renderer/features/tasks/hooks/useTaskSettings.ts Extends TaskSettingsModel with deleteBehavior, updateDeleteBehavior, and resetDeleteBehavior; falls back to 'ask' when the field is absent.
apps/emdash-desktop/src/shared/core/app-settings.ts Exports new TaskDeleteBehavior type; straightforward addition.
apps/emdash-desktop/src/renderer/features/settings/components/SettingsPage.tsx Registers TaskDeleteBehaviorRow in the General settings page; no issues.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User clicks Delete task] --> B[Open DeleteTaskModal]
    B --> C{taskSettings.loading?}
    C -- yes --> D[Show Loading... / disable button]
    D --> C
    C -- no --> E{deleteBehavior}
    E -- ask --> F[Fetch preflight data]
    F --> G{hasWorktree?}
    G -- yes --> H[Show worktree checkbox checked=true]
    G -- no --> I[No worktree checkbox]
    H --> J{hasDeletableBranch?}
    J -- yes --> K[Show branch checkbox checked=true]
    J -- no --> L[No branch checkbox]
    K --> M[User confirms]
    I --> M
    L --> M
    M --> N[onSuccess with checkbox values]
    E -- delete-worktree-and-branch --> O[Show scope notice + dirty warning if needed]
    O --> P[User confirms]
    P --> Q[onSuccess with deleteWorktree:true deleteBranch:true]
    N --> R[deleteTask IPC call]
    Q --> R
    R --> S[deleteTask.ts deleteWorktree + deleteBranch]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[User clicks Delete task] --> B[Open DeleteTaskModal]
    B --> C{taskSettings.loading?}
    C -- yes --> D[Show Loading... / disable button]
    D --> C
    C -- no --> E{deleteBehavior}
    E -- ask --> F[Fetch preflight data]
    F --> G{hasWorktree?}
    G -- yes --> H[Show worktree checkbox checked=true]
    G -- no --> I[No worktree checkbox]
    H --> J{hasDeletableBranch?}
    J -- yes --> K[Show branch checkbox checked=true]
    J -- no --> L[No branch checkbox]
    K --> M[User confirms]
    I --> M
    L --> M
    M --> N[onSuccess with checkbox values]
    E -- delete-worktree-and-branch --> O[Show scope notice + dirty warning if needed]
    O --> P[User confirms]
    P --> Q[onSuccess with deleteWorktree:true deleteBranch:true]
    N --> R[deleteTask IPC call]
    Q --> R
    R --> S[deleteTask.ts deleteWorktree + deleteBranch]
Loading

Reviews (2): Last reviewed commit: "fix(tasks): make delete behavior safer" | Re-trigger Greptile

Comment thread apps/emdash-desktop/src/main/core/settings/settings-registry.ts Outdated
@janburzinski

Copy link
Copy Markdown
Collaborator Author

@greptileai

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