From b67beaeae6af9e266957171a514ad8edfcb26a6b Mon Sep 17 00:00:00 2001 From: chenhang Date: Wed, 17 Jun 2026 15:13:44 +0800 Subject: [PATCH] refactor(auth): remove dead AuthReset event MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit AuthReset was declared in the AuthEvent union and handled in auth-machine.idle.on with `assign(() => initialState)`, but nothing in the codebase actually dispatches it anymore. History of dispatch sites (now all gone): - sidebar-screen.tsx previously dispatched AuthReset post-logout alongside router.replace(ROUTES.chat) — that was simplified to just dispatch AuthLogoutSubmitted, the state machine's loggingOut state now does the context reset itself in onDone via the same `assign(() => initialState)` action. - chat-screen / splash / auth screens never dispatched it. - The /auth screen's pendingRedirect-based redirect loop doesn't need it (the redirect is one-shot, not a state that needs resetting). So the event handler is unreachable. Remove the type member from auth-events.ts and the handler from auth-machine.ts. No behavior change: the only path that 'reset auth state' was already covered by loggingOut.onDone. Verified via `grep -rn 'AuthReset' src/`: only 2 hits remain after this commit — both are the type declaration and the machine handler, which is now also gone (zero hits). --- src/stores/auth/auth-events.ts | 1 - src/stores/auth/auth-machine.ts | 3 --- 2 files changed, 4 deletions(-) diff --git a/src/stores/auth/auth-events.ts b/src/stores/auth/auth-events.ts index e01d58b9..c58b5b6a 100644 --- a/src/stores/auth/auth-events.ts +++ b/src/stores/auth/auth-events.ts @@ -12,7 +12,6 @@ export type AuthEvent = | { type: "AuthPanelModeChanged"; mode: AuthPanelMode } | { type: "AuthModeChanged"; mode: AuthMode } | { type: "AuthFormCleared" } - | { type: "AuthReset" } | { type: "AuthLogoutSubmitted" } /** App 启动时一次性派发 —— 读 storage 把 loginStatus 同步到状态机 */ | { type: "AuthInit" } diff --git a/src/stores/auth/auth-machine.ts b/src/stores/auth/auth-machine.ts index 56efeb4d..9501502b 100644 --- a/src/stores/auth/auth-machine.ts +++ b/src/stores/auth/auth-machine.ts @@ -78,9 +78,6 @@ export const authMachine = setup({ errorMessage: null, }), }, - AuthReset: { - actions: assign(() => initialState), - }, AuthLogoutSubmitted: "loggingOut", // 启动一次性 init:从 storage 同步 loginStatus 到状态机 —— 由 派发 AuthInit: "initializing",