From 65f0e3da532cafeae58cf747461fc64c577f0b76 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 22 Nov 2026 18:45:00 +0800 Subject: [PATCH] feat(home): newcomer home opens on the three questions with the chart folded; the first-chart animation has a real skip button (BUG-2200, BUG-2201) Owner approved the v2 screenshots on 2026-11-22: no separate expand row; the existing top-right toggle opens the chart (own storage key), phones use the existing bottom sheet, and the normal layout returns after the first question. The old skip hint was aria-hidden, non-focusable 13px text. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01DbBXoyn7Hj3LCW3BUs5bZ8 --- docs/BUG_HISTORY.md | 26 ++++ frontend/src/app/(app)/page.tsx | 8 +- frontend/src/app/globals.css | 2 + .../birth-sky/birth-sky-converge.css | 13 +- .../birth-sky/birth-sky-converge.tsx | 20 ++- frontend/src/components/chat-chart-frame.tsx | 35 ++++- frontend/src/components/starter-questions.tsx | 6 +- frontend/src/lib/birth-sky/converge.ts | 8 ++ frontend/src/lib/starter-chart-details.ts | 49 +++++++ frontend/src/stores/ui-store.ts | 14 ++ frontend/tests/newcomer-2200-2201.test.tsx | 121 ++++++++++++++++++ .../onboarding-three-screens-2144.test.tsx | 9 +- ...rofile-onboarding-birth-sky-reveal.test.ts | 9 +- 13 files changed, 296 insertions(+), 24 deletions(-) create mode 100644 frontend/src/lib/starter-chart-details.ts create mode 100644 frontend/tests/newcomer-2200-2201.test.tsx diff --git a/docs/BUG_HISTORY.md b/docs/BUG_HISTORY.md index 0ca7f6111..d0a39b377 100644 --- a/docs/BUG_HISTORY.md +++ b/docs/BUG_HISTORY.md @@ -29682,3 +29682,29 @@ - 防复发:同一测试固定文字和标签。 - 关联记录:复用现有组件规则。 - 修复版本:`claude/acceptance-fixes-d`。 + +## BUG-2200 | 首次排盘后的星空动画只有一行不可聚焦的小字「点一下跳过」,着急看结果的人以为还在计算 + +- 状态:fixed-pending-verify。 +- 首次发现 / 最近更新:2026-11-22 / 2026-11-22。 +- 现象:负责人 2026-11-22 的 AI 验收(staging 1b2af85ba):首次排完盘的星空动画覆盖刚生成的结果,右下角「点一下跳过」很小。 +- 触发条件:新用户首次排盘后的动画(电脑和手机)。 +- 根因:BUG-2144 的「点一下跳过」是 aria-hidden、不可聚焦的 13px 文字,键盘和读屏用户都无法跳过,视觉上也不像按钮。 +- 修复:换成可聚焦的按钮「跳过,查看星盘」(现有按钮样式),键盘可达,点击即结束动画显示星盘。负责人看过截图后同意。 +- 验证:`frontend/tests/newcomer-2200-2201.test.tsx`;截图 /workspace/eval-read-1116/newcomer-2200/desktop-1*、phone-1(本地构建 + 模拟数据)。 +- 防复发:同上测试。 +- 关联记录:BUG-2144。 +- 修复版本:`claude/newcomer-2200`。 + +## BUG-2201 | 新手首页同时铺开完整星盘和提问,第一次进来不知道先看哪个 + +- 状态:fixed-pending-verify。 +- 首次发现 / 最近更新:2026-11-22 / 2026-11-22。 +- 现象:AI 验收:桌面首页左侧导航、中间输入、右侧完整星盘同时出现,`Bhava`、`D9`、`罗睺` 等进阶内容在入门阶段就出现。 +- 触发条件:还没发出第一问的新用户首页(电脑和手机)。 +- 根因:#114 起星盘面板默认展开,对所有用户一样。 +- 修复:新手首页标题「从这三个问题开始」;星盘面板默认收起(`chat-chart-frame.tsx` 的 `useStarterChartFold`,layout effect,避免先闪出展开状态),用右上角原有按钮开合,桌面记在单独的键 `starter_chart_details_open`,不动 `chat_chart_panel_open`;手机同一按钮打开原有底部面板;发出第一问后恢复现有布局和已存状态。负责人看 v1 截图后要求去掉「展开星盘详情」那一行,v2 截图同意。 +- 验证:`frontend/tests/newcomer-2200-2201.test.tsx`;截图 /workspace/eval-read-1116/newcomer-2200/*-v2.png(本地构建 + 模拟数据)。 +- 防复发:同上测试。 +- 关联记录:#114、BUG-1431、BUG-2050、BUG-2144。 +- 修复版本:`claude/newcomer-2200`。 diff --git a/frontend/src/app/(app)/page.tsx b/frontend/src/app/(app)/page.tsx index 9b633e282..bfcdcf769 100644 --- a/frontend/src/app/(app)/page.tsx +++ b/frontend/src/app/(app)/page.tsx @@ -19,7 +19,7 @@ import { toggleChatMessageFeedback } from "@/components/chat-message-actions"; import type { ChatTranscriptActions } from "@/components/chat-transcript"; import { ChatStreamingTranscript, useStreamingReplyHasText } from "@/components/chat-streaming-transcript"; import { ChatProfilePicker } from "@/components/chat-profile-picker"; -import { ChatChartFrame, ChatChartToggle } from "@/components/chat-chart-frame"; +import { ChatChartFrame, ChatChartToggle, useStarterChartFold } from "@/components/chat-chart-frame"; import { usePageCurtain } from "@/hooks/use-page-curtain"; import { readStoredChatChartOpen } from "@/lib/chat-chart-panel-state"; import { preloadChatChartPanel } from "@/lib/chat-chart-preload"; @@ -570,6 +570,10 @@ export default function Home() { && !activeSession.messagesHydrated && pendingSessionId !== activeSession.id, ); + // BUG-2201: the free first question is unused: the three starters lead and the natal panel is folded. + const newcomerHome = starterHomeVisible && account?.firstConsultFree === true + && (currentSubjectId === "self" ? selfChartComplete(profile) : Boolean(dailyProfile && selfChartComplete(dailyProfile))); + useStarterChartFold(newcomerHome); // BUG-2144: every onboarding screen, the name included, is a card; the composer waits until the chart is made. const onboardingFormActive = !synastryChat && subjectCatalogReady && !profileComplete; const starterHasPriorSessions = sessions.some((session) => session.id !== activeSession?.id); @@ -1062,7 +1066,7 @@ export default function Home() { {!onboardingFormActive &&
- {starterHomeVisible && account?.firstConsultFree === true && (currentSubjectId === "self" ? selfChartComplete(profile) : Boolean(dailyProfile && selfChartComplete(dailyProfile))) ? ( + {newcomerHome ? ( {subjectLine ?

{subjectLine}

: null} - {mode === "reveal" ? : null} + {mode === "reveal" ? ( +
+ +
+ ) : null} {controls} , document.body, diff --git a/frontend/src/components/chat-chart-frame.tsx b/frontend/src/components/chat-chart-frame.tsx index 66a25ed15..926da2142 100644 --- a/frontend/src/components/chat-chart-frame.tsx +++ b/frontend/src/components/chat-chart-frame.tsx @@ -1,7 +1,7 @@ "use client"; import { PanelRightClose, PanelRightOpen } from "lucide-react"; -import { useEffect, useState, type ReactNode } from "react"; +import { useEffect, useLayoutEffect, useState, type ReactNode } from "react"; import { ChartStyleIcon } from "@/components/chart-style-icon"; import { Button } from "@/components/ui/button"; @@ -9,16 +9,42 @@ import { useSidebar } from "@/components/ui/sidebar"; import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip"; import { peekChatChartSplit, preloadChatChartSplit, type ChatChartSplitComponent } from "@/lib/chat-chart-preload"; import { useCurrentSubject } from "@/lib/current-subject"; +import { chatChartPanelOpen } from "@/lib/starter-chart-details"; import { useUiStore } from "@/stores/ui-store"; type SheetComponent = (props: { open: boolean; onOpenChange: (open: boolean) => void }) => ReactNode; type SplitComponent = ChatChartSplitComponent; +/** + * BUG-2201: while the newcomer home is on screen the panel is in fold mode + * (folded unless this browser opened it). A layout effect: it runs before + * paint, so the open-by-default panel is never painted on a newcomer home. + */ +export function useStarterChartFold(active: boolean): void { + const setFold = useUiStore((state) => state.setStarterChartFold); + useLayoutEffect(() => { + if (!active) return; + setFold(true); + return () => setFold(false); + }, [active, setFold]); +} + +/** + * The desktop panel's open state and its setter. On the newcomer home + * (BUG-2201) both are the newcomer fold; otherwise the regular panel. + */ +export function useChatChartPanel(): { open: boolean; setOpen: (open: boolean) => void } { + const fold = useUiStore((state) => state.starterChartFold); + const open = useUiStore(chatChartPanelOpen); + const setPanelOpen = useUiStore((state) => state.setChatChartOpen); + const setDetailsOpen = useUiStore((state) => state.setStarterChartDetailsOpen); + return { open, setOpen: fold ? setDetailsOpen : setPanelOpen }; +} + export function ChatChartToggle() { const { isMobile, ready } = useSidebar(); - const open = useUiStore((state) => state.chatChartOpen); - const setOpen = useUiStore((state) => state.setChatChartOpen); + const { open, setOpen } = useChatChartPanel(); const setSheetOpen = useUiStore((state) => state.setChatChartSheetOpen); if (!ready) return null; if (isMobile) { @@ -69,11 +95,10 @@ export function ChatChartToggle() { export function ChatChartFrame({ children }: { children: ReactNode }) { const { isMobile, ready } = useSidebar(); const subjectId = useCurrentSubject(); - const open = useUiStore((state) => state.chatChartOpen); + const { open, setOpen } = useChatChartPanel(); const width = useUiStore((state) => state.chatChartWidth); const hydrated = useUiStore((state) => state.chatChartHydrated); const hydrate = useUiStore((state) => state.hydrateChatChart); - const setOpen = useUiStore((state) => state.setChatChartOpen); const setWidth = useUiStore((state) => state.setChatChartWidth); // Warmed by the home bootstrap behind the curtain: then it is here in the first render. const [Split, setSplit] = useState(() => peekChatChartSplit()); diff --git a/frontend/src/components/starter-questions.tsx b/frontend/src/components/starter-questions.tsx index 5e0fbc4f7..e1cf0f251 100644 --- a/frontend/src/components/starter-questions.tsx +++ b/frontend/src/components/starter-questions.tsx @@ -13,6 +13,7 @@ import { } from "@/lib/starter-questions"; // BUG-2161: the third starter tells the server it came from this button (it asks for the plan and deadline first). import { STARTER_PLAN_TIMING_ENTRYPOINT } from "@/lib/plan-timing-clarify"; +import { STARTER_QUESTIONS_TITLE } from "@/lib/starter-chart-details"; import { AppLink } from "@/components/app-link"; import { RECTIFICATION_PAGE_HREF } from "@/lib/chat-session-url"; import type { Theme } from "@/lib/home-types"; @@ -20,8 +21,8 @@ import type { Theme } from "@/lib/home-types"; /** * The first question (BUG-2144): three equal cards right above the composer, * as wide as its column (three in a row, stacked at 640px and below). All three - * send. The greeting above already invites the question, so there is no lead - * line of its own. + * send. BUG-2201 (owner 2026-11-22): the group is headed 「从这三个问题开始」, + * so a newcomer knows where to begin. */ export function StarterQuestions({ audience, @@ -53,6 +54,7 @@ export function StarterQuestions({ }, [moonKnown, subjectId]); return (
+

{STARTER_QUESTIONS_TITLE}

{audience.kind === "other" ? {starterWatching(audience)} : null}
diff --git a/frontend/src/lib/birth-sky/converge.ts b/frontend/src/lib/birth-sky/converge.ts index 39e349f08..5fe30212a 100644 --- a/frontend/src/lib/birth-sky/converge.ts +++ b/frontend/src/lib/birth-sky/converge.ts @@ -125,6 +125,14 @@ export type BirthSkyRevealTimeline = Readonly<{ */ export type BirthSkyRevealMode = "reveal" | "hold"; +/** BUG-2200: the one control on the first-chart reveal. */ +export const BIRTH_SKY_SKIP_LABEL = "跳过,查看星盘"; + +/** BUG-2200: with reduced motion the first-chart reveal is skipped; the chart page's replay (`hold`) still shows its poster. */ +export function birthSkyRevealSkipped(mode: BirthSkyRevealMode, reducedMotion: boolean): boolean { + return mode === "reveal" && reducedMotion; +} + /** `hold`: elapsed time at which the settled frame is fully on screen (words faded in). */ export function birthSkyHoldAtMs(reducedMotion: boolean): number { return reducedMotion ? REDUCED_FADE_IN_MS : BIRTH_SKY_CONVERGE_MS + TEXT_FADE_IN_MS; diff --git a/frontend/src/lib/starter-chart-details.ts b/frontend/src/lib/starter-chart-details.ts new file mode 100644 index 000000000..176544fa5 --- /dev/null +++ b/frontend/src/lib/starter-chart-details.ts @@ -0,0 +1,49 @@ +/** + * BUG-2201: the newcomer home (the free first question is still unused) leads + * with the three starter questions and the composer; the natal panel starts + * folded and the top bar's existing chart button opens it (owner 2026-11-22: + * no separate 「展开星盘详情」 row). Whether the reader opened it is remembered + * per browser, apart from the regular panel's `chat_chart_panel_open`: once + * the first question is asked, the home is today's layout with today's default. + */ + +import { chatChartStorage, type ChatChartStorage } from "@/lib/chat-chart-panel-state"; + +export const STARTER_CHART_DETAILS_STORAGE_KEY = "starter_chart_details_open"; +export const STARTER_QUESTIONS_TITLE = "从这三个问题开始"; + +/** Folded unless this browser stored an explicit unfold. */ +export function readStoredStarterChartDetailsOpen( + storage: ChatChartStorage | null = chatChartStorage(), +): boolean { + if (storage === null) return false; + try { + return storage.getItem(STARTER_CHART_DETAILS_STORAGE_KEY) === "1"; + } catch { + return false; + } +} + +export function writeStoredStarterChartDetailsOpen( + open: boolean, + storage: ChatChartStorage | null = chatChartStorage(), +): void { + if (storage === null) return; + try { + storage.setItem(STARTER_CHART_DETAILS_STORAGE_KEY, open ? "1" : "0"); + } catch { + /* private mode */ + } +} + +/** + * The desktop panel's open state. A newcomer home uses its own fold (default + * folded); everyone else keeps the regular panel state (default open). + */ +export function chatChartPanelOpen(state: { + readonly starterChartFold: boolean; + readonly starterChartDetailsOpen: boolean; + readonly chatChartOpen: boolean; +}): boolean { + return state.starterChartFold ? state.starterChartDetailsOpen : state.chatChartOpen; +} diff --git a/frontend/src/stores/ui-store.ts b/frontend/src/stores/ui-store.ts index 9332c3a29..0ed7a1598 100644 --- a/frontend/src/stores/ui-store.ts +++ b/frontend/src/stores/ui-store.ts @@ -11,6 +11,7 @@ import { writeStoredChatChartOpen, writeStoredChatChartWidth, } from "@/lib/chat-chart-panel-state"; +import { readStoredStarterChartDetailsOpen, writeStoredStarterChartDetailsOpen } from "@/lib/starter-chart-details"; import { readStoredChartBoardStyle, writeStoredChartBoardStyle, @@ -35,6 +36,11 @@ type UiState = { setChatChartOpen: (open: boolean) => void; setChatChartWidth: (width: number) => void; hydrateChatChart: () => void; + /** BUG-2201: the newcomer home is on screen; the panel follows `starterChartDetailsOpen` (default folded), toggled by the top bar's chart button. */ + starterChartFold: boolean; + setStarterChartFold: (fold: boolean) => void; + starterChartDetailsOpen: boolean; + setStarterChartDetailsOpen: (open: boolean) => void; /** Phone bottom sheet with the chat's board; not persisted. */ chatChartSheetOpen: boolean; setChatChartSheetOpen: (open: boolean) => void; @@ -78,10 +84,18 @@ export const useUiStore = create((set) => ({ hydrateChatChart: () => { set({ chatChartOpen: readStoredChatChartOpen(), + starterChartDetailsOpen: readStoredStarterChartDetailsOpen(), chatChartWidth: readStoredChatChartWidth(), chatChartHydrated: true, }); }, + starterChartFold: false, + setStarterChartFold: (fold) => set({ starterChartFold: fold }), + starterChartDetailsOpen: false, + setStarterChartDetailsOpen: (open) => { + writeStoredStarterChartDetailsOpen(open); + set({ starterChartDetailsOpen: open }); + }, chatChartSheetOpen: false, setChatChartSheetOpen: (open) => set({ chatChartSheetOpen: open }), chatChartFocus: null, diff --git a/frontend/tests/newcomer-2200-2201.test.tsx b/frontend/tests/newcomer-2200-2201.test.tsx new file mode 100644 index 000000000..6afca83ec --- /dev/null +++ b/frontend/tests/newcomer-2200-2201.test.tsx @@ -0,0 +1,121 @@ +import "./install-test-document"; +import assert from "node:assert/strict"; +import { readFileSync } from "node:fs"; +import test from "node:test"; +import React from "react"; +import { renderToStaticMarkup } from "react-dom/server"; + +import { createClientLifecycleHarness } from "./react-client-lifecycle-test-support"; +import { BIRTH_SKY_SKIP_LABEL, birthSkyRevealSkipped } from "../src/lib/birth-sky/converge"; +import { ChatChartToggle, useStarterChartFold } from "../src/components/chat-chart-frame"; +import { StarterQuestions } from "../src/components/starter-questions"; +import { SidebarProvider } from "../src/components/ui/sidebar"; +import { CHAT_CHART_OPEN_STORAGE_KEY, type ChatChartStorage } from "../src/lib/chat-chart-panel-state"; +import { + STARTER_CHART_DETAILS_STORAGE_KEY, + chatChartPanelOpen, + readStoredStarterChartDetailsOpen, + writeStoredStarterChartDetailsOpen, +} from "../src/lib/starter-chart-details"; +import { useUiStore } from "../src/stores/ui-store"; + +Object.assign(globalThis, { React }); + +const read = (path: string) => readFileSync(new URL(`../src/${path}`, import.meta.url), "utf8"); +const css = read("app/globals.css"); +const noop = () => undefined; + +function memoryStorage(seed: Record = {}): ChatChartStorage & { values: Map } { + const values = new Map(Object.entries(seed)); + return { values, getItem: (key) => values.get(key) ?? null, setItem: (key, value) => { values.set(key, String(value)); } }; +} + +test("BUG-2200: the first-chart reveal has a real, focusable 「跳过,查看星盘」 button and is not played with reduced motion", () => { + const converge = read("components/birth-sky/birth-sky-converge.tsx"); + const style = read("components/birth-sky/birth-sky-converge.css"); + assert.equal(BIRTH_SKY_SKIP_LABEL, "跳过,查看星盘"); + // A UI-kit Button (a native