From 7562b79a6a57fecd9e39a0bc93269cc52cb3ffbc Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 00:46:31 +0800 Subject: [PATCH] feat(chat): questions on every new conversation with a refresh icon (BUG-2282); the waiting screen draws the person's chart and plain steps from the run's real events (BUG-2283) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01DbBXp2Vp62Ur3C7yRWQdSq --- docs/BUG_HISTORY.md | 27 ++ frontend/src/app/(app)/page.tsx | 8 +- frontend/src/app/globals.css | 54 +++- frontend/src/components/chat-message-row.tsx | 6 +- frontend/src/components/chat-wait-board.tsx | 63 +++++ .../src/components/chat-wait-progress.tsx | 97 +++++++ .../components/consultation-run-timeline.tsx | 5 +- frontend/src/components/starter-questions.tsx | 106 +++++-- frontend/src/hooks/use-consultation-run.ts | 4 + frontend/src/lib/chat-chart-areas.ts | 14 + frontend/src/lib/chat-wait-progress.ts | 267 ++++++++++++++++++ frontend/src/lib/chat-wait-store.ts | 43 +++ frontend/src/lib/starter-questions.ts | 106 +++++++ .../tests/chat-wait-progress-2283.test.tsx | 187 ++++++++++++ frontend/tests/newcomer-2200-2201.test.tsx | 8 +- .../tests/onboarding-intake-20261022.test.ts | 21 +- .../onboarding-three-screens-2144.test.tsx | 6 +- frontend/tests/starter-arrive-2282.test.tsx | 85 ++++++ .../starter-plan-entrypoint-2160.test.ts | 12 +- 19 files changed, 1081 insertions(+), 38 deletions(-) create mode 100644 frontend/src/components/chat-wait-board.tsx create mode 100644 frontend/src/components/chat-wait-progress.tsx create mode 100644 frontend/src/lib/chat-wait-progress.ts create mode 100644 frontend/src/lib/chat-wait-store.ts create mode 100644 frontend/tests/chat-wait-progress-2283.test.tsx create mode 100644 frontend/tests/starter-arrive-2282.test.tsx diff --git a/docs/BUG_HISTORY.md b/docs/BUG_HISTORY.md index 6438db95f..e5adace51 100644 --- a/docs/BUG_HISTORY.md +++ b/docs/BUG_HISTORY.md @@ -30815,3 +30815,30 @@ - 防复发:新形状的节名和标签只在 `chat-answer-shape.ts` 里定义,写法、解析和页面都引用它;改标题必须同时过 `chat-answer-shape-2281` 的解析和渲染测试。旧回答渲染由同一测试逐字比对。 - 关联记录:BUG-2247(正文说人话、编号和判断依据,本次在它上面改形状和长度)、BUG-2248(加粗配对,新形状照常经过)、BUG-2241(土星压力段覆盖,时间条语气用它)、BUG-2239(运期覆盖行)、BUG-2235(补写只补必看层)、BUG-2229(问答写法)、BUG-1539(推荐问题按回答生成;新形状的回答自带)、BUG-2182(用户要的长度优先,照旧)。 - 修复版本:分支 `claude/chat-ux-answer`(本地提交,待父会话推送 staging)。 + +## BUG-2282 | 新对话进来不知道问什么:常用问题藏在输入框的小按钮里,三个起步问题只在第一次免费提问前出现 + +- 状态:fixed-pending-verify(待负责人看截图、staging 实测)。 +- 首次发现 / 最近更新:2026-11-24 / 2026-11-24。 +- 现象:内测用户反馈,进来以后不知道该问什么;「常用问题」藏在输入框左边的小按钮里;首页的三个起步问题只在第一次免费提问还没用掉时出现(BUG-1431、BUG-2144),老用户新开对话只有问候语和输入框。 +- 触发条件:任何已建档用户新开一个空的问答对话(首问免费已用过)。 +- 根因:不是代码缺陷。BUG-1431 定的「起步三问只在首问免费未用时显示」;之后常用问题库(12 组,每组 5 条)只从输入框按钮进入。 +- 修复(负责人 2026-11-24 同意原型「刚进来」,同日改为一次三问 + 刷新图标):`frontend/src/app/(app)/page.tsx` 新增 `starterQuestionsVisible`:首问免费未用时照旧(`newcomerHome`),另外在每个新的空问答对话里也显示(不含合盘对话、已删的人、旧的生时纠正对话)。`StarterQuestions` 改为三张卡,每张前面一个话题词(例如「性格」「工作」「感情」「钱」,`starter-question-topic`,说明文字样式,无提示副标题),点一下就发;标题右边一枚刷新图标(`aria-label` 「换一组」,ghost 图标按钮),点一下三张一起换成下一组,三个不同话题,循环。第一组就是原来的三个起步问题(「我是一个什么样的人?」「未来两年事业有哪些变化」「今年推进重要计划,先看什么?」,第三问仍带 plan-timing 入口,出生时间是估的仍链到生时纠正);之后各组取自常用问题库(`starterLibrarySets`:工作 / 感情 / 钱 / 性格在前,其余话题按库的顺序;只取不用填空就能发的、标题里没有术语的问题;帮别人看时沿用「我」换成对方称呼的规则)。卡片固定高度(电脑 88px,两行问题 + 话题词;手机 68px,话题词在左),换一组时输入框不动;换组淡入 180ms,减少动态时没有动画。标题:首问免费未用时仍是「从这三个问题开始」(BUG-2201),老用户是原型的「想知道什么,点一个就能问」。 +- 老用户的变化:新开的空对话里,问候语下面多了这一块(标题、刷新图标、三张卡),其他不变:星盘面板照旧按已存的开合状态(只有新手首页默认收起,`useStarterChartFold(newcomerHome)` 未改);输入框的「常用问题」按钮照旧;扣点、首问免费的判断和发送路径(`startSuggestedConsultation`)不变。 +- 验证:新增 `frontend/tests/starter-arrive-2282.test.tsx`(第一组与话题词、后续各组三个不同话题、无术语、可直接发、不重复、帮别人看换称呼;点一下发送、刷新换组并循环回第一组;每个新空对话显示、新手标题和收起与扣点条件不变;固定卡高与减少动态)。按原值 / 新值 / 原因更新:`onboarding-intake-20261022`、`onboarding-three-screens-2144`、`newcomer-2200-2201`、`starter-plan-entrypoint-2160`。截图(组件渲染,用产品编译后的样式表;登录态的真实页面本机没有起):`/workspace/eval-read-1116/chat-ux-prototype/build/entry-arrive-{phone,desktop}-{light,dark}.png`。 +- 防复发:上面的测试。 +- 关联记录:BUG-1431、BUG-2144、BUG-2160、BUG-2199、BUG-2201、BUG-2279(协调窗口的「换一组」,本条在每个新对话上实现同样行为并加话题词)。 +- 修复版本:分支 `claude/chat-ux-entry-wait`(未推送)。 + +## BUG-2283 | 等回答的时候只有一行文字,感觉不到是在看自己的星盘 + +- 状态:fixed-pending-verify(待负责人看截图、staging 实测)。 +- 首次发现 / 最近更新:2026-11-24 / 2026-11-24。 +- 现象:内测用户反馈,产品不像是在解读她自己的盘;等回答的半分钟到两分钟里只有一行状态(BUG-2048)。 +- 触发条件:任何问答在回答出字之前。 +- 根因:不是代码缺陷。BUG-2048 的一行状态只说「正在……」,不画盘。 +- 修复(负责人 2026-11-24 同意原型「等回答的时候」,盘上不画星):回答出字前,回答位置上显示这次问的那个人的星盘(产品自己的 `ChartBoardSvg`,用户选的南北式,220px,只有格子,不画星、不写星座和宫号),上面一行小字说是哪张盘(默认「本命盘」),下面是白话步骤。全部由路由已经发出的真实事件驱动,没有计时器(`frontend/src/lib/chat-wait-progress.ts`):`skill.started`(对话第一问)→「先看性格的底子」亮「性格」;`tool.started` 带的领域 → 每个领域一行(「再看事业这一块」等),亮这个领域在路由里的宫(`requiredLayers` 里的宫号,经共用表 `frontend/src/lib/chat-chart-areas.ts` 写成白话名);`chart-calculation` 的「第 i/N 项」→ 第 i 个领域成为当前;`tool.completed` 且路由的领域要用 D10 / D9 →「换到专门看事业 / 感情的那张盘」,画面换成那张盘、只亮它对应的一块,标题换成白话名;查卡外资料的 `activity`「正在多看一眼:D10 分盘…」同样换盘(只认 D10、D9 两张有白话名的盘),查大运、行运类 →「(回到本命盘,)对一遍这几年的时间」,查别的 →「再多看一处细节」;`answer-composition`(不是查资料那句)、`phase.started compose`、第一段正文 →「正在整理回答」。亮过的地方一直亮着;换盘那一步结束后回到本命盘,之前的地方仍亮。某一步慢,就一直停在那一步。接着问的回合不显示第一步,列表更短。盘的数据只读页面已经有的星盘缓存(`peekChartPage`,同一个人才用),不发任何请求;没有缓存时只显示步骤;South 式缺那张分盘时不换画面。事件对不上(旧路径、闲聊、出错、接着问还没到领域)时照旧显示原来的一行状态;原来的一行状态一直挂着(隐藏),用时和完成后「分析了 N 步」不变。正文一出字就回到原来的一行「正在写回答」,回答不被推动。亮的格子 0.5s 淡入,减少动态时直接出现;读屏读步骤列表和一条 `aria-live` 的当前步骤,盘是带标签的装饰图。聊天里没有「可以先离开」这类现成的句子,没有新加。 +- 验证:新增 `frontend/tests/chat-wait-progress-2283.test.tsx`(7 条:共用表与领域取宫、事业 / 钱 / 感情 / 综合 / 两个领域的步骤与亮区、只在事件出现时换盘、退回一行状态的各种情况、组件渲染与隐藏的一行状态、不发请求不画星、缺分盘时南北式的处理),事件序列按 `stream-agent-response.ts` 和 `consultation-tools.ts` 实际发出的顺序录入。截图(组件渲染:真实组件 + 产品编译后的样式表 + 测试用的公开示例盘,未登录真实页面):`/workspace/eval-read-1116/chat-ux-prototype/build/entry-wait-{early,switch,last}-{phone,desktop}-{light,dark}.png`、`entry-wait-switch-south-phone-light.png`。 +- 防复发:上面的测试;`use-consultation-run.ts` 用同一份事件喂时间线和等待画面。 +- 关联记录:BUG-2048、BUG-2053、BUG-2241(改成白话那一步已去掉,不出现在步骤里)、BUG-2281(回答里的「从你的星盘里看出来的」用同一张白话表)。 +- 修复版本:分支 `claude/chat-ux-entry-wait`(未推送)。 diff --git a/frontend/src/app/(app)/page.tsx b/frontend/src/app/(app)/page.tsx index bfcdcf769..316a3a152 100644 --- a/frontend/src/app/(app)/page.tsx +++ b/frontend/src/app/(app)/page.tsx @@ -574,6 +574,11 @@ export default function Home() { const newcomerHome = starterHomeVisible && account?.firstConsultFree === true && (currentSubjectId === "self" ? selfChartComplete(profile) : Boolean(dailyProfile && selfChartComplete(dailyProfile))); useStarterChartFold(newcomerHome); + // BUG-2282: the three questions show on every new, empty conversation (原值:只在首问免费未用时,BUG-1431; + // 原因:内测用户进来不知道问什么,负责人 2026-11-24 同意原型「刚进来」). The fold and the first-question billing are unchanged. + const starterQuestionsVisible = newcomerHome || (starterHomeVisible + && activeSession?.sessionType === "consultation" + && !synastryChat && !subjectDeleted && !retiredRectificationSession); // 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); @@ -1066,8 +1071,9 @@ export default function Home() { {!onboardingFormActive &&
- {newcomerHome ? ( + {starterQuestionsVisible ? ( + // BUG-2283: before the answer has text, the chart and plain steps (falls back to this same one-line status). + ? : null; // Above the answer while the run is live. The slot stays for the fold-away // after it, so the same element carries the transition. diff --git a/frontend/src/components/chat-wait-board.tsx b/frontend/src/components/chat-wait-board.tsx new file mode 100644 index 000000000..f578b241a --- /dev/null +++ b/frontend/src/components/chat-wait-board.tsx @@ -0,0 +1,63 @@ +"use client"; + +import { useEffect, useMemo } from "react"; + +import { ChartBoardSvg, type ChartBoardHouseNote } from "@/components/chart-board/chart-board-svg"; +import type { BoardFocus } from "@/lib/chart-board-focus"; +import { boardFromChart, type BoardModel } from "@/lib/chart-board-model"; +import type { ChartBoardStyle } from "@/lib/chart-board-style"; +import { CHART_AREA_NAMES } from "@/lib/chat-chart-areas"; +import type { ChartViewOk } from "@/lib/chart-view-contract"; + +const NO_BODIES = new Set(); +const NO_MARKS = new Map(); +const noop = () => {}; + +/** The chart's houses with every body removed (owner 2026-11-24: no planets on the waiting chart). */ +export function waitBoardModel(chart: ChartViewOk["vedic"]["vargas"][number]["chart"]): BoardModel { + const model = boardFromChart(chart); + return { ...model, houses: model.houses.map((house) => ({ ...house, bodies: [] })) }; +} + +/** + * BUG-2283: the product's own board (ChartBoardSvg, the reader's North / South style) at a compact size, areas only. + * Lit houses use the board's own wash (`is-tinted`); a lit natal house carries its plain name from the shared table. + * Decorative: the caller wraps it in a labelled `role="img"`; the step list is what assistive technology reads. + */ +export function ChatWaitBoard({ + chart, + style, + lit, + labeled, +}: Readonly<{ + chart: ChartViewOk["vedic"]["vargas"][number]["chart"]; + style: ChartBoardStyle; + lit: readonly number[]; + labeled: readonly number[]; +}>) { + useEffect(() => { + void import("@/components/chart-board/chart-board-styles").catch(() => undefined); + }, []); + const model = useMemo(() => waitBoardModel(chart), [chart]); + const focus = useMemo(() => ({ + lit: NO_BODIES, + dimmed: NO_BODIES, + marks: NO_MARKS, + houses: new Set(lit), + outlined: new Set(), + links: [], + numberFrom: null, + chips: [], + }), [lit]); + const notes = useMemo<(ChartBoardHouseNote | null)[]>( + () => Array.from({ length: 12 }, (_, index) => (labeled.includes(index + 1) ? { text: CHART_AREA_NAMES[index + 1]!, tone: "plain" } : null)), + [labeled], + ); + return ( + + ); +} + +export default ChatWaitBoard; diff --git a/frontend/src/components/chat-wait-progress.tsx b/frontend/src/components/chat-wait-progress.tsx new file mode 100644 index 000000000..2fae86e9e --- /dev/null +++ b/frontend/src/components/chat-wait-progress.tsx @@ -0,0 +1,97 @@ +"use client"; + +import { lazy, Suspense, useEffect, useSyncExternalStore } from "react"; + +import { ConsultationRunStatus } from "@/components/consultation-run-timeline"; +import type { ChartViewOk } from "@/lib/chart-view-contract"; +import type { ConsultationTimelineRow } from "@/lib/consultation-run-timeline"; +import { readCurrentSubjectId } from "@/lib/current-subject"; +import { WAIT_CHART_LABEL, waitView, type WaitChart, type WaitView } from "@/lib/chat-wait-progress"; +import { readChatWait, subscribeChatWait } from "@/lib/chat-wait-store"; +import { peekChartPage, subscribeChartPageChanges } from "@/lib/secondary-page-data"; +import { useUiStore } from "@/stores/ui-store"; + +const ChatWaitBoard = lazy(() => import("@/components/chat-wait-board")); + +/** The chart the page already holds for the selected person; null when it is not loaded (no request is made). */ +function readWaitChartView(): ChartViewOk | null { + const snapshot = peekChartPage(); + if (snapshot?.kind !== "view" || snapshot.view.status !== "ok") return null; + const view = snapshot.view; + if (view.subjectId && view.subjectId !== readCurrentSubjectId()) return null; + return view; +} + +type Board = Readonly<{ chart: ChartViewOk["vedic"]["vargas"][number]["chart"]; caption: string; lit: readonly number[]; labeled: readonly number[] }>; + +/** + * Which drawing to show. A switched chart the page has not loaded keeps its place on the North board (the cells do + * not depend on the signs there and no sign is written); on the South board, where the cells are the signs, it + * stays on 本命盘 rather than draw a wrong picture. + */ +export function waitBoard(view: Extract, chartView: ChartViewOk | null, style: "north" | "south"): Board | null { + if (!chartView) return null; + const find = (id: WaitChart) => chartView.vedic.vargas.find((varga) => varga.id === id)?.chart ?? null; + const natal = find("D1"); + if (!natal) return null; + if (view.chart === "D1") return { chart: natal, caption: view.caption, lit: view.lit, labeled: view.labeled }; + const varga = find(view.chart); + if (varga) return { chart: varga, caption: view.caption, lit: view.lit, labeled: [] }; + if (style === "north") return { chart: natal, caption: view.caption, lit: view.lit, labeled: [] }; + return { chart: natal, caption: "本命盘", lit: view.natal, labeled: view.natal }; +} + +/** + * BUG-2283 (原型「等回答的时候」): before the answer has text, the person's chart (areas only) and the plain step list, + * both driven by the run's real events (chat-wait-progress.ts). When the events do not map, or once the answer is + * being written, today's one-line status shows instead; it stays mounted throughout, so its elapsed time and + * settled summary are unchanged. + */ +export function ChatWaitProgress({ + rows, + live, + answering, + question, +}: Readonly<{ + rows: readonly ConsultationTimelineRow[]; + live: boolean; + answering: boolean; + question?: string | null; +}>) { + const slot = useSyncExternalStore(subscribeChatWait, readChatWait, readChatWait); + const chartView = useSyncExternalStore(subscribeChartPageChanges, readWaitChartView, readWaitChartView); + const style = useUiStore((state) => state.chartBoardStyle); + const hydrated = useUiStore((state) => state.chartBoardStyleHydrated); + const hydrate = useUiStore((state) => state.hydrateChartBoardStyle); + useEffect(() => { + if (!hydrated) hydrate(); + }, [hydrate, hydrated]); + const view = live && !answering ? waitView(slot?.state) : { mappable: false as const }; + const board = view.mappable ? waitBoard(view, chartView, style) : null; + return ( + <> + {view.mappable ? ( +
+ {board ? ( +
+ + +
+ ) : null} +
    + {view.steps.map((step) => ( +
  1. +
  2. + ))} +
+ {view.current} +
+ ) : null} + + + ); +} diff --git a/frontend/src/components/consultation-run-timeline.tsx b/frontend/src/components/consultation-run-timeline.tsx index 2920fd147..bf703b83d 100644 --- a/frontend/src/components/consultation-run-timeline.tsx +++ b/frontend/src/components/consultation-run-timeline.tsx @@ -251,11 +251,14 @@ export function ConsultationRunStatus({ live = false, answering = false, question, + concealed = false, }: Readonly<{ rows: readonly ConsultationTimelineRow[]; live?: boolean; answering?: boolean; question?: string | null; + /** BUG-2283: the waiting chart stands in for the line; it stays mounted so its elapsed time keeps counting. */ + concealed?: boolean; }>) { const bodyId = useId(); const [open, setOpen] = useState(false); @@ -282,7 +285,7 @@ export function ConsultationRunStatus({ if (view.kind === "hidden" || (view.kind === "done" && startedAt === null)) return null; if (view.kind === "live") { return ( -
+