fix(rectification): start new case from homepage
Staging Backend Quality Gate / validate (pull_request) Successful in 24m42s
Staging Backend Quality Gate / publish (pull_request) Has been skipped

This commit is contained in:
Jesse_Chen
2026-08-12 21:21:26 +08:00
parent 90199b4d9b
commit 4deb5c2378
12 changed files with 273 additions and 45 deletions
@@ -12,7 +12,7 @@ export const runtime = "nodejs";
/**
* GET /api/rectification/cases/entry-summary
*
* Server-truth homepage CTA: "开始生时校正" / "继续上次校正" / "再次校正".
* Server-truth context for homepage copy; the primary homepage action always creates.
*/
export async function GET() {
let supabase;
@@ -28,7 +28,7 @@ function serviceErrorResponse(error: unknown) {
*
* Browser sends only { intent, requestId } (+ sessionId for intent=session).
* The server derives the user from the session, normalizes the profile and
* decides resume-or-create. Double-click / multi-tab are idempotent.
* creates for homepage/new or restores the exact requested session. Retries are idempotent.
*/
export async function POST(request: Request) {
let supabase;
+2 -2
View File
@@ -3423,8 +3423,8 @@ export default function Home() {
<div className="product-entrypoint-copy">
<span className="product-entrypoint-kicker"></span>
<h2 id="birth-rectification-title"></h2>
<p>{rectificationCardAction === "resume"
? "你有一段未完成的校正记录,可以从上次的位置继续。"
<p>{rectificationEntrySummary?.hasResumableCase
? "新建一段独立校正;未完成的记录仍可从左侧历史会话继续。"
: rectificationCardAction === "restart"
? "上一次校正已经完成,可以基于最新资料再次校正。"
: "不确定准确出生时间时,可通过已经发生的人生事件逐步缩小范围。"}</p>
+2 -4
View File
@@ -20,18 +20,16 @@ export type RectificationEntrySummary = Readonly<{
}> | null;
}>;
export type RectificationCardAction = "start" | "resume" | "restart";
export type RectificationCardAction = "start" | "restart";
export const rectificationEntryLabels: Readonly<Record<RectificationCardAction, string>> = {
start: "开始生时校正",
resume: "继续上次校正",
start: "开始新的生时校正",
restart: "再次校正",
};
export function resolveRectificationEntryAction(
summary: RectificationEntrySummary,
): RectificationCardAction {
if (summary.hasResumableCase) return "resume";
if (summary.hasTerminalCaseWithTime) return "restart";
return "start";
}