Skip to content

🗂️ Worktree Lifecycle Management #312

@vasconceloscezar

Description

@vasconceloscezar

Summary

Improve git worktree lifecycle management - from creation options to cleanup. Team feedback highlighted worktrees accumulating on disk and lack of flexibility in worktree creation.

Problems Identified

1. Worktrees Not Cleaned on Task Archive (High Priority)

Current: Archiving a task only changes status - worktree persists indefinitely.
Impact: Disk space accumulation, orphaned worktrees, manual cleanup required.

Evidence:

  • TaskAttempt.worktree_deleted field exists but isn't used
  • ArchiveTaskConfirmationDialog only updates status

Solution:

  • Archive dialog offers: "Remove worktree? (recommended)" checkbox
  • Show worktree size before deletion
  • Success/failure notification
  • Option to keep worktree if user wants

2. Bulk Worktree Cleanup Tool

Current: No way to clean up multiple orphaned worktrees at once.

Solution:

  • Settings or Tools page: "Manage Worktrees"
  • List all worktrees with their task status (active/archived/orphaned)
  • Select multiple for bulk deletion
  • Show disk space that will be freed
  • "Clean All Archived" quick action

3. Skip Worktree Option on Task Creation

Current: Every task creates a worktree, no option to skip.
Impact: Sometimes users want to work directly in main branch.

Solution:

  • Checkbox in task creation: "Create isolated worktree" (default: checked)
  • When unchecked, task runs in main project directory
  • Clear warning about working in shared space

4. Worktree Status Visibility

Current: Hard to know worktree state for a task.

Solution:

  • Show worktree path in task details
  • Indicator if worktree exists vs deleted
  • Quick action to open worktree in file explorer

Acceptance Criteria

  • Archive dialog has worktree cleanup option
  • Bulk cleanup tool accessible from settings
  • Task creation has "skip worktree" option
  • Worktree status visible in task details

Related Issues

Technical Notes

Affected Files:

  • ArchiveTaskConfirmationDialog.tsx
  • TaskFormDialog.tsx
  • forge-app/src/router.rs (worktree endpoints)

Database:

  • TaskAttempt.worktree_deleted already exists

Team Feedback Sources

  • Feedback 2: Worktree cleanup on archive
  • Feedback 3: "Option to start task without worktree"
  • Feedback 4: Git/worktree transparency

Priority

🔴 P0 - High (2/6 feedbacks, disk space impact)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions