Skip to content

fix(tui): complete PR #3051 — Esc must not exit plan mode; Ctrl+C keeps draft#3670

Merged
esengine merged 3 commits into
esengine:main-v2from
CnsMaple:fix/esc-ctrlc-yolo
Jun 9, 2026
Merged

fix(tui): complete PR #3051 — Esc must not exit plan mode; Ctrl+C keeps draft#3670
esengine merged 3 commits into
esengine:main-v2from
CnsMaple:fix/esc-ctrlc-yolo

Conversation

@CnsMaple

@CnsMaple CnsMaple commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

🤖 Generated by AI (CnsMaple + Reasonix)

Follow-up to #3051

PR #3051 (merged) removed the Esc-from-YOLO branch but left the
Esc-from-plan-mode branch in place. In practice that means once the user
entered plan mode (/plan, Shift+Tab), a single Esc would silently flip
them back to the less-permissive "normal" mode — exactly the surprise that
#3051 set out to eliminate for YOLO. Mode toggles are now exclusively
driven by Shift+Tab, matching how YOLO is treated.

While in the file, the idle Ctrl+C branch was also reordered: an active
text selection now takes precedence over the composer-clear / double-press
quit gestures, so Ctrl+C stops silently wiping a half-typed draft just
because the user happened to have a selection.

Changes

  • internal/cli/chat_tui.go (+26/-20): drop the m.planMode arm from the
    Esc handler; comment updated to spell out the Shift+Tab-only mode rule.
  • internal/cli/chat_tui_test.go (+59): regression coverage for Esc in
    plan mode and Ctrl+C-with-active-selection.

Tests

  • go test ./internal/cli/ -count=1 -run 'TestEsc|TestCtrl|TestPlan'
    → all pass.
  • Rebased onto esengine:main-v2 @ 90c24655.

Out of scope

…rl+C keeps draft

PR esengine#3051 split Shift+Tab (mode cycle) from Esc (cancel) by removing the
case m.bypass branch in the Esc handler, but missed the adjacent
case m.planMode branch sitting right next to it. Result: plan mode was
still escapable by hitting Esc, and the second unwanted behaviour fell
in the Ctrl+C branch: when both an active text selection and a
non-empty composer existed, Ctrl+C used to wipe the draft text while
also dropping the selection.

Two changes in internal/cli/chat_tui.go:

  1. Esc handler: drop the case m.planMode := false branch entirely.
     The mode-cycle switch (Shift+Tab) is now the single, documented
     way to toggle plan / YOLO. PR esengine#3051 already did the YOLO side;
     this commit finishes the plan side. The comment block above the
     switch is updated to match.

  2. Ctrl+C handler: hoist the selection-copy branch above the
     clear-input branch. Standard terminal convention: Ctrl+C copies
     the active selection. If we processed clear-input first we'd
     silently destroy the user's draft. After the copy a second
     Ctrl+C will still clear the composer; on an empty composer the
     double-press-quit gesture continues to work.

Tests (internal/cli/chat_tui_test.go):
  - TestEscInPlanModeDoesNotExitPlan: regression for the PR esengine#3051
    miss. The YOLO equivalent was already removed in esengine#3051 and is
    covered by control/yolo_test.go at the controller layer; not
    duplicated here.
  - TestCtrlCCopyBeatsClearInput: regression for the priority swap.
    Composer draft survives the copy; a follow-up Ctrl+C clears it.
  - Pre-existing TestCtrlCCopySelection and TestCtrlCClearsThen...
    continue to pass.
@github-actions github-actions Bot added v2 Go rewrite (1.x) — main-v2 branch, active development tui Terminal UI / CLI (internal/cli, internal/control) labels Jun 9, 2026
@CnsMaple

CnsMaple commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

Re-running CI via empty commit (gh run rerun requires admin rights).

@esengine esengine left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified end-to-end. Reverting each hunk to base behavior fails the two new tests: Esc flips plan mode off (TestEscInPlanModeDoesNotExitPlan) and Ctrl+C wipes a draft when a selection exists (TestCtrlCCopyBeatsClearInput). With the fix both pass and the full cli package is green. This correctly completes the plan-mode half that #3051 missed and makes selection-copy take precedence over clear-input. The earlier Windows CI red was the unrelated TestRunShell_CancelStopsCommand timing flake, green on re-run after updating the base. Thanks.

@esengine esengine merged commit dfd7ff0 into esengine:main-v2 Jun 9, 2026
20 of 21 checks passed
@CnsMaple CnsMaple deleted the fix/esc-ctrlc-yolo branch June 10, 2026 02:10
SuMuxi66 pushed a commit to SuMuxi66/DeepSeek-Reasonix that referenced this pull request Jun 10, 2026
Complete esengine#3051: drop the plan-mode arm from the Esc handler so mode switches are exclusively Shift+Tab driven (Esc must not silently drop to a less-permissive mode). Also hoist Ctrl+C selection-copy above clear-input so copying a selection no longer wipes a half-typed draft.
dorokuma pushed a commit to dorokuma/DeepSeek-Reasonix that referenced this pull request Jun 10, 2026
Complete esengine#3051: drop the plan-mode arm from the Esc handler so mode switches are exclusively Shift+Tab driven (Esc must not silently drop to a less-permissive mode). Also hoist Ctrl+C selection-copy above clear-input so copying a selection no longer wipes a half-typed draft.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tui Terminal UI / CLI (internal/cli, internal/control) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants