fix(tui): use correct DiffDisplayMode enum members + typed compose() result
CI / lint (pull_request) Successful in 41s
CI / build (pull_request) Successful in 51s
CI / quality (pull_request) Successful in 55s
CI / helm (pull_request) Successful in 48s
CI / typecheck (pull_request) Successful in 1m15s
CI / security (pull_request) Successful in 1m19s
CI / push-validation (pull_request) Successful in 26s
CI / unit_tests (pull_request) Successful in 6m7s
CI / docker (pull_request) Successful in 1m45s
CI / integration_tests (pull_request) Successful in 11m3s
CI / coverage (pull_request) Successful in 11m59s
CI / status-check (pull_request) Successful in 4s

The diff-mode cycle in PermissionsScreen referenced DiffDisplayMode.SIDE_BY_SIDE
and DiffDisplayMode.CONTEXT, but the enum only defines UNIFIED / SPLIT / AUTO.
Pyright flagged both as reportAttributeAccessIssue and behave failed to import
the screen module, masking the entire scenario suite under a single
traceback-outside-scenario error.

Also addresses the prior re-review feedback on the same PR:
- compose() return type was Any; tighten to collections.abc.Iterator[Any] so the
  generator shape is exposed to type checkers without taking a hard textual
  dependency at typecheck time (Iterator[Any] is the structural type of a
  Textual ComposeResult; we stay importable when textual is absent).
- The Bug #10488 TDD scenario asserting action methods now also covers
  action_dismiss_screen so a future refactor cannot silently drop the escape
  binding without test failure.

Verified locally on this worktree:
- typecheck gate: 0 errors, 4 unrelated warnings.
- unit_tests gate on features/tui_permissions_screen.feature: 65/65 scenarios
  pass.
- lint gate: clean.

ISSUES CLOSED: #10488
This commit is contained in:
2026-06-06 11:13:48 -04:00
committed by Forgejo
parent f2b23e397f
commit f86553670b
2 changed files with 12 additions and 4 deletions
+1
View File
@@ -396,3 +396,4 @@ Feature: TUI PermissionsScreen
And PermissionsScreen should have action method "action_nav_next"
And PermissionsScreen should have action method "action_nav_prev"
And PermissionsScreen should have action method "action_cycle_diff"
And PermissionsScreen should have action method "action_dismiss_screen"
+11 -4
View File
@@ -10,6 +10,7 @@ from __future__ import annotations
import contextlib
import importlib
from collections.abc import Iterator
from typing import Any, ClassVar
from cleveragents.tui.permissions.models import (
@@ -45,8 +46,8 @@ _ScreenBase = _load_screen_base()
_DIFF_MODE_CYCLE: list[DiffDisplayMode] = [
DiffDisplayMode.UNIFIED,
DiffDisplayMode.SIDE_BY_SIDE,
DiffDisplayMode.CONTEXT,
DiffDisplayMode.SPLIT,
DiffDisplayMode.AUTO,
]
@@ -167,8 +168,14 @@ class PermissionsScreen(_ScreenBase):
"""
self._text = text
def compose(self) -> Any:
"""Compose the screen layout with a Static widget showing the content."""
def compose(self) -> Iterator[Any]:
"""Compose the screen layout with a Static widget showing the content.
Returns a generator over Textual ``Widget`` instances (the
``ComposeResult`` type), but typed as ``Iterator[Any]`` here so
the module stays importable in environments where ``textual`` is
not installed (typecheck gate, pure-domain tests).
"""
with contextlib.suppress(Exception): # pragma: no cover
Static = importlib.import_module("textual.widgets").Static
yield Static(self._text, id="permissions-content")