Skip to main content

teardown_worker

Function teardown_worker 

Source
fn teardown_worker(
    workspace: &Arc<Workspace>,
    project_key: &ProjectKey,
    label: &str,
) -> Option<WorkerEntry>
Expand description

Shared worker teardown used by both handle_close_worker (a view’s X-button) and handle_despawn_worker (the agents__despawn MCP tool): remove the latest-spawned worker matching label from live_workers[project_key] and release its session (terminates the claude subprocess on drop). Returns the removed WorkerEntry, or None when no live worker matched. JSONL on disk is NOT deleted - teardown only removes the in-memory live state.

The Removed event is the caller’s to emit via emit_worker_removed: the despawn path only learns what became of the worktree after this returns.