Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix(terminal): close two gaps in the inherited-colour-claim drop
Ruben Lütkef5ec31ddc3f2
diff --git a/jarvis/core/colour_env.py b/jarvis/core/colour_env.pyindex d972676f4f..a45fb62299 100644--- a/jarvis/core/colour_env.py+++ b/jarvis/core/colour_env.py@@ -24,6 +24,14 @@ DISABLES colour — a positive value is an escalation the user meant.``COLORTERM`` counts only when EMPTY, because the common colour libraries readits mere presence as "sixteen colours": an empty one inherited from a pipeDOWNGRADES a 256-colour terminal, while a real value is authoritative.++``NO_COLOR`` counts whenever it is PRESENT, empty value included. The published+convention asks consumers to act only on a non-empty value, but consumers+disagree in practice — several check presence alone — and the two readings+point opposite ways for ``NO_COLOR=``. That ambiguity cannot express a user's+intent either way: anyone who actually wants colour off writes a value, so an+empty one reaching a terminal host is an inheritance artefact by construction.+Dropping it removes the ambiguity instead of betting on which library reads it."""from __future__ import annotations@@ -42,7 +50,7 @@ def stale_colour_claims(source: Mapping[str, str]) -> tuple[str, ...]:which lets callers skip copying it at all."""stale: list[str] = []- if source.get("NO_COLOR", "").strip():+ if "NO_COLOR" in source:stale.append("NO_COLOR")if source.get("FORCE_COLOR", "").strip().lower() in _FORCE_COLOR_OFF:stale.append("FORCE_COLOR")@@ -56,8 +64,11 @@ def sanitize_process_environment() -> tuple[str, ...]:Called once at start-up so that no child of the app can inherit them,whichever spawn path it takes. Returning the names rather than logging here- keeps the decision to log — and in whose voice — with the caller, which at- start-up is the only layer that knows whether logging is up yet.+ keeps the decision to log — and in whose voice — with the caller. That+ caller owes the user the line: an app that silently rewrites its own+ environment and leaves no trace is the thing nobody can debug later, and at+ start-up the stdlib root logger discards INFO records, so it takes a sink+ that is live from import (`jarvis.ui.web.launcher` uses loguru).Cheap by construction: a few dict lookups, no import, no I/O, so it is safeon the boot critical path (AP-26).diff --git a/jarvis/ui/web/launcher.py b/jarvis/ui/web/launcher.pyindex d52bd65455..e802a8faeb 100644--- a/jarvis/ui/web/launcher.py+++ b/jarvis/ui/web/launcher.py@@ -1066,10 +1066,15 @@ def main(argv: list[str] | None = None) -> int:_dropped_colour_claims = sanitize_process_environment()if _dropped_colour_claims:- import logging as _clog-- _clog.getLogger(__name__).info(- "Dropped inherited colour-suppressing variables (%s) so hosted "+ # loguru, not stdlib logging: this runs before anything configures the+ # stdlib root logger, whose default level then discards an INFO record+ # outright — so the one line explaining why the app rewrote its own+ # environment would never reach console or log file. loguru carries a+ # live sink from import.+ from loguru import logger as _clog++ _clog.info(+ "Dropped inherited colour-suppressing variables ({}) so hosted ""terminals render in colour; this app was started from a shell that ""declared it had none.",", ".join(_dropped_colour_claims),diff --git a/tests/unit/core/test_colour_env.py b/tests/unit/core/test_colour_env.pyindex 7a14f915dd..18396c8d94 100644--- a/tests/unit/core/test_colour_env.py+++ b/tests/unit/core/test_colour_env.py@@ -19,13 +19,20 @@ def test_an_environment_that_says_nothing_about_colour_is_left_alone() -> None:def test_no_color_is_recognised_whatever_its_value() -> None:- """The convention is presence, not value — "0" still means no colour."""+ """Presence is the trigger, not the value — "0" still means no colour."""assert stale_colour_claims({"NO_COLOR": "1"}) == ("NO_COLOR",)assert stale_colour_claims({"NO_COLOR": "0"}) == ("NO_COLOR",)-def test_an_empty_no_color_is_not_a_claim() -> None:- assert stale_colour_claims({"NO_COLOR": ""}) == ()+def test_an_empty_no_color_is_dropped_too() -> None:+ """Consumers disagree on whether ``NO_COLOR=`` suppresses colour.++ The published convention says a non-empty value is required; several+ libraries check presence alone. An empty value therefore cannot express an+ intent either way — and nobody who wants colour off writes one — so a+ terminal host drops it rather than betting on the reader.+ """+ assert stale_colour_claims({"NO_COLOR": ""}) == ("NO_COLOR",)def test_force_color_counts_only_when_it_disables_colour() -> None:@@ -74,3 +81,84 @@ def test_sanitizing_a_clean_environment_is_a_no_op(monkeypatch.setenv("COLORTERM", "truecolor")assert sanitize_process_environment() == ()+++# --------------------------------------------------------------------------+# The wiring, not just the helper. Both defects this module was corrected for+# lived in the seam between the two: a helper that is never called, or called+# too late, passes every test above.+# --------------------------------------------------------------------------+++def _main_stopped_at_arg_parsing(monkeypatch: pytest.MonkeyPatch) -> None:+ """Run ``launcher.main`` up to the first thing that follows the drop.++ Stopping at ``_parse_args`` is the assertion: everything the app does with+ its environment happens after it, so a drop that still ran is a drop that+ beat every spawn path.+ """+ import jarvis.core.path_augment as path_augment+ import jarvis.ui.web.launcher as launcher++ monkeypatch.setattr(path_augment, "ensure_cli_paths", lambda: None)++ def _stop(_argv: object) -> None:+ raise RuntimeError("stop: argument parsing reached")++ monkeypatch.setattr(launcher, "_parse_args", _stop)+ with pytest.raises(RuntimeError, match="argument parsing reached"):+ launcher.main([])+++def test_start_up_drops_the_claims_before_anything_else_runs(+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ import os++ monkeypatch.setenv("NO_COLOR", "1")+ monkeypatch.setenv("COLORTERM", "")++ _main_stopped_at_arg_parsing(monkeypatch)++ assert "NO_COLOR" not in os.environ+ assert "COLORTERM" not in os.environ+++def test_the_drop_is_announced_somewhere_a_person_can_read_it(+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ """An app that silently rewrites its own environment cannot be debugged.++ Pinned against a live sink because the first version of this logged through+ the stdlib root logger, which at that point in ``main`` discards INFO+ outright — the line existed in the source and reached nobody.+ """+ from loguru import logger++ monkeypatch.setenv("NO_COLOR", "1")+ written: list[str] = []+ sink = logger.add(written.append, level="INFO", format="{message}")+ try:+ _main_stopped_at_arg_parsing(monkeypatch)+ finally:+ logger.remove(sink)++ assert any("NO_COLOR" in line for line in written), written+++def test_nothing_is_announced_when_there_was_nothing_to_drop(+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ from loguru import logger++ monkeypatch.delenv("NO_COLOR", raising=False)+ monkeypatch.delenv("FORCE_COLOR", raising=False)+ monkeypatch.delenv("COLORTERM", raising=False)+ written: list[str] = []+ sink = logger.add(written.append, level="INFO", format="{message}")+ try:+ _main_stopped_at_arg_parsing(monkeypatch)+ finally:+ logger.remove(sink)++ assert not [line for line in written if "colour-suppressing" in line]