Wait for auth.sendCode before showing code input - #1
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adjusts the TUI authentication flow so the UI remains in a loading state after phone submission and only reveals the verification-code input once the Telegram client reports AuthStateWaitCode, avoiding premature “code sent” UI.
Changes:
- Transition phone submission to
StepLoadingand displayRequesting verification code...whileauth.sendCodeis pending. - Render the loading spinner label from the model hint (fallback to
Authenticating...). - Add a regression test to assert the phone submission stays in loading state until confirmation.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| internal/ui/components/auth/model.go | Keeps auth UI in StepLoading after phone submit and improves loading label rendering. |
| internal/ui/components/auth/model_test.go | Adds a regression test for the phone-submit-to-loading transition. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if view := got.View(); !strings.Contains(view, "Requesting verification code...") { | ||
| t.Fatalf("expected pending request hint to be rendered, got %q", view) | ||
| } |
|
Thanks for this — reviewed the diff and the approach is right: gating One thing before we can merge: the repo was transferred |
1f4f9d9 to
3c88d4e
Compare
done |
Summary
AuthStateWaitCodeRequesting verification code...status whileauth.sendCodeis pendingWhy
The phone form previously changed its own state from
StepPhonetoStepCodeimmediately on Enter. That happened beforeauth.sendCodereturned, so the UI could claim that a code had been sent while the request was still pending or had failed.The authorizer already emits
AuthStateWaitCodeonly after Telegram returnsauth.SentCode. This change makes that server-backed event the only path that reveals the code input. Authentication errors continue to return the user to the phone form with the API error displayed.Validation
go test -count=1 -timeout=5m ./...go vet ./...go build ./...git diff --check