From f88ee692c968e88782ec55951907d51c76d53220 Mon Sep 17 00:00:00 2001 From: Hare Date: Mon, 13 Jul 2026 20:54:33 +0900 Subject: [PATCH] workspace: allow not-found workdir cleanup --- .yoi/tickets/00001KXDMM975/item.md | 4 ++-- .yoi/tickets/00001KXDMM975/thread.md | 34 +++++++++++++++++++++++++++ crates/workspace-server/src/server.rs | 12 +++++++++- 3 files changed, 47 insertions(+), 3 deletions(-) diff --git a/.yoi/tickets/00001KXDMM975/item.md b/.yoi/tickets/00001KXDMM975/item.md index 0c4c64b3..95cbd61d 100644 --- a/.yoi/tickets/00001KXDMM975/item.md +++ b/.yoi/tickets/00001KXDMM975/item.md @@ -1,8 +1,8 @@ --- title: 'Allow not-found Workdir cleanup action' -state: 'inprogress' +state: 'done' created_at: '2026-07-13T11:43:33Z' -updated_at: '2026-07-13T11:44:18Z' +updated_at: '2026-07-13T11:51:11Z' assignee: null queued_by: 'yoi ticket' queued_at: '2026-07-13T11:44:18Z' diff --git a/.yoi/tickets/00001KXDMM975/thread.md b/.yoi/tickets/00001KXDMM975/thread.md index 9d7d4d3f..4d6f592a 100644 --- a/.yoi/tickets/00001KXDMM975/thread.md +++ b/.yoi/tickets/00001KXDMM975/thread.md @@ -39,4 +39,38 @@ Ticket を `yoi ticket` が queued にしました。 State changed to `inprogress`. +--- + + + +## Implementation report + +Fixed not-found Workdir cleanup plan classification. + +Root cause: +- Cleanup plan converted `WorkingDirectoryStatusKind::NotFound` with `format!("{:?}").to_lowercase()`, producing `notfound` instead of the canonical API/status label `not_found`. +- The action classifier only recognized `missing` / `not_found`, so the candidate fell through to `workdir_dirty_discard`, which the frontend disables by design. + +Changes: +- Added explicit `workdir_status_kind_label` mapping for `WorkingDirectoryStatusKind`. +- `NotFound` now maps to `not_found`, so cleanup plan candidates become `workdir_record_delete`. + +Validation: +- `cargo fmt --check` +- `git diff --check` +- `cargo check -q` +- `cargo test -q -p yoi-workspace-server` +- targeted cleanup plan test +- `nix build .#yoi --no-link` + + +--- + + + +## State changed + +State changed to `done`. + + --- diff --git a/crates/workspace-server/src/server.rs b/crates/workspace-server/src/server.rs index 3afc3b3c..234afd63 100644 --- a/crates/workspace-server/src/server.rs +++ b/crates/workspace-server/src/server.rs @@ -1683,7 +1683,7 @@ fn build_runtime_cleanup_plan( let running_linked = !linked_running_worker_ids.is_empty(); let observed_status = observed_workdirs .get(record.workdir_id.as_str()) - .map(|summary| format!("{:?}", summary.status).to_lowercase()); + .map(|summary| workdir_status_kind_label(&summary.status).to_string()); let file_status = observed_status.unwrap_or_else(|| record.materialization_status.clone()); let cleanliness = record.cleanliness.clone(); let action = if matches!(file_status.as_str(), "missing" | "not_found") { @@ -4287,6 +4287,16 @@ fn sync_runtime_workdir_observations( Ok(response.diagnostics) } +fn workdir_status_kind_label(status: &WorkingDirectoryStatusKind) -> &'static str { + match status { + WorkingDirectoryStatusKind::Active => "active", + WorkingDirectoryStatusKind::CleanupPending => "cleanup_pending", + WorkingDirectoryStatusKind::Corrupted => "corrupted", + WorkingDirectoryStatusKind::NotFound => "not_found", + WorkingDirectoryStatusKind::Unknown => "unknown", + } +} + fn workdir_status_from_runtime_miss(diagnostics: &[RuntimeDiagnostic]) -> &'static str { if diagnostics .iter()