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): stop inheriting the launcher's "no colour" declaration
Ruben Lütkefd0304612bc5
diff --git a/jarvis/terminal/pty_manager.py b/jarvis/terminal/pty_manager.pyindex b91b8dad84..5ab26d9cd0 100644--- a/jarvis/terminal/pty_manager.py+++ b/jarvis/terminal/pty_manager.py@@ -149,20 +149,61 @@ UNKNOWN_EXIT_CODE = -1_INTERACTIVE_TERM = "xterm-256color"+def _stale_colour_claims(source: Mapping[str, str]) -> tuple[str, ...]:+ """Inherited "colour is impossible here" declarations that are now false.++ Each of these describes the LAUNCHER's own stdout, and each stops being+ true at this boundary for the same reason ``TERM=dumb`` does: the child is+ attached to a PTY drawn by xterm.js with a full sixteen-colour theme. They+ matter more than the terminal type, because every mainstream CLI colour+ library obeys them unconditionally — a pane that inherits ``NO_COLOR``+ renders its agent in plain monochrome no matter how capable ``TERM`` says+ the terminal is.++ This is not a hypothetical: an app started once from a coding agent's own+ shell inherits that shell's ``TERM=dumb`` + ``NO_COLOR=1``, hands it to+ every pane it opens, and passes it on across each in-app restart.++ Deliberate settings survive. ``FORCE_COLOR`` is dropped only when it+ DISABLES colour; a positive value is an escalation the user meant.+ ``COLORTERM`` is dropped only when EMPTY — the common colour libraries read+ its mere presence as "sixteen colours", so an empty one inherited from a+ pipe downgrades a 256-colour pane, while a real value stays authoritative.+ """+ stale: list[str] = []+ if source.get("NO_COLOR", "").strip():+ stale.append("NO_COLOR")+ if source.get("FORCE_COLOR", "").strip().lower() in {"0", "false"}:+ stale.append("FORCE_COLOR")+ if "COLORTERM" in source and not source["COLORTERM"].strip():+ stale.append("COLORTERM")+ return tuple(stale)++def _interactive_child_env(env: Mapping[str, str] | None) -> Mapping[str, str] | None:- """Replace a missing/``dumb`` parent TERM at the PTY capability boundary.+ """Correct the parent's non-interactive claims at the PTY capability boundary.++ Two corrections, both describing what the child is ACTUALLY connected to: a+ missing/``dumb`` TERM becomes the xterm.js terminal type, and the inherited+ colour-suppressing variables listed by :func:`_stale_colour_claims` are+ dropped.``env`` is a complete replacement when supplied to either backend. Only- materialize one when TERM needs correction; otherwise preserve the old+ materialize one when something needs correcting; otherwise preserve the oldinheritance/identity behaviour exactly. A meaningful caller-selectedterminal type (for example ``screen-256color``) remains authoritative."""source = os.environ if env is None else envterm = source.get("TERM", "").strip()- if term and term.lower() != "dumb":+ term_is_stale = not term or term.lower() == "dumb"+ colour_claims = _stale_colour_claims(source)+ if not term_is_stale and not colour_claims:return envchild_env = dict(source)- child_env["TERM"] = _INTERACTIVE_TERM+ if term_is_stale:+ child_env["TERM"] = _INTERACTIVE_TERM+ for key in colour_claims:+ child_env.pop(key, None)return child_env@@ -348,10 +389,11 @@ class PtyManager:a choice made here), so a caller passing one must hand over a COMPLETEenvironment — typically ``os.environ`` plus its own keys. Building thatoverlay is what `jarvis.agent_accounts.spawn_env` exists for. ``None``- normally inherits this process's environment. The one correction made at- this layer is replacing a missing/``dumb`` TERM with the xterm.js terminal- type the child is actually connected to; doing that requires a complete- snapshot of the inherited environment.+ normally inherits this process's environment. The corrections made at+ this layer describe what the child is actually connected to — the+ xterm.js terminal type in place of a missing/``dumb`` TERM, and no+ inherited claim that colour is impossible (`_interactive_child_env`);+ both require a complete snapshot of the inherited environment."""backend = make_pty_backend()child_env = _interactive_child_env(env)diff --git a/tests/unit/terminal/test_pty_environment.py b/tests/unit/terminal/test_pty_environment.pyindex bebc17d257..79e2db480b 100644--- a/tests/unit/terminal/test_pty_environment.py+++ b/tests/unit/terminal/test_pty_environment.py@@ -1,10 +1,13 @@"""The PTY advertises its own capability, not its launcher's stdout.The desktop app may be started from a coding-agent or CI terminal whose-``TERM=dumb`` correctly describes that parent. The child is subsequently-attached to ConPTY/ptyprocess and rendered by xterm.js, so inheriting the old-marker is false. Codex 0.146 pauses every interactive pane for confirmation in-that mismatch. These tests pin the correction at the shared PTY boundary on+``TERM=dumb`` and ``NO_COLOR=1`` correctly describe that parent. The child is+subsequently attached to ConPTY/ptyprocess and rendered by xterm.js, so+inheriting either marker is false. Codex 0.146 pauses every interactive pane+for confirmation in the TERM mismatch; the colour variables are worse, because+every mainstream CLI colour library obeys them unconditionally and the whole+workspace comes up monochrome — inherited once, then handed down across every+in-app restart. These tests pin both corrections at the shared PTY boundary onall operating systems."""@@ -55,7 +58,8 @@ async def _spawn_and_capture(on_closed=_closed,env=env,)- captured = backend.spawn_calls[0]["env"]+ # The LAST call, so a test may contrast two spawns on one backend.+ captured = backend.spawn_calls[-1]["env"]manager.close_all()assert isinstance(captured, Mapping)return captured@@ -103,3 +107,51 @@ async def test_meaningful_terminal_type_remains_caller_controlled(env = await _spawn_and_capture(backend, supplied)assert env is supplied+++async def test_inherited_no_color_does_not_reach_the_pane(+ backend: FakePtyBackend, monkeypatch: pytest.MonkeyPatch+) -> None:+ """The whole workspace came up monochrome from this one inherited variable."""+ monkeypatch.setenv("NO_COLOR", "1")+ monkeypatch.setenv("TERM", "dumb")++ env = await _spawn_and_capture(backend, None)++ assert "NO_COLOR" not in env+ assert env["TERM"] == "xterm-256color"+++async def test_no_color_is_dropped_even_when_the_terminal_type_is_already_good(+ backend: FakePtyBackend,+) -> None:+ """The correction is per-variable: a sane TERM must not shield NO_COLOR."""+ supplied = {"TERM": "xterm-256color", "PATH": "/safe", "NO_COLOR": "1"}++ env = await _spawn_and_capture(backend, supplied)++ assert env == {"TERM": "xterm-256color", "PATH": "/safe"}+ assert supplied["NO_COLOR"] == "1", "the caller-owned mapping must not be mutated"+++async def test_force_color_is_dropped_only_when_it_disables_colour(+ backend: FakePtyBackend,+) -> None:+ disabling = await _spawn_and_capture(backend, {"TERM": "xterm-256color", "FORCE_COLOR": "0"})+ escalating = await _spawn_and_capture(backend, {"TERM": "xterm-256color", "FORCE_COLOR": "3"})++ assert "FORCE_COLOR" not in disabling+ assert escalating["FORCE_COLOR"] == "3", "a deliberate escalation is the user's call"+++async def test_empty_colorterm_is_dropped_while_a_real_one_survives(+ backend: FakePtyBackend,+) -> None:+ """Presence alone reads as "sixteen colours" — an empty one downgrades the pane."""+ emptied = await _spawn_and_capture(backend, {"TERM": "xterm-256color", "COLORTERM": ""})+ declared = await _spawn_and_capture(+ backend, {"TERM": "xterm-256color", "COLORTERM": "truecolor"}+ )++ assert "COLORTERM" not in emptied+ assert declared["COLORTERM"] == "truecolor"