Skip to content

fix(web): keep the connecting splash and retry the first-load auth check - #1574

Merged
wbxl2000 merged 7 commits into
mainfrom
fix/web-first-load-auth-gate
Jul 12, 2026
Merged

fix(web): keep the connecting splash and retry the first-load auth check#1574
wbxl2000 merged 7 commits into
mainfrom
fix/web-first-load-auth-gate

Conversation

@wbxl2000

@wbxl2000 wbxl2000 commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

No linked issue — the problem is explained below (reported by users).

Problem

Right after starting or updating the web UI, the first visit lands on /login; a manual refresh then loads the app normally.

Root cause: the first GET /api/v1/auth failing transiently (daemon still booting, config being rewritten by an upgrade, network blip, 5xx) was silently swallowed by the auth check, leaving authReady at its default false. The initial load then unconditionally marked itself initialized, so the auth gate (initialized && !authReady) rewrote the URL to /login — with no re-check anywhere, the page stayed there until a full reload.

What changed

  • The auth check now distinguishes three outcomes instead of swallowing all errors: proceed (a definitive response, ready or not), retry (transient failure: network error, timeout, 5xx), and server-auth-required (401 or envelope code 40101). The web bundle always ships paired with its daemon, so a daemon lacking this endpoint is out of scope by design.
  • The first load gates on /auth before health/meta/models: a transient failure keeps the existing connecting splash up and retries /auth every 2s until it answers; a definitive answer proceeds exactly as before (ready:true → app, ready:false/login); a 401/40101 stops and hands over to the server-token dialog, which already reloads the page once the token is entered.
  • While the splash is retrying, it now shows a "cannot reach the server — retrying…" line with the last error message underneath, so a stuck "connecting" state is diagnosable from the page itself.
  • App.vue: the token dialog flag now starts false and is only set by a real 401/40101 — previously it started from "no credential ⇒ prompt" and flashed the dialog for a frame in --dangerous-bypass-auth mode before /meta arrived. The 401 listener is also registered before the initial load starts.
  • ServerAuthDialog: z-index --z-modal--z-max, so the prompt stays reachable above the connecting splash (--z-toast) when a 401 happens during first load.
  • Onboarding overlay: now gated on client.initialized too — it teleports to <body> and previously floated above the connecting splash (and its retry error) when the first load was still stuck.
  • Tests: three new cases in workspace-state.test.ts — transient failure keeps the splash and retries until success (first failure silent, error surfaced from the second); a definitive ready:false still initializes into the login gate; 401/40101 stops without retrying or initializing.

Verified: pnpm --filter @moonshot-ai/kimi-web test|typecheck|check:style|build all pass; oxlint reports no new warnings on the touched files.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update (bug fix restoring the intended behavior; no documented behavior changes).

@changeset-bot

changeset-bot Bot commented Jul 12, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 08592d0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jul 12, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@08592d0
npx https://pkg.pr.new/@moonshot-ai/kimi-code@08592d0

commit: 08592d0

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: faaa38d6c7

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/kimi-web/src/composables/client/useWorkspaceState.ts
@wbxl2000

Copy link
Copy Markdown
Collaborator Author

@codex

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b7702ea9b1

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/kimi-web/src/composables/client/useWorkspaceState.ts Outdated
@wbxl2000

Copy link
Copy Markdown
Collaborator Author

@codex

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 490593582a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/kimi-web/src/composables/client/useWorkspaceState.ts Outdated
Comment thread apps/kimi-code/dist-web Outdated
@wbxl2000

Copy link
Copy Markdown
Collaborator Author

@codex

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 08592d08bf

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@wbxl2000
wbxl2000 merged commit b1942bd into main Jul 12, 2026
11 of 12 checks passed
@wbxl2000
wbxl2000 deleted the fix/web-first-load-auth-gate branch July 12, 2026 11:54
@github-actions github-actions Bot mentioned this pull request Jul 12, 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.

1 participant