diff --git a/docs/BUG_HISTORY.md b/docs/BUG_HISTORY.md
index 4a3e36ac1..676cac1ba 100644
--- a/docs/BUG_HISTORY.md
+++ b/docs/BUG_HISTORY.md
@@ -27527,3 +27527,15 @@
- 验证与防复发:`frontend/tests/overseas-place-search-2049.test.tsx`:排序、重音与标点、20 条上限、美国全表的耗时、别名表每一条都能在地点表里找到、中文别名与找不到的状态、国家筛选、搜索选中与两级下拉选中得到完全相同的结果、方向键与回车和 Esc、中国不出现搜索框、样式沿用下拉选项且没有左侧色条。`world-location-table.test.ts` 里「不使用搜索」的断言按原值、新值、原因更新。登录后的页面本机起不来,外观只用产品样式表渲染成静态页面看过(电脑和手机宽度、浅色和深色)。
- 关联记录:BUG-1506、BUG-2047。
- 修复版本:`claude/overseas-place-search-2049`。
+
+## BUG-2050 | 首页输入框上方的开场语读起来像在叮嘱人,说完就停,不把话头递给用户
+
+- 状态:fixed-pending-verify(待测试环境确认)。
+- 首次发现 / 最近更新:2026-11-20 / 2026-11-20。
+- 触发与现象:产品负责人走查首页,觉得开场语效果不好。原表二十来句里一半是叮嘱(「中午好,记得吃饭」「周一了,别太累」「下午好,歇口气吧」),一半不带称呼,没有一句邀请用户开口。
+- 触发条件:任何已建档的用户打开首页的空白对话。
+- 根因:2026-10-01 定的口吻是「只问候和关心、不提问」,规则把邀请式的句子整类排除了;关心写成了嘱咐。
+- 修复:产品负责人 2026-11-20 确认新表:去掉叮嘱类句子;取消「不提问」,新增「邀请」一组(任何时段都在池里);多数句子带称呼;本人生日当天只用生日问候(只取本人出生日期的月和日,2 月 29 日生的平年在 2 月 28 日)。仍然不评价用户、不用星月陪伴的比喻、不用表情、句末不用句号。句子一字不为排版缩短:排不下折成两行,只在逗号或问号后折,不拆开称呼;问候块贴着输入框上沿,第二行向上长,输入框不动。
+- 验证与防复发:`frontend/tests/home-greeting-2050.test.tsx` 逐句检查整张表(禁用词、比喻、句末标点)、每个时段都有不带称呼的句子、生日判定和生日池独占、同一选择值取到同一句、折行短语与称呼完整;`onboarding-presentation.test.ts` 按原值、新值、原因更新。两行时的版面是按字号和栏宽算的,没有在真机上看过。
+- 关联记录:BUG-1052。首页刚部署后出现过一次的水合报错与开场语无关:开场语只在客户端取到档案和会话之后才渲染,首屏不含它。
+- 修复版本:`claude/home-greeting-2050`。
diff --git a/frontend/DESIGN.md b/frontend/DESIGN.md
index 87100ff37..f93680bde 100644
--- a/frontend/DESIGN.md
+++ b/frontend/DESIGN.md
@@ -717,7 +717,12 @@ page. Then (2026-09-26) a greeting, a 今日星语 sub-line, the composer and a
from three pools — daypart (morning / noon / afternoon / evening / late-night),
weekday (Mon, Fri, Sat, Sun only), and returning (accounts that already have a
session) — concatenated in that order and indexed by one random seed, with the
- `{名字}` entries dropped when no name is set. It lives in the conversation area
+ `{名字}` entries dropped when no name is set. Since 2026-11-20 (BUG-2050) a
+ fourth pool of invitations (lines that hand the turn to the user) is always
+ in, the advice lines are gone, and on the account holder's birthday the
+ birthday lines are the whole pool. A long line may take two rows: it breaks
+ only after a comma or question mark (`.starter-greeting-phrase`), never
+ inside the name, and grows upward. It lives in the conversation area
with `align-content: end`, so it sits directly above the composer rather than
floating in the middle of the row. Nothing sits under it: the 今日星语 trend
line (`.starter-greeting-sub`, with its 240ms fade-in and the static
diff --git a/frontend/src/app/(app)/page.tsx b/frontend/src/app/(app)/page.tsx
index ef93a5ac1..1dabfc618 100644
--- a/frontend/src/app/(app)/page.tsx
+++ b/frontend/src/app/(app)/page.tsx
@@ -102,7 +102,7 @@ import {
CONSULTATION_EVIDENCE_VALIDATION_LABEL,
CONSULTATION_LOADING_METHOD_LABEL,
} from "@/lib/consultation-activity-labels";
-import { createStartGreetingParts } from "@/lib/starter-greeting";
+import { createStartGreetingParts, greetingBirthdayFromDate } from "@/lib/starter-greeting";
import {
type PublicLanguageModelCatalog,
} from "@/lib/public-models";
@@ -606,7 +606,8 @@ export default function Home() {
);
const onboardingFormActive = !synastryChat && subjectCatalogReady && !profileComplete && shownOnboardingStep !== "name";
const starterHasPriorSessions = sessions.some((session) => session.id !== activeSession?.id);
- const starterGreeting = createStartGreetingParts(profile.name, new Date(), starterGreetingSelection, starterHasPriorSessions);
+ // `profile` is the account holder's own profile (BUG-2050): the greeting names them and knows only the month and day of their birthday.
+ const starterGreeting = createStartGreetingParts(profile.name, new Date(), starterGreetingSelection, starterHasPriorSessions, greetingBirthdayFromDate(profile.date));
const conversationAnchor = useConversationScrollAnchor(
conversation,
!starterHomeVisible,
diff --git a/frontend/src/app/globals.css b/frontend/src/app/globals.css
index 90bb7e6ed..521479b3a 100644
--- a/frontend/src/app/globals.css
+++ b/frontend/src/app/globals.css
@@ -2885,7 +2885,7 @@ input:not([type="radio"]):not([type="checkbox"]):not([class^="ant-"]):not([class
padding: var(--space-8) 0 var(--space-5);
}
-/* The greeting: one line, two to five words. It used to be an h1 at
+/* The greeting: one short line, two rows at most (BUG-2050). It used to be an h1 at
clamp(34px, 5vw, 52px) inside a bordered hero card, with two 132px product
cards under it — together about 800px sitting on top of the composer; then a
salutation line above a question. The question moved into the composer
@@ -2907,6 +2907,13 @@ input:not([type="radio"]):not([type="checkbox"]):not([class^="ant-"]):not([class
text-wrap: balance;
}
+/* BUG-2050: a greeting that needs two rows breaks between phrases (after a
+ comma or question mark). A phrase wider than the row still wraps inside. */
+.starter-greeting-phrase {
+ display: inline-block;
+ max-width: 100%;
+}
+
/* One column width across both states: the empty-state composer used to be
1040px while the session composer was 760px, so the input visibly jumped
width the moment the first message landed. */
diff --git a/frontend/src/components/starter-home.tsx b/frontend/src/components/starter-home.tsx
index eadcbc506..d471c7465 100644
--- a/frontend/src/components/starter-home.tsx
+++ b/frontend/src/components/starter-home.tsx
@@ -18,11 +18,29 @@ export type StarterGreetingProps = {
readonly starterGreeting: { readonly text: string };
};
-/* One line. The composer placeholder asks the question. */
+/**
+ * The phrases a greeting may break between: each ends at a comma or question
+ * mark. A line with no such mark is one phrase.
+ */
+export function starterGreetingPhrases(text: string): readonly string[] {
+ return text.match(/[^,?]*[,?]|[^,?]+/gu) ?? [];
+}
+
+/*
+ * One greeting. A long line may take two rows (product owner 2026-11-20: wrap
+ * rather than shorten the copy); it then breaks after a comma or question mark,
+ * never inside a phrase or the name. The block is bottom-aligned above the
+ * composer, so a second row grows upward and the composer stays where it is.
+ */
export function StarterGreeting({ starterGreeting }: StarterGreetingProps) {
+ const phrases = starterGreetingPhrases(starterGreeting.text);
return (
- {starterGreeting.text}
+
+ {phrases.length > 1
+ ? phrases.map((phrase, index) => {phrase})
+ : starterGreeting.text}
+
);
}
diff --git a/frontend/src/lib/starter-greeting.ts b/frontend/src/lib/starter-greeting.ts
index 5ff1778ac..b3da95f8d 100644
--- a/frontend/src/lib/starter-greeting.ts
+++ b/frontend/src/lib/starter-greeting.ts
@@ -1,42 +1,90 @@
type GreetingPeriod = "morning" | "noon" | "afternoon" | "evening" | "late-night";
/**
- * One line, two to five words, no follow-up question. Since 2026-10-01 the voice
- * is a warm older sister's (知心姐姐): it greets and cares, never comments on the
- * user (no 夜猫子 / 还没睡呀).
+ * One line above the composer. Voice since 2026-11-20 (product owner, BUG-2050):
+ * a short hello that hands the conversation over, the way claude.ai greets:
+ * name first where there is one, light invitations allowed, a little playful.
*
- * The homepage opening used to be a salutation plus a question ("这么晚还醒着,
- * {名字}。直接说说最在意的问题吧。") — an office voice that answered for the user
- * before they had said anything. Asking is the composer placeholder's job now;
- * the greeting only greets. No metaphors (星 / 月 / 陪), no emoji, no period.
+ * Still out: remarks about the user (夜猫子 / 还没睡呀, 产品 2026-10-01
+ * 「你管别人睡不睡」), advice or caretaking (记得吃饭 / 别太累, removed 2026-11-20),
+ * star / moon / companionship metaphors (「星盘」 as the product's own noun is
+ * fine), emoji, and a closing full stop (a question mark is allowed).
+ *
+ * To change the copy, edit the tables below; nothing else needs to move. Every
+ * daypart keeps at least one line without `{名字}` for accounts with no name.
*/
const NAME_TOKEN = "{名字}";
const periodGreetings: Record = {
- morning: ["早安", "早安,{名字}", "早呀,今天慢慢来"],
- noon: ["中午好,记得吃饭", "午安,{名字}"],
- afternoon: ["下午好,歇口气吧", "下午好,{名字}"],
- evening: ["今天辛苦了", "晚上好,{名字}", "晚上好,歇一歇"],
- // Late night never remarks on being awake (产品 2026-10-01: 「你管别人睡不睡」).
- "late-night": ["这会儿很安静", "夜里好,{名字}", "慢慢说,{名字}"],
+ morning: ["早,{名字}", "早上好,{名字}", "{名字},今天从哪儿聊起", "新的一天,想先看哪件事"],
+ noon: ["中午好,{名字}", "午休时间,聊两句?", "{名字},趁午饭说点正事"],
+ afternoon: ["下午好,{名字}", "下午茶配个问题,{名字}?", "{名字},这会儿在琢磨什么", "下午好,想聊点什么"],
+ evening: ["晚上好,{名字}", "今晚想聊点什么,{名字}", "{名字},白天没空想的事现在说", "今晚想聊点什么"],
+ "late-night": ["夜里好,{名字}", "夜聊开张,{名字}", "{名字},这个点适合说心里话", "夜聊开张"],
};
/** Keyed by `Date#getDay()`. Days with nothing worth saying stay out of the pool. */
const weekdayGreetings: Readonly> = {
- 0: ["周日,慢一点"],
- 1: ["周一了,别太累"],
- 5: ["周五了,松口气"],
- 6: ["周末好好歇歇"],
+ 0: ["周日好,{名字}"],
+ 1: ["周一好,{名字},这周先看哪件事"],
+ 5: ["周五了,{名字},聊点轻松的?"],
+ 6: ["周末好,{名字},慢慢聊"],
};
/** Only reachable once the account has at least one session behind it. */
const returningGreetings: readonly string[] = [
"又见面了,{名字}",
- "你来啦,{名字}",
- "欢迎回来",
- "最近还好吗,{名字}?",
+ "{名字}回来啦",
+ "接着上次的聊,{名字}?",
+ "欢迎回来,{名字},今天问什么",
+ "又见面了",
];
+/** Any time of day: the line that passes the turn to the user. */
+const invitationGreetings: readonly string[] = [
+ "{名字},最近在纠结什么",
+ "有什么事想问问星盘,{名字}",
+ "说吧,{名字},想知道什么",
+ "{名字},今天想弄明白哪件事",
+ "心里有事?说来听听",
+ "说吧,想知道什么",
+];
+
+/** On the account holder's birthday this is the whole pool. */
+const birthdayGreetings: readonly string[] = [
+ "生日快乐,{名字}",
+ "{名字},生日快乐,新的一岁从今天算起",
+ "生日快乐",
+];
+
+/** Month and day of the account holder's own birth date; nothing else is needed. */
+export type GreetingBirthday = { readonly month: number; readonly day: number };
+
+/** Reads `YYYY-MM-DD`; anything else is "no birthday known". */
+export function greetingBirthdayFromDate(date: string | null | undefined): GreetingBirthday | null {
+ const match = /^\d{4}-(\d{2})-(\d{2})$/.exec((date ?? "").trim());
+ if (!match) return null;
+ const month = Number(match[1]);
+ const day = Number(match[2]);
+ if (month < 1 || month > 12 || day < 1 || day > 31) return null;
+ return { month, day };
+}
+
+function isLeapYear(year: number): boolean {
+ return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
+}
+
+/** Local calendar day. A 29 February birthday is greeted on 28 February in a common year. */
+export function isGreetingBirthday(birthday: GreetingBirthday | null | undefined, now: Date): boolean {
+ if (!birthday) return false;
+ const month = now.getMonth() + 1;
+ const day = now.getDate();
+ if (birthday.month === 2 && birthday.day === 29 && !isLeapYear(now.getFullYear())) {
+ return month === 2 && day === 28;
+ }
+ return birthday.month === month && birthday.day === day;
+}
+
function greetingPeriod(hour: number): GreetingPeriod {
if (hour >= 5 && hour < 11) return "morning";
if (hour >= 11 && hour < 14) return "noon";
@@ -46,19 +94,37 @@ function greetingPeriod(hour: number): GreetingPeriod {
}
/**
- * Every line this moment can produce, in pool order: daypart, weekday, returning.
- * A blank name drops the lines that would print an empty one; the daypart pool
- * always keeps a nameless line, so the result is never empty.
+ * Every line this moment can produce, in pool order: daypart, weekday, returning,
+ * invitation. On the birthday only the birthday lines. A blank name drops the
+ * lines that would print an empty one; every pool keeps a nameless line, so the
+ * result is never empty.
*/
-function starterGreetingPool(name: string, now: Date, hasSessions: boolean): readonly string[] {
- const templates = [
- ...periodGreetings[greetingPeriod(now.getHours())],
- ...(weekdayGreetings[now.getDay()] ?? []),
- ...(hasSessions ? returningGreetings : []),
- ];
+function starterGreetingPool(
+ name: string,
+ now: Date,
+ hasSessions: boolean,
+ birthday: GreetingBirthday | null | undefined,
+): readonly string[] {
+ const templates = isGreetingBirthday(birthday, now)
+ ? birthdayGreetings
+ : [
+ ...periodGreetings[greetingPeriod(now.getHours())],
+ ...(weekdayGreetings[now.getDay()] ?? []),
+ ...(hasSessions ? returningGreetings : []),
+ ...invitationGreetings,
+ ];
return name ? templates : templates.filter((template) => !template.includes(NAME_TOKEN));
}
+/** Test and review hook: every template, so one loop can check the whole table. */
+export const STARTER_GREETING_TEMPLATES: readonly string[] = [
+ ...Object.values(periodGreetings).flat(),
+ ...Object.values(weekdayGreetings).flat(),
+ ...returningGreetings,
+ ...invitationGreetings,
+ ...birthdayGreetings,
+];
+
export type StartGreetingParts = {
readonly text: string;
};
@@ -68,9 +134,10 @@ export function createStartGreetingParts(
now = new Date(),
variantSelection = Math.random(),
hasSessions = false,
+ birthday: GreetingBirthday | null = null,
): StartGreetingParts {
const displayName = name.trim();
- const pool = starterGreetingPool(displayName, now, hasSessions);
+ const pool = starterGreetingPool(displayName, now, hasSessions, birthday);
const index = Math.min(Math.max(Math.floor(variantSelection * pool.length), 0), pool.length - 1);
return { text: pool[index]!.replaceAll(NAME_TOKEN, displayName) };
}
@@ -80,8 +147,9 @@ export function createStartGreeting(
now = new Date(),
variantSelection = Math.random(),
hasSessions = false,
+ birthday: GreetingBirthday | null = null,
): string {
- return createStartGreetingParts(name, now, variantSelection, hasSessions).text;
+ return createStartGreetingParts(name, now, variantSelection, hasSessions, birthday).text;
}
export function createOnboardingFallbackGreeting(name: string): string {
diff --git a/frontend/tests/consultation-entrypoint.test.ts b/frontend/tests/consultation-entrypoint.test.ts
index cbb7fa40b..32bc9cfda 100644
--- a/frontend/tests/consultation-entrypoint.test.ts
+++ b/frontend/tests/consultation-entrypoint.test.ts
@@ -302,7 +302,11 @@ test("the starter heading is drawn per visit and the entry pills carry no fine p
// Given: the heading reads from a variant seeded once per mount and redrawn when the home is left.
// 原值 `{starterGreeting.question}` / 新值 `{starterGreeting.text}` / 原因:开场语改成单行问候,
// 「招呼语 + 问句」两半的形状取消,heading 直接就是整行;「每次进首页重抽」这条意图没变。
- assert.match(source, /\{starterGreeting\.text\}<\/h1>/);
+ // 原值: `{starterGreeting.text}
`,h1 里只有一段文字
+ // 新值: h1 里按逗号、问号分成短语,一句话仍是原样的一段文字
+ // 原因: BUG-2050,产品负责人 2026-11-20:句子排不下就折成两行,折在标点处,不拆开称呼。h1 仍只有一个。
+ assert.match(source, /\s*\{phrases\.length > 1[\s\S]*?starter-greeting-phrase[\s\S]*?: starterGreeting\.text\}\s*<\/h1>/);
+ assert.equal(source.match(/ Math\.random\(\)\)/);
assert.match(source, /starterGreetingUnseen\.current = true;\s*\n\s*setStarterGreetingSelection\(Math\.random\(\)\)/);
diff --git a/frontend/tests/home-greeting-2050.test.tsx b/frontend/tests/home-greeting-2050.test.tsx
new file mode 100644
index 000000000..c3dff437e
--- /dev/null
+++ b/frontend/tests/home-greeting-2050.test.tsx
@@ -0,0 +1,129 @@
+import assert from "node:assert/strict";
+import { readFileSync } from "node:fs";
+import test from "node:test";
+import { renderToStaticMarkup } from "react-dom/server";
+
+import { StarterGreeting, starterGreetingPhrases } from "../src/components/starter-home.tsx";
+import {
+ STARTER_GREETING_TEMPLATES,
+ createStartGreeting,
+ createStartGreetingParts,
+ greetingBirthdayFromDate,
+ isGreetingBirthday,
+} from "../src/lib/starter-greeting.ts";
+
+// BUG-2050 (product owner 2026-11-20): the greeting hands the turn to the user,
+// names them, never remarks on them or advises them, and knows their birthday.
+
+const WEDNESDAY = (hour: number) => new Date(2026, 6, 22, hour);
+const BIRTHDAY = { month: 8, day: 8 } as const;
+
+test("no line remarks on the user, advises them, uses a metaphor or ends with a full stop", () => {
+ assert.ok(STARTER_GREETING_TEMPLATES.length >= 35);
+ const banned = /夜猫子|还没睡|不睡|晚安|记得吃饭|歇口气|辛苦了|别太累|慢慢来|松口气|好好歇歇|慢慢说|这会儿很安静|最近还好吗|熬夜/;
+ for (const line of STARTER_GREETING_TEMPLATES) {
+ assert.doesNotMatch(line, banned, line);
+ assert.doesNotMatch(line.replaceAll("星盘", ""), /[星月陪]/, line);
+ assert.doesNotMatch(line, /[。!!.]$/, line);
+ assert.doesNotMatch(line, /\p{Extended_Pictographic}/u, line);
+ assert.doesNotMatch(line, /\n/, line);
+ }
+});
+
+test("every hour of every day has a line for an account with no name", () => {
+ for (let day = 19; day <= 25; day += 1) {
+ for (let hour = 0; hour < 24; hour += 1) {
+ for (const hasSessions of [false, true]) {
+ for (let step = 0; step < 50; step += 1) {
+ const text = createStartGreeting("", new Date(2026, 6, day, hour), step / 50, hasSessions);
+ assert.ok(text.length > 0);
+ assert.doesNotMatch(text, /\{名字\}/);
+ assert.doesNotMatch(text, /^[,?]|,,|,?|,$/, text);
+ }
+ }
+ }
+ }
+});
+
+test("most lines carry the name when there is one", () => {
+ const named = STARTER_GREETING_TEMPLATES.filter((line) => line.includes("{名字}"));
+ assert.ok(named.length / STARTER_GREETING_TEMPLATES.length > 0.6);
+});
+
+test("a birth date gives a month and day and nothing else", () => {
+ assert.deepEqual(greetingBirthdayFromDate("1990-08-08"), { month: 8, day: 8 });
+ assert.equal(greetingBirthdayFromDate(""), null);
+ assert.equal(greetingBirthdayFromDate(undefined), null);
+ assert.equal(greetingBirthdayFromDate("1990-13-08"), null);
+ assert.equal(greetingBirthdayFromDate("8/8/1990"), null);
+});
+
+test("the birthday is the local calendar day, and 29 February falls on 28 February in a common year", () => {
+ assert.equal(isGreetingBirthday(BIRTHDAY, new Date(2026, 7, 8, 0, 0)), true);
+ assert.equal(isGreetingBirthday(BIRTHDAY, new Date(2026, 7, 8, 23, 59)), true);
+ assert.equal(isGreetingBirthday(BIRTHDAY, new Date(2026, 7, 7, 23, 59)), false);
+ assert.equal(isGreetingBirthday(BIRTHDAY, new Date(2026, 7, 9, 0, 0)), false);
+ assert.equal(isGreetingBirthday(null, new Date(2026, 7, 8)), false);
+
+ const leapDay = { month: 2, day: 29 } as const;
+ assert.equal(isGreetingBirthday(leapDay, new Date(2028, 1, 29)), true);
+ assert.equal(isGreetingBirthday(leapDay, new Date(2028, 1, 28)), false);
+ assert.equal(isGreetingBirthday(leapDay, new Date(2027, 1, 28)), true);
+ assert.equal(isGreetingBirthday(leapDay, new Date(2027, 2, 1)), false);
+});
+
+test("on the birthday only the birthday lines can appear, with or without a name", () => {
+ const day = new Date(2026, 7, 8, 9);
+ const named = new Set(Array.from({ length: 300 }, (_, step) =>
+ createStartGreetingParts("周宁", day, step / 300, true, BIRTHDAY).text));
+ assert.deepEqual([...named].sort(), ["生日快乐", "生日快乐,周宁", "周宁,生日快乐,新的一岁从今天算起"].sort());
+ const nameless = new Set(Array.from({ length: 300 }, (_, step) =>
+ createStartGreetingParts("", day, step / 300, true, BIRTHDAY).text));
+ assert.deepEqual([...nameless], ["生日快乐"]);
+
+ const dayAfter = new Set(Array.from({ length: 300 }, (_, step) =>
+ createStartGreetingParts("周宁", new Date(2026, 7, 9, 9), step / 300, true, BIRTHDAY).text));
+ for (const line of dayAfter) assert.doesNotMatch(line, /生日/);
+});
+
+test("the same selection value always picks the same line", () => {
+ for (const selection of [0, 0.13, 0.5, 0.87, 0.999999, 1]) {
+ const first = createStartGreeting("周宁", WEDNESDAY(20), selection, true, BIRTHDAY);
+ assert.equal(first, createStartGreeting("周宁", WEDNESDAY(20), selection, true, BIRTHDAY));
+ }
+ assert.equal(createStartGreeting("周宁", WEDNESDAY(20), 0), "晚上好,周宁");
+});
+
+test("a greeting breaks only after a comma or question mark, and the name stays whole", () => {
+ assert.deepEqual(starterGreetingPhrases("早上好"), ["早上好"]);
+ assert.deepEqual(starterGreetingPhrases("周一好,周宁,这周先看哪件事"), ["周一好,", "周宁,", "这周先看哪件事"]);
+ assert.deepEqual(starterGreetingPhrases("心里有事?说来听听"), ["心里有事?", "说来听听"]);
+ assert.deepEqual(starterGreetingPhrases("周五了,周宁,聊点轻松的?"), ["周五了,", "周宁,", "聊点轻松的?"]);
+ for (const template of STARTER_GREETING_TEMPLATES) {
+ const line = template.replaceAll("{名字}", "欧阳景行之");
+ const phrases = starterGreetingPhrases(line);
+ assert.equal(phrases.join(""), line);
+ assert.ok(phrases.some((phrase) => phrase.includes("欧阳景行之")) || !template.includes("{名字}"));
+ }
+
+ const one = renderToStaticMarkup();
+ assert.equal(one, '');
+ const two = renderToStaticMarkup();
+ assert.equal(two, ''
+ + '周宁,生日快乐,'
+ + '新的一岁从今天算起
');
+
+ const css = readFileSync(new URL("../src/app/globals.css", import.meta.url), "utf8");
+ const rule = css.match(/\.starter-greeting-phrase \{([^}]*)\}/)?.[1] ?? "";
+ assert.match(rule, /display: inline-block/);
+ assert.match(rule, /max-width: 100%/);
+ assert.match(css.match(/\.starter-greeting-block h1 \{([^}]*)\}/)?.[1] ?? "", /text-wrap: balance/);
+});
+
+test("the home page gives the greeting the account holder's own name and birthday", () => {
+ const page = readFileSync(new URL("../src/app/(app)/page.tsx", import.meta.url), "utf8");
+ assert.match(page, /createStartGreetingParts\(profile\.name, new Date\(\), starterGreetingSelection, starterHasPriorSessions, greetingBirthdayFromDate\(profile\.date\)\)/);
+ // `profile` is the self profile; the current subject (possibly someone else) is `dailyProfile`.
+ assert.match(page, /const dailyProfile = useCurrentSubjectProfile\(profile\);/);
+ assert.doesNotMatch(page, /createStartGreetingParts\(dailyProfile/);
+});
diff --git a/frontend/tests/onboarding-presentation.test.ts b/frontend/tests/onboarding-presentation.test.ts
index 6a58256df..100c606d5 100644
--- a/frontend/tests/onboarding-presentation.test.ts
+++ b/frontend/tests/onboarding-presentation.test.ts
@@ -15,55 +15,49 @@ const WEDNESDAY = (hour: number) => new Date(2026, 6, 22, hour);
const FRIDAY = (hour: number) => new Date(2026, 6, 24, hour);
test("terminal and fallback greetings follow the current profile name", () => {
- // 原值: 同时锁 onboardingRequestIdentity / isCurrentOnboardingRequest,避免建议问题串号。
- // 新值: 只保留问候语随当前称呼变化。
- // 原因: 建议问题请求已删除,身份去重不再有消费点。
- //
- // 原值 `createStartGreeting("周宁", …, 0)` + `"周宁,从你此刻最关心的问题开始吧。"`
- // / 新值 `createStartGreeting("周宁", …, 0.25)` + `"欢迎,周宁"`
- // / 原因:时段池现在第一条是不带称呼的「早上好」,要取带称呼的条目得换下标;
- // 兜底问候按产品口径改成单行「欢迎,{名字}」,不再追问。断言强度没变:
- // 两条都仍然必须带当前称呼、不得带旧称呼。
- const terminalGreeting = createStartGreeting("周宁", SUNDAY(8), 0.25);
+ // 原值 `createStartGreeting("周宁", SUNDAY(8), 0.25)` === "早安,周宁"
+ // 新值 `createStartGreeting("周宁", SUNDAY(8), 0)` === "早,周宁"
+ // 原因: BUG-2050,产品负责人 2026-11-20 换了整张开场语表(去掉叮嘱、允许把话头递给用户、更活泼)。
+ // 断言强度不变:两条都必须带当前称呼、不得带旧称呼。
+ const terminalGreeting = createStartGreeting("周宁", SUNDAY(8), 0);
const fallbackGreeting = createOnboardingFallbackGreeting("周宁");
for (const greeting of [terminalGreeting, fallbackGreeting]) {
assert.match(greeting, /周宁/);
assert.doesNotMatch(greeting, /林遥/);
}
- // 原值 "早上好,周宁" / 新值 "早安,周宁" / 原因:开场语改知心姐姐口吻(产品 2026-10-01)。
- assert.equal(terminalGreeting, "早安,周宁");
+ assert.equal(terminalGreeting, "早,周宁");
assert.equal(fallbackGreeting, "欢迎,周宁");
});
-test("the starter greeting is one line drawn from daypart, weekday and returning pools", () => {
- // 原值:`parts.salutation` = "中午好,周宁。"、`parts.question` = "现在最想理清哪件事?",
- // 并断言两半拼起来等于整行、每个时段至少 12 条不同问句。
- // 新值:`parts.text` 就是整行问候;断言时段池按下标取到「中午好」/「中午好,周宁」。
- // 原因:产品把开场语改成 claude.ai 式的单行问候,追问句移到输入框占位符,
- // 「招呼语 + 问句」两半这个形状本身被取消,问句池不再存在。
+// 2026-07-22 周三中午:时段 3 条 + 邀请 6 条,共 9 条;星期池为空。
+test("the starter greeting is one line drawn from daypart, weekday, returning and invitation pools", () => {
+ // 原值: 中午池两条「中午好,记得吃饭」「午安,周宁」,下标 0 / 0.5 / 1。
+ // 新值: 中午池三条,后面接六条邀请;下标按九条取。
+ // 原因: BUG-2050 换表,并新增「邀请」一组(任何时段都在池里)。
const noon = WEDNESDAY(12);
- // 原值 "中午好" / "中午好,周宁" / 新值 "中午好,记得吃饭" / "午安,周宁"
- // / 原因:开场语改知心姐姐口吻(产品 2026-10-01);下标与池长不变。
- assert.equal(createStartGreetingParts("周宁", noon, 0).text, "中午好,记得吃饭");
- assert.equal(createStartGreetingParts("周宁", noon, 0.5).text, "午安,周宁");
+ assert.equal(createStartGreetingParts("周宁", noon, 0).text, "中午好,周宁");
+ assert.equal(createStartGreetingParts("周宁", noon, 1 / 9).text, "午休时间,聊两句?");
+ assert.equal(createStartGreetingParts("周宁", noon, 2 / 9).text, "周宁,趁午饭说点正事");
+ assert.equal(createStartGreetingParts("周宁", noon, 3 / 9).text, "周宁,最近在纠结什么");
assert.equal(createStartGreeting("周宁", noon, 0.5), createStartGreetingParts("周宁", noon, 0.5).text);
// 边界不越界:1 与 0.999999 都落在池内最后一条。
- assert.equal(createStartGreetingParts("周宁", noon, 1).text, "午安,周宁");
- assert.equal(createStartGreetingParts("周宁", noon, 0.999999).text, "午安,周宁");
+ assert.equal(createStartGreetingParts("周宁", noon, 1).text, "说吧,想知道什么");
+ assert.equal(createStartGreetingParts("周宁", noon, 0.999999).text, "说吧,想知道什么");
});
-test("late night has its own three lines and none of them remarks on being awake", () => {
- // 原值 "夜猫子,晚上好" / "还没睡呀,周宁" / "晚安前再聊一会"
- // / 新值 "这会儿很安静" / "夜里好,周宁" / "慢慢说,周宁"
- // / 原因:产品 2026-10-01「夜猫子、还不睡,用户会觉得你管别人睡不睡」;断言加严:深夜池任何一条都不得提睡觉。
+test("late night has its own lines and none of them remarks on being awake", () => {
+ // 原值 "这会儿很安静" / "夜里好,周宁" / "慢慢说,周宁"
+ // 新值 "夜里好,周宁" / "夜聊开张,周宁" / "周宁,这个点适合说心里话" / "夜聊开张"
+ // 原因: BUG-2050 换表。「任何一条都不得提睡觉」的断言保留并扩大到整张表(见下一个测试文件)。
const lateNight = WEDNESDAY(2);
- assert.equal(createStartGreetingParts("周宁", lateNight, 0).text, "这会儿很安静");
- assert.equal(createStartGreetingParts("周宁", lateNight, 1 / 3).text, "夜里好,周宁");
- assert.equal(createStartGreetingParts("周宁", lateNight, 0.7).text, "慢慢说,周宁");
+ assert.equal(createStartGreetingParts("周宁", lateNight, 0).text, "夜里好,周宁");
+ assert.equal(createStartGreetingParts("周宁", lateNight, 1 / 10).text, "夜聊开张,周宁");
+ assert.equal(createStartGreetingParts("周宁", lateNight, 2 / 10).text, "周宁,这个点适合说心里话");
+ assert.equal(createStartGreetingParts("周宁", lateNight, 3 / 10).text, "夜聊开张");
// 23 点与 4 点同属深夜。
- assert.equal(createStartGreetingParts("周宁", WEDNESDAY(23), 1 / 3).text, "夜里好,周宁");
- assert.equal(createStartGreetingParts("周宁", WEDNESDAY(4), 1 / 3).text, "夜里好,周宁");
+ assert.equal(createStartGreetingParts("周宁", WEDNESDAY(23), 0).text, "夜里好,周宁");
+ assert.equal(createStartGreetingParts("周宁", WEDNESDAY(4), 0).text, "夜里好,周宁");
for (let step = 0; step < 100; step += 1) {
assert.doesNotMatch(createStartGreetingParts("周宁", lateNight, step / 100).text, /睡|夜猫子|晚安/);
}
@@ -71,56 +65,62 @@ test("late night has its own three lines and none of them remarks on being awake
test("a blank name leaves only the lines that carry no name", () => {
const lateNight = WEDNESDAY(2);
- // 原值 "夜猫子,晚上好" / "晚安前再聊一会" / 新值 "这会儿很安静"(深夜池唯一不带称呼的一条)
- // / 原因:深夜池换句(产品 2026-10-01)。
- assert.equal(createStartGreetingParts("", lateNight, 0).text, "这会儿很安静");
- assert.equal(createStartGreetingParts(" ", lateNight, 0.9).text, "这会儿很安静");
+ // 原值 "这会儿很安静"(深夜池唯一不带称呼的一条)
+ // 新值 深夜不带称呼的是「夜聊开张」,后面是两条不带称呼的邀请
+ // 原因: BUG-2050 换表。
+ assert.equal(createStartGreetingParts("", lateNight, 0).text, "夜聊开张");
+ assert.equal(createStartGreetingParts(" ", lateNight, 0.99).text, "说吧,想知道什么");
- // 原值:断言名字为空时不出现「周一了」/ 新值:只断言带称呼的回访条目不可达
- // / 原因:周一条目改成不带称呼的「周一了,别太累」,名字为空也该出现;带称呼条目不可达的断言保留。
for (let step = 0; step < 100; step += 1) {
for (const hasSessions of [false, true]) {
const text = createStartGreetingParts("", MONDAY(9), step / 100, hasSessions).text;
- assert.doesNotMatch(text, /又见面了|你来啦|最近还好吗/);
assert.ok(text.length > 0);
assert.doesNotMatch(text, /\{名字\}/);
- assert.doesNotMatch(text, /,$|^,/);
+ assert.doesNotMatch(text, /,$|^,|,,|,?/);
+ // 原值: 不出现「又见面了 / 你来啦 / 最近还好吗」
+ // 新值: 回访池里不带称呼的只有「又见面了」,没有会话时它也不可达
+ // 原因: BUG-2050 回访池保留了一条不带称呼的句子,给没填称呼的老用户用。
+ if (!hasSessions) assert.notEqual(text, "又见面了");
+ assert.doesNotMatch(text, /回来啦|接着上次的聊|欢迎回来/);
}
}
});
test("the weekday pool only opens on its own day", () => {
- const friday = FRIDAY(9);
+ // 原值 "周五了,松口气" / "周一了,别太累" / "周日,慢一点";周三早上池长 3
+ // 新值 "周五了,周宁,聊点轻松的?" / "周一好,周宁,这周先看哪件事" / "周日好,周宁";周三早上 4 条时段 + 6 条邀请 = 10
+ // 原因: BUG-2050 换表,星期句带上称呼,去掉叮嘱。
const fridayLines = new Set(Array.from({ length: 100 }, (_, step) =>
- createStartGreetingParts("周宁", friday, step / 100).text));
- // 原值 "周五快乐" / "周一了,周宁" / 新值 "周五了,松口气" / "周一了,别太累" / 原因:知心姐姐口吻(产品 2026-10-01)。
- assert.ok(fridayLines.has("周五了,松口气"));
+ createStartGreetingParts("周宁", FRIDAY(9), step / 100).text));
+ assert.ok(fridayLines.has("周五了,周宁,聊点轻松的?"));
const wednesdayLines = new Set(Array.from({ length: 100 }, (_, step) =>
createStartGreetingParts("周宁", WEDNESDAY(9), step / 100).text));
- assert.ok(!wednesdayLines.has("周五了,松口气"));
- assert.equal(wednesdayLines.size, 3);
+ assert.ok(!wednesdayLines.has("周五了,周宁,聊点轻松的?"));
+ assert.equal(wednesdayLines.size, 10);
assert.ok(new Set(Array.from({ length: 100 }, (_, step) =>
- createStartGreetingParts("周宁", MONDAY(9), step / 100).text)).has("周一了,别太累"));
+ createStartGreetingParts("周宁", MONDAY(9), step / 100).text)).has("周一好,周宁,这周先看哪件事"));
assert.ok(new Set(Array.from({ length: 100 }, (_, step) =>
- createStartGreetingParts("周宁", SUNDAY(9), step / 100).text)).has("周日,慢一点"));
+ createStartGreetingParts("周宁", SUNDAY(9), step / 100).text)).has("周日好,周宁"));
});
test("the returning pool needs at least one session behind the account", () => {
const evening = WEDNESDAY(20);
- // 原值 "嗨,周宁" / 新值 "你来啦,周宁" / 原因:知心姐姐口吻(产品 2026-10-01);池长不变。
- const returning = ["又见面了,周宁", "你来啦,周宁", "欢迎回来", "最近还好吗,周宁?"];
+ // 原值 ["又见面了,周宁", "你来啦,周宁", "欢迎回来", "最近还好吗,周宁?"];首访池长 3,回访 7
+ // 新值 下面五条;首访 4 条时段 + 6 条邀请 = 10,回访 15
+ // 原因: BUG-2050 换表。
+ const returning = ["又见面了,周宁", "周宁回来啦", "接着上次的聊,周宁?", "欢迎回来,周宁,今天问什么", "又见面了"];
- const firstVisit = new Set(Array.from({ length: 100 }, (_, step) =>
- createStartGreetingParts("周宁", evening, step / 100, false).text));
+ const firstVisit = new Set(Array.from({ length: 200 }, (_, step) =>
+ createStartGreetingParts("周宁", evening, step / 200, false).text));
for (const line of returning) assert.ok(!firstVisit.has(line), `first visit must not reach ${line}`);
- assert.equal(firstVisit.size, 3);
+ assert.equal(firstVisit.size, 10);
- const returnVisit = new Set(Array.from({ length: 100 }, (_, step) =>
- createStartGreetingParts("周宁", evening, step / 100, true).text));
+ const returnVisit = new Set(Array.from({ length: 300 }, (_, step) =>
+ createStartGreetingParts("周宁", evening, step / 300, true).text));
for (const line of returning) assert.ok(returnVisit.has(line), `return visit must reach ${line}`);
- assert.equal(returnVisit.size, 7);
+ assert.equal(returnVisit.size, 15);
});
test("the same inputs always produce the same line", () => {
@@ -148,10 +148,14 @@ test("no greeting line uses a metaphor or trails off into a sentence", () => {
step / 100,
hasSessions,
).text;
- assert.doesNotMatch(text, /[星月陪]/, `metaphor in ${text}`);
+ // 原值: 任何一句都不含「星 / 月 / 陪」,长度不超过 12
+ // 新值: 「星盘」作为产品自己的名词可以出现,其余的星、月、陪仍不许;长度不超过 20(两字称呼)
+ // 原因: BUG-2050。产品负责人 2026-11-20 要更活泼、能把话头递给用户的句子,并明确排不下就折成两行、不缩短句子;
+ // 「有什么事想问问星盘」是字面的产品名词,不是比喻。
+ assert.doesNotMatch(text.replaceAll("星盘", ""), /[星月陪]/, `metaphor in ${text}`);
assert.doesNotMatch(text, /。$/, `sentence period in ${text}`);
assert.ok(text.length > 0);
- assert.ok(text.length <= 12, `${text} is longer than one short line`);
+ assert.ok(text.length <= 20, `${text} is longer than two short rows`);
}
}
}
@@ -169,7 +173,11 @@ test("the starter hero is one heading and nothing else", () => {
// 原值:断言 `
` 与 `
{starterGreeting.question}
` 同时存在
// / 新值:断言只剩 `{starterGreeting.text}
`,且 `starter-salutation` 在源码与样式里都消失
// / 原因:开场语改成单行问候,副标题那一行连同它的样式一起下线;断言从「两行」改成「一行且不得有第二行」,强度不降反升。
- assert.match(source, /\{starterGreeting\.text\}<\/h1>/);
+ // 原值: `{starterGreeting.text}
`,h1 里只有一段文字
+ // 新值: h1 里按逗号、问号分成短语,一句话仍是原样的一段文字
+ // 原因: BUG-2050,产品负责人 2026-11-20:句子排不下就折成两行,折在标点处,不拆开称呼。h1 仍只有一个。
+ assert.match(source, /\s*\{phrases\.length > 1[\s\S]*?starter-greeting-phrase[\s\S]*?: starterGreeting\.text\}\s*<\/h1>/);
+ assert.equal(source.match(/ {
test("the greeting knows whether the account already has sessions", () => {
// hasSessions 必须来自已有的会话列表变量,不得新开一份状态。
assert.match(homeSurface, /const starterHasPriorSessions = sessions\.some\(/);
- assert.match(homeSurface, /createStartGreetingParts\(profile\.name, new Date\(\), starterGreetingSelection, starterHasPriorSessions\)/);
+ // 原值: 调用只有四个参数
+ // 新值: 第五个参数是本人出生日期的月和日(生日当天换成生日问候)
+ // 原因: BUG-2050。
+ assert.match(homeSurface, /createStartGreetingParts\(profile\.name, new Date\(\), starterGreetingSelection, starterHasPriorSessions, greetingBirthdayFromDate\(profile\.date\)\)/);
});