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
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
- 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
- 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