fix: detect $ prefix as shell mode trigger in InputModeRouter #10752

Merged
HAL9000 merged 2 commits from fix/10412-dollar-prefix-shell-mode into master 2026-04-24 03:17:34 +00:00
3 changed files with 31 additions and 1 deletions
+10
View File
@@ -143,3 +143,13 @@ def step_run_fallback_tui_app(context: Context) -> None:
def step_fallback_tui_fails(context: Context, message: str) -> None:
assert context.tui_fallback_error is not None
assert message in str(context.tui_fallback_error)
@when('I detect mode for "{text}"')
def step_detect_mode(context: Context, text: str) -> None:
context.detected_mode = InputModeRouter.detect_mode(text)
@then('the detected mode should be "{mode}"')
def step_detected_mode_equals(context: Context, mode: str) -> None:
assert context.detected_mode.value == mode
+20
View File
@@ -37,3 +37,23 @@ Feature: TUI input modes
Then TUI textual availability should be boolean
When I run fallback TUI app
Then fallback TUI app should fail with "Textual dependency missing."
Scenario: Dollar prefix activates shell mode
When I route TUI input "$echo hello"
Then the TUI mode should be "shell"
And the TUI shell stdout should contain "hello"
Scenario: Dollar prefix detect_mode returns shell
When I detect mode for "$echo hello"
Then the detected mode should be "shell"
Scenario: Dollar prefix with leading whitespace activates shell mode
When I detect mode for " $echo hello"
Then the detected mode should be "shell"
Scenario: Dollar prefix blocks dangerous command by default
When I route TUI input "$rm -rf /"
Then the TUI mode should be "shell"
And the TUI shell stderr should contain "blocked dangerous shell command"
+1 -1
View File
@@ -51,7 +51,7 @@ class InputModeRouter:
stripped = text.lstrip()
if stripped.startswith("/"):
return InputMode.COMMAND
if stripped.startswith("!"):
if stripped.startswith(("!", "$")):
return InputMode.SHELL
return InputMode.NORMAL