@@ -70,18 +70,36 @@ pub fn anon_client() -> Result<(HarmontClient, String)> {
7070
7171/// Render preferences for cloud commands that stream through `hm-render`.
7272///
73- /// Returns `(color, logs)`, both derived from `hm-render`'s shared TTY/color
74- /// helpers (the single source of truth, also used by `hm/src/context.rs`):
75- /// - `color` — ANSI enabled when `NO_COLOR` is unset and stderr is a TTY.
76- /// The plugin verbs have no `--no-color` flag, so we pass `false` for the
77- /// flag; the `--no-color` asymmetry vs. the host `hm run` path is explicit
78- /// here at the call site.
79- /// - `logs` — force the streaming `HumanRenderer` over the live
80- /// `ProgressRenderer`. True when stdout is **not** an interactive terminal
81- /// (CI / pipe / log file), so nothing animates into a non-TTY sink.
82- #[ must_use]
83- pub fn render_prefs ( ) -> ( bool , bool ) {
84- ( hm_render:: color_enabled ( false ) , hm_render:: stdout_piped ( ) )
73+ /// Both fields are derived from `hm-render`'s shared TTY/color helpers (the
74+ /// single source of truth, also used by `hm/src/context.rs`).
75+ #[ derive( Debug , Clone , Copy ) ]
76+ pub struct RenderPrefs {
77+ /// ANSI enabled when `NO_COLOR` is unset and stderr is a TTY.
78+ ///
79+ /// The plugin verbs have no `--no-color` flag, so we pass `false` for the
80+ /// flag; the `--no-color` asymmetry vs. the host `hm run` path is explicit
81+ /// here at the call site.
82+ pub color : bool ,
83+ /// Force the streaming `HumanRenderer` over the live `ProgressRenderer`.
84+ ///
85+ /// True when stdout is **not** an interactive terminal (CI / pipe / log
86+ /// file), so nothing animates into a non-TTY sink.
87+ pub logs : bool ,
88+ }
89+
90+ impl RenderPrefs {
91+ /// Detect render preferences from the live environment via `hm-render`'s
92+ /// shared TTY/color helpers — the single source of truth, also used by
93+ /// `hm/src/context.rs`. This inspects `NO_COLOR` and the stdout/stderr
94+ /// TTY state at call time, so it is a deliberate observation of the
95+ /// environment rather than a constant default.
96+ #[ must_use]
97+ pub fn detect ( ) -> Self {
98+ Self {
99+ color : hm_render:: color_enabled ( false ) ,
100+ logs : hm_render:: stdout_piped ( ) ,
101+ }
102+ }
85103}
86104
87105/// Map a raw generated-client error into an `anyhow` error with a readable
0 commit comments