fix(tui): refocus the editor after external editing so Enter sends the content#3690
Merged
Merged
Conversation
…e content
Ctrl+g opened the external editor from any focused panel, but after
exit focus stayed on the content panel — Enter did nothing. The
externalEditorCallback (extracted for testability) now returns
messages.RequestFocusMsg{Target: PanelEditor} so the input editor
regains focus.
Assisted-By: docker-agent
Assisted-By: Docker AI
docker-agent
left a comment
Contributor
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
The fix is clean and correct. The extracted externalEditorCallback function properly returns messages.RequestFocusMsg{Target: messages.PanelEditor} on success, ensuring the input editor regains focus after external editing. Temp-file cleanup is present in all code paths. The new regression tests cover the four main cases (happy path, blank content, editor exit error, read failure) and are structurally sound.
No medium or high severity issues found in the changed code.
Sayt-0
approved these changes
Jul 16, 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.
When
Ctrl+Gopens the external editor, the edited content is written back into the input box once the editor exits. The bug was that focus was not restored to the input panel at that point — so if the user had tabbed away or clicked the transcript while watching a running turn, pressing Enter would route to the transcript rather than the input box, silently discarding the composed message. The same problem prevented the message from being queued when the agent was busy andbusy_send_mode: queuewas configured.The fix extracts the
tea.ExecProcesscallback into a package-levelexternalEditorCallbackfunction inpkg/tui/tui.go. On a successful edit it now returns amessages.RequestFocusMsg{Target: messages.PanelEditor}alongside the content update, so the input editor always regains focus after an external edit. Error paths (editor exit error, temp-file read failure) are unchanged and continue to surface a notification without touching the input content.Regression tests in
pkg/tui/external_editor_test.gocover the happy path (content written back with trailing newline trimmed, refocus message returned), blank content clearing the editor, editor-exit errors surfacing a notification, temp-file cleanup on both success and error, and the temp-file read-failure path.