Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions libs/code/deepagents_code/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
49 changes: 39 additions & 10 deletions libs/code/deepagents_code/tui/widgets/welcome.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -125,12 +142,16 @@ 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
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 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.
"""

# Disable Textual's auto_links to prevent a flicker cycle: Style.__add__
Expand Down Expand Up @@ -208,7 +229,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:
Expand Down Expand Up @@ -350,8 +372,15 @@ def _build_banner(self) -> Content:
]
if not self._hide_version:
parts.append((f" v{__version__}", "dim"))
if _is_editable_install():
parts.append((" (local)", _local_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)))

# Row labels share a common column width so values stay aligned; the
# longest label ("directory:") needs 11 columns including its space.
Expand Down Expand Up @@ -468,7 +497,7 @@ def _build_banner(self) -> Content:
parts.extend(line)
Comment thread
robin-agent[bot] marked this conversation as resolved.
Resolved

# 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")
Expand Down
9 changes: 4 additions & 5 deletions libs/code/tests/unit_tests/test_charset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
116 changes: 108 additions & 8 deletions libs/code/tests/unit_tests/tui/widgets/test_welcome.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -18,6 +19,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,
Expand All @@ -29,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(
Expand Down Expand Up @@ -185,6 +206,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."""

Expand All @@ -199,19 +242,75 @@ 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
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` 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
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."""
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_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 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.

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."""
Expand Down Expand Up @@ -595,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."""
Expand Down
Loading