fix(tui): integrate ShellSafetyService properly in TUI app #6576

Merged
HAL9000 merged 10 commits from feat/issue-6361-shell-safety-service-tui into master 2026-06-17 04:36:59 +00:00

10 Commits

Author SHA1 Message Date
HAL9000 6b2a97ecda refactor(tui-tests): extract mock-Textual infrastructure to _tui_mock_helpers.py
CI / load-versions (pull_request) Successful in 14s
CI / push-validation (pull_request) Successful in 24s
CI / lint (pull_request) Successful in 45s
CI / quality (pull_request) Successful in 58s
CI / security (pull_request) Successful in 1m4s
CI / typecheck (pull_request) Successful in 1m12s
CI / build (pull_request) Successful in 40s
CI / helm (pull_request) Successful in 38s
CI / unit_tests (pull_request) Successful in 4m51s
CI / docker (pull_request) Successful in 1m29s
CI / integration_tests (pull_request) Successful in 10m12s
CI / coverage (pull_request) Successful in 9m40s
CI / status-check (pull_request) Successful in 3s
Move _MOCK_TEXTUAL_KEYS, _build_mock_textual, _install_mock_textual,
_restore_modules, _make_persona_state, _cleanup_tmpdir, and
_FakeCommandRouter out of tui_app_coverage_steps.py into a shared
_tui_mock_helpers.py module so both step files can import them without
duplication and the coverage steps file stays within the 500-line budget.

ISSUES CLOSED: #6361
2026-06-17 00:21:34 -04:00
drew c78862fe8b test(tui): cover shell safety confirmation callbacks
ISSUES CLOSED: #6361
2026-06-17 00:21:34 -04:00
drew b83b84ca79 fix(test): restore SimpleNamespace import in tui_app_coverage_steps (rebase fixup)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 00:21:34 -04:00
controller-ci-rerun 64147c8d1f chore: re-trigger CI [controller] 2026-06-17 00:21:34 -04:00
controller-ci-rerun 5e6bad359d chore: re-trigger CI [controller] 2026-06-17 00:21:34 -04:00
controller-ci-rerun 4900d757f7 chore: re-trigger CI [controller] 2026-06-17 00:21:34 -04:00
HAL9000 b56c824909 fix(tui): repair shell-safety test scaffolding
Three independent test-scaffold defects blocked the unit_tests and
integration_tests gates on PR #6361's shell-safety wiring:

- features/steps/_tui_helpers.py: the mocked-shell helper patched
  cleveragents.tui.input.shell_exec.run_shell_command, but modes.py
  binds the symbol into its own namespace via `from ... import`. The
  patch was inert, and only the CLEVERAGENTS_ALLOW_DANGEROUS_SHELL=1
  gate kept the real `rm -rf /tmp` from running in the behave runner.
  Patch the use site (modes.run_shell_command) instead.

- src/cleveragents/tui/widgets/prompt.py: _FallbackPromptInput (used
  whenever Textual is mocked or unavailable) had no add_class /
  remove_class / has_class, so the new "prompt should be marked as
  dangerous" assertions raised AttributeError and the three new
  scenarios errored. The production path (_TextualPromptInput) already
  inherits these from textual.containers.Horizontal; the fallback now
  mirrors that contract via a small self._classes set.

- robot/tui_shell_safety.robot: Catenate's space-based argument
  separator collapses multi-space indentation, so the Python function
  bodies (warn_callback, deny) landed at column 0 and the helper
  scripts died with IndentationError before either assertion ran.
  Preserve the 4-space indent with ${SPACE * 4} markers.

ISSUES CLOSED: #6361
2026-06-17 00:21:34 -04:00
HAL9000 9c6e6ce55f fix(tui): remove dead state fields and DRY up step helpers
- Remove `_shell_warning_active` and `_last_shell_warning` from
  CleverAgentsTuiApp.__init__, _show_shell_warning, and
  _clear_shell_warning — both fields were set but never consumed
- Extract shared `_submit_text` and `_submit_text_with_mocked_shell`
  into features/steps/_tui_helpers.py; update tui_app_coverage_steps
  and tui_shell_safety_steps to import from shared module, eliminating
  the duplicate definitions flagged across multiple review cycles
2026-06-17 00:21:34 -04:00
HAL9000 8e8f2d5f89 fix(tui): enforce shell safety gating
- honour ShellSafetyService verdicts before executing shell commands
- tighten TUI confirmation defaults and align warning messaging with spec
- split shell-safety Behave steps and add Robot coverage

ISSUES CLOSED: #6361
2026-06-17 00:21:34 -04:00
HAL9000 6fe9b86b60 fix(tui): integrate ShellSafetyService properly in TUI app (#6361)
- route shell submissions through ShellSafetyService and surface warnings in the UI
- add shell warning banner, prompt styling, and configurable shell.warn_dangerous flag
- extend TUI coverage scenarios for shell safety and document the fix

ISSUES CLOSED: #6361
2026-06-17 00:21:34 -04:00