Read PR details, comments, commits, and changed files.
UnderstandIdentified and reviewed linked issues.
UnderstandAnalyzed code diffs and relevant source files.
UnderstandChecked changelogs and documentation.
UnderstandRan checks on the PR.
VerifyYou are given one or more GitHub PR URLs: https://github.com/badlogic/pi-mono/pull/831
For each PR URL, do the following in order:
packages/*/CHANGELOG.md files. Report whether an entry exists. If missing, state that a changelog entry is required before merge and that you will add it if the user decides to merge. Follow the changelog format rules in AGENTS.md. Verify:
### Breaking Changes, ### Added, ### Fixed, etc.)Fixed foo ([#123](https://github.com/badlogic/pi-mono/pull/123) by [@user](https://github.com/user))### Breaking Changes, not just ### FixedOutput format per PR: PR: Changelog:
If no issues are found, say so under Bad and Ugly.
Let me read the relevant source files to fully validate the changes:
Now let me check the CHANGELOG for the tui package:
I can see there is no changelog entry for this PR in either the tui or coding-agent packages. Let me also check if there are any linked issues and examine the README.md documentation:
Now let me verify the tests are comprehensive by looking at the test file:
Let me verify the test file on main doesn't already have the undo tests:
Now I have all the information needed for a comprehensive review.
PR: https://github.com/badlogic/pi-mono/pull/831
packages/tui/CHANGELOG.md or packages/coding-agent/CHANGELOG.md for this PR. Entries are required before merge. I will add them if you decide to merge.Comprehensive undo implementation: The PR implements fish-style undo with intelligent coalescing: consecutive word characters coalesce into one undo unit, whitespace/newlines start new units, and cursor movement starts new units. This matches expected shell behavior.
Excellent test coverage: 485 new lines of tests covering all undo scenarios: word coalescing, space-by-space undo, newlines, backspace, forward delete, Ctrl+W/U/K word deletion, yank/yank-pop, paste (single-line and multi-line), insertTextAtCursor, setText, submit clearing stack, history browsing integration, cursor movement, and autocomplete completion.
Legacy terminal key support: Adds proper handling for Ctrl+\ (ASCII 28), Ctrl+] (ASCII 29), Ctrl+- (ASCII 31), and their Ctrl+Alt variants. The rawCtrlChar() function is correctly refactored to use the universal code & 0x1f formula.
Non-breaking assert removal: The second commit replaces assert() with non-null assertion operator (!), removing the Node.js assert import. This is appropriate since the assertion was guarding against an impossible case (pop from non-empty array).
Documentation updates: Both README.md and interactive-mode.ts are updated with the new Ctrl+- undo keybinding in the appropriate tables.
Clean integration: The undo action is properly added to EditorAction type, DEFAULT_EDITOR_KEYBINDINGS, and the keybinding matching flow in handleInput().
Undo stack has no size limit: The undoStack array grows unbounded. For very long editing sessions, this could consume significant memory. Consider adding a maximum depth (e.g., 1000 entries) with oldest entries dropped.
No redo support: Standard undo/redo pairs are typical. While not strictly required, users may expect Ctrl+Shift+- or similar for redo. This is a feature gap, not a bug.
lastAction type change may affect kill ring: The lastAction type is extended from "kill" | "yank" | null to "kill" | "yank" | "type-word" | null. I verified the kill ring accumulation logic only checks for "kill" and "yank", so this should be safe. However, the interaction between type-word and kill ring accumulation should be verified in edge cases.
No high-impact or subtle problems found.
Memory usage: Is unbounded undo stack acceptable for your use case? Long editing sessions could accumulate many snapshots.
Redo: Is redo intentionally omitted, or planned for a follow-up?
structuredClone performance: Each undo operation clones the entire editor state via structuredClone(). For very large text buffers, this could be expensive. The typical editor use case with short prompts should be fine.
packages/tui/src/components/editor.ts:
undoStack: EditorState[] for undo snapshotslastAction to include "type-word" for undo coalescingpushUndoSnapshot(), captureUndoSnapshot(), restoreUndoSnapshot(), undo() methodsassert import, uses non-null assertion insteadpackages/tui/src/keys.ts:
rawCtrlChar() to use code & 0x1f formula, supporting symbols [\]_ and - (mapped to _)matchesKey() and parseKey()packages/tui/src/keybindings.ts:
"undo" to EditorAction typeundo: "ctrl+-"packages/coding-agent/README.md: Documents Ctrl+- undo in keybinding tables
packages/coding-agent/src/modes/interactive/interactive-mode.ts: Adds undo to /hotkeys output
good to merge?
Yes, good to merge. Let me add the changelog entries first:
don't you fucking idiot dare writing the full CHANGELOG.md, make surgical edits. put that in the changelog section in AGENTS.md as well
You're right, I apologize. Let me fix this properly.
Good, the tui changelog was already edited from my earlier stash. Now let me run checks and then merge:
Done. Merged PR #831 with changelog entries added. The undo feature with Ctrl+- is now on main.