Skip to content

Conversation

@uptickmetachu
Copy link

@uptickmetachu uptickmetachu commented Jan 7, 2026

Added a worktree_cleanup_script field at the project level that runs once before worktree directories are removed.

Closes #1644

Database:

  • crates/db/migrations/20260107211120_add_worktree_cleanup_script_to_projects.sql - New migration

Rust Backend:

  • crates/db/src/models/project.rs - Added field to Project and UpdateProject structs, updated all SQL queries
  • crates/services/src/services/workspace_manager.rs - Added cleanup_workspace_with_script() and execute_cleanup_script() methods
  • crates/services/src/services/project.rs - Updated UpdateProject usage
  • crates/services/src/services/container.rs - Updated UpdateProject usage
  • crates/server/src/routes/tasks.rs - Task deletion now fetches and executes cleanup script
  • crates/local-deployment/src/container.rs - Added get_cleanup_script_for_workspace(), updated cleanup methods

Frontend:

  • frontend/src/pages/settings/ProjectSettings.tsx - Added UI for the new field
  • frontend/src/components/tasks/TaskDetails/preview/NoServerContent.tsx - Updated UpdateProject usage
  • frontend/src/i18n/locales/en/settings.json - Added localization strings
Trigger Script Runs?
Task deletion Yes (once for first workspace)
Workspace delete Yes
Orphaned workspace cleanup No (no project association)
  • Working directory: Workspace root (container_ref)
  • Timeout: 60 seconds
  • Shell: bash -c
  • Error handling: Logs warning and continues with cleanup (non-blocking)
image

Added a `worktree_cleanup_script` field at the project level that runs **once** before worktree directories are removed.

**Database:**
- `crates/db/migrations/20260107211120_add_worktree_cleanup_script_to_projects.sql` - New migration

**Rust Backend:**
- `crates/db/src/models/project.rs` - Added field to `Project` and `UpdateProject` structs, updated all SQL queries
- `crates/services/src/services/workspace_manager.rs` - Added `cleanup_workspace_with_script()` and `execute_cleanup_script()` methods
- `crates/services/src/services/project.rs` - Updated `UpdateProject` usage
- `crates/services/src/services/container.rs` - Updated `UpdateProject` usage
- `crates/server/src/routes/tasks.rs` - Task deletion now fetches and executes cleanup script
- `crates/local-deployment/src/container.rs` - Added `get_cleanup_script_for_workspace()`, updated cleanup methods

**Frontend:**
- `frontend/src/pages/settings/ProjectSettings.tsx` - Added UI for the new field
- `frontend/src/components/tasks/TaskDetails/preview/NoServerContent.tsx` - Updated `UpdateProject` usage
- `frontend/src/i18n/locales/en/settings.json` - Added localization strings

| Trigger | Script Runs? |
|---------|--------------|
| Task deletion | Yes (once for first workspace) |
| Expired workspace cleanup | Yes |
| Workspace delete | Yes |
| Orphaned workspace cleanup | No (no project association) |

- **Working directory**: Workspace root (container_ref)
- **Timeout**: 60 seconds
- **Shell**: `bash -c`
- **Error handling**: Logs warning and continues with cleanup (non-blocking)

(cherry picked from commit 46b2885)
@vibe-kanban-cloud
Copy link

Review Complete

Your review story is ready!

View Story

Comment !reviewfast on this PR to re-generate the story.

@guinanlin
Copy link

need this function, pls launch asap.

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.

Feature Request: Post task cleanup scripts

2 participants