Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions libs/code/deepagents_code/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -10730,6 +10730,7 @@ async def _prompt_launch_tavily(self) -> None:
allow_empty_submit=True,
input_placeholder="Tavily API key (optional)",
submit_label="Enter save/skip",
show_cancel_hint=False,
)
)
if result is not AuthResult.SAVED:
Expand Down
10 changes: 9 additions & 1 deletion libs/code/deepagents_code/tui/widgets/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,7 @@ def __init__(
allow_empty_submit: bool = False,
input_placeholder: str | None = None,
submit_label: str | None = None,
show_cancel_hint: bool = True,
) -> None:
"""Initialize the prompt for `provider`.

Expand All @@ -647,6 +648,7 @@ def __init__(
with `AuthResult.CANCELLED` instead of showing a validation error.
input_placeholder: Optional placeholder override for the key input.
submit_label: Optional help-label override for the Enter action.
show_cancel_hint: Whether the footer advertises the Escape action.
"""
super().__init__()
self._provider = provider
Expand All @@ -655,6 +657,7 @@ def __init__(
self._allow_empty_submit = allow_empty_submit
self._input_placeholder = input_placeholder
self._submit_label = submit_label
self._show_cancel_hint = show_cancel_hint
# LangSmith is configured as a tracing service: it carries an optional
# project name and an endpoint chosen from a region selector (US/EU SaaS
# or a custom self-hosted URL), and saving a key turns tracing on.
Expand Down Expand Up @@ -1000,8 +1003,13 @@ def compose(self) -> ComposeResult:
save_label = self._submit_label or (
"Enter replace" if self._has_existing else "Enter save"
)
save_help = (
f"{save_label} {glyphs.bullet} Esc cancel"
if self._show_cancel_hint
else save_label
)
help_parts = [
f"{save_label} {glyphs.bullet} Esc cancel",
save_help,
"F2 advanced",
"Ctrl+R reload",
]
Expand Down
1 change: 1 addition & 0 deletions libs/code/tests/unit_tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2137,6 +2137,7 @@ def capture_prompt(screen: object) -> AuthResult:
assert prompt._allow_empty_submit is True
assert prompt._input_placeholder == "Tavily API key (optional)"
assert prompt._submit_label == "Enter save/skip"
assert prompt._show_cancel_hint is False
assert "Web search is optional" in (prompt._reason or "")
apply_credentials.assert_called_once_with()

Expand Down
14 changes: 14 additions & 0 deletions libs/code/tests/unit_tests/tui/widgets/test_auth_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def show_prompt(
allow_empty_submit: bool = False,
input_placeholder: str | None = None,
submit_label: str | None = None,
show_cancel_hint: bool = True,
) -> None:
"""Push the prompt and capture the dismissal result."""

Expand All @@ -97,6 +98,7 @@ def handle(result: AuthResult | None) -> None:
allow_empty_submit=allow_empty_submit,
input_placeholder=input_placeholder,
submit_label=submit_label,
show_cancel_hint=show_cancel_hint,
),
handle,
)
Expand Down Expand Up @@ -1155,6 +1157,7 @@ async def test_optional_prompt_customizes_new_user_copy(self) -> None:
allow_empty_submit=True,
input_placeholder="Tavily API key (optional)",
submit_label="Enter save/skip",
show_cancel_hint=False,
)
await pilot.pause()

Expand All @@ -1167,11 +1170,22 @@ async def test_optional_prompt_customizes_new_user_copy(self) -> None:
assert key_input.password is True
assert "Web search is optional" in copy
assert "Enter save/skip" in str(help_text.content)
assert "Esc cancel" not in str(help_text.content)
# Services (Tavily) omit the storage note entirely — the title and
# reason already explain the key, so it would only be redundant copy.
assert has_storage_note is False
assert "stores the above key locally" not in copy

async def test_default_prompt_keeps_cancel_hint(self) -> None:
"""Regular auth prompts continue to advertise Escape."""
app = _AuthHostApp()
async with app.run_test() as pilot:
app.show_prompt("openai", "OPENAI_API_KEY")
await pilot.pause()
help_text = app.screen.query_one(".auth-prompt-help", Static)

assert "Esc cancel" in str(help_text.content)

async def test_optional_prompt_surfaces_save_failure_and_stays_open(
self, monkeypatch: pytest.MonkeyPatch
) -> None:
Expand Down