Improve editing past user messages#1850
Merged
dgageot merged 3 commits intodocker:mainfrom Feb 26, 2026
Merged
Conversation
Member
dgageot
commented
Feb 25, 2026
- Better multi-line editing
- Support pasting
Route tea.PasteMsg to the messages component when a past user message is being edited inline, instead of always forwarding it to the main editor. - Add IsInlineEditing() to chat.Page interface and chatPage - Handle tea.PasteMsg in messages component to insert into inline textarea - Update mock in tui_exit_test.go to satisfy the new interface Assisted-By: cagent
The textarea's internal viewport was scrolling due to an incorrect height calculation that used simple character division instead of matching the textarea's word-aware wrapping. This caused ctrl-e, ctrl-a, ctrl-w to operate on wrong lines, and typing to go to unexpected positions. Fix by setting the textarea height to a generous value (the messages panel height) so the internal viewport never scrolls, then trimming end-of-buffer padding lines from the rendered output. This eliminates the height calculation entirely, along with the fragile cursor save/restore workaround. Assisted-By: cagent
When the textarea content was empty, trimEndOfBufferLines stripped all lines (including the cursor line) since they all appear as whitespace after ANSI stripping. The fallback returned the full untrimmed view, causing the edit box to fill the entire panel. Fix by stopping the trim loop at 1 instead of 0, so the cursor line is always preserved. Assisted-By: cagent
There was a problem hiding this comment.
Review Summary
This PR improves inline editing of past user messages by adding paste support and fixing multi-line editing issues. The changes refactor the height calculation approach to use a generous fixed height with post-render trimming, which is a cleaner solution than the previous dynamic height adjustments.
Key changes reviewed:
- ✅ Added
PasteMsghandler for inserting pasted content - ✅ Removed complex
updateInlineEditTextareaHeight()function - ✅ Introduced
trimEndOfBufferLines()to handle rendering of fixed-height textarea - ✅ Updated height calculation to use screen height with proper trimming
- ✅ Added
IsInlineEditing()method and proper paste message routing
No functional issues found. The architectural change from dynamic height calculation to fixed-height-with-trimming is sound and should resolve the cursor positioning bugs mentioned in the comments.
rumpl
approved these changes
Feb 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.