feat(ui): 报告中心改行式列表,阅读页并入外壳并把目录挪到右侧常驻
Independent Staging Quality Gate / validate (push) Canceled after 3m14s
Independent Staging Quality Gate / publish (push) Canceled after 0s

报告中心原来是卡片方阵,状态只靠三块底色区分;报告一多,扫读成本
按卡片数线性涨。现在一列一行:带色点的状态 chip、标题、创建时间 ·
深度 · 主题,操作靠右。失败原因从右边一小块挪进行内,能完整读到。

chip 里原来的 StatusIcon(generating 转圈、ready 打勾、failed 警告)
换成 5px 色点——原型如此,且列表是轮询不是演出。失败行不加「重新
生成」,顶栏已经有唯一的生成入口。

行内小字只写接口真给的东西。GET /api/reports 不返回节数和盘数,所以
不写「9 节 · 22 张盘」(VOICE.md 第 2 条),原型图上那行是 mock。

/reports/[reportId] 是最后一个脱离外壳的全屏路由,九个 phase 全部并进
SecondaryShell,根节点从 <main> 改成 <div>(外壳自己就是 main)。

任务书 E10「没有目录」已过期:目录在 cfcd369d 就存在。本轮把它从左栏
挪到正文右侧并定稿视觉,位置用 grid-column 显式指定而不是靠 DOM 次序,
这样窄屏抽屉仍能排在源码最前面,不会掉到全文末尾。860px 以下常驻栏
消失、折叠抽屉保留——删掉抽屉等于窄屏彻底失去章节定位。

挂外壳带出一个真实风险:window.print() 打的是整篇,而 .chat-app /
.chat-panel 是 height:100%;overflow:hidden,会把九节报告裁成一页。阅读
页因此多挂一条 media="print" 样式,把外壳既隐藏又解锁。放组件里而不是
globals.css:它只在阅读页挂载期存在,对话页的打印不受影响,也不用
:has() 去够祖先,更不越界到并行轮次的 CSS 区段。

纸面三个 token 一个没动,--report-accent 仍是 #85432f;目录栏用应用
调色板,因为它是 chrome 不是纸。report-chart-grid-rehype.ts 一行未动,
新增断言守住它仍然接线(BUG-616/617)。

tsc 0 错;lint 0 error / 118 warning(未增);3350→3355 条,0 条既有
断言被改,31 条无 Docker 失败与基线逐条一致;四个路由渲染标记不变,
/ 首屏 gzip −0.58%。

