Skip to content

Wait for auth.sendCode before showing code input - #1

Merged
fdciabdul merged 1 commit into
imtaqin:mainfrom
I3eka:fix/wait-for-auth-code-confirmation
Aug 3, 2026
Merged

Wait for auth.sendCode before showing code input#1
fdciabdul merged 1 commit into
imtaqin:mainfrom
I3eka:fix/wait-for-auth-code-confirmation

Conversation

@I3eka

@I3eka I3eka commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • keep the auth UI in a loading state after the phone number is submitted
  • show the code input only after the Telegram client reports AuthStateWaitCode
  • render a specific Requesting verification code... status while auth.sendCode is pending
  • add a regression test for the phone submission transition

Why

The phone form previously changed its own state from StepPhone to StepCode immediately on Enter. That happened before auth.sendCode returned, so the UI could claim that a code had been sent while the request was still pending or had failed.

The authorizer already emits AuthStateWaitCode only after Telegram returns auth.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

Copilot AI review requested due to automatic review settings August 3, 2026 02:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 StepLoading and display Requesting verification code... while auth.sendCode is 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.

Comment on lines +25 to +27
if view := got.View(); !strings.Contains(view, "Requesting verification code...") {
t.Fatalf("expected pending request hint to be rendered, got %q", view)
}
@fdciabdul

Copy link
Copy Markdown
Member

Thanks for this — reviewed the diff and the approach is right: gating StepCode on the server-backed AuthStateWaitCode instead of assuming auth.sendCode succeeded fixes a real UX lie (e.g. when sendCode fails with AUTH_UNREGISTERED).

One thing before we can merge: the repo was transferred tegal1337imtaqin and the Go module path was renamed to github.com/imtaqin/telegram-cli in e34c971 (touches every import). Could you rebase onto current main and update the import paths? After that this is good to merge.

@I3eka
I3eka force-pushed the fix/wait-for-auth-code-confirmation branch from 1f4f9d9 to 3c88d4e Compare August 3, 2026 15:31
@I3eka

I3eka commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for this — reviewed the diff and the approach is right: gating StepCode on the server-backed AuthStateWaitCode instead of assuming auth.sendCode succeeded fixes a real UX lie (e.g. when sendCode fails with AUTH_UNREGISTERED).

One thing before we can merge: the repo was transferred tegal1337imtaqin and the Go module path was renamed to github.com/imtaqin/telegram-cli in e34c971 (touches every import). Could you rebase onto current main and update the import paths? After that this is good to merge.

done

@fdciabdul
fdciabdul merged commit 13290ae into imtaqin:main Aug 3, 2026
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