Skip to content

fix(tui): restore cleared composer with Ctrl+Z#1911

Closed
LING71671 wants to merge 1 commit into
Hmbown:mainfrom
LING71671:fix/composer-ctrl-z-restore
Closed

fix(tui): restore cleared composer with Ctrl+Z#1911
LING71671 wants to merge 1 commit into
Hmbown:mainfrom
LING71671:fix/composer-ctrl-z-restore

Conversation

@LING71671

Copy link
Copy Markdown
Contributor

Summary

  • Add a single-slot undo buffer for recoverable composer clears
  • Restore the last cleared composer draft with Ctrl+Z when the composer is empty
  • Keep existing drafts untouched and avoid overwriting the undo buffer on empty clears

Closes #1771

Validation

  • cargo fmt --all
  • cargo test -p deepseek-tui --bin deepseek-tui restore_last_cleared_input
  • cargo test -p deepseek-tui --bin deepseek-tui recoverable_clear_stashes_nonempty_draft
  • cargo test -p deepseek-tui --bin deepseek-tui empty_recoverable_clear_does_not_overwrite_undo_buffer
  • git diff --check
  • cargo build

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a mechanism to undo the clearing of the composer text in the TUI. It adds a clear_undo_buffer to the ComposerState and maps Ctrl-z to restore the last cleared non-empty input if the current composer is empty. Feedback suggests refining the empty-check logic to use trim().is_empty() to prevent whitespace-only strings from overwriting or being restored from the undo buffer.

Comment thread crates/tui/src/tui/app.rs Outdated
Comment thread crates/tui/src/tui/app.rs Outdated
@LING71671 LING71671 force-pushed the fix/composer-ctrl-z-restore branch from 168fa9a to 03cbb8d Compare May 21, 2026 15:25
@LING71671

Copy link
Copy Markdown
Contributor Author

Thanks for the review. The whitespace-only cases are covered in this branch now: recoverable clears only stash drafts when \ rim().is_empty()\ is false, restores filter out whitespace-only drafts, and \whitespace_recoverable_clear_does_not_overwrite_undo_buffer\ covers the regression. I re-ran the focused composer undo tests locally and they pass.

@Hmbown Hmbown mentioned this pull request May 24, 2026
reidliu41 pushed a commit to reidliu41/CodeWhale that referenced this pull request May 24, 2026
- grep_files now respects cancellation token (Hmbown#1839, thanks @LING71671)
- Ctrl+Z restores last cleared composer draft (Hmbown#1911, thanks @LING71671)
- Clipboard works on non-wlroots Wayland via wl-copy (Hmbown#1938, thanks @ousamabenyounes)
aboimpinto pushed a commit to aboimpinto/CodeWhale that referenced this pull request May 24, 2026
…c, receipt truncation fix

- SWE-bench: codewhale swebench run/export writes prediction JSONL
  from working-tree diff, with untracked-file inclusion via git add -N
- CLI: --workspace / -C global flag forwards to TUI for file ops
- CLI: codewhale exec --auto semantics clarified in help text
- Markdown: table pipes inside inline code no longer create phantom columns
  (split_table_cells with backtick-awareness)
- Receipt: floor_char_boundary prevents multibyte UTF-8 slice panic
- Contributors: Ling (LING71671 Hmbown#1839 Hmbown#1911), Ben Younes (ousamabenyounes Hmbown#1938),
  jeoor npm fix (Hmbown#1860) credited across all 3 READMEs
- ja-JP README: 19 contributors synced to parity with EN/zh-CN (80 each)
- Docs: SWEBENCH.md, RECURSIVE_SELF_IMPROVEMENT.md, MODES.md exec clarification
- Sub-agent footer: Alt+V hint now says 'details' not 'raw'
@Hmbown

Hmbown commented May 24, 2026

Copy link
Copy Markdown
Owner

Thanks @LING71671 — this landed in #1988 and is on main via commit 8878ac0. The shipped change adds the clear undo buffer, Ctrl+Z restore path, and the focused composer regression tests around recoverable clears.\n\nI am closing this PR now that the code is on main. The release notes and README Thanks list both credit you for #1911. Apologies that the harvest commit missed the exact 'Harvested from PR #1911 by @LING71671' trailer, which is why the auto-close workflow did not close this at merge time.

@Hmbown Hmbown closed this May 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ctrl+Z to restore accidentally deleted composer text

2 participants