diff --git a/docs/BUG_HISTORY.md b/docs/BUG_HISTORY.md index 8bd3e81e0..5af183dff 100644 --- a/docs/BUG_HISTORY.md +++ b/docs/BUG_HISTORY.md @@ -28712,3 +28712,15 @@ - 尚未处理:拆分方式是按原顺序重算每一小段,只在与原结果一致时保留,需占星师确认这符合她「不得重新执行任意表达式来猜分支」的要求;`any(...)` 一类单行表达式和多语句规则仍整体记录;整个表达式出错时不保留分支记录;资料章节的格局汇总表仍写「满足自定义条件」。 - 关联记录:BUG-2075,占星师 2026-11-20 第 10 问。 - 修复版本:`claude/custom-branch-trace-2124`。 + +## BUG-2127 | 不在聊天页时点头像菜单的设置,会先跳回聊天页再弹出设置 + +- 状态:fixed-pending-verify。 +- 首次发现 / 最近更新:2026-11-21 / 2026-11-21。 +- 触发与现象:在星盘、人物、报告、合盘、生时纠正、星历等页面点头像菜单里的个人资料 / 账户与点数 / 通用设置 / 退出,页面先跳到首页聊天界面,再弹出设置弹窗;各处「去补点数」也一样。 +- 触发条件:任何非首页页面。 +- 根因:设计限制,不是回归。设置弹窗的状态、遮罩、头像保存、退出、Esc 与焦点处理和 `?account=` 深链都只挂在首页 `(app)/page.tsx`;其他页面的菜单项因此只能是 `/?account=` 链接(TASK-self-edit-avatar-menu-20260928 S2,`frontend/src/lib/account-dialog-intent.ts`),点了先回首页、首页加载完再开弹窗。 +- 修复:新 `frontend/src/components/account-dialog-provider.tsx`(`AccountDialogProvider` + `AccountDialogHost`)接管原来首页的弹窗状态和处理函数(函数体原样搬过来),挂在 `(app)/layout.tsx`,所有页面原地打开同一个弹窗;只用共享的会话列表账户,不另取账户,首页不重复加载、其他页面首屏不等它;`?account=` 深链在首页和其他页面都能用。侧栏菜单在非首页直接打开弹窗并把焦点还给头像;首页 `openAccountDialog` 改为调用共享的打开函数。年运报告、合盘选人、个人报告开始卡片、报告提问面板的「去补点数」改用 `BillingDialogLink`(同一个链接外观,普通点击原地打开账户与点数,带修饰键时仍是普通链接)。保留:`LegalConsentGate` 与 BUG-2072 报告提醒的挂载顺序和条件、BUG-2070 点数记录先关弹窗再跳转、BUG-2086 在其他页面保存头像不会让首页重走首次引导、BUG-2059 弹窗 880×640 且在提问面板之上。 +- 验证与防复发:`frontend/tests/account-dialogs-every-page-2127.test.tsx`(6 条:非首页打开不跳转、深链在首页和报告页都能打开且只去掉 account 参数、在合盘页保存头像后首次引导不重来、外壳只有一个弹窗且首页不再画遮罩、补点数链接原地打开与修饰键行为、四处入口不再用跳转链接);钉住旧链接的 15 个前端测试和 `tests/test_session_management_entrypoints.py` 按原值、新值、原因更新。本地生产构建在报告页、合盘报告页(提问面板打开)、星盘页看过:弹窗 880×640 盖在面板之上,网址不变,Esc 关闭后焦点回到头像。首页因登录状态带不到本机没有在浏览器里看,靠测试覆盖。 +- 关联记录:BUG-554、BUG-698、BUG-970、BUG-2059、BUG-2070、BUG-2072、BUG-2086,TASK-self-edit-avatar-menu-20260928。 +- 修复版本:`claude/settings-anywhere-2127`。 diff --git a/frontend/src/app/(app)/layout.tsx b/frontend/src/app/(app)/layout.tsx index 5ae2fb815..7f3b8277a 100644 --- a/frontend/src/app/(app)/layout.tsx +++ b/frontend/src/app/(app)/layout.tsx @@ -5,6 +5,7 @@ import dynamic from "next/dynamic"; import { usePathname, useRouter } from "next/navigation"; import { AccountDeletionGate } from "@/components/account-deletion-gate"; +import { AccountDialogHost, AccountDialogProvider, useAccountDialogs } from "@/components/account-dialog-provider"; import { AppSidebar } from "@/components/app-sidebar"; import { LegalConsentGate } from "@/components/legal/legal-consent-gate"; import { ReportReminderWatcher } from "@/components/report-reminder-watcher"; @@ -48,11 +49,16 @@ function AppShell({ children }: { children: ReactNode }) { }, [router]); // The rows' menu, delete confirmation and drag sorting, on every page (issue #116). const sessionActions = useShellSessionActions(list, registration?.sessionHooks ?? null); + // The account dialogs open where the reader is, on every page (BUG-2127). + const accountDialogs = useAccountDialogs(); + const accountDialogOpen = accountDialogs.activeDialog !== null; return ( - +
+ {/* First, so a `/?account=` deep link is read before a page rewrites its URL (BUG-2127). */} + { + // Same source as the menu on `/` (use-home-shell-registration). + accountDialogs.open(dialog, { returnTarget, source: dialog === "billing" ? "account-menu" : undefined }); + }} onOpenSession={(sessionId) => { navigateAppPath(sessionHref("", sessionId), router.push); }} @@ -101,7 +111,9 @@ function AppShell({ children }: { children: ReactNode }) { export default function AppLayout({ children }: { children: ReactNode }) { return ( - {children} + + {children} + ); } diff --git a/frontend/src/app/(app)/page.tsx b/frontend/src/app/(app)/page.tsx index 5f4c620cd..98cb3ce4b 100644 --- a/frontend/src/app/(app)/page.tsx +++ b/frontend/src/app/(app)/page.tsx @@ -1,19 +1,13 @@ "use client"; -import dynamic from "next/dynamic"; -import { BillingBalance, BillingPagesWaiting } from "@/components/billing-balance"; -import { loadBillingPanel, prefetchBillingPanel, prefetchBillingPanelWhenIdle } from "@/lib/billing-panel-loader"; +import { prefetchBillingPanelWhenIdle } from "@/lib/billing-panel-loader"; import type { BirthHistorySubject, ConsultationBirthHistory } from "@/lib/consultation-birth-history"; import { useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react"; import type { FormEvent, KeyboardEvent } from "react"; -import { AccountDialogOverlay, type AccountOverlayModel } from "@/components/account-dialog-overlay"; -import { Button } from "@/components/ui/button"; +import { useAccountDialogs } from "@/components/account-dialog-provider"; import { navigateInApp } from "@/lib/app-navigation"; import { RECTIFICATION_PAGE_HREF } from "@/lib/chat-session-url"; import { birthTimeNeedsRectification } from "@/lib/rectification-links"; -import { ProfilePanel } from "@/components/profile-panel"; -import { AccountDeletionSection } from "@/components/account-deletion-section"; -import { ThemePreferencePanel } from "@/components/theme-preference-menu"; import type { BirthTimeAssessmentPhase } from "@/components/birth-time-assessment-overlay"; import { OnboardingChecklistSlot } from "@/components/onboarding-checklist-slot"; import { HomeBootstrapError } from "@/components/home-bootstrap-error"; @@ -48,7 +42,7 @@ import { personRelationLabel } from "@/lib/person-relation"; import { readStarterSignMap, readStarterSigns, subscribeStarterSigns } from "@/lib/starter-questions"; import { OnboardingChartDot } from "@/components/onboarding-dot"; import { OnboardingHomeBridge } from "@/components/onboarding-home-bridge"; -import { AccountDialogDeepLink, SynastryDeepLink } from "@/components/people-home-links"; +import { SynastryDeepLink } from "@/components/people-home-links"; import { StarterGreeting } from "@/components/starter-home"; import { StarterQuestions } from "@/components/starter-questions"; import { type ConsultationEntrypoint } from "@/lib/consultation-entrypoint"; @@ -67,7 +61,6 @@ import { useProfileOnboarding } from "@/hooks/use-profile-onboarding"; import { useSessionManagement } from "@/hooks/use-session-management"; import { showChatNotice as setComposerNotice } from "@/lib/chat-notice"; import { chatReplyAnnouncement, type ChatReplyPhase } from "@/lib/chat-reply-announcement"; -import { keepFocusWithin } from "@/lib/focus-trap"; import { BALANCE_SYNC_KEY, BALANCE_CHANGED_EVENT, @@ -108,8 +101,7 @@ import { type PublicLanguageModelCatalog, } from "@/lib/public-models"; import { - accountDialogClasses, - accountDialogTitles, + accountDialogOptions, pendingConsultationStorageKey, presetOnboardingMessage, type AccountDialog, @@ -167,12 +159,6 @@ import { const EMPTY_SUBJECT_CATALOG: readonly ChartLibraryRecord[] = []; -const BillingPanel = dynamic(loadBillingPanel, { - ssr: false, - // BUG-2059: the tab line and bars of the real heights, never a sentence or a blank. - loading: () => , -}); - let nudgeComposerTimer: number | undefined; @@ -213,11 +199,11 @@ export default function Home() { // it decides once per mount. Null means the unchanged cold bootstrap. const warmStart = () => takeHomeWarmStart(() => homeWarmStartInput(sessionList)); const [accountMenuOpen, setAccountMenuOpen] = useState(false); - const [activeAccountDialog, setActiveAccountDialog] = useState(null); + // The account dialogs are the app shell's (BUG-2127): the same ones on every page. + const accountDialogs = useAccountDialogs(); + const activeAccountDialog = accountDialogs.activeDialog; const [chartLibrary, setChartLibrary] = useState([]); - const [billingPane, setBillingPane] = useState({}); const [accountError, setAccountError] = useState(""); - const [signingOut, setSigningOut] = useState(false); const [modelCatalog, setModelCatalog] = useState(() => { const warm = warmStart(); useSessionStore.getState().mountHomeConversation(warm?.landing.activeSessionId ?? ""); @@ -288,9 +274,6 @@ export default function Home() { const [presetMessageLength, setPresetMessageLength] = useState(0); const conversation = useRef(null); const accountTrigger = useRef(null); - const accountDialog = useRef(null); - const dialogReturnTargetRef = useRef(null); - const closeButton = useRef(null); const onboardingPaywallShown = useRef(false); const starterGreetingUnseen = useRef(true); const composerInput = useRef(null); @@ -328,36 +311,42 @@ export default function Home() { profile, setProfile, setProfileDraft, - profileNotice, setProfileNotice, - avatarSaving, profileSaving, refreshAccount, - openAccountDialog, - closeAccountDialog, - persistAvatar, saveOnboardingName, saveOnboardingBirth, saveOnboardingPlace, - signOut, onboardingDraft, setOnboardingDraft, intakeTarget, chooseOnboardingSelf, chooseOnboardingOther, } = useProfileOnboarding({ - account, accountRefreshGuard, accountTrigger, - dialogReturnTargetRef, - setAccount, setAccountError, setAccountMenuOpen, setActiveAccountDialog, + account, accountRefreshGuard, + setAccount, setAccountError, setBirthTimeAssessmentPhase, - setBillingPane, setDraft, + setDraft, setOnboardingJustCompleted, setOnboardingStep, setPresetMessageLength, - setSigningOut, setStartGreeting, signingOut, uiPreview, + setStartGreeting, uiPreview, initialProfile: () => warmStart()?.profile ?? null, onOwnBirthPlaceSaved: birthSkyReveal.begin, chartLibrary: subjectCatalog, }); + // Home's way into the shell's account dialogs: its own menu closes, and focus + // goes back to the avatar unless the caller names another trigger. + function openAccountDialog( + dialog: AccountDialog, + returnTargetOrOptions?: HTMLButtonElement | null | OpenAccountDialogOptions, + ) { + const options = accountDialogOptions(returnTargetOrOptions); + setAccountMenuOpen(false); + setAccountError(""); + if (dialog === "profile") setProfileNotice(""); + accountDialogs.open(dialog, { ...options, returnTarget: options.returnTarget ?? accountTrigger.current }); + } + const activeSession = sessions.find((session) => session.id === activeSessionId) ?? pendingWarmLandingSession(activeSessionId) ?? sessions.find((session) => !isRetiredRectificationSession(session) && sessionMatchesSubject(session, readCurrentSubjectId())); @@ -833,35 +822,10 @@ export default function Home() { }, [startNewChat]); // BUG-2057: the 账户与点数 panel is downloaded while the home page is idle, - // and at the latest when any settings section opens. + // and at the latest when any settings section opens (the shell's account dialogs). useEffect(() => { if (accountId && hydrated) prefetchBillingPanelWhenIdle(); }, [accountId, hydrated]); - useEffect(() => { - if (activeAccountDialog !== null) prefetchBillingPanel(); - }, [activeAccountDialog]); - - useEffect(() => { - if (activeAccountDialog === null) return; - window.requestAnimationFrame(() => { - if (signingOut) return; - closeButton.current?.focus(); - }); - const closeOnEscape = (event: globalThis.KeyboardEvent) => { - if (event.key === "Escape") { - if (signingOut) return; - setActiveAccountDialog(null); - const returnTarget = dialogReturnTargetRef.current; - window.requestAnimationFrame(() => returnTarget?.focus()); - return; - } - const container = accountDialog.current; - if (container) keepFocusWithin(event, container); - }; - window.addEventListener("keydown", closeOnEscape); - return () => window.removeEventListener("keydown", closeOnEscape); - }, [activeAccountDialog, signingOut]); - useEffect(() => { if (!accountId || !hydrated) return; const onBalanceStorage = (event: StorageEvent) => { @@ -1065,50 +1029,6 @@ export default function Home() { ); } - const accountOverlayModel: AccountOverlayModel | null = activeAccountDialog === null ? null : { - title: activeAccountDialog ? accountDialogTitles[activeAccountDialog] : "", - dialogClass: activeAccountDialog ? accountDialogClasses[activeAccountDialog] : "", - signingOut, - close: closeAccountDialog, - navigate: (dialog) => openAccountDialog(dialog, dialogReturnTargetRef.current), - overlayRef: accountDialog, - closeButtonRef: closeButton, - renderProfile: () => ( - setAccount((current) => current ? { ...current, avatarImage: version === null ? null : { version } } : current)} - /> - ), - renderChartLibrary() { - return null; - }, - renderBilling: () => ( -
- {/* BUG-2059: the balance is drawn here, not in the lazy panel, so it is on screen at once. */} - - -
- ), - - renderGeneral() { - return <>; - }, - renderLogout() { - return ( - <> -

退出后,需要重新登录才能继续查看对话。

-
- - -
- - ); - }, - }; - // One person switcher, in the top bar only (2026-11-02; issue #150 had a second one above the chart panel). const subjectPicker = activeSession?.sessionType === "consultation" || activeSession?.sessionType === "synastry_report" ? ( - {replyAnnouncement}
@@ -1258,11 +1177,6 @@ export default function Home() { : null} - {onboardingPaywallOpen && account && ( ` and the reader landed on the + * chat page. The state, the actions and the overlay are mounted once by + * `(app)/layout.tsx`; Home and the sidebar call the same `open`. + * + * Nothing here reads the account: it is the layout's session-list account, + * the one Home already uses, so no page loads it twice and no page waits for it. + */ + +const BillingPanel = dynamic(loadBillingPanel, { + ssr: false, + // BUG-2059: the tab line and bars of the real heights, never a sentence or a blank. + loading: () => , +}); + +export type AccountDialogsValue = Readonly<{ + activeDialog: AccountDialog | null; + open: (dialog: AccountDialog, returnTargetOrOptions?: HTMLButtonElement | null | OpenAccountDialogOptions) => void; + close: () => void; +}>; + +const AccountDialogContext = createContext(null); + +const INERT_ACCOUNT_DIALOGS: AccountDialogsValue = { + activeDialog: null, + open: () => undefined, + close: () => undefined, +}; + +/** The shell's account dialogs. Outside the provider (unit tests that mount a page alone): never open. */ +export function useAccountDialogs(): AccountDialogsValue { + return useContext(AccountDialogContext) ?? INERT_ACCOUNT_DIALOGS; +} + +/** + * 「去补点数」 inside the app: 账户与点数 opens over the page the reader is on + * (BUG-2127; these were links to `/?account=billing`, which went to the chat + * page first). Still a real link to the deep link, so a new tab, a modified + * click, or a render outside the shell lands on the same dialog. + */ +export function BillingDialogLink({ children, className }: { children: ReactNode; className?: string }) { + const dialogs = useContext(AccountDialogContext); + return ( + ) => { + if (!dialogs || event.defaultPrevented || event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return; + event.preventDefault(); + dialogs.open("billing", { source: "insufficient-credits" }); + }} + > + {children} + + ); +} + +type AccountDialogState = Readonly<{ + activeDialog: AccountDialog | null; + billingPane: OpenAccountDialogOptions; + signingOut: boolean; + avatarSaving: boolean; +}>; + +type AccountDialogInternals = Readonly<{ + state: AccountDialogState; + signOut: () => Promise; + persistAvatar: (patch: BeamAvatarPatch) => Promise; + overlayRef: { current: HTMLElement | null }; + closeButtonRef: { current: HTMLButtonElement | null }; + returnTargetRef: { current: HTMLButtonElement | null }; +}>; + +const AccountDialogStateContext = createContext(null); + +/** What the overlay draws from: the panes' state and their two writes (avatar, sign-out). */ +export function useAccountDialogInternals(): AccountDialogInternals | null { + return useContext(AccountDialogStateContext); +} + +export function AccountDialogProvider({ children }: { children: ReactNode }) { + const { account, setAccount } = useSessionList(); + const [activeDialog, setActiveDialog] = useState(null); + const [billingPane, setBillingPane] = useState({}); + const [signingOut, setSigningOut] = useState(false); + const [avatarSaving, setAvatarSaving] = useState(false); + const overlayRef = useRef(null); + const closeButtonRef = useRef(null); + const returnTargetRef = useRef(null); + const signingOutRef = useRef(false); + const avatarSavingRef = useRef(false); + const accountRef = useRef(account); + useEffect(() => { + signingOutRef.current = signingOut; + avatarSavingRef.current = avatarSaving; + accountRef.current = account; + }); + + const open = useCallback(( + dialog: AccountDialog, + returnTargetOrOptions?: HTMLButtonElement | null | OpenAccountDialogOptions, + ) => { + const options = accountDialogOptions(returnTargetOrOptions); + returnTargetRef.current = options.returnTarget ?? null; + if (dialog === "chart-library") { + window.location.assign("/people"); + return; + } + if (dialog === "billing") { + setBillingPane({ + source: options.source, + plan: options.plan, + tab: options.tab, + }); + } + setActiveDialog(dialog); + }, []); + + const close = useCallback(() => { + if (signingOutRef.current) return; + setActiveDialog(null); + const returnTarget = returnTargetRef.current; + window.requestAnimationFrame(() => returnTarget?.focus()); + }, []); + + const persistAvatar = useCallback(async (patch: BeamAvatarPatch) => { + if (!accountRef.current?.avatar || avatarSavingRef.current) return; + avatarSavingRef.current = true; + setAvatarSaving(true); + try { + const response = await fetch("/api/account/avatar", { + method: "PATCH", + credentials: "same-origin", + headers: { "content-type": "application/json" }, + body: JSON.stringify(patch), + }); + const payload = await response.json().catch(() => null) as { avatar?: unknown; error?: string } | null; + if (!response.ok) throw new Error(payload?.error || "头像暂时无法保存。"); + const avatar = beamAvatarSchema.parse(payload?.avatar); + setAccount((current) => current ? { ...current, avatar } : current); + notifySuccess(patch.action === "randomize" ? "已生成并保存新头像。" : "头像配色已保存。"); + } catch (caught) { + notifyError(friendlyError(caught instanceof Error ? caught.message : "头像保存失败")); + } finally { + avatarSavingRef.current = false; + setAvatarSaving(false); + } + }, [setAccount]); + + const signOut = useCallback(async () => { + if (signingOutRef.current) return; + signingOutRef.current = true; + setSigningOut(true); + try { + // The auth client is only needed here, so it is not in the first screen (issue #125). + const { selfHostedOtpActions } = await import("@/modules/identity/client"); + // Signing out ends this account's warm return to `/` (BUG-1040); a + // failed sign-out only costs one loading ring on the next return. + // Nor does this account's chart stay in memory for the next one (BUG-1530). + clearChartPageCache(); + clearBirthSkyMemory(); + clearHomeWarmSnapshot(); + await selfHostedOtpActions.signOut(); + window.location.assign("/login"); + } catch (caught) { + const message = caught instanceof Error ? caught.message : "退出失败"; + notifyError(friendlyError(message)); + signingOutRef.current = false; + setSigningOut(false); + } + }, []); + + // BUG-2057: the 账户与点数 panel is downloaded at the latest when any settings section opens. + useEffect(() => { + if (activeDialog !== null) prefetchBillingPanel(); + }, [activeDialog]); + + useEffect(() => { + if (activeDialog === null) return; + window.requestAnimationFrame(() => { + if (signingOut) return; + closeButtonRef.current?.focus(); + }); + const closeOnEscape = (event: globalThis.KeyboardEvent) => { + if (event.key === "Escape") { + if (signingOut) return; + setActiveDialog(null); + const returnTarget = returnTargetRef.current; + window.requestAnimationFrame(() => returnTarget?.focus()); + return; + } + const container = overlayRef.current; + if (container) keepFocusWithin(event, container); + }; + window.addEventListener("keydown", closeOnEscape); + return () => window.removeEventListener("keydown", closeOnEscape); + }, [activeDialog, signingOut]); + + const value = useMemo(() => ({ activeDialog, open, close }), [activeDialog, open, close]); + const state = useMemo(() => ({ + state: { activeDialog, billingPane, signingOut, avatarSaving }, + signOut, + persistAvatar, + overlayRef, + closeButtonRef, + returnTargetRef, + }), [activeDialog, avatarSaving, billingPane, persistAvatar, signOut, signingOut]); + + return ( + + + {children} + + + ); +} + +/** + * The overlay itself, and the `/?account=` deep link (external links, + * the paywall, the redeem flows). Mounted once by the app layout. The deep + * link is read again on every page entry, so a link to it from any page works. + */ +export function AccountDialogHost() { + const holder = useAccountDialogInternals(); + const dialogs = useAccountDialogs(); + const { account, setAccount } = useSessionList(); + const pathname = usePathname() ?? ""; + const profile = useMemo(() => readProfile(account?.profile), [account?.profile]); + const { open, close } = dialogs; + const openFromLink = useCallback((dialog: AccountDialog, options?: OpenAccountDialogOptions) => { + // Focus goes back to the avatar when the dialog closes, as from the menu. + const trigger = document.querySelector("button.sidebar-account-trigger"); + open(dialog, { ...options, returnTarget: trigger }); + }, [open]); + if (!holder) return null; + const { state, signOut, persistAvatar, overlayRef, closeButtonRef, returnTargetRef } = holder; + const { activeDialog, billingPane, signingOut, avatarSaving } = state; + + const model: AccountOverlayModel | null = activeDialog === null || !account ? null : { + title: accountDialogTitles[activeDialog], + dialogClass: accountDialogClasses[activeDialog], + signingOut, + close, + navigate: (dialog) => open(dialog, returnTargetRef.current), + overlayRef, + closeButtonRef, + renderProfile: () => ( + setAccount((current) => current ? { ...current, avatarImage: version === null ? null : { version } } : current)} + /> + ), + renderChartLibrary() { + return null; + }, + // BUG-2070: a ledger row that opens another page closes the dialog first, on every page. + renderBilling: () => ( +
+ {/* BUG-2059: the balance is drawn here, not in the lazy panel, so it is on screen at once. */} + + +
+ ), + renderGeneral() { + return <>; + }, + renderLogout() { + return ( + <> +

退出后,需要重新登录才能继续查看对话。

+
+ + +
+ + ); + }, + }; + + return ( + <> + + + + ); +} diff --git a/frontend/src/components/annual/annual-report-page.tsx b/frontend/src/components/annual/annual-report-page.tsx index 97a586df9..67793f863 100644 --- a/frontend/src/components/annual/annual-report-page.tsx +++ b/frontend/src/components/annual/annual-report-page.tsx @@ -29,7 +29,7 @@ import { REPORT_ASK_TEXT } from "@/lib/report-ask-client"; import { Button } from "@/components/ui/button"; import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"; import { useVisibilityAwarePoll } from "@/hooks/use-visibility-aware-poll"; -import { accountDialogHref } from "@/lib/account-dialog-intent"; +import { BillingDialogLink } from "@/components/account-dialog-provider"; import { reportPriceLine, reportStartErrorFor } from "@/lib/report-start-copy"; import { notifyError } from "@/lib/notify"; import { askNotificationPermissionOnce, reportStatusesSeen, watchStartedReport } from "@/lib/report-reminders"; @@ -539,7 +539,7 @@ export function AnnualOverlay(props: Readonly<{ {props.error ? (

{props.error.message} - {props.error.billing ? <> 去补点数 : null} + {props.error.billing ? <> 去补点数 : null}

) :

{priceLine(overview.creditCost)}

} {overview.existing?.status === "ready" ? ( diff --git a/frontend/src/components/app-sidebar.tsx b/frontend/src/components/app-sidebar.tsx index 55fe4722d..76534cbe9 100644 --- a/frontend/src/components/app-sidebar.tsx +++ b/frontend/src/components/app-sidebar.tsx @@ -28,9 +28,8 @@ import { import { usePathname } from "next/navigation"; import { useEffect, useRef, useState } from "react"; import type { MouseEvent, ReactNode, Ref } from "react"; -import { AppLink } from "@/components/app-link"; import { OnboardingDot } from "@/components/onboarding-dot"; -import { accountDialogHref, type AccountDialogIntent } from "@/lib/account-dialog-intent"; +import type { AccountDialogIntent } from "@/lib/account-dialog-intent"; import { newChatHref, sessionHref } from "@/lib/chat-session-url"; import { useOnboardingJourneyOptional } from "@/lib/onboarding-journey"; import { prefetchSecondaryPage } from "@/lib/secondary-page-data"; @@ -78,9 +77,10 @@ export type SidebarAccount = { /** * Everything only `/` can supply: new chat in place, opening a row in place, * and the settings dialogs behind the account menu. Omit `controls` and new - * chat is a link, a row opens `/?c=`, and the account menu's dialog - * entries become links to `/?account=` - * (TASK-self-edit-avatar-menu-20260928 S2). + * chat is a link and a row opens `/?c=`. The account menu's dialog + * entries open in place on every page: through `controls` on `/`, through + * `onOpenAccountDialog` (the shell's account dialogs) elsewhere (BUG-2127; + * they were links to `/?account=`, which took the reader to the chat). * * The rows' own menu (收藏、重命名、转发、删除) and drag sorting are not in * here: they come from the shell through `sessionControls` on every page @@ -125,6 +125,8 @@ export type AppSidebarProps = { sessionControls?: SidebarSessionControls | null; /** Opens a row off `/`: the shell routes it to `/?c=`. `controls` wins on `/`. */ onOpenSession?: (sessionId: string) => void; + /** Off `/`: opens an account dialog in place, from the shell's account dialogs (BUG-2127). `controls` wins on `/`. */ + onOpenAccountDialog?: (dialog: AccountDialogIntent, returnTarget: HTMLButtonElement | null) => void; }; const NAV_PAGES = [ @@ -148,6 +150,7 @@ export function AppSidebar({ controls, sessionControls, onOpenSession, + onOpenAccountDialog, }: AppSidebarProps) { const { isMobile, setOpen, setOpenMobile, state, viewport } = useSidebar(); const showChartDot = useOnboardingJourneyOptional()?.showChartDot ?? false; @@ -180,6 +183,8 @@ export function AppSidebar({ const onSelectSession = controlledSelectSession ?? onOpenSession; /* Off `/` nothing controls the account menu, so it keeps its own open state (S2). */ const [ownMenuOpen, setOwnMenuOpen] = useState(false); + /* Off `/` the avatar is where focus goes back when the dialog closes. */ + const ownTriggerRef = useRef(null); /* 反馈与投诉 is the sidebar's own dialog, so it opens the same way on every page. */ const [feedbackOpen, setFeedbackOpen] = useState(false); /* 「新建对话」 off `/` waiting for the home's warm snapshot (BUG-1509). */ @@ -343,8 +348,9 @@ export function AppSidebar({ ); } - /* One entry of the account menu: on `/` the dialog opens in place; on - another page the entry is a link to `/?account=` (S2). */ + /* One entry of the account menu. The dialog opens in place on every page: + on `/` through Home's controls, elsewhere through the shell (BUG-2127; + off `/` the entry used to be a link to `/?account=`). */ function accountEntry( dialog: AccountDialogIntent, onOpen: (() => void) | undefined, @@ -352,17 +358,12 @@ export function AppSidebar({ content: ReactNode, pointer: { onPointerEnter?: () => void; onPointerDown?: () => void } = {}, ) { - return onOpen ? ( - {content} - ) : ( - } - {...pointer} - > - {content} - + const openInPlace = onOpen ?? (() => { + setOwnMenuOpen(false); + onOpenAccountDialog?.(dialog, ownTriggerRef.current); + }); + return ( + {content} ); } @@ -496,14 +497,13 @@ export function AppSidebar({ ) : null} {account ? ( - /* One account menu on every page. On `/` Home controls it and its - entries open the dialogs in place; elsewhere it keeps its own open - state and the dialog entries go to `/?account=`, where Home - opens that dialog (S2). Theme applies where the reader is. */ + /* One account menu on every page. On `/` Home controls it; elsewhere + it keeps its own open state. Its entries open the dialogs in place + everywhere (BUG-2127). Theme applies where the reader is. */ {account.avatar diff --git a/frontend/src/components/personal-report/personal-report-start-dialog.tsx b/frontend/src/components/personal-report/personal-report-start-dialog.tsx index 637841233..4fee839e7 100644 --- a/frontend/src/components/personal-report/personal-report-start-dialog.tsx +++ b/frontend/src/components/personal-report/personal-report-start-dialog.tsx @@ -13,7 +13,7 @@ "use client"; -import { accountDialogHref } from "@/lib/account-dialog-intent"; +import { BillingDialogLink } from "@/components/account-dialog-provider"; import { PERSONAL_REPORT_START_ACTION, PERSONAL_REPORT_START_NOTES, @@ -84,7 +84,7 @@ export function PersonalReportStartCard(props: Readonly<{ {error ? (

{error.message} - {props.error?.billing ? <> 去补点数 : null} + {props.error?.billing ? <> 去补点数 : null}

) : (

{overview === null ? "正在读取价格…" : reportPriceLine(cost)}

diff --git a/frontend/src/components/report-ask/report-ask-panel.tsx b/frontend/src/components/report-ask/report-ask-panel.tsx index d1667c63a..34a83c543 100644 --- a/frontend/src/components/report-ask/report-ask-panel.tsx +++ b/frontend/src/components/report-ask/report-ask-panel.tsx @@ -6,7 +6,6 @@ import { type ChangeEvent, type FormEvent, type KeyboardEvent, type PointerEvent as ReactPointerEvent, } from "react"; -import { AppLink } from "@/components/app-link"; import { ChatComposer } from "@/components/chat-composer"; import { ChatMessageActions, toggleChatMessageFeedback, type ChatMessageFeedback } from "@/components/chat-message-actions"; import { ChatMessageRow } from "@/components/chat-message-row"; @@ -16,7 +15,7 @@ import { Button } from "@/components/ui/button"; import { Drawer, DrawerContent, DrawerTitle } from "@/components/ui/drawer"; import type { ReportAskPending, ReportAskState } from "@/components/report-ask/use-report-ask"; import { useReportAskWidth, useReportAskWidthProperty } from "@/components/report-ask/use-report-ask-width"; -import { accountDialogHref } from "@/lib/account-dialog-intent"; +import { BillingDialogLink } from "@/components/account-dialog-provider"; import type { ChatMessageView } from "@/lib/chat-message-view"; import { isWholeReportAnchor, type ReportAnchor } from "@/lib/report-ask-anchor"; import { REPORT_ASK_MAX_QUESTION_CHARS, type ReportAskText } from "@/lib/report-ask-client"; @@ -202,7 +201,7 @@ export function ReportAskBody({ state, text, draftAnchor, sectionTitle, onAsk, o {state.short ? (

{price !== null && balance !== null ? text.short(balance, price) : text.shortPlain} - {text.toBilling} + {text.toBilling}

) : null} earlier.map((report) => report.id), [earlier])); const [confirming, setConfirming] = useState(false); + // 「去补点数」 opens 账户与点数 over this page (BUG-2127; it used to load `/?account=billing`). + const accountDialogs = useAccountDialogs(); const [compareRamanKuja, setCompareRamanKuja] = useState(false); // BUG-2083: a start the server refused for missing birth data widens the lines under the selectors. const [refused, setRefused] = useState(false); @@ -414,7 +416,7 @@ export function SynastryPicker() { 取消 {charge.short ? ( - { window.location.assign(accountDialogHref("billing")); }}>去补点数 + { setConfirming(false); accountDialogs.open("billing", { source: "insufficient-credits" }); }}>去补点数 ) : ( { setConfirming(false); void createReport(); }}>开始 )} diff --git a/frontend/src/hooks/use-profile-onboarding.ts b/frontend/src/hooks/use-profile-onboarding.ts index 4cb07469c..d60978d01 100644 --- a/frontend/src/hooks/use-profile-onboarding.ts +++ b/frontend/src/hooks/use-profile-onboarding.ts @@ -2,10 +2,6 @@ import { useRef, useState, type Dispatch, FormEvent, MutableRefObject, SetStateAction } from "react"; -import { - beamAvatarSchema, - type BeamAvatarPatch, -} from "@/lib/beam-avatar"; import { isBirthTimeDraftReady, } from "@/lib/birth-time-intake-model"; @@ -22,10 +18,8 @@ import { import { accountChartPinStillCurrent, beginChartCacheAccountRead, - clearChartPageCache, pinChartSnapshotIdentity, } from "@/lib/secondary-page-data"; -import { clearBirthSkyMemory } from "@/lib/birth-sky/cover"; import { missingOtherProfileStep, missingProfileStep, @@ -42,19 +36,15 @@ import { } from "@/lib/onboarding-intake"; import { saveOtherProfile } from "@/lib/other-profile-save"; import type { PersonRelation } from "@/lib/person-relation"; -import { notifyError, notifySuccess } from "@/lib/notify"; +import { notifyError } from "@/lib/notify"; import { extractOnboardingName, fallbackOnboardingName } from "@/lib/onboarding-name"; import { saveSelfName, saveSelfProfile } from "@/lib/self-profile-save"; import { createStartGreeting } from "@/lib/starter-greeting"; -import { clearHomeWarmSnapshot } from "@/lib/home-warm-snapshot"; import { type Account, - type AccountDialog, type ChartLibraryRecord, type OnboardingStep, - type OpenAccountDialogOptions, type Profile, - accountDialogOptions, emptyProfile, } from "@/lib/home-types"; import { preserveShallowEqual } from "@/lib/preserve-shallow-equal"; @@ -63,21 +53,14 @@ import type { BirthTimeAssessmentPhase } from "@/components/birth-time-assessmen export type ProfileOnboardingParams = { account: Account | null; accountRefreshGuard: MutableRefObject; - accountTrigger: MutableRefObject; - dialogReturnTargetRef: MutableRefObject; setAccount: Dispatch>; setAccountError: Dispatch>; - setAccountMenuOpen: Dispatch>; - setActiveAccountDialog: Dispatch>; setBirthTimeAssessmentPhase: Dispatch>; - setBillingPane: Dispatch>; setDraft: (value: string) => void; setOnboardingJustCompleted: Dispatch>; setOnboardingStep: Dispatch>; setPresetMessageLength: Dispatch>; - setSigningOut: Dispatch>; setStartGreeting: Dispatch>; - signingOut: boolean; uiPreview: MutableRefObject; /** Warm return to `/` (BUG-1040): the profile Home starts with instead of empty. */ initialProfile?: () => Profile | null; @@ -91,21 +74,14 @@ export function useProfileOnboarding(params: ProfileOnboardingParams) { const { account, accountRefreshGuard, - accountTrigger, - dialogReturnTargetRef, setAccount, setAccountError, - setAccountMenuOpen, - setActiveAccountDialog, setBirthTimeAssessmentPhase, - setBillingPane, setDraft, setOnboardingJustCompleted, setOnboardingStep, setPresetMessageLength, - setSigningOut, setStartGreeting, - signingOut, uiPreview, initialProfile, onOwnBirthPlaceSaved, @@ -117,7 +93,6 @@ export function useProfileOnboarding(params: ProfileOnboardingParams) { const [profile, setProfile] = useState(() => initialProfile?.() ?? emptyProfile); const [profileDraft, setProfileDraft] = useState(() => initialProfile?.() ?? emptyProfile); const [profileNotice, setProfileNotice] = useState(""); - const [avatarSaving, setAvatarSaving] = useState(false); const [profileSaving, setProfileSaving] = useState(false); const [intakeChoice, setIntakeChoice] = useState<"self" | "other" | null>(null); const [chosenOtherId, setChosenOtherId] = useState(null); @@ -156,59 +131,8 @@ export function useProfileOnboarding(params: ProfileOnboardingParams) { } - function openAccountDialog( - dialog: AccountDialog, - returnTargetOrOptions?: HTMLButtonElement | null | OpenAccountDialogOptions, - ) { - const options = accountDialogOptions(returnTargetOrOptions); - dialogReturnTargetRef.current = options.returnTarget ?? accountTrigger.current; - setAccountMenuOpen(false); - setAccountError(""); - if (dialog === "profile") { - setProfileNotice(""); - } - if (dialog === "chart-library") { - window.location.assign("/people"); - return; - } - if (dialog === "billing") { - setBillingPane({ - source: options.source, - plan: options.plan, - tab: options.tab, - }); - } - setActiveAccountDialog(dialog); - } - - function closeAccountDialog() { - if (signingOut) return; - setActiveAccountDialog(null); - const returnTarget = dialogReturnTargetRef.current; - window.requestAnimationFrame(() => returnTarget?.focus()); - } - - async function persistAvatar(patch: BeamAvatarPatch) { - if (!account?.avatar || avatarSaving) return; - setAvatarSaving(true); - try { - const response = await fetch("/api/account/avatar", { - method: "PATCH", - credentials: "same-origin", - headers: { "content-type": "application/json" }, - body: JSON.stringify(patch), - }); - const payload = await response.json().catch(() => null) as { avatar?: unknown; error?: string } | null; - if (!response.ok) throw new Error(payload?.error || "头像暂时无法保存。"); - const avatar = beamAvatarSchema.parse(payload?.avatar); - setAccount((current) => current ? { ...current, avatar } : current); - notifySuccess(patch.action === "randomize" ? "已生成并保存新头像。" : "头像配色已保存。"); - } catch (caught) { - notifyError(friendlyError(caught instanceof Error ? caught.message : "头像保存失败")); - } finally { - setAvatarSaving(false); - } - } + // The account dialogs, their avatar save and sign-out moved to the app + // shell on 2026-11-21 (BUG-2127): components/account-dialog-provider.tsx. async function persistProfile(nextProfile: Profile): Promise { if (!account) throw new Error("账户尚未加载完成"); @@ -390,28 +314,6 @@ export function useProfileOnboarding(params: ProfileOnboardingParams) { const onboardingDraft = intakeTarget === "other" && otherDraft ? otherDraft : profileDraft; - async function signOut() { - if (signingOut) return; - setSigningOut(true); - try { - // The auth client is only needed here, so it is not in the first screen (issue #125). - const { selfHostedOtpActions } = await import("@/modules/identity/client"); - // Signing out ends this account's warm return to `/` (BUG-1040); a - // failed sign-out only costs one loading ring on the next return. - // Nor does this account's chart stay in memory for the next one (BUG-1530). - clearChartPageCache(); - clearBirthSkyMemory(); - clearHomeWarmSnapshot(); - await selfHostedOtpActions.signOut(); - window.location.assign("/login"); - } catch (caught) { - const message = caught instanceof Error ? caught.message : "退出失败"; - notifyError(friendlyError(message)); - setSigningOut(false); - } - } - - return { profile, setProfile, @@ -424,16 +326,11 @@ export function useProfileOnboarding(params: ProfileOnboardingParams) { chooseOnboardingOther, profileNotice, setProfileNotice, - avatarSaving, profileSaving, refreshAccount, - openAccountDialog, - closeAccountDialog, - persistAvatar, persistProfile, saveOnboardingName, saveOnboardingBirth, saveOnboardingPlace, - signOut, }; } diff --git a/frontend/tests/account-dialogs-every-page-2127.test.tsx b/frontend/tests/account-dialogs-every-page-2127.test.tsx new file mode 100644 index 000000000..96094aa66 --- /dev/null +++ b/frontend/tests/account-dialogs-every-page-2127.test.tsx @@ -0,0 +1,271 @@ +/** + * BUG-2127. On any page that is not the chat page, choosing a settings entry in + * the avatar menu went to the chat page first and opened the dialog there: the + * dialogs were mounted by Home only, and off `/` the entries were links to + * `/?account=`. The dialogs now belong to the (app) shell and open in + * place on every page; Home calls the same `open`. + * Synthetic ids and profiles only. + */ +import "./install-test-document"; +import assert from "node:assert/strict"; +import { readFileSync } from "node:fs"; +import test from "node:test"; +import React, { createElement } from "react"; + +import { onboardingCatalogDecision, readProfile } from "../src/lib/home-profile.ts"; +import type { Account } from "../src/lib/home-types.ts"; +import { SessionListProvider, useSessionList } from "../src/lib/session-list-context.tsx"; +import { renderToStaticMarkup } from "react-dom/server"; +import { + AccountDialogHost, + AccountDialogProvider, + BillingDialogLink, + useAccountDialogInternals, + useAccountDialogs, +} from "../src/components/account-dialog-provider.tsx"; +import { createClientLifecycleHarness } from "./react-client-lifecycle-test-support.ts"; + +Object.assign(globalThis, { React }); + +const read = (path: string) => readFileSync(new URL(`../src/${path}`, import.meta.url), "utf8"); + +const USER = "00000000-0000-4000-8000-000000002127"; +const finishedProfile = { + name: "林遥", date: "1990-06-15", time: "12:30", reportedTime: "12:30", birthTimeSource: "hospital_record", + birthTimePeriod: "", declaredWindowStart: "", declaredWindowEnd: "", birthTimeClue: "", + birthTimeUncertaintyKnown: false, uncertaintyBeforeMinutes: null, uncertaintyAfterMinutes: null, + birthTimeStatus: "accepted", rectificationCaseId: "", countryCode: "CN", birthPlaceLabel: "北京市", + latitude: 39.9, longitude: 116.4, timezoneId: "Asia/Shanghai", timezoneOffset: 8, ayanamsa: "lahiri", +}; +const account = { + user: { id: USER, email: "fictional@example.test" }, + profile: finishedProfile, + avatar: { seed: "22222222-2222-4222-8222-222222222222", palette: 1, rendererVersion: 1 }, + credits: 7, + isAdmin: false, adminUrl: null, rectificationPriceCredits: 1, activeSubscription: null, + hasConfirmedBirthTime: true, hasUsableBirthTime: true, +} as unknown as Account; + +type Harness = ReturnType; +type HostNode = ReturnType[number]; + +function bodyNodes(h: Harness): HostNode[] { + const walk = (node: HostNode): HostNode[] => [node, ...node.childNodes.flatMap((child) => walk(child))]; + return [...h.document.body.childNodes].flatMap((child) => walk(child as HostNode)); +} + +function dialogTitle(h: Harness): string | null { + return bodyNodes(h).find((node) => node.getAttribute("id") === "account-dialog-title")?.text ?? null; +} + +/** + * The layout's providers on a page other than `/`, with the overlay host, and + * a probe that reads the shell's dialogs as a page would. + */ +async function mountShell(page: { pathname: string; search: string }, run: (shell: { + h: Harness; + dialogs: () => ReturnType; + internals: () => NonNullable>; + list: () => ReturnType; + assigned: string[]; + location: { pathname: string; search: string; hash: string }; + avatarPatches: unknown[]; +}) => Promise) { + const original = globalThis.fetch; + const avatarPatches: unknown[] = []; + const json = (body: unknown) => new Response(JSON.stringify(body), { status: 200, headers: { "content-type": "application/json" } }); + globalThis.fetch = (async (input: unknown, init?: RequestInit) => { + const path = new URL(String(input), "http://localhost").pathname; + if (path === "/api/account") return json(account); + if (path === "/api/chart-profiles") return json({ profiles: [] }); + if (path === "/api/sessions") return json({ sessions: [], nextCursor: null }); + if (path === "/api/account/avatar" && init?.method === "PATCH") { + avatarPatches.push(JSON.parse(String(init.body))); + return json({ avatar: { seed: "33333333-3333-4333-8333-333333333333", palette: 1, rendererVersion: 1 } }); + } + return new Response(JSON.stringify({ error: "not_mocked" }), { status: 404 }); + }) as typeof fetch; + const { resetSubjectCatalogForTests } = await import("../src/lib/current-subject.ts"); + resetSubjectCatalogForTests(); + let dialogs: ReturnType | null = null; + let internals: ReturnType = null; + let list: ReturnType | null = null; + function Probe() { + dialogs = useAccountDialogs(); + return createElement(BillingDialogLink, null, "去补点数"); + } + function ProbeState() { + internals = useAccountDialogInternals(); + list = useSessionList(); + return null; + } + const h = createClientLifecycleHarness(); + const assigned: string[] = []; + const location = { + pathname: page.pathname, search: page.search, hash: "", origin: "http://localhost", + get href() { return `http://localhost${this.pathname}${this.search}`; }, + assign(url: string) { assigned.push(url); }, + replace(url: string) { assigned.push(url); }, + }; + const win = globalThis.window as unknown as { location?: unknown; history?: unknown }; + const previousLocation = win.location; + const previousHistory = win.history; + win.location = location; + win.history = { + replaceState(_state: unknown, _title: string, url: string) { + const next = new URL(url, "http://localhost"); + location.pathname = next.pathname; + location.search = next.search; + }, + pushState(_state: unknown, _title: string, url: string) { assigned.push(`push:${url}`); }, + }; + try { + await h.render(createElement(SessionListProvider, null, + createElement(AccountDialogProvider, null, createElement(AccountDialogHost), createElement(Probe), createElement(ProbeState)))); + for (let tick = 0; tick < 6; tick += 1) await h.idle(); + await run({ + h, + dialogs: () => dialogs as unknown as ReturnType, + internals: () => internals as unknown as NonNullable>, + list: () => list as unknown as ReturnType, + assigned, + location, + avatarPatches, + }); + } finally { + await h.close(); + win.location = previousLocation; + win.history = previousHistory; + globalThis.fetch = original; + } +} + +test("on a page other than the chat page, a settings entry opens the dialog where the reader is", async () => { + await mountShell({ pathname: "/chart", search: "" }, async ({ h, dialogs, assigned, location }) => { + assert.ok(dialogs().activeDialog === null); + assert.equal(dialogTitle(h), null); + await h.update(() => dialogs().open("general", { returnTarget: null })); + await h.idle(); + assert.equal(dialogs().activeDialog, "general"); + assert.equal(dialogTitle(h), "设置", "the settings dialog is on screen"); + assert.deepEqual(assigned, [], "no navigation, no document load"); + assert.equal(location.pathname, "/chart"); + // The tab line inside the dialog moves between panes in place too. + await h.update(() => dialogs().open("profile", null)); + await h.idle(); + assert.equal(dialogs().activeDialog, "profile"); + assert.ok(bodyNodes(h).some((node) => node.text === "林遥"), "the profile pane shows the account's own name"); + await h.update(() => dialogs().close()); + await h.idle(); + assert.equal(dialogs().activeDialog, null); + assert.equal(dialogTitle(h), null); + assert.deepEqual(assigned, []); + assert.deepEqual(h.errors, []); + }); +}); + +test("the `/?account=` deep link still opens its dialog, on Home and on another page, and drops the parameter", async () => { + for (const pathname of ["/", "/reports"]) { + await mountShell({ pathname, search: "?account=billing&tab=redeem" }, async ({ h, dialogs, assigned, location }) => { + assert.equal(dialogs().activeDialog, "billing", pathname); + assert.equal(location.search, "?tab=redeem", "read once and removed, so a reload or Back never reopens it"); + assert.equal(location.pathname, pathname); + assert.deepEqual(assigned, []); + await h.update(() => dialogs().close()); + await h.idle(); + }); + } +}); + +test("BUG-2086: a profile write from the dialog on another page keeps the boot record current, so Home does not ask for the name again", async () => { + await mountShell({ pathname: "/synastry", search: "" }, async ({ h, dialogs, internals, list, avatarPatches }) => { + const bootAtOpen = list().boot(); + assert.ok(bootAtOpen?.account); + await h.update(() => dialogs().open("profile", null)); + await h.update(() => void internals().persistAvatar({ action: "randomize" })); + for (let tick = 0; tick < 4; tick += 1) await h.idle(); + assert.deepEqual(avatarPatches, [{ action: "randomize" }]); + const bootOnReturn = list().boot(); + assert.equal(bootOnReturn, bootAtOpen, "the same record, as the warm snapshot compares it"); + assert.equal(bootOnReturn?.account?.avatar?.seed, "33333333-3333-4333-8333-333333333333", "the saved avatar reached the record Home cold-starts from"); + const profile = readProfile(bootOnReturn?.account?.profile); + assert.equal(profile.name, "林遥"); + assert.equal(onboardingCatalogDecision(profile, []).step, null, "a finished profile is not sent back into onboarding"); + }); +}); + +test("the shell mounts the dialogs once; Home and the sidebar call the same open", () => { + const layout = read("app/(app)/layout.tsx"); + const page = read("app/(app)/page.tsx"); + const sidebar = read("components/app-sidebar.tsx"); + const provider = read("components/account-dialog-provider.tsx"); + assert.match(layout, /\s*\s*\{children\}<\/AppShell>\s*<\/AccountDialogProvider>\s*<\/SessionListProvider>/); + assert.equal(layout.match(//g)?.length, 1); + assert.match(layout, /onOpenAccountDialog=\{\(dialog, returnTarget\) => \{[\s\S]*?accountDialogs\.open\(dialog, \{ returnTarget, source: dialog === "billing" \? "account-menu" : undefined \}\);/); + // BUG-2072's watcher keeps its place right after the consent gate, with the same condition. + assert.match(layout, /\s*\{\/\*[^*]*\*\/\}\s*/); + // Home draws no overlay of its own and does not read the account for it. + assert.doesNotMatch(page, /]*onNavigate=\{close\}/); + // Focus back to the trigger, Esc, and the close button stay as they were on Home. + assert.match(provider, /window\.requestAnimationFrame\(\(\) => returnTarget\?\.focus\(\)\);/); + assert.match(provider, /if \(event\.key === "Escape"\)/); + assert.match(provider, /closeButtonRef\.current\?\.focus\(\);/); +}); + +test("「去补点数」 on a report or synastry page opens 账户与点数 over that page", async () => { + await mountShell({ pathname: "/reports/annual", search: "" }, async ({ h, dialogs, assigned, location }) => { + const link = h.elements().find((node) => node.tagName === "A" && node.text === "去补点数"); + assert.ok(link, "the 「去补点数」 link is rendered"); + // Still a real link to the deep link: a new tab or a render outside the shell lands on the same dialog. + assert.equal(link.getAttribute("href"), "/?account=billing"); + const propsKey = Object.keys(link).find((key) => key.startsWith("__reactProps$")); + assert.ok(propsKey); + const onClick = (link as unknown as Record void }>)[propsKey].onClick; + let prevented = false; + const click = (extra: Record = {}) => ({ + defaultPrevented: false, button: 0, metaKey: false, ctrlKey: false, shiftKey: false, altKey: false, + preventDefault() { prevented = true; }, ...extra, + }); + // A modified click keeps the browser's own link behaviour (new tab). + await h.update(() => onClick(click({ metaKey: true }))); + assert.equal(prevented, false); + assert.equal(dialogs().activeDialog, null); + await h.update(() => onClick(click())); + await h.idle(); + assert.equal(prevented, true, "the plain click does not navigate"); + assert.equal(dialogs().activeDialog, "billing"); + assert.equal(dialogTitle(h), "设置"); + assert.deepEqual(assigned, []); + assert.equal(location.pathname, "/reports/annual"); + await h.update(() => dialogs().close()); + await h.idle(); + }); + // Outside the shell the same element is a plain link to the deep link. + assert.equal(renderToStaticMarkup(createElement(BillingDialogLink, null, "去补点数")), '去补点数'); +}); + +test("every in-app 「去补点数」 uses the shell's dialog; only the deep-link reader and the link fallback name `/?account=`", () => { + // 原值:年运卡、个人报告开始卡是 ``,报告提问栏是 ``, + // 合盘确认框是 `window.location.assign(accountDialogHref("billing"))`——都先跳到聊天页再开弹窗 + // 新值:前三处是 ``(普通点击原地打开,href 仍是深链),合盘确认框直接调外壳的 open("billing") + // 原因:BUG-2127,账户弹窗搬到 (app) 外壳后每页原地打开;同类入口一并改 + for (const path of [ + "components/annual/annual-report-page.tsx", + "components/personal-report/personal-report-start-dialog.tsx", + "components/report-ask/report-ask-panel.tsx", + ]) { + const source = read(path); + assert.doesNotMatch(source, /accountDialogHref/, path); + assert.match(source, //, path); + } + const picker = read("components/synastry/synastry-picker.tsx"); + assert.doesNotMatch(picker, /accountDialogHref/); + const provider = read("components/account-dialog-provider.tsx"); + assert.match(provider, /dialogs\.open\("billing", \{ source: "insufficient-credits" \}\);/); +}); diff --git a/frontend/tests/account-menu-every-page-20260928.test.tsx b/frontend/tests/account-menu-every-page-20260928.test.tsx index 494a72dec..c75d28d90 100644 --- a/frontend/tests/account-menu-every-page-20260928.test.tsx +++ b/frontend/tests/account-menu-every-page-20260928.test.tsx @@ -57,17 +57,18 @@ test("the read-only sidebar renders the account menu's button, not a link home", assert.match(markup, /示例甲/); }); -test("the four dialog entries open in place on `/` and link to `/?account=` elsewhere; theme stays in place", () => { +test("the four dialog entries open in place on every page; theme stays in place", () => { assert.match(sidebar, /accountEntry\("profile", onOpenProfile,/); assert.match(sidebar, /accountEntry\("general", onOpenGeneral,/); assert.match(sidebar, /accountEntry\("billing", onOpenBilling,/); assert.match(sidebar, /accountEntry\("logout", onOpenLogout,/); const entry = sidebar.slice(sidebar.indexOf("function accountEntry("), sidebar.indexOf(" return (\n \}/); + // 原值:`return onOpen ? () : (}>)` + // 新值:只有一种 `DropdownMenuItem onClick={openInPlace}`:首页用 Home 的 controls,别的页用外壳的 onOpenAccountDialog + // 原因:BUG-2127,站外页点设置会先跳到聊天页再开弹窗;弹窗搬到 (app) 外壳后每页原地打开,不再链到 `/?account=` + assert.match(entry, /const openInPlace = onOpen \?\? \(\(\) => \{\s*setOwnMenuOpen\(false\);\s*onOpenAccountDialog\?\.\(dialog, ownTriggerRef\.current\);/); + assert.match(entry, //g)?.length, 1); // Off `/` the menu keeps its own open state; on `/` Home controls it. @@ -131,7 +132,12 @@ test("an unknown value is dropped from the URL and opens nothing", async () => { } }); -test("Home wires it in one line and does not grow", () => { - assert.match(page, /import \{ AccountDialogDeepLink, SynastryDeepLink \} from "@\/components\/people-home-links";/); - assert.equal(page.match(//g)?.length, 1); +test("the app shell wires the deep link in one line; Home no longer carries it", () => { + const provider = readFileSync(new URL("../src/components/account-dialog-provider.tsx", import.meta.url), "utf8"); + // 原值:page.tsx 里 `` + // 新值:外壳的 AccountDialogHost 里挂一次,按页面路径重读,账户一到就开 + // 原因:BUG-2127,弹窗搬进 (app) 外壳,`/?account=` 在任何页都能原地打开,首页不再单独挂 + assert.match(page, /import \{ SynastryDeepLink \} from "@\/components\/people-home-links";/); + assert.doesNotMatch(page, /AccountDialogDeepLink/); + assert.equal(provider.match(//g)?.length, 1); }); diff --git a/frontend/tests/beam-avatar.test.ts b/frontend/tests/beam-avatar.test.ts index f663c8b84..bd684f116 100644 --- a/frontend/tests/beam-avatar.test.ts +++ b/frontend/tests/beam-avatar.test.ts @@ -18,6 +18,7 @@ const avatarRoute = readProjectFile("src/app/api/account/avatar/route.ts"); const avatarComponent = readProjectFile("src/components/user-avatar.tsx"); const sidebar = readProjectFile("src/components/app-sidebar.tsx"); const page = readProjectFile("src/app/(app)/page.tsx"); +const accountDialogs = readProjectFile("src/components/account-dialog-provider.tsx"); const profilePanel = readProjectFile("src/components/profile-panel.tsx"); const migration = readProjectFile("db/migrations/20260807010000_profile_beam_avatars.sql"); @@ -114,7 +115,10 @@ test("renders the persisted Beam avatar in the sidebar, account menu, and profil // 新值:配色格里画这套配色本身(paletteFill(palette.colors)) // 原因:同一个 seed 的脸在八套配色里都是浅色,预览分不出配色(2026-11-03 设置改版复查) assert.match(profilePanel, //); - assert.match(page, / { // 原因: BUG-2059 assert.doesNotMatch(panelSource, /

|billing-summary|membership-order-row|刷新|href="\/membership/); assert.match(panelSource, /aria-label="账户与点数"/); - assert.match(pageSource, //); + // 原值:在 page.tsx 里找 `` + // 新值:在外壳的 account-dialog-provider.tsx 里找 + // 原因:BUG-2127,账户弹窗从首页搬到 (app) 外壳(components/account-dialog-provider.tsx),每页原地打开,内容不变 + assert.match(accountDialogsSource, //); assert.match(panelSource, /value="redeem"/); assert.match(panelSource, /value="ledger"/); assert.match(panelSource, /value="recharge"/); diff --git a/frontend/tests/chart-page-view.test.tsx b/frontend/tests/chart-page-view.test.tsx index 5a9871fec..47ec9c206 100644 --- a/frontend/tests/chart-page-view.test.tsx +++ b/frontend/tests/chart-page-view.test.tsx @@ -691,7 +691,10 @@ test("the (app) layout mounts one sidebar for home and the four secondary routes // 原因:TASK-session-list-single-source T2,列表只拉一次、侧栏不卸载 const layout = readFileSync(new URL("../src/app/(app)/layout.tsx", import.meta.url), "utf8"); assert.match(layout, //); - assert.match(layout, //); + // 原值:// + // 新值:再或上外壳的账户弹窗是否打开(accountDialogOpen) + // 原因:BUG-2127,账户弹窗从首页搬到 (app) 外壳(components/account-dialog-provider.tsx),每页原地打开 + assert.match(layout, //); assert.match(layout, / scenario(as assert.ok(peekReusableChartPage()); clearChartPageCache(); assert.equal(peekChartPage(), null); - const source = read("../src/hooks/use-profile-onboarding.ts"); - const signOut = source.slice(source.indexOf("async function signOut()")); + // 原值:read("../src/hooks/use-profile-onboarding.ts"),找 `async function signOut()` + // 新值:退出登录在外壳的 account-dialog-provider.tsx,`const signOut = useCallback(async () => {` + // 原因:BUG-2127,账户弹窗从首页搬到 (app) 外壳(components/account-dialog-provider.tsx),每页原地打开 + const source = read("../src/components/account-dialog-provider.tsx"); + const signOut = source.slice(source.indexOf("const signOut = useCallback(async () => {")); assert.ok(signOut.indexOf("clearChartPageCache()") > 0 && signOut.indexOf("clearChartPageCache()") < signOut.indexOf("selfHostedOtpActions.signOut()")); assert.ok(signOut.indexOf("clearBirthSkyMemory()") > 0 && signOut.indexOf("clearBirthSkyMemory()") < signOut.indexOf("selfHostedOtpActions.signOut()")); })); diff --git a/frontend/tests/chat-navigation-a11y-contract.test.ts b/frontend/tests/chat-navigation-a11y-contract.test.ts index 3c83e33ca..25824656f 100644 --- a/frontend/tests/chat-navigation-a11y-contract.test.ts +++ b/frontend/tests/chat-navigation-a11y-contract.test.ts @@ -113,7 +113,11 @@ test("auth redirects stay hard document loads so stale session state cannot surv // 原因: 状态下沉第二批把六个 profile 状态搬进 use-profile-onboarding.ts,hook 的 // return 现在以 profile 开头,refreshAccount 不再是第一个字段。切的还是 // signOut 函数体,断言主语(退出后硬跳 /login)一字未改。 - const signOut = sourceBetween(pageSource, "async function signOut()", "return {\n profile,"); + // 原值: sourceBetween(pageSource, "async function signOut()", "return {\n profile,") + // 新值: sourceBetween(pageSource, "const signOut = useCallback(async () => {", "}, []);") + // 原因: BUG-2127,退出登录随账户弹窗搬到 (app) 外壳(account-dialog-provider.tsx),每页原地打开; + // 切的仍是 signOut 函数体,断言主语(退出后硬跳 /login)一字未改。 + const signOut = sourceBetween(pageSource, "const signOut = useCallback(async () => {", "}, []);"); assert.match(signOut, /await selfHostedOtpActions\.signOut\(\);\n\s*window\.location\.assign\("\/login"\)/); // And: the billing pane keeps the same 401 precedent without a dedicated membership page. diff --git a/frontend/tests/credits-groundwork-2057.test.ts b/frontend/tests/credits-groundwork-2057.test.ts index 338d2a7c4..2aa4b42c6 100644 --- a/frontend/tests/credits-groundwork-2057.test.ts +++ b/frontend/tests/credits-groundwork-2057.test.ts @@ -399,7 +399,10 @@ test("BUG-2057: the 账户与点数 page shows the balance at once and asks for // 原值: 摘要句 billing-summary 和兑换页签不读套餐状态;套餐未知时用一行同高的 membership-empty 占位 // 新值: 余额由首页画(BillingBalance),兑换码页和点数记录页不读套餐状态;充值页在套餐未知时画三张同样大小的卡片骨架 // 原因: BUG-2059 把面板改成「余额 + 页签 + 三页」;BUG-2057 要守的事不变:余额和兑换不等套餐 - assert.match(page, //); + // 原值:在 page.tsx 里找 BillingBalance + // 新值:在外壳的 account-dialog-provider.tsx 里找 + // 原因:BUG-2127,账户弹窗从首页搬到 (app) 外壳(components/account-dialog-provider.tsx),每页原地打开,内容不变 + assert.match(read("src/components/account-dialog-provider.tsx"), //); const redeemTab = panel.slice(panel.indexOf('value="redeem">'), panel.indexOf('value="recharge">')); assert.ok(redeemTab.length > 500); assert.doesNotMatch(redeemTab, /packagesSettled|paymentEnabled/); @@ -411,10 +414,14 @@ test("BUG-2057: the 账户与点数 page shows the balance at once and asks for // 原因: BUG-2059,负责人:默认页签是兑换码,充值由后台开关控制、默认关 assert.match(panel, /const pages = billingPages\(paymentOpen\);/); assert.match(panel, /\{pages\.includes\("recharge"\) && \(/); - assert.match(page, /initialTab=\{billingPane\.tab\}/); + // 原值:initialTab 和「打开设置时预取」都在 page.tsx(`if (activeAccountDialog !== null) prefetchBillingPanel();`) + // 新值:这两处在外壳的 account-dialog-provider.tsx(`if (activeDialog !== null) prefetchBillingPanel();`);空闲预取仍在首页 + // 原因:BUG-2127,账户弹窗从首页搬到 (app) 外壳,每页原地打开 + const accountDialogs = read("src/components/account-dialog-provider.tsx"); + assert.match(accountDialogs, /initialTab=\{billingPane\.tab\}/); // The panel code is fetched while idle and when a settings section opens. assert.match(page, /if \(accountId && hydrated\) prefetchBillingPanelWhenIdle\(\);/); - assert.match(page, /if \(activeAccountDialog !== null\) prefetchBillingPanel\(\);/); + assert.match(accountDialogs, /if \(activeDialog !== null\) prefetchBillingPanel\(\);/); }); test("BUG-2057: the idle prefetch runs once and falls back to a timer", () => { diff --git a/frontend/tests/home-first-screen-deps-20261028.test.tsx b/frontend/tests/home-first-screen-deps-20261028.test.tsx index 2cbeb25f5..e88d99b55 100644 --- a/frontend/tests/home-first-screen-deps-20261028.test.tsx +++ b/frontend/tests/home-first-screen-deps-20261028.test.tsx @@ -21,7 +21,10 @@ const read = (path: string) => readFileSync(new URL(path, import.meta.url), "utf test("first-screen modules import none of the three click-only dependencies statically", () => { assert.doesNotMatch(read("../src/lib/birth-time-intake-model.ts"), /from "date-fns"/); - for (const path of ["../src/hooks/use-profile-onboarding.ts", "../src/components/account-deletion-gate.tsx"]) { + // 原值:["../src/hooks/use-profile-onboarding.ts", "../src/components/account-deletion-gate.tsx"] + // 新值:退出登录从 use-profile-onboarding.ts 搬到外壳的 account-dialog-provider.tsx,查它 + // 原因:BUG-2127,账户弹窗从首页搬到 (app) 外壳(components/account-dialog-provider.tsx),每页原地打开 + for (const path of ["../src/components/account-dialog-provider.tsx", "../src/components/account-deletion-gate.tsx"]) { const source = read(path); assert.doesNotMatch(source, /^import .*"@\/modules\/identity\/client"/m, path); assert.match(source, /await import\("@\/modules\/identity\/client"\)/, path); diff --git a/frontend/tests/home-surface.ts b/frontend/tests/home-surface.ts index a60e83256..087122d7d 100644 --- a/frontend/tests/home-surface.ts +++ b/frontend/tests/home-surface.ts @@ -30,6 +30,8 @@ const optionalHomeHookFiles = [ "../src/lib/home-bootstrap-run.ts", "../src/lib/consultation-recovery-poll.ts", "../src/lib/self-profile-save.ts", + // BUG-2127:账户弹窗(个人资料/账户与点数/通用设置/退出)从首页搬到 (app) 外壳,每页原地打开。 + "../src/components/account-dialog-provider.tsx", ] as const; export const homeSurface = [ diff --git a/frontend/tests/home-warm-snapshot.test.ts b/frontend/tests/home-warm-snapshot.test.ts index 06cdada36..8a7ebfb43 100644 --- a/frontend/tests/home-warm-snapshot.test.ts +++ b/frontend/tests/home-warm-snapshot.test.ts @@ -122,7 +122,10 @@ test("a 401 login redirect clears the snapshot", async () => { }); test("sign-out and the provider's signed-out and account-change branches clear the snapshot", () => { - const onboarding = readFileSync(new URL("../src/hooks/use-profile-onboarding.ts", import.meta.url), "utf8"); + // 原值:读 ../src/hooks/use-profile-onboarding.ts + // 新值:退出登录在外壳的 account-dialog-provider.tsx + // 原因:BUG-2127,账户弹窗从首页搬到 (app) 外壳(components/account-dialog-provider.tsx),每页原地打开 + const onboarding = readFileSync(new URL("../src/components/account-dialog-provider.tsx", import.meta.url), "utf8"); assert.match(onboarding, /clearHomeWarmSnapshot\(\);\n\s+await selfHostedOtpActions\.signOut\(\);\n\s+window\.location\.assign\("\/login"\);/); const provider = readFileSync(new URL("../src/lib/session-list-context.tsx", import.meta.url), "utf8"); assert.match(provider, /accountResult\.status === 401\) \{\n\s+clearHomeWarmSnapshot\(\);/); diff --git a/frontend/tests/session-list-provider.test.ts b/frontend/tests/session-list-provider.test.ts index 69d7fb4ea..b69a55340 100644 --- a/frontend/tests/session-list-provider.test.ts +++ b/frontend/tests/session-list-provider.test.ts @@ -12,7 +12,10 @@ const sessionHook = readFileSync(new URL("../src/hooks/use-session-management.ts test("the app layout owns one SessionListProvider and one SidebarProvider", () => { assert.match(layout, //); assert.equal(layout.match(//g)?.length, 1); - assert.match(layout, //); + // 原值:// + // 新值:再或上外壳的账户弹窗是否打开(accountDialogOpen) + // 原因:BUG-2127,账户弹窗从首页搬到 (app) 外壳(components/account-dialog-provider.tsx),每页原地打开 + assert.match(layout, //); assert.equal(layout.match(/` + // 新值:没有这种链接;弹窗项在每页都是按钮,交给外壳的 onOpenAccountDialog 原地打开 + // 原因:BUG-2127,账户弹窗从首页搬到 (app) 外壳(components/account-dialog-provider.tsx),每页原地打开,站外页不再先跳回聊天页 + assert.doesNotMatch(appSidebar, /accountDialogHref/); + assert.match(appSidebar, /onOpenAccountDialog\?\.\(dialog, ownTriggerRef\.current\)/); // And nothing in read-only mode can write: the write callbacks only exist // inside `controls`, which the secondary layout never passes. @@ -400,7 +404,10 @@ test("composes the chat page with the app sidebar shell", () => { const shell = readProjectFile("src/hooks/use-home-shell-registration.ts"); assert.match(page, /const modalOpen = activeAccountDialog !== null \|\| onboardingPaywallOpen/); - assert.match(layout, //); + // 原值:// + // 新值:再或上外壳的账户弹窗是否打开 + // 原因:BUG-2127,账户弹窗从首页搬到 (app) 外壳(components/account-dialog-provider.tsx),每页原地打开;别的页没有 Home 的登记,弹窗开着时手机抽屉也不能被 Esc 收起 + assert.match(layout, //); assert.match(layout, /
[\s\S]* const sidebar = readProjectFile("src/components/ui/sidebar.tsx"); assert.match(shell, /escapeBlocked: accountMenuOpen \|\| modalOpen/); - assert.match(layout, /escapeBlocked=\{registration\?\.escapeBlocked \?\? false\}/); + // 原值:/escapeBlocked=\{registration\?\.escapeBlocked \?\? false\}/ + // 新值:同上,再或上 accountDialogOpen + // 原因:BUG-2127,账户弹窗从首页搬到 (app) 外壳(components/account-dialog-provider.tsx),每页原地打开 + assert.match(layout, /escapeBlocked=\{\(registration\?\.escapeBlocked \?\? false\) \|\| accountDialogOpen\}/); assert.match(sidebar, /event\.key === "Escape" && isMobile && openMobile && !escapeBlocked/); }); diff --git a/frontend/tests/starter-questions.test.ts b/frontend/tests/starter-questions.test.ts index 6b9e04ba9..9ea3a570f 100644 --- a/frontend/tests/starter-questions.test.ts +++ b/frontend/tests/starter-questions.test.ts @@ -92,7 +92,11 @@ test("routes account actions through a menu and focused dialogs", () => { // When: the page source is inspected for independent menu and dialog routes. // Then: profile and logout stay focused dialogs; billing opens in the settings pane. assert.match(pageSource, /const \[accountMenuOpen, setAccountMenuOpen\] = useState\(false\)/); - assert.match(pageSource, /const \[activeAccountDialog, setActiveAccountDialog\] = useState\(null\)/); + // 原值:/const \[activeAccountDialog, setActiveAccountDialog\] = useState\(null\)/(首页自己的状态) + // 新值:状态在外壳 `const [activeDialog, setActiveDialog] = useState(null)`,首页读 `accountDialogs.activeDialog` + // 原因:BUG-2127,账户弹窗从首页搬到 (app) 外壳(components/account-dialog-provider.tsx),每页原地打开 + assert.match(pageSource, /const \[activeDialog, setActiveDialog\] = useState\(null\)/); + assert.match(pageSource, /const activeAccountDialog = accountDialogs\.activeDialog;/); assert.match(pageSource, /openAccountDialog\("profile"/); assert.match(pageSource, /openAccountDialog\("logout"/); assert.doesNotMatch(pageSource, /type AccountDialog = "profile" \| "redeem" \| "logout"/); diff --git a/frontend/tests/synastry-full-report.test.ts b/frontend/tests/synastry-full-report.test.ts index 1e0a037ec..29cca0c78 100644 --- a/frontend/tests/synastry-full-report.test.ts +++ b/frontend/tests/synastry-full-report.test.ts @@ -211,7 +211,11 @@ test("the synastry page is a static shell and reads the flag in the browser", () assert.match(picker, /会用掉 \$\{creditCost\} 点,余额 \$\{balance\} 点。/); assert.match(picker, /需要 \$\{creditCost\} 点,余额只有 \$\{balance\} 点。/); assert.match(picker, /去补点数/); - assert.match(picker, /accountDialogHref\("billing"\)/); + // 原值:/accountDialogHref\("billing"\)/——「去补点数」整页跳到 `/?account=billing`,落到聊天页再开弹窗 + // 新值:先关确认框,再用外壳的 open("billing", { source: "insufficient-credits" }) 在合盘页原地打开账户与点数 + // 原因:BUG-2127,账户弹窗搬到 (app) 外壳后每页原地打开;同类入口一并改 + assert.doesNotMatch(picker, /accountDialogHref/); + assert.match(picker, /setConfirming\(false\); accountDialogs\.open\("billing", \{ source: "insufficient-credits" \}\);/); const again = renderToStaticMarkup(createElement(SynastryGoNotes, { creditCost: 19, pricingNote: "", diff --git a/frontend/tests/ui-fixes-2070.test.ts b/frontend/tests/ui-fixes-2070.test.ts index cc12a757b..986ac8f46 100644 --- a/frontend/tests/ui-fixes-2070.test.ts +++ b/frontend/tests/ui-fixes-2070.test.ts @@ -53,7 +53,11 @@ test("a contents pick moves the page to its target after the chapter is drawn", test("a ledger row that opens another page closes the settings dialog", () => { assert.match(panel, /className="billing-row billing-ledger-row is-link" href=\{href\} onClick=\{onNavigate\}/); assert.match(panel, //); - assert.match(page, /]*onNavigate=\{closeAccountDialog\}/); + // 原值:/]*onNavigate=\{closeAccountDialog\}/ 在 page.tsx + // 新值:在外壳的 account-dialog-provider.tsx 里 `onNavigate={close}`(外壳的关弹窗,同一个函数也给首页用) + // 原因:BUG-2127,账户弹窗从首页搬到 (app) 外壳(components/account-dialog-provider.tsx),每页原地打开;任何页上点点数记录行都先关弹窗再跳转 + assert.doesNotMatch(page, /]*onNavigate=\{close\}/); }); test("the last rows of a long contents rail scroll clear of the floating button", () => { diff --git a/tests/test_session_management_entrypoints.py b/tests/test_session_management_entrypoints.py index 427fa50ea..05a638d9f 100644 --- a/tests/test_session_management_entrypoints.py +++ b/tests/test_session_management_entrypoints.py @@ -22,6 +22,8 @@ OPTIONAL_HOME_HOOKS = ( _FRONTEND_SRC / "hooks" / "use-consultation-run.ts", _FRONTEND_SRC / "hooks" / "use-profile-onboarding.ts", _FRONTEND_SRC / "hooks" / "use-rectification-surface.ts", + # BUG-2127:账户弹窗(含 Escape 关闭)从首页搬到 (app) 外壳,每页原地打开。 + _FRONTEND_SRC / "components" / "account-dialog-provider.tsx", ) STYLES = Path("frontend/src/app/globals.css") SESSION_ROW = Path("frontend/src/components/sidebar-session-row.tsx")