From 77652277650f00acd40245dd5951e5ed97e301c6 Mon Sep 17 00:00:00 2001 From: Mason Daugherty <61371264+mdrxy@users.noreply.github.com> Date: Thu, 9 Jul 2026 02:49:55 +0000 Subject: [PATCH 1/6] feat(code): show `(debug enabled)` on splash when `DEEPAGENTS_CODE_DEBUG` is set Annotate the welcome banner version line with a `(debug enabled)` tag whenever `DEEPAGENTS_CODE_DEBUG` is truthy, rendered before the existing `(local)` editable-install tag. Makes it obvious at a glance when debug logging is active. Co-authored-by: open-swe[bot] --- .../deepagents_code/tui/widgets/welcome.py | 31 ++++++++++- .../unit_tests/tui/widgets/test_welcome.py | 54 +++++++++++++++++++ 2 files changed, 83 insertions(+), 2 deletions(-) diff --git a/libs/code/deepagents_code/tui/widgets/welcome.py b/libs/code/deepagents_code/tui/widgets/welcome.py index d7058e49067..376369833ae 100644 --- a/libs/code/deepagents_code/tui/widgets/welcome.py +++ b/libs/code/deepagents_code/tui/widgets/welcome.py @@ -98,6 +98,23 @@ def _local_tag_style(*, ansi: bool, colors: theme.ThemeColors) -> str | TStyle: return TStyle(foreground=TColor.parse(colors.tool), bold=True) +def _debug_tag_style(*, ansi: bool, colors: theme.ThemeColors) -> str | TStyle: + """Build the style for the `(debug enabled)` tag. + + Args: + ansi: Whether the active theme is an ANSI terminal theme. + colors: Active Deep Agents theme colors. + + Returns: + A bold yellow markup style under ANSI themes (whose palette the terminal + owns, so a parsed color could be invisible) or a bold themed warning + color otherwise. + """ + if ansi: + return "bold yellow" + return TStyle(foreground=TColor.parse(colors.warning), bold=True) + + def _home_prefixed(cwd: str) -> str: """Format a directory path, using `~` for the home directory when possible. @@ -125,7 +142,9 @@ def _home_prefixed(cwd: str) -> str: class WelcomeBanner(Static): """Compact welcome banner shown at startup. - Renders a bordered box with the product title and version, followed by rows + Renders a bordered box with the product title and version (annotated with + `(debug enabled)` when `DEEPAGENTS_CODE_DEBUG` is set and `(local)` for + editable installs), followed by rows that appear only when their data (and any env gate) is present. In render order: the active model (`SPLASH_SHOW_MODEL`, opt-in), working directory (`SPLASH_SHOW_CWD`, opt-in), LangSmith tracing project and its replica (each @@ -208,7 +227,8 @@ def __init__( else None ) self._project_urls: dict[str, str] = {} - self._show_thread_id = is_env_truthy(DEBUG) + self._debug_enabled = is_env_truthy(DEBUG) + self._show_thread_id = self._debug_enabled super().__init__(self._build_banner(), **kwargs) def on_mount(self) -> None: @@ -350,6 +370,13 @@ def _build_banner(self) -> Content: ] if not self._hide_version: parts.append((f" v{__version__}", "dim")) + if self._debug_enabled: + parts.append( + ( + " (debug enabled)", + _debug_tag_style(ansi=ansi, colors=colors), + ) + ) if _is_editable_install(): parts.append((" (local)", _local_tag_style(ansi=ansi, colors=colors))) diff --git a/libs/code/tests/unit_tests/tui/widgets/test_welcome.py b/libs/code/tests/unit_tests/tui/widgets/test_welcome.py index 5a204ed575b..8a16f874d67 100644 --- a/libs/code/tests/unit_tests/tui/widgets/test_welcome.py +++ b/libs/code/tests/unit_tests/tui/widgets/test_welcome.py @@ -18,6 +18,7 @@ from deepagents_code._version import __version__ from deepagents_code.tui.widgets.welcome import ( WelcomeBanner, + _debug_tag_style, _home_prefixed, _langsmith_project_link, _langsmith_project_link_style, @@ -185,6 +186,28 @@ def test_non_ansi_uses_themed_color(self) -> None: assert style.foreground == TColor.parse(DARK_COLORS.tool) +class TestDebugTagStyle: + """Tests for the `(debug enabled)` tag style.""" + + def test_ansi_uses_bold_yellow_markup(self) -> None: + """Under ANSI themes the tag stays visible via bold yellow terminal text.""" + from deepagents_code.theme import DARK_COLORS + + assert _debug_tag_style(ansi=True, colors=DARK_COLORS) == "bold yellow" + + def test_non_ansi_uses_themed_warning_color(self) -> None: + """Non-ANSI themes color the tag with the theme's warning color.""" + from textual.color import Color as TColor + from textual.style import Style as TStyle + + from deepagents_code.theme import DARK_COLORS + + style = _debug_tag_style(ansi=False, colors=DARK_COLORS) + assert isinstance(style, TStyle) + assert style.bold is True + assert style.foreground == TColor.parse(DARK_COLORS.warning) + + class TestTitle: """Tests for the banner title line.""" @@ -212,6 +235,37 @@ def test_marks_editable_install_as_local(self) -> None: assert f"v{__version__}" in plain assert "(local)" in plain + def test_no_debug_tag_by_default(self) -> None: + """No `(debug enabled)` tag when `DEEPAGENTS_CODE_DEBUG` is unset.""" + with patch(_EDITABLE, return_value=False): + plain = _make_banner()._build_banner().plain + assert "(debug enabled)" not in plain + + def test_marks_debug_enabled_when_env_set(self) -> None: + """`DEEPAGENTS_CODE_DEBUG` appends a `(debug enabled)` tag to the version.""" + with patch(_EDITABLE, return_value=False): + plain = _make_banner(env={DEBUG: "1"})._build_banner().plain + assert f"v{__version__}" in plain + assert "(debug enabled)" in plain + assert "(local)" not in plain + + def test_debug_tag_precedes_local_tag(self) -> None: + """`(debug enabled)` renders before `(local)` when both apply.""" + with patch(_EDITABLE, return_value=True): + plain = _make_banner(env={DEBUG: "1"})._build_banner().plain + assert "(debug enabled)" in plain + assert "(local)" in plain + assert plain.index("(debug enabled)") < plain.index("(local)") + + def test_no_debug_tag_when_version_hidden(self) -> None: + """`HIDE_SPLASH_VERSION` also suppresses the `(debug enabled)` tag.""" + plain = ( + _make_banner(env={DEBUG: "1", HIDE_SPLASH_VERSION: "1"}) + ._build_banner() + .plain + ) + assert "(debug enabled)" not in plain + class TestModelLine: """Tests for the model row.""" From d7bebb9d83efe4abec7f6ba3a399d0f8d43d81f5 Mon Sep 17 00:00:00 2001 From: Mason Daugherty Date: Sat, 11 Jul 2026 18:53:39 -0400 Subject: [PATCH 2/6] cr --- .../deepagents_code/tui/widgets/welcome.py | 17 ++++---- .../unit_tests/tui/widgets/test_welcome.py | 43 +++++++++++++++++++ 2 files changed, 52 insertions(+), 8 deletions(-) diff --git a/libs/code/deepagents_code/tui/widgets/welcome.py b/libs/code/deepagents_code/tui/widgets/welcome.py index 376369833ae..fb81c921f29 100644 --- a/libs/code/deepagents_code/tui/widgets/welcome.py +++ b/libs/code/deepagents_code/tui/widgets/welcome.py @@ -142,14 +142,15 @@ def _home_prefixed(cwd: str) -> str: class WelcomeBanner(Static): """Compact welcome banner shown at startup. - Renders a bordered box with the product title and version (annotated with - `(debug enabled)` when `DEEPAGENTS_CODE_DEBUG` is set and `(local)` for - editable installs), followed by rows - that appear only when their data (and any env gate) is present. In render - order: the active model (`SPLASH_SHOW_MODEL`, opt-in), working directory - (`SPLASH_SHOW_CWD`, opt-in), LangSmith tracing project and its replica (each - clickable once its URL resolves), thread ID (debug mode only), and the MCP - tool count. MCP server warnings and the editable-install path follow. + Renders a bordered box with the product title and version. The version + carries a `(debug enabled)` tag when `DEEPAGENTS_CODE_DEBUG` is set and a + `(local)` tag for editable installs; both appear only when the version is + shown. Rows follow that appear only when their data (and any env gate) is + present. In render order: the active model (`SPLASH_SHOW_MODEL`, opt-in), + working directory (`SPLASH_SHOW_CWD`, opt-in), LangSmith tracing project and + its replica (each clickable once its URL resolves), thread ID (debug mode + only), and the MCP tool count. MCP server warnings and the editable-install + path follow. """ # Disable Textual's auto_links to prevent a flicker cycle: Style.__add__ diff --git a/libs/code/tests/unit_tests/tui/widgets/test_welcome.py b/libs/code/tests/unit_tests/tui/widgets/test_welcome.py index 8a16f874d67..31a68edc0a5 100644 --- a/libs/code/tests/unit_tests/tui/widgets/test_welcome.py +++ b/libs/code/tests/unit_tests/tui/widgets/test_welcome.py @@ -5,6 +5,7 @@ import pytest from textual.content import Content +from textual.style import Style as TStyle from deepagents_code._env_vars import ( DEBUG, @@ -30,6 +31,25 @@ _PROJECT_NAME = "deepagents_code.tui.widgets.welcome.get_langsmith_project_name" _REPLICA_PROJECT = "deepagents_code.tui.widgets.welcome.get_langsmith_replica_project" _FETCH_URL = "deepagents_code.tui.widgets.welcome.fetch_langsmith_project_url" +_DEBUG_STYLE = "deepagents_code.tui.widgets.welcome._debug_tag_style" +_LOCAL_STYLE = "deepagents_code.tui.widgets.welcome._local_tag_style" + + +def _style_covering(content: Content, needle: str) -> TStyle: + """Return the style of the single span whose text contains `needle`. + + Args: + content: Assembled banner content to inspect. + needle: Substring identifying the span whose style to return. + + Returns: + The `TStyle` of the one span covering `needle`. + """ + spans = [s for s in content.spans if needle in content._text[s.start : s.end]] + assert len(spans) == 1, f"expected exactly one span covering {needle!r}" + style = spans[0].style + assert isinstance(style, TStyle) + return style def _make_banner( @@ -248,6 +268,7 @@ def test_marks_debug_enabled_when_env_set(self) -> None: assert f"v{__version__}" in plain assert "(debug enabled)" in plain assert "(local)" not in plain + assert plain.index(f"v{__version__}") < plain.index("(debug enabled)") def test_debug_tag_precedes_local_tag(self) -> None: """`(debug enabled)` renders before `(local)` when both apply.""" @@ -266,6 +287,28 @@ def test_no_debug_tag_when_version_hidden(self) -> None: ) assert "(debug enabled)" not in plain + def test_title_tags_carry_their_own_styles(self) -> None: + """Each title tag's span carries its own style helper's output. + + Guards against wiring regressions where a tag renders with the wrong + helper's style or the style lands on the wrong segment; the plain-text + assertions above cannot catch either. + """ + from textual.color import Color as TColor + + debug_style = TStyle(foreground=TColor.parse("#010203"), bold=True) + local_style = TStyle(foreground=TColor.parse("#040506"), bold=True) + with ( + patch(_EDITABLE, return_value=True), + patch(_DEBUG_STYLE, return_value=debug_style), + patch(_LOCAL_STYLE, return_value=local_style), + ): + content = _make_banner(env={DEBUG: "1"})._build_banner() + assert _style_covering(content, "(debug enabled)").foreground == TColor.parse( + "#010203" + ) + assert _style_covering(content, "(local)").foreground == TColor.parse("#040506") + class TestModelLine: """Tests for the model row.""" From 33779a93a31a14030e64908bbc29b2181f25fc62 Mon Sep 17 00:00:00 2001 From: Mason Daugherty Date: Sat, 11 Jul 2026 19:11:39 -0400 Subject: [PATCH 3/6] cr --- libs/code/deepagents_code/config.py | 6 ++-- .../deepagents_code/tui/widgets/welcome.py | 29 ++++++++++--------- libs/code/tests/unit_tests/test_charset.py | 9 +++--- .../unit_tests/tui/widgets/test_welcome.py | 27 +++++++++-------- 4 files changed, 37 insertions(+), 34 deletions(-) diff --git a/libs/code/deepagents_code/config.py b/libs/code/deepagents_code/config.py index 4c104498aca..6e4f7c96983 100644 --- a/libs/code/deepagents_code/config.py +++ b/libs/code/deepagents_code/config.py @@ -1434,12 +1434,12 @@ def get_banner() -> str: else: banner = _UNICODE_BANNER - if is_env_truthy(HIDE_SPLASH_VERSION): - return banner.replace(f"v{__version__}", "") - if _is_editable_install(): banner = banner.replace(f"v{__version__}", f"v{__version__} (local)") + if is_env_truthy(HIDE_SPLASH_VERSION): + banner = banner.replace(f"v{__version__}", "") + return banner diff --git a/libs/code/deepagents_code/tui/widgets/welcome.py b/libs/code/deepagents_code/tui/widgets/welcome.py index fb81c921f29..5c3095a58be 100644 --- a/libs/code/deepagents_code/tui/widgets/welcome.py +++ b/libs/code/deepagents_code/tui/widgets/welcome.py @@ -142,11 +142,12 @@ def _home_prefixed(cwd: str) -> str: class WelcomeBanner(Static): """Compact welcome banner shown at startup. - Renders a bordered box with the product title and version. The version - carries a `(debug enabled)` tag when `DEEPAGENTS_CODE_DEBUG` is set and a - `(local)` tag for editable installs; both appear only when the version is - shown. Rows follow that appear only when their data (and any env gate) is - present. In render order: the active model (`SPLASH_SHOW_MODEL`, opt-in), + Renders a bordered box with the product title and optional version. A + `(debug enabled)` tag appears when `DEEPAGENTS_CODE_DEBUG` is set, and a + `(local)` tag appears for editable installs. These tags are independent of + whether the version is shown. Rows follow that appear only when their data + (and any env gate) is present. In render order: the active model + (`SPLASH_SHOW_MODEL`, opt-in), working directory (`SPLASH_SHOW_CWD`, opt-in), LangSmith tracing project and its replica (each clickable once its URL resolves), thread ID (debug mode only), and the MCP tool count. MCP server warnings and the editable-install @@ -371,15 +372,15 @@ def _build_banner(self) -> Content: ] if not self._hide_version: parts.append((f" v{__version__}", "dim")) - if self._debug_enabled: - parts.append( - ( - " (debug enabled)", - _debug_tag_style(ansi=ansi, colors=colors), - ) + if self._debug_enabled: + parts.append( + ( + " (debug enabled)", + _debug_tag_style(ansi=ansi, colors=colors), ) - if _is_editable_install(): - parts.append((" (local)", _local_tag_style(ansi=ansi, colors=colors))) + ) + if _is_editable_install(): + parts.append((" (local)", _local_tag_style(ansi=ansi, colors=colors))) # Row labels share a common column width so values stay aligned; the # longest label ("directory:") needs 11 columns including its space. @@ -496,7 +497,7 @@ def _build_banner(self) -> Content: parts.extend(line) # Editable-install path for local development visibility. - if not self._hide_version and not self._hide_cwd: + if not self._hide_cwd: editable_path = _get_editable_install_path() if editable_path: parts.append("\n") diff --git a/libs/code/tests/unit_tests/test_charset.py b/libs/code/tests/unit_tests/test_charset.py index 210163818a4..be28896cf95 100644 --- a/libs/code/tests/unit_tests/test_charset.py +++ b/libs/code/tests/unit_tests/test_charset.py @@ -339,13 +339,12 @@ def test_get_banner_adds_local_install_suffix_for_editable_ascii(self) -> None: {"UI_CHARSET_MODE": "unicode", HIDE_SPLASH_VERSION: "1"}, clear=False, ) - def test_get_banner_hides_version_and_local_suffix(self) -> None: - """Splash version override should hide version and skip local detection.""" - with patch("deepagents_code.config._is_editable_install") as editable: + def test_get_banner_hides_version_but_keeps_local_suffix(self) -> None: + """Splash version override hides only the version text.""" + with patch("deepagents_code.config._is_editable_install", return_value=True): banner = get_banner() - editable.assert_not_called() assert f"v{__version__}" not in banner - assert "(local)" not in banner + assert "(local)" in banner def test_unicode_banner_contains_box_drawing_chars(self) -> None: """Test that Unicode banner contains non-ASCII box drawing characters.""" diff --git a/libs/code/tests/unit_tests/tui/widgets/test_welcome.py b/libs/code/tests/unit_tests/tui/widgets/test_welcome.py index 31a68edc0a5..21b89863b06 100644 --- a/libs/code/tests/unit_tests/tui/widgets/test_welcome.py +++ b/libs/code/tests/unit_tests/tui/widgets/test_welcome.py @@ -242,14 +242,15 @@ def test_shows_version_by_default(self) -> None: assert f"v{__version__}" in plain assert "(local)" not in plain - def test_hides_version_when_env_set(self) -> None: - """`HIDE_SPLASH_VERSION` removes the version from the title.""" - plain = _make_banner(env={HIDE_SPLASH_VERSION: "1"})._build_banner().plain + def test_hides_only_version_when_env_set(self) -> None: + """`HIDE_SPLASH_VERSION` leaves the editable-install tag visible.""" + with patch(_EDITABLE, return_value=True): + plain = _make_banner(env={HIDE_SPLASH_VERSION: "1"})._build_banner().plain assert f"v{__version__}" not in plain - assert "(local)" not in plain + assert "(local)" in plain def test_marks_editable_install_as_local(self) -> None: - """Editable installs append a `(local)` tag to the version.""" + """Editable installs show a `(local)` tag.""" with patch(_EDITABLE, return_value=True): plain = _make_banner()._build_banner().plain assert f"v{__version__}" in plain @@ -262,7 +263,7 @@ def test_no_debug_tag_by_default(self) -> None: assert "(debug enabled)" not in plain def test_marks_debug_enabled_when_env_set(self) -> None: - """`DEEPAGENTS_CODE_DEBUG` appends a `(debug enabled)` tag to the version.""" + """`DEEPAGENTS_CODE_DEBUG` shows a `(debug enabled)` tag.""" with patch(_EDITABLE, return_value=False): plain = _make_banner(env={DEBUG: "1"})._build_banner().plain assert f"v{__version__}" in plain @@ -278,14 +279,15 @@ def test_debug_tag_precedes_local_tag(self) -> None: assert "(local)" in plain assert plain.index("(debug enabled)") < plain.index("(local)") - def test_no_debug_tag_when_version_hidden(self) -> None: - """`HIDE_SPLASH_VERSION` also suppresses the `(debug enabled)` tag.""" + def test_debug_tag_when_version_hidden(self) -> None: + """`HIDE_SPLASH_VERSION` leaves the debug tag visible.""" plain = ( _make_banner(env={DEBUG: "1", HIDE_SPLASH_VERSION: "1"}) ._build_banner() .plain ) - assert "(debug enabled)" not in plain + assert f"v{__version__}" not in plain + assert "(debug enabled)" in plain def test_title_tags_carry_their_own_styles(self) -> None: """Each title tag's span carries its own style helper's output. @@ -692,14 +694,15 @@ def test_no_install_path_for_non_editable(self) -> None: plain = _make_banner()._build_banner().plain assert "installed:" not in plain - def test_no_install_path_when_version_hidden(self) -> None: - """No install path row when the version is hidden.""" + def test_install_path_when_version_hidden(self) -> None: + """Hiding the version does not hide the editable-install path.""" with ( patch(_EDITABLE, return_value=True), patch(_EDITABLE_PATH, return_value="~/code"), ): plain = _make_banner(env={HIDE_SPLASH_VERSION: "1"})._build_banner().plain - assert "installed:" not in plain + assert "installed:" in plain + assert "~/code" in plain def test_no_install_path_when_cwd_hidden(self) -> None: """No install path row when local path displays are hidden.""" From cae598ad2f9563f7d6b3db747f07d7146f01a5e2 Mon Sep 17 00:00:00 2001 From: Mason Daugherty Date: Mon, 13 Jul 2026 00:21:34 -0400 Subject: [PATCH 4/6] cr --- libs/code/deepagents_code/config.py | 6 +- .../deepagents_code/tui/widgets/welcome.py | 21 +++---- libs/code/tests/unit_tests/test_charset.py | 9 +-- .../unit_tests/tui/widgets/test_welcome.py | 62 +++++++++++++++---- 4 files changed, 67 insertions(+), 31 deletions(-) diff --git a/libs/code/deepagents_code/config.py b/libs/code/deepagents_code/config.py index 6e4f7c96983..4c104498aca 100644 --- a/libs/code/deepagents_code/config.py +++ b/libs/code/deepagents_code/config.py @@ -1434,12 +1434,12 @@ def get_banner() -> str: else: banner = _UNICODE_BANNER + if is_env_truthy(HIDE_SPLASH_VERSION): + return banner.replace(f"v{__version__}", "") + if _is_editable_install(): banner = banner.replace(f"v{__version__}", f"v{__version__} (local)") - if is_env_truthy(HIDE_SPLASH_VERSION): - banner = banner.replace(f"v{__version__}", "") - return banner diff --git a/libs/code/deepagents_code/tui/widgets/welcome.py b/libs/code/deepagents_code/tui/widgets/welcome.py index 5c3095a58be..b11db11dd7c 100644 --- a/libs/code/deepagents_code/tui/widgets/welcome.py +++ b/libs/code/deepagents_code/tui/widgets/welcome.py @@ -143,15 +143,14 @@ class WelcomeBanner(Static): """Compact welcome banner shown at startup. Renders a bordered box with the product title and optional version. A - `(debug enabled)` tag appears when `DEEPAGENTS_CODE_DEBUG` is set, and a - `(local)` tag appears for editable installs. These tags are independent of - whether the version is shown. Rows follow that appear only when their data - (and any env gate) is present. In render order: the active model - (`SPLASH_SHOW_MODEL`, opt-in), - working directory (`SPLASH_SHOW_CWD`, opt-in), LangSmith tracing project and - its replica (each clickable once its URL resolves), thread ID (debug mode - only), and the MCP tool count. MCP server warnings and the editable-install - path follow. + `(debug enabled)` tag appears when `DEEPAGENTS_CODE_DEBUG` is set, even when + the version is hidden. A `(local)` tag appears for editable installs only + when the version is shown. Rows follow that appear only when their data (and + any env gate) is present. In render order: the active model + (`SPLASH_SHOW_MODEL`, opt-in), working directory (`SPLASH_SHOW_CWD`, + opt-in), LangSmith tracing project and its replica (each clickable once its + URL resolves), thread ID (debug mode only), and the MCP tool count. MCP + server warnings and the editable-install path follow. """ # Disable Textual's auto_links to prevent a flicker cycle: Style.__add__ @@ -379,7 +378,7 @@ def _build_banner(self) -> Content: _debug_tag_style(ansi=ansi, colors=colors), ) ) - if _is_editable_install(): + if not self._hide_version and _is_editable_install(): parts.append((" (local)", _local_tag_style(ansi=ansi, colors=colors))) # Row labels share a common column width so values stay aligned; the @@ -497,7 +496,7 @@ def _build_banner(self) -> Content: parts.extend(line) # Editable-install path for local development visibility. - if not self._hide_cwd: + if not self._hide_version and not self._hide_cwd: editable_path = _get_editable_install_path() if editable_path: parts.append("\n") diff --git a/libs/code/tests/unit_tests/test_charset.py b/libs/code/tests/unit_tests/test_charset.py index be28896cf95..210163818a4 100644 --- a/libs/code/tests/unit_tests/test_charset.py +++ b/libs/code/tests/unit_tests/test_charset.py @@ -339,12 +339,13 @@ def test_get_banner_adds_local_install_suffix_for_editable_ascii(self) -> None: {"UI_CHARSET_MODE": "unicode", HIDE_SPLASH_VERSION: "1"}, clear=False, ) - def test_get_banner_hides_version_but_keeps_local_suffix(self) -> None: - """Splash version override hides only the version text.""" - with patch("deepagents_code.config._is_editable_install", return_value=True): + def test_get_banner_hides_version_and_local_suffix(self) -> None: + """Splash version override should hide version and skip local detection.""" + with patch("deepagents_code.config._is_editable_install") as editable: banner = get_banner() + editable.assert_not_called() assert f"v{__version__}" not in banner - assert "(local)" in banner + assert "(local)" not in banner def test_unicode_banner_contains_box_drawing_chars(self) -> None: """Test that Unicode banner contains non-ASCII box drawing characters.""" diff --git a/libs/code/tests/unit_tests/tui/widgets/test_welcome.py b/libs/code/tests/unit_tests/tui/widgets/test_welcome.py index 21b89863b06..ed67315e62d 100644 --- a/libs/code/tests/unit_tests/tui/widgets/test_welcome.py +++ b/libs/code/tests/unit_tests/tui/widgets/test_welcome.py @@ -38,6 +38,12 @@ def _style_covering(content: Content, needle: str) -> TStyle: """Return the style of the single span whose text contains `needle`. + Only usable for spans whose style resolves to a `TStyle` (i.e. built from a + themed `TStyle`, not ANSI string markup, which `Content.assemble` preserves + as a raw `str` — see `test_debug_tag_uses_ansi_markup_under_ansi_theme`). + Reaches into Textual internals (`Content._text` and `Span.style`); update if + those change. + Args: content: Assembled banner content to inspect. needle: Substring identifying the span whose style to return. @@ -242,12 +248,12 @@ def test_shows_version_by_default(self) -> None: assert f"v{__version__}" in plain assert "(local)" not in plain - def test_hides_only_version_when_env_set(self) -> None: - """`HIDE_SPLASH_VERSION` leaves the editable-install tag visible.""" + def test_hides_version_and_local_tag_when_env_set(self) -> None: + """`HIDE_SPLASH_VERSION` removes version and local-install details.""" with patch(_EDITABLE, return_value=True): plain = _make_banner(env={HIDE_SPLASH_VERSION: "1"})._build_banner().plain assert f"v{__version__}" not in plain - assert "(local)" in plain + assert "(local)" not in plain def test_marks_editable_install_as_local(self) -> None: """Editable installs show a `(local)` tag.""" @@ -280,14 +286,16 @@ def test_debug_tag_precedes_local_tag(self) -> None: assert plain.index("(debug enabled)") < plain.index("(local)") def test_debug_tag_when_version_hidden(self) -> None: - """`HIDE_SPLASH_VERSION` leaves the debug tag visible.""" - plain = ( - _make_banner(env={DEBUG: "1", HIDE_SPLASH_VERSION: "1"}) - ._build_banner() - .plain - ) + """The debug tag remains visible without exposing local-install details.""" + with patch(_EDITABLE, return_value=True): + plain = ( + _make_banner(env={DEBUG: "1", HIDE_SPLASH_VERSION: "1"}) + ._build_banner() + .plain + ) assert f"v{__version__}" not in plain assert "(debug enabled)" in plain + assert "(local)" not in plain def test_title_tags_carry_their_own_styles(self) -> None: """Each title tag's span carries its own style helper's output. @@ -311,6 +319,34 @@ def test_title_tags_carry_their_own_styles(self) -> None: ) assert _style_covering(content, "(local)").foreground == TColor.parse("#040506") + def test_debug_tag_uses_ansi_markup_under_ansi_theme(self) -> None: + """Under an ANSI theme the assembled debug span carries bold-yellow markup. + + `TestDebugTagStyle` covers `_debug_tag_style` in isolation; only an + assembled banner confirms the ANSI branch's markup survives + `Content.assemble`, which keeps it a raw `str` rather than a parsed + `TStyle` (so `_style_covering` cannot be used here). Guards the ANSI + rendering path that every other assembled test misses, since they run + under the non-ANSI default theme. + """ + from textual._context import active_app + + app = active_app.get() + previous_theme = app.theme + app.theme = "ansi-dark" + try: + with patch(_EDITABLE, return_value=False): + content = _make_banner(env={DEBUG: "1"})._build_banner() + finally: + app.theme = previous_theme + spans = [ + s + for s in content.spans + if "(debug enabled)" in content._text[s.start : s.end] + ] + assert len(spans) == 1, "expected exactly one span covering the debug tag" + assert spans[0].style == "bold yellow" + class TestModelLine: """Tests for the model row.""" @@ -694,15 +730,15 @@ def test_no_install_path_for_non_editable(self) -> None: plain = _make_banner()._build_banner().plain assert "installed:" not in plain - def test_install_path_when_version_hidden(self) -> None: - """Hiding the version does not hide the editable-install path.""" + def test_no_install_path_when_version_hidden(self) -> None: + """Hiding the version also hides the editable-install path.""" with ( patch(_EDITABLE, return_value=True), patch(_EDITABLE_PATH, return_value="~/code"), ): plain = _make_banner(env={HIDE_SPLASH_VERSION: "1"})._build_banner().plain - assert "installed:" in plain - assert "~/code" in plain + assert "installed:" not in plain + assert "~/code" not in plain def test_no_install_path_when_cwd_hidden(self) -> None: """No install path row when local path displays are hidden.""" From cbb029cf4c7992dc3c103c0d268aac2d15826a73 Mon Sep 17 00:00:00 2001 From: Mason Daugherty Date: Mon, 13 Jul 2026 00:46:16 -0400 Subject: [PATCH 5/6] cr --- .../deepagents_code/tui/widgets/welcome.py | 4 +- .../unit_tests/tui/widgets/test_welcome.py | 55 +++++++++++++------ 2 files changed, 41 insertions(+), 18 deletions(-) diff --git a/libs/code/deepagents_code/tui/widgets/welcome.py b/libs/code/deepagents_code/tui/widgets/welcome.py index b11db11dd7c..cb1b2b9f009 100644 --- a/libs/code/deepagents_code/tui/widgets/welcome.py +++ b/libs/code/deepagents_code/tui/widgets/welcome.py @@ -349,7 +349,9 @@ def _build_banner(self) -> Content: """Build the banner content. Returns: - Content with the title and version, followed by any applicable rows + Content with the title, optional version, and any applicable header + tags (`(debug enabled)` when debug is on; `(local)` for editable + installs when the version is shown), followed by any applicable rows in order: model (when `SPLASH_SHOW_MODEL`), directory (when `SPLASH_SHOW_CWD`), tracing and replica (each clickable once its URL resolves), thread ID (debug only), MCP tool count, MCP server diff --git a/libs/code/tests/unit_tests/tui/widgets/test_welcome.py b/libs/code/tests/unit_tests/tui/widgets/test_welcome.py index ed67315e62d..add07dbdb27 100644 --- a/libs/code/tests/unit_tests/tui/widgets/test_welcome.py +++ b/libs/code/tests/unit_tests/tui/widgets/test_welcome.py @@ -35,14 +35,33 @@ _LOCAL_STYLE = "deepagents_code.tui.widgets.welcome._local_tag_style" -def _style_covering(content: Content, needle: str) -> TStyle: +def _raw_style_covering(content: Content, needle: str) -> str | TStyle: """Return the style of the single span whose text contains `needle`. + The style may be a parsed `TStyle` (from a themed style) or a raw `str` + (ANSI string markup, which `Content.assemble` preserves verbatim — see + `test_debug_tag_uses_ansi_markup_under_ansi_theme`). Use `_style_covering` + when the style must be a `TStyle`. Indexes the public `content.plain` and + reads the public `Span.style` field; update if Textual's span model changes. + + Args: + content: Assembled banner content to inspect. + needle: Substring identifying the span whose style to return. + + Returns: + The style of the one span covering `needle`. + """ + spans = [s for s in content.spans if needle in content.plain[s.start : s.end]] + assert len(spans) == 1, f"expected exactly one span covering {needle!r}" + return spans[0].style + + +def _style_covering(content: Content, needle: str) -> TStyle: + """Return the `TStyle` of the single span whose text contains `needle`. + Only usable for spans whose style resolves to a `TStyle` (i.e. built from a themed `TStyle`, not ANSI string markup, which `Content.assemble` preserves as a raw `str` — see `test_debug_tag_uses_ansi_markup_under_ansi_theme`). - Reaches into Textual internals (`Content._text` and `Span.style`); update if - those change. Args: content: Assembled banner content to inspect. @@ -51,9 +70,7 @@ def _style_covering(content: Content, needle: str) -> TStyle: Returns: The `TStyle` of the one span covering `needle`. """ - spans = [s for s in content.spans if needle in content._text[s.start : s.end]] - assert len(spans) == 1, f"expected exactly one span covering {needle!r}" - style = spans[0].style + style = _raw_style_covering(content, needle) assert isinstance(style, TStyle) return style @@ -224,7 +241,6 @@ def test_ansi_uses_bold_yellow_markup(self) -> None: def test_non_ansi_uses_themed_warning_color(self) -> None: """Non-ANSI themes color the tag with the theme's warning color.""" from textual.color import Color as TColor - from textual.style import Style as TStyle from deepagents_code.theme import DARK_COLORS @@ -268,12 +284,23 @@ def test_no_debug_tag_by_default(self) -> None: plain = _make_banner()._build_banner().plain assert "(debug enabled)" not in plain + def test_no_debug_tag_when_env_falsy(self) -> None: + """A present-but-falsy `DEEPAGENTS_CODE_DEBUG` shows no `(debug enabled)` tag. + + Locks the truthy gate (`is_env_truthy`) against a regression to a bare + presence check (`DEBUG in os.environ`), which every other test would pass. + """ + with patch(_EDITABLE, return_value=False): + plain = _make_banner(env={DEBUG: "0"})._build_banner().plain + assert "(debug enabled)" not in plain + def test_marks_debug_enabled_when_env_set(self) -> None: """`DEEPAGENTS_CODE_DEBUG` shows a `(debug enabled)` tag.""" with patch(_EDITABLE, return_value=False): plain = _make_banner(env={DEBUG: "1"})._build_banner().plain assert f"v{__version__}" in plain - assert "(debug enabled)" in plain + # Leading space guards the separator from the preceding segment. + assert " (debug enabled)" in plain assert "(local)" not in plain assert plain.index(f"v{__version__}") < plain.index("(debug enabled)") @@ -339,13 +366,7 @@ def test_debug_tag_uses_ansi_markup_under_ansi_theme(self) -> None: content = _make_banner(env={DEBUG: "1"})._build_banner() finally: app.theme = previous_theme - spans = [ - s - for s in content.spans - if "(debug enabled)" in content._text[s.start : s.end] - ] - assert len(spans) == 1, "expected exactly one span covering the debug tag" - assert spans[0].style == "bold yellow" + assert _raw_style_covering(content, "(debug enabled)") == "bold yellow" class TestModelLine: @@ -465,7 +486,7 @@ def test_project_name_is_clickable_when_url_resolved(self) -> None: s for s in content.spans if isinstance(s.style, TStyle) and s.style.link ] assert any( - "dcode-johannes" in content._text[s.start : s.end] for s in linked_spans + "dcode-johannes" in content.plain[s.start : s.end] for s in linked_spans ) def test_project_name_not_clickable_without_url(self) -> None: @@ -589,7 +610,7 @@ def test_replica_project_is_clickable_when_url_resolved(self) -> None: s for s in content.spans if isinstance(s.style, TStyle) and s.style.link ] assert any( - "dcode-replica" in content._text[s.start : s.end] for s in linked_spans + "dcode-replica" in content.plain[s.start : s.end] for s in linked_spans ) async def test_fetch_and_update_sets_primary_and_replica_urls(self) -> None: From 28f238e8d4e9fb94fde85465747201a008d7025e Mon Sep 17 00:00:00 2001 From: Mason Daugherty Date: Mon, 13 Jul 2026 01:28:12 -0400 Subject: [PATCH 6/6] cr --- .../deepagents_code/tui/widgets/welcome.py | 9 +-- .../unit_tests/tui/widgets/test_welcome.py | 58 ++++++++++++++----- 2 files changed, 49 insertions(+), 18 deletions(-) diff --git a/libs/code/deepagents_code/tui/widgets/welcome.py b/libs/code/deepagents_code/tui/widgets/welcome.py index cb1b2b9f009..a205ec332b3 100644 --- a/libs/code/deepagents_code/tui/widgets/welcome.py +++ b/libs/code/deepagents_code/tui/widgets/welcome.py @@ -143,10 +143,11 @@ class WelcomeBanner(Static): """Compact welcome banner shown at startup. Renders a bordered box with the product title and optional version. A - `(debug enabled)` tag appears when `DEEPAGENTS_CODE_DEBUG` is set, even when - the version is hidden. A `(local)` tag appears for editable installs only - when the version is shown. Rows follow that appear only when their data (and - any env gate) is present. In render order: the active model + `(debug enabled)` tag appears when `DEEPAGENTS_CODE_DEBUG` is enabled + (truthy), even when the version is hidden. A `(local)` tag appears for + editable installs only when the version is shown. Rows follow that appear + only when their data (and any env gate) is present. In render order: the + active model (`SPLASH_SHOW_MODEL`, opt-in), working directory (`SPLASH_SHOW_CWD`, opt-in), LangSmith tracing project and its replica (each clickable once its URL resolves), thread ID (debug mode only), and the MCP tool count. MCP diff --git a/libs/code/tests/unit_tests/tui/widgets/test_welcome.py b/libs/code/tests/unit_tests/tui/widgets/test_welcome.py index add07dbdb27..bf66ac08ef9 100644 --- a/libs/code/tests/unit_tests/tui/widgets/test_welcome.py +++ b/libs/code/tests/unit_tests/tui/widgets/test_welcome.py @@ -38,11 +38,12 @@ def _raw_style_covering(content: Content, needle: str) -> str | TStyle: """Return the style of the single span whose text contains `needle`. - The style may be a parsed `TStyle` (from a themed style) or a raw `str` - (ANSI string markup, which `Content.assemble` preserves verbatim — see - `test_debug_tag_uses_ansi_markup_under_ansi_theme`). Use `_style_covering` - when the style must be a `TStyle`. Indexes the public `content.plain` and - reads the public `Span.style` field; update if Textual's span model changes. + The style may be a `TStyle` (built from a themed style) or a raw `str` style + string (used under the ANSI theme branch, which `Content.assemble` preserves + verbatim — see `test_debug_tag_uses_ansi_markup_under_ansi_theme`). Use + `_style_covering` when the style must be a `TStyle`. Indexes the public + `content.plain` and reads the public `Span.style` field; update if Textual's + span model changes. Args: content: Assembled banner content to inspect. @@ -60,8 +61,9 @@ def _style_covering(content: Content, needle: str) -> TStyle: """Return the `TStyle` of the single span whose text contains `needle`. Only usable for spans whose style resolves to a `TStyle` (i.e. built from a - themed `TStyle`, not ANSI string markup, which `Content.assemble` preserves - as a raw `str` — see `test_debug_tag_uses_ansi_markup_under_ansi_theme`). + themed `TStyle`, not a raw `str` style string as used under the ANSI theme + branch, which `Content.assemble` preserves as a raw `str` — see + `test_debug_tag_uses_ansi_markup_under_ansi_theme`). Args: content: Assembled banner content to inspect. @@ -219,7 +221,6 @@ def test_ansi_uses_bold_markup(self) -> None: def test_non_ansi_uses_themed_color(self) -> None: """Non-ANSI themes color the tag with the theme's tool color.""" from textual.color import Color as TColor - from textual.style import Style as TStyle from deepagents_code.theme import DARK_COLORS @@ -312,6 +313,20 @@ def test_debug_tag_precedes_local_tag(self) -> None: assert "(local)" in plain assert plain.index("(debug enabled)") < plain.index("(local)") + def test_version_debug_local_render_in_order(self) -> None: + """Version, `(debug enabled)`, and `(local)` render in that fixed order. + + The pairwise ordering assertions each pin only two of the three segments, + and under different editable states; this locks all three in one banner. + """ + with patch(_EDITABLE, return_value=True): + plain = _make_banner(env={DEBUG: "1"})._build_banner().plain + assert ( + plain.index(f"v{__version__}") + < plain.index("(debug enabled)") + < plain.index("(local)") + ) + def test_debug_tag_when_version_hidden(self) -> None: """The debug tag remains visible without exposing local-install details.""" with patch(_EDITABLE, return_value=True): @@ -368,6 +383,27 @@ def test_debug_tag_uses_ansi_markup_under_ansi_theme(self) -> None: app.theme = previous_theme assert _raw_style_covering(content, "(debug enabled)") == "bold yellow" + def test_debug_tag_uses_themed_warning_color_when_assembled(self) -> None: + """The real themed warning color reaches the assembled debug span. + + `TestDebugTagStyle` checks `_debug_tag_style` in isolation and + `test_title_tags_carry_their_own_styles` patches it with a sentinel; + neither confirms the unpatched helper's themed color lands on the span + under the default (non-ANSI) theme. Anchored to the banner's resolved + theme colors so it tracks whatever palette the active theme provides. + """ + from textual.color import Color as TColor + + from deepagents_code.theme import get_theme_colors + + with patch(_EDITABLE, return_value=False): + banner = _make_banner(env={DEBUG: "1"}) + content = banner._build_banner() + warning = get_theme_colors(banner).warning + assert _style_covering(content, "(debug enabled)").foreground == TColor.parse( + warning + ) + class TestModelLine: """Tests for the model row.""" @@ -473,8 +509,6 @@ def test_shows_project_name_without_url(self) -> None: def test_project_name_is_clickable_when_url_resolved(self) -> None: """The project name is a hyperlink when the URL has been fetched.""" - from textual.style import Style as TStyle - widget = _make_banner( project_name="dcode-johannes", project_urls={ @@ -491,8 +525,6 @@ def test_project_name_is_clickable_when_url_resolved(self) -> None: def test_project_name_not_clickable_without_url(self) -> None: """The project name has no link when the URL has not been fetched.""" - from textual.style import Style as TStyle - widget = _make_banner(project_name="dcode-johannes") content = widget._build_banner() linked = [ @@ -596,8 +628,6 @@ def test_hidden_when_primary_tracing_hidden(self) -> None: def test_replica_project_is_clickable_when_url_resolved(self) -> None: """The replica project is a hyperlink when the URL has been fetched.""" - from textual.style import Style as TStyle - widget = _make_banner( project_name="dcode-primary", replica_project="dcode-replica",