fix(cli): refocus previous input on esc in manual provider form - #630
Merged
lizhengfeng101 merged 1 commit intoAug 1, 2026
Merged
Conversation
Contributor
|
✅ OpenCodeReview: No comments generated. Looks good to me. |
Contributor
|
Thanks for the PR! I've gone through the changes and they look good to me. |
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.
Description
In
ocr config provider, the Manual tab form loses input focus when the user presses Esc to go back to a previous field. For example: fill in the URL, press Enter to reach the Protocol step, then press Esc to go back and edit the URL — the URL field is rendered as active, but it has no cursor and ignores all typing. The same back-navigation works correctly in the Custom provider form.Root cause:
focusManualStepis declared with a value receiver, whiletextinput.Model.Focus()uses a pointer receiver. In the Esc branch ofupdateManualForm(return m, m.focusManualStep()), the method receives a copy of the model, soFocus()marks the input as focused only on that discarded copy — the model actually returned fromUpdatestill holds a blurred input, and bubbles'textinputignores key messages while blurred.The fix changes
focusManualStepto a pointer receiver, matching its Custom-form counterpartfocusCPStep(which is why the Custom form was unaffected). All back-navigation paths with a text input are covered: Protocol→URL, Auth Token→Model, Auth Header→Auth Token. (Model→Protocol was unaffected: the protocol step has no text input.)Type of Change
How Has This Been Tested?
make testpasses locallyManual testing (describe below)
Added
TestProviderTUI_ManualFormEscRefocusesPreviousInput, a table-driven regression test covering the three back-navigation paths that land on a text input. Each case asserts the previous step's input is focused after Esc and accepts subsequent typing. Verified the test fails on the unfixed code (all three cases) and passes with the fix.Full suite:
make checkandmake test(with-race) pass locally.Manual testing with a locally built binary (
ocr config provider, isolated$HOMEsandbox): Manual tab → fill URL → Enter → Esc — the URL field regains the cursor and is editable again; same verified for the Auth Token and Auth Header back-navigation paths. Reproduced the broken behavior with an unfixed main binary as an A/B control.Checklist
go fmt,go vet)Related Issues
Closes #628