From aa56b670962f6dab7fc4e86701a8828f35fff9b9 Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Wed, 6 May 2026 15:54:00 -0400 Subject: [PATCH] fix(server): preserve worker terminal color env Keep non-secret terminal color controls in the worker subprocess environment so inherited stdout logs use the same color decision as the foreground server. --- lib/crates/fabro-server/src/spawn_env.rs | 15 +++++++++++++++ lib/crates/fabro-static/src/env_vars.rs | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/lib/crates/fabro-server/src/spawn_env.rs b/lib/crates/fabro-server/src/spawn_env.rs index 934729af8..2dd7100b4 100644 --- a/lib/crates/fabro-server/src/spawn_env.rs +++ b/lib/crates/fabro-server/src/spawn_env.rs @@ -13,6 +13,10 @@ const WORKER_ENV_ALLOWLIST: &[&str] = &[ EnvVars::FABRO_LOG, EnvVars::FABRO_HOME, EnvVars::FABRO_STORAGE_ROOT, + EnvVars::TERM, + EnvVars::NO_COLOR, + EnvVars::CLICOLOR, + EnvVars::CLICOLOR_FORCE, ]; const RENDER_GRAPH_ENV_ALLOWLIST: &[&str] = &[EnvVars::PATH, EnvVars::HOME, EnvVars::TMPDIR]; @@ -83,6 +87,10 @@ mod tests { "FABRO_STORAGE_ROOT".to_string(), "/tmp/fabro-storage".to_string(), ), + ("TERM".to_string(), "xterm-256color".to_string()), + ("NO_COLOR".to_string(), "1".to_string()), + ("CLICOLOR".to_string(), "0".to_string()), + ("CLICOLOR_FORCE".to_string(), "1".to_string()), ("SESSION_SECRET".to_string(), "leak".to_string()), ("FABRO_JWT_PRIVATE_KEY".to_string(), "leak".to_string()), ("FABRO_JWT_PUBLIC_KEY".to_string(), "leak".to_string()), @@ -106,6 +114,13 @@ mod tests { assert_eq!(actual.get("PATH").map(String::as_str), Some("/bin")); assert_eq!(actual.get("HOME").map(String::as_str), Some("/tmp/home")); assert_eq!(actual.get("FABRO_LOG").map(String::as_str), Some("debug")); + assert_eq!( + actual.get("TERM").map(String::as_str), + Some("xterm-256color") + ); + assert_eq!(actual.get("NO_COLOR").map(String::as_str), Some("1")); + assert_eq!(actual.get("CLICOLOR").map(String::as_str), Some("0")); + assert_eq!(actual.get("CLICOLOR_FORCE").map(String::as_str), Some("1")); assert!(!actual.contains_key("FABRO_LOG_DESTINATION")); assert_eq!( actual.get("FABRO_DEV_TOKEN").map(String::as_str), diff --git a/lib/crates/fabro-static/src/env_vars.rs b/lib/crates/fabro-static/src/env_vars.rs index 483010c9d..f1c5937d7 100644 --- a/lib/crates/fabro-static/src/env_vars.rs +++ b/lib/crates/fabro-static/src/env_vars.rs @@ -103,6 +103,8 @@ impl EnvVars { pub const CARGO_HOME: &'static str = "CARGO_HOME"; pub const CARGO_MANIFEST_DIR: &'static str = "CARGO_MANIFEST_DIR"; pub const CI: &'static str = "CI"; + pub const CLICOLOR: &'static str = "CLICOLOR"; + pub const CLICOLOR_FORCE: &'static str = "CLICOLOR_FORCE"; pub const HOME: &'static str = "HOME"; pub const KUBERNETES_SERVICE_HOST: &'static str = "KUBERNETES_SERVICE_HOST"; pub const LANG: &'static str = "LANG"; @@ -230,6 +232,8 @@ mod tests { EnvVars::CARGO_HOME, EnvVars::CARGO_MANIFEST_DIR, EnvVars::CI, + EnvVars::CLICOLOR, + EnvVars::CLICOLOR_FORCE, EnvVars::HOME, EnvVars::KUBERNETES_SERVICE_HOST, EnvVars::LANG,