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
8 changes: 8 additions & 0 deletions libs/code/deepagents_code/tui/widgets/notification_center.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import logging
from dataclasses import dataclass
from importlib import import_module
from typing import TYPE_CHECKING, ClassVar

from textual.binding import Binding, BindingType
Expand Down Expand Up @@ -356,6 +357,12 @@ def on_notification_row_clicked(self, message: NotificationRowClicked) -> None:
self._set_selected(index)
self._drill_into(self._notifications[index])

@staticmethod
def _preload_follow_up(entry: PendingNotification) -> None:
"""Load deferred follow-up UI before its detail screen becomes active."""
if any(action.action_id == ActionId.ENTER_API_KEY for action in entry.actions):
import_module("deepagents_code.tui.widgets.auth")

def _drill_into(self, entry: PendingNotification) -> None:
"""Push a detail modal for *entry*.

Expand All @@ -367,6 +374,7 @@ def _drill_into(self, entry: PendingNotification) -> None:
"""
if self._drilling:
return
self._preload_follow_up(entry)
detail_screen = self._detail_screen_for(entry)
self._drilling = True

Expand Down
23 changes: 23 additions & 0 deletions libs/code/tests/unit_tests/tui/widgets/test_notification_center.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
PendingNotification,
UpdateAvailablePayload,
)
from deepagents_code.tui.widgets import notification_center
from deepagents_code.tui.widgets.notification_center import (
NotificationActionRequested,
NotificationActionResult,
Expand Down Expand Up @@ -122,6 +123,28 @@ async def test_enter_drills_into_update_available_screen(self) -> None:
await pilot.pause()
assert isinstance(app.screen, UpdateAvailableScreen)

async def test_enter_preloads_api_key_screen_before_detail(
self, monkeypatch: pytest.MonkeyPatch
) -> None:
"""API-key UI loads while the center still covers the base screen."""
imports: list[tuple[str, object]] = []
app = App()
screen = NotificationCenterScreen([_service_entry()])

def capture_import(name: str) -> None:
imports.append((name, app.screen))

monkeypatch.setattr(notification_center, "import_module", capture_import)
async with app.run_test() as pilot:
app.push_screen(screen)
await pilot.pause()
await pilot.press("enter")
await pilot.pause()

assert isinstance(app.screen, NotificationDetailScreen)

assert imports == [("deepagents_code.tui.widgets.auth", screen)]

async def test_detail_action_dismisses_center_with_result(self) -> None:
"""Selecting an action in the detail dismisses the center with it."""
results: list[NotificationActionResult | None] = []
Expand Down