Skip to content

fix(cli): refocus previous input on esc in manual provider form - #630

Merged
lizhengfeng101 merged 1 commit into
alibaba:mainfrom
hanhaiqingchuan:fix/manual-form-esc-focus
Aug 1, 2026
Merged

fix(cli): refocus previous input on esc in manual provider form#630
lizhengfeng101 merged 1 commit into
alibaba:mainfrom
hanhaiqingchuan:fix/manual-form-esc-focus

Conversation

@hanhaiqingchuan

Copy link
Copy Markdown
Contributor

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: focusManualStep is declared with a value receiver, while textinput.Model.Focus() uses a pointer receiver. In the Esc branch of updateManualForm (return m, m.focusManualStep()), the method receives a copy of the model, so Focus() marks the input as focused only on that discarded copy — the model actually returned from Update still holds a blurred input, and bubbles' textinput ignores key messages while blurred.

The fix changes focusManualStep to a pointer receiver, matching its Custom-form counterpart focusCPStep (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

  • Bug fix (non-breaking change that fixes an issue)

How Has This Been Tested?

  • make test passes locally

  • Manual 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 check and make test (with -race) pass locally.

  • Manual testing with a locally built binary (ocr config provider, isolated $HOME sandbox): 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

  • My code follows the project's coding style (go fmt, go vet)
  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or my feature works
  • New and existing unit tests pass locally with my changes
  • I have updated the documentation accordingly (if applicable) — not applicable, no user-facing docs describe this interaction
  • I have signed the CLA

Related Issues

Closes #628

@github-actions

Copy link
Copy Markdown
Contributor

OpenCodeReview: No comments generated. Looks good to me.

@5wxwxwxw5

Copy link
Copy Markdown
Contributor

Thanks for the PR! I've gone through the changes and they look good to me.

@lizhengfeng101 lizhengfeng101 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@lizhengfeng101
lizhengfeng101 merged commit dfc9340 into alibaba:main Aug 1, 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.

config provider TUI: Manual mode — ESC to go back to previous field makes it uneditable (cursor disappears)

3 participants