Skip to content

Improve editing past user messages#1850

Merged
dgageot merged 3 commits intodocker:mainfrom
dgageot:paste-past-pasta
Feb 26, 2026
Merged

Improve editing past user messages#1850
dgageot merged 3 commits intodocker:mainfrom
dgageot:paste-past-pasta

Conversation

@dgageot
Copy link
Member

@dgageot 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
@dgageot dgageot requested a review from a team as a code owner February 25, 2026 17:08
Copy link

@docker-agent docker-agent bot left a comment

Choose a reason for hiding this comment

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

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 PasteMsg handler 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.

@dgageot dgageot merged commit 9817e64 into docker:main Feb 26, 2026
8 checks passed
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.

2 participants