Skip to content

feat: ! prefix for direct shell execution#2993

Open
lanshi17 wants to merge 14 commits into
esengine:main-v2from
lanshi17:feat/bang-shell-execution
Open

feat: ! prefix for direct shell execution#2993
lanshi17 wants to merge 14 commits into
esengine:main-v2from
lanshi17:feat/bang-shell-execution

Conversation

@lanshi17
Copy link
Copy Markdown
Contributor

@lanshi17 lanshi17 commented Jun 4, 2026

Summary

  • Add RunShell() to Controller — executes shell commands directly (bypassing the AI model) and streams output as ToolDispatch/ToolProgress/ToolResult events
  • Intercept ! prefix in all three frontends: TUI Enter handler, desktop handleSend, and Controller Submit (HTTP/SSE)
  • Platform-specific process-tree kill on timeout (unix: Setpgid + SIGKILL group; Windows: taskkill /T)
  • i18n support (EN + ZH) for error messages

Test Plan

  • go test ./internal/control/ — 18 tests pass (5 new shell tests)
  • go test ./internal/i18n/ — catalog drift-guard passes
  • go build ./cmd/reasonix/ — binary builds
  • TypeScript type-check passes (no new errors)
  • Manual: !echo hello in TUI shows tool card with output
  • Manual: !ls -la lists project directory
  • Manual: bare ! shows usage notice
  • Manual: Esc cancels running shell command

@github-actions github-actions Bot added the v2 Go rewrite (1.x) — main-v2 branch, active development label Jun 4, 2026
@lanshi17 lanshi17 marked this pull request as draft June 4, 2026 02:54
@lanshi17 lanshi17 marked this pull request as ready for review June 4, 2026 03:03
@lanshi17 lanshi17 closed this Jun 4, 2026
@lanshi17 lanshi17 reopened this Jun 4, 2026
@lanshi17 lanshi17 force-pushed the feat/bang-shell-execution branch from 3f11952 to d9bdcae Compare June 4, 2026 03:09
lanshi17 added 13 commits June 4, 2026 13:57
Commands now run in the project directory (c.cpRoot), not wherever the
process started. Matches the bash tool's behavior where cmd.Dir is set
to the workspace directory.
TUI:
- Shell commands show first 10 lines after collapse instead of 'N lines'
- Ctrl+B toggles between preview and full output for the most recent shell command
- Input box border turns green and status shows 'Shell' mode tag when typing !

Desktop:
- Shell tool cards auto-expand showing first 10 lines of output
- 'show all N lines' button to reveal full output
- Cmd+B / Ctrl+B toggles the most recent shell card
- Composer caret changes to $ and border turns green in shell mode
- ShellExpandProvider context coordinates global toggle hotkey
- toggleShellOutput now caps expanded output at shellExpandMaxLines (200)
  to prevent huge transcript entries from hanging the TUI or pushing the
  input box off-screen.
- Added shellExpandMaxLines constant alongside shellPreviewLines.
- Ensured innerW fallback when width is very small.
- Mouse left-click on the '… N more lines (click/Ctrl+B)' hint line
  toggles shell output expand/collapse
- Hint text updated to mention click alongside Ctrl+B
- ShellModeHint updated: 'click output to expand' / '点击输出展开'
- Avoids tmux Ctrl+B conflict — mouse click works everywhere
Upstream changed App.ctrl to activeCtrl() for multi-tab support.
- TUI: check empty command before entering tuiRunning state, show usage
  notice directly instead of calling RunShell which would return without
  emitting TurnDone, leaving the TUI stuck in 'thinking' state.
- Desktop: show notice directly for bare !, skip empty RunShell round-trip.
When Esc cancels a running shell command, the cancel may complete
synchronously (the process is killed and runGuarded finishes before
the TUI re-enters the event loop). In that case, ctrl.Running() is
already false and the TUI can transition to idle immediately instead
of waiting for a TurnDone event that may have already been consumed.
@lanshi17 lanshi17 force-pushed the feat/bang-shell-execution branch from e3372e8 to 28782dc Compare June 4, 2026 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant