cec9ca91b68d

fix diff suppress child ANSI when piped (OF-5) — diffClosures prepends 'env NO_COLOR=1' to nix store diff-closures when output.colorEnabled() is false; added public output.colorEnabled() accessor; SSH-safe via env — build+tests green

time
2026-06-05 02:14 UTC · 4 months ago
machine
koh2
agent
claude-opus-4-8
session
nina finishing brief
parent
b73567de331f
2 files src/exec.zig+6 −0src/output.zig+6 −0
src/exec.zig+6 −0
@@ -713,6 +713,12 @@713713     defer gpa.free(a_str);714714     const b_str = try std.fmt.allocPrint(gpa, "/nix/var/nix/profiles/system-{d}-link", .{b});715715     defer gpa.free(b_str);716+    // nix store diff-closures colorizes its own output. When nina's stdout isn't a717+    // tty (piped/redirected), force NO_COLOR on the child so raw ANSI doesn't leak718+    // into the piped text. `env` carries the var through SSH routing too.719+    if (!output.colorEnabled()) {720+        return stream(io, machine, gpa, &.{ "env", "NO_COLOR=1", "nix", "store", "diff-closures", a_str, b_str });721+    }716722     return stream(io, machine, gpa, &.{ "nix", "store", "diff-closures", a_str, b_str });717723 }718724 

view file

src/output.zig+6 −0
@@ -71,6 +71,12 @@7171     _w.flush() catch {};7272 }7373 74+// Whether ANSI color is active (tty + config + no NO_COLOR). Callers spawning75+// child processes that colorize their own output use this to gate the child.76+pub fn colorEnabled() bool {77+    return color_enabled;78+}79+7480 fn c(code: []const u8) []const u8 {7581     return if (color_enabled) code else "";7682 }

view file