3bec58cfa908

fix clean phrasing under generation limit (OF-9) — clean() prints ':: cleaning <machine>' + 'only N generation(s) — nothing to remove.' and skips gc when total <= keep (keep=1 for 'clean all', else cfg.generations), killing 'keeping 5 of 1'; cleaning case now clamps to 'keeping {keep} of {total}' — build+tests green

time
2026-06-05 02:20 UTC · 4 months ago
machine
koh2
agent
claude-opus-4-8
session
nina finishing brief
parent
6016e2b06f60
2 files src/commands.zig+10 −2src/output.zig+7 −0
src/commands.zig+10 −2
@@ -150,9 +150,17 @@150150 pub fn clean(ctx: Ctx) !void {151151     const gens = try exec.getGenerations(ctx.gpa, ctx.io, &ctx.machine);152152     defer ctx.gpa.free(gens);153-    output.cleanStart(ctx.machine.name, ctx.cfg.generations, @intCast(gens.len));154-    if (ctx.cfg.confirm and !output.confirm("removing — cannot be undone")) return;155153     const all = ctx.all or std.mem.eql(u8, ctx.sub, "all");154+    const total: u32 = @intCast(gens.len);155+    // `clean all` keeps only the current generation; otherwise keep the configured156+    // count. With nothing older than the keep limit, there's nothing to collect.157+    const keep: u32 = if (all) 1 else ctx.cfg.generations;158+    if (total <= keep) {159+        output.cleanNothing(ctx.machine.name, total);160+        return;161+    }162+    output.cleanStart(ctx.machine.name, keep, total);163+    if (ctx.cfg.confirm and !output.confirm("removing — cannot be undone")) return;156164     _ = try exec.collectGarbage(ctx.io, &ctx.machine, ctx.gpa, all, ctx.cfg.generations);157165     output.cleanDone("?");158166 }

view file

src/output.zig+7 −0
@@ -256,6 +256,13 @@256256     p("{s}cleaning  {s}  keeping {d} of {d}\n", .{ hdr(), machine, keep, total });257257 }258258 259+// Fewer generations than the keep limit — there's nothing to collect. Avoids the260+// nonsensical 'keeping 5 of 1'.261+pub fn cleanNothing(machine: []const u8, total: u32) void {262+    p("{s}cleaning  {s}\n\n", .{ hdr(), machine });263+    p("   only {d} generation{s} — nothing to remove.\n", .{ total, if (total == 1) "" else "s" });264+}265+259266 pub fn cleanDone(freed: []const u8) void {260267     p("{s}{s}freed {s}\n", .{ KAO_CONTENT, hdr(), freed });261268 }

view file