「20 张盘以上不重叠、滚动不卡」与「挂外壳后的打印真实输出」无真机做
不了,已写成环境缺口,清单在 docs/testing/cend-report-20260916.md。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0193vBv6w5MV2cifdTUu9H5P
This commit is contained in:
Jesse_Chen
2026-09-16 06:41:39 +00:00
co-authored by Claude Opus 5
parent c3bcddb652
commit a1a78c7ebc
10 changed files with 590 additions and 149 deletions
@@ -1,7 +1,7 @@
"use client";
import Link from "next/link";
import { Check, Clock3, FileText, RefreshCw, TriangleAlert } from "lucide-react";
import { Clock3, FileText, RefreshCw } from "lucide-react";
import { InlineSpinner } from "@/components/inline-spinner";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
@@ -87,10 +87,14 @@ function formatDate(value: string): string {
}).format(date);
}
function StatusIcon({ status }: { status: ReportListItem["status"] }) {
if (status === "generating") return <InlineSpinner size={16} />;
if (status === "ready") return <Check aria-hidden="true" className="size-4" />;
return <TriangleAlert aria-hidden="true" className="size-4" />;
/**
* One row's quiet second line. Only what the list endpoint actually returns:
* `GET /api/reports` carries no section or chart counts, so the row says the
* creation time, the depth and the requested themes and nothing more. Inventing
* 「9 节 · 22 张盘」 on the client would be a made-up number (VOICE.md 第 2 条).
*/
function rowMeta(report: ReportListItem): string {
return `${formatDate(report.createdAt)} · ${report.depth} · ${report.themes.join(" / ") || "综合主题"}`;
}
export function PersonalReportCenter() {
@@ -219,21 +223,29 @@ export function PersonalReportCenter() {
<div className="report-center-list">
{state.reports.map((report) => {
const copy = STATUS_COPY[report.status];
const note = report.status === "ready"
? report.cardSummary
: report.status === "generating"
? copy.description
: null;
return (
<article className="report-center-card" key={report.id}>
<div className="report-center-card-body">
<div className={`report-center-status is-${report.status}`} role={report.status === "generating" ? "status" : undefined}>
<StatusIcon status={report.status} />{copy.label}
</div>
<article className={`report-center-row is-${report.status}`} key={report.id}>
<div className="report-center-row-main">
<span
className={`report-center-status is-${report.status}`}
role={report.status === "generating" ? "status" : undefined}
>
{copy.label}
</span>
<h3>{report.reportType === "personal_thematic" ? "个人主题报告" : "个人完整报告"}</h3>
<p>{report.status === "ready" && report.cardSummary ? report.cardSummary : copy.description}</p>
<small>{formatDate(report.createdAt)} · {report.depth} · {report.themes.join(" / ") || "综合主题"}</small>
<p className="report-center-row-meta">{rowMeta(report)}</p>
{note ? <p className="report-center-row-note">{note}</p> : null}
{report.status === "failed" ? (
<p className="report-center-failure">{report.failureSummary ?? report.failureCode ?? "生成失败"}</p>
) : null}
</div>
{report.status === "ready" ? (
<div className="report-center-card-actions">
<Button render={<Link href={`/reports/${encodeURIComponent(report.id)}`} />} nativeButton={false} variant="outline">
</Button>
<div className="report-center-row-actions">
<Button
type="button"
variant="ghost"
@@ -243,6 +255,9 @@ export function PersonalReportCenter() {
{exportingReportId === report.id ? <InlineSpinner size={14} /> : null}
{PERSONAL_REPORT_EXPORT_LABEL}
</Button>
<Button render={<Link href={`/reports/${encodeURIComponent(report.id)}`} />} nativeButton={false} variant="outline">
</Button>
{exportError?.reportId === report.id ? (
<span className="report-center-export-error" role="alert">
{exportError.message}
@@ -250,12 +265,12 @@ export function PersonalReportCenter() {
) : null}
</div>
) : report.status === "generating" ? (
<Button render={<Link href={`/reports/${encodeURIComponent(report.id)}`} />} nativeButton={false} variant="ghost">
</Button>
) : (
<span className="report-center-failure">{report.failureSummary ?? report.failureCode ?? "生成失败"}</span>
)}
<div className="report-center-row-actions">
<Button render={<Link href={`/reports/${encodeURIComponent(report.id)}`} />} nativeButton={false} variant="outline">
</Button>
</div>
) : null}
</article>
);
})}
@@ -17,6 +17,7 @@ import { Clock3, TriangleAlert } from "lucide-react";
import { InlineSpinner } from "@/components/inline-spinner";
import { SecondaryShell } from "@/components/secondary-shell";
import { ReportActions } from "./report-actions";
import { PersonalReportMarkdownView } from "./personal-report-markdown-view";
import { PersonalReportProgressPanel } from "./personal-report-progress-panel";
@@ -169,6 +170,23 @@ function isRecord(value: unknown): value is Record<string, unknown> {
return typeof value === "object" && value !== null && !Array.isArray(value);
}
/**
* The reader renders inside the app shell now (nav rail + 46px header), the same
* one /chart, /ephemeris and /reports carry. Printing takes the whole document,
* so the shell has to be neutralised on paper — not only hidden but unlocked:
* `.chat-app` and `.chat-panel` are `height: 100%; overflow: hidden`, which would
* clip a nine-section report down to one page.
*
* It lives here rather than in globals.css on purpose. This style tag exists only
* while the reader is mounted, so the chat page's own print behaviour is
* untouched and no other surface has to know about it.
*/
const REPORT_SHELL_PRINT_CSS = ".chat-app, .chat-panel, [data-slot='sidebar-inset']"
+ " { display: block !important; width: auto !important; height: auto !important;"
+ " min-height: 0 !important; overflow: visible !important; }"
+ " [data-slot='sidebar'], [data-slot='sidebar-rail'], [data-slot='sidebar-scrim'], .chat-header"
+ " { display: none !important; }";
/** Wall-clock budget for one uninterrupted wait: 8 minutes, then we stop and say so. */
export const POLL_BUDGET_MS = 8 * 60 * 1000;
const POLL_TICK_MS = 1000;
@@ -298,137 +316,156 @@ export function PersonalReportPage({ reportId }: { reportId: string }) {
: null;
const writing = progress?.stage === "writing";
return (
<main className="personal-report-state">
{writing ? null : <InlineSpinner className="text-primary" size={32} />}
<p role="status" className={writing ? "personal-report-progress-headline" : undefined}>
{generating ? (progress?.headline ?? PERSONAL_REPORT_GENERATING_COPY) : "正在加载报告…"}
</p>
{progress && writing && <PersonalReportProgressPanel progress={progress} />}
{generating && (
<>
<p> {formatWaitedDuration(waitedMs)}</p>
<p></p>
<Button render={<Link href="/reports" />} nativeButton={false} variant="ghost"></Button>
</>
)}
</main>
<SecondaryShell title="个人报告">
<div className="personal-report-state">
{writing ? null : <InlineSpinner className="text-primary" size={32} />}
<p role="status" className={writing ? "personal-report-progress-headline" : undefined}>
{generating ? (progress?.headline ?? PERSONAL_REPORT_GENERATING_COPY) : "正在加载报告…"}
</p>
{progress && writing && <PersonalReportProgressPanel progress={progress} />}
{generating && (
<>
<p> {formatWaitedDuration(waitedMs)}</p>
<p></p>
<Button render={<Link href="/reports" />} nativeButton={false} variant="ghost"></Button>
</>
)}
</div>
</SecondaryShell>
);
}
if (state.phase === "timed-out") {
return (
<main className="personal-report-state">
<Clock3 aria-hidden="true" className="size-8 text-ink-secondary" />
<h1></h1>
<p> {formatWaitedDuration(waitedMs)}</p>
<p></p>
<div className="flex flex-wrap items-center justify-center gap-3">
<Button type="button" variant="default" onClick={() => keepWaiting()}>
</Button>
<Button render={<Link href="/reports" />} nativeButton={false} variant="outline">
</Button>
<SecondaryShell title="个人报告">
<div className="personal-report-state">
<Clock3 aria-hidden="true" className="size-8 text-ink-secondary" />
<h1></h1>
<p> {formatWaitedDuration(waitedMs)}</p>
<p></p>
<div className="flex flex-wrap items-center justify-center gap-3">
<Button type="button" variant="default" onClick={() => keepWaiting()}>
</Button>
<Button render={<Link href="/reports" />} nativeButton={false} variant="outline">
</Button>
</div>
</div>
</main>
</SecondaryShell>
);
}
if (state.phase === "unauthorized") {
return (
<main className="personal-report-state">
<h1></h1>
<p></p>
<Button render={<Link href="/login" />} nativeButton={false} variant="default">
</Button>
</main>
<SecondaryShell title="个人报告">
<div className="personal-report-state">
<h1></h1>
<p></p>
<Button render={<Link href="/login" />} nativeButton={false} variant="default">
</Button>
</div>
</SecondaryShell>
);
}
if (state.phase === "not-found") {
return (
<main className="personal-report-state">
<h1></h1>
<p></p>
<Button render={<Link href="/reports" />} nativeButton={false} variant="outline">
</Button>
</main>
<SecondaryShell title="个人报告">
<div className="personal-report-state">
<h1></h1>
<p></p>
<Button render={<Link href="/reports" />} nativeButton={false} variant="outline">
</Button>
</div>
</SecondaryShell>
);
}
if (state.phase === "failed") {
return (
<main className="personal-report-state">
<TriangleAlert aria-hidden="true" className="size-8 text-warning" />
<h1></h1>
<p>{state.failureSummary ?? "生成过程中出现问题,未产出可用报告。请稍后重试。"}</p>
{state.failureCode && (
<p>{state.failureCode}</p>
)}
<Button render={<Link href="/reports" />} nativeButton={false} variant="outline">
</Button>
</main>
<SecondaryShell title="个人报告">
<div className="personal-report-state">
<TriangleAlert aria-hidden="true" className="size-8 text-warning" />
<h1></h1>
<p>{state.failureSummary ?? "生成过程中出现问题,未产出可用报告。请稍后重试。"}</p>
{state.failureCode && (
<p>{state.failureCode}</p>
)}
<Button render={<Link href="/reports" />} nativeButton={false} variant="outline">
</Button>
</div>
</SecondaryShell>
);
}
if (state.phase === "invalid" || state.phase === "network-error") {
return (
<main className="personal-report-state">
<TriangleAlert aria-hidden="true" className="size-8 text-danger" />
<h1></h1>
<p>
{state.phase === "invalid"
? `报告数据未通过校验(${state.message}),已停止渲染。`
: "网络连接失败,请检查网络后重试。"}
</p>
<Button type="button" variant="outline" onClick={() => void reload()}>
</Button>
</main>
<SecondaryShell title="个人报告">
<div className="personal-report-state">
<TriangleAlert aria-hidden="true" className="size-8 text-danger" />
<h1></h1>
<p>
{state.phase === "invalid"
? `报告数据未通过校验(${state.message}),已停止渲染。`
: "网络连接失败,请检查网络后重试。"}
</p>
<Button type="button" variant="outline" onClick={() => void reload()}>
</Button>
</div>
</SecondaryShell>
);
}
if (state.phase === "legacy-unavailable") {
return (
<main className="personal-report-state">
<TriangleAlert aria-hidden="true" className="size-8 text-warning" />
<h1></h1>
<p>{PERSONAL_REPORT_LEGACY_PLACEHOLDER}</p>
<Button render={<Link href="/reports" />} nativeButton={false} variant="outline">
</Button>
</main>
<SecondaryShell title="个人报告">
<div className="personal-report-state">
<TriangleAlert aria-hidden="true" className="size-8 text-warning" />
<h1></h1>
<p>{PERSONAL_REPORT_LEGACY_PLACEHOLDER}</p>
<Button render={<Link href="/reports" />} nativeButton={false} variant="outline">
</Button>
</div>
</SecondaryShell>
);
}
if (state.phase !== "markdown-ready") {
return (
<main className="personal-report-state">
<TriangleAlert aria-hidden="true" className="size-8 text-danger" />
<h1></h1>
<p></p>
<Button type="button" variant="outline" onClick={() => void reload()}>
</Button>
</main>
<SecondaryShell title="个人报告">
<div className="personal-report-state">
<TriangleAlert aria-hidden="true" className="size-8 text-danger" />
<h1></h1>
<p></p>
<Button type="button" variant="outline" onClick={() => void reload()}>
</Button>
</div>
</SecondaryShell>
);
}
return (
<main className="personal-report-reader">
<style media="print">{"@page { size: A4; margin: 13mm 12mm 14mm; }"}</style>
<ReportActions
reportId={state.reportId || reportId}
reportTitle="个人报告"
markdown={state.markdown}
reportDate={state.createdAt}
/>
<div className="personal-report-reader-body">
<PersonalReportMarkdownView markdown={state.markdown} />
<SecondaryShell title="个人报告">
<div className="personal-report-reader">
<style media="print">{"@page { size: A4; margin: 13mm 12mm 14mm; }"}</style>
<style media="print">{REPORT_SHELL_PRINT_CSS}</style>
<ReportActions
reportId={state.reportId || reportId}
reportTitle="个人报告"
markdown={state.markdown}
reportDate={state.createdAt}
/>
<div className="personal-report-reader-body">
<PersonalReportMarkdownView markdown={state.markdown} />
</div>
</div>
</main>
</SecondaryShell>
);
}