Skip to content

fix(tui): refocus the editor after external editing so Enter sends the content#3690

Merged
Sayt-0 merged 2 commits into
docker:mainfrom
dgageot:fix/external-editor-refocus
Jul 16, 2026
Merged

fix(tui): refocus the editor after external editing so Enter sends the content#3690
Sayt-0 merged 2 commits into
docker:mainfrom
dgageot:fix/external-editor-refocus

Conversation

@dgageot

@dgageot dgageot commented Jul 16, 2026

Copy link
Copy Markdown
Member

When Ctrl+G opens 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 and busy_send_mode: queue was configured.

The fix extracts the tea.ExecProcess callback into a package-level externalEditorCallback function in pkg/tui/tui.go. On a successful edit it now returns a messages.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.go cover 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.

dgageot added 2 commits July 16, 2026 17:18
…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
@dgageot
dgageot requested a review from a team as a code owner July 16, 2026 15:47

@docker-agent docker-agent 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.

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
Sayt-0 merged commit bbe2d96 into docker:main Jul 16, 2026
10 of 11 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.

3 participants