A local-first multi-agent app development platform, built on PenguinHarness
fix(web): the Evaluation Center's score lines connect across other agents, owner-only creation is hidden from members, and English labels no longer truncate (#775)
Yaowei Zheng5e5d5c375323
diff --git a/changelog/unreleased/2026-09-17-evaluation-center-lines-owner-actions-labels.md b/changelog/unreleased/2026-09-17-evaluation-center-lines-owner-actions-labels.mdnew file mode 100644index 00000000..2120a3db--- /dev/null+++ b/changelog/unreleased/2026-09-17-evaluation-center-lines-owner-actions-labels.md@@ -0,0 +1,49 @@+# The Evaluation Center's score lines connect across other agents, owner-only creation is hidden from members, and English labels no longer truncate++- **Date:** 2026-09-17+- **Type:** fix+- **Scope:** `web`+- **PR:** [#775](https://github.com/Prism-Shadow/penguin-harness/pull/775)++[中文版](2026-09-17-evaluation-center-lines-owner-actions-labels.zh.md)++A series on a Benchmark's score chart was drawn only between neighbouring slots of the time axis,+so another agent's evaluation between two of its points broke the line, and where two agents took+turns no line was drawn at all. Each series became one line through its own points. Two owner-only+actions stopped being offered to Project members, a failed Benchmark stopped telling a member to+delete it, and the labels the English UI cut short now fit.++## Score chart++- Each series is drawn through its own evaluations, in scoreboard order, straight over the slots+ other series hold between them; every point keeps its slot on the time axis.+- `seriesPoints` in `benchmark-metrics.ts` builds a series' points and `segmentPath` strokes them.+ It replaced `seriesValues`, and `lineSegments`, which split a series at every slot it did not+ hold, was removed from `chart-geom.ts` together with its tests.++## Owner-only actions++- The Evaluation Center offers "Create manually" to the Project's owner only, in its header and in+ its empty state. A member keeps "Create with AI", and the first step card no longer names the+ manual path to them. The server refuses a member's `POST /api/projects/:projectId/benchmarks`+ with 403; deleting a Benchmark was owner-only on the page before this change.+- The "Import Trace" row in "System settings" › "General" lists only the Projects the viewer owns+ and starts on the open one when they own it; a viewer who owns no Project gets no row. The import+ route, `POST /api/projects/:projectId/agents/:agentId/traces/import`, refuses anyone but the+ owner.+- A Benchmark whose creation failed tells the owner to delete it and create it again, on its card+ and on its own page; a member, who has no delete button, is told only that calibration did not+ finish.++## English labels++- A Benchmark card's score column grows past its minimum width to fit its label, so "first+ evaluation" is no longer cut and "Not evaluated yet" stays on one line. The Chinese card keeps its+ layout.+- The file tree in a case's dialog is 330px wide in English, so "Scoring rubric" reads in full+ beside its "Hidden from Target Agent" badge, and stays 240px in Chinese. The width is fixed per+ language, so opening or closing a folder does not move the preview beside the tree.+- On the org chart, the CEO's card no longer carries a "CEO" chip beside the name: the CEO is the+ tree's root, and its title already reads CEO. A CEO's name — created as+ `<organization name> CEO` — has as much room as any other employee's, and a name still too long+ for the fixed-size card is in the card's tooltip in full.diff --git a/changelog/unreleased/2026-09-17-evaluation-center-lines-owner-actions-labels.zh.md b/changelog/unreleased/2026-09-17-evaluation-center-lines-owner-actions-labels.zh.mdnew file mode 100644index 00000000..3855f781--- /dev/null+++ b/changelog/unreleased/2026-09-17-evaluation-center-lines-owner-actions-labels.zh.md@@ -0,0 +1,44 @@+# 评估中心的分数曲线跨过其他 Agent 连成一线,成员看不到仅 owner 可用的创建入口,英文标签不再被截断++- **Date:** 2026-09-17+- **Type:** fix+- **Scope:** `web`+- **PR:** [#775](https://github.com/Prism-Shadow/penguin-harness/pull/775)++[English](2026-09-17-evaluation-center-lines-owner-actions-labels.md)++Benchmark 分数曲线上的一个系列此前只在时间轴上相邻的槽位之间连线,+于是两个点之间只要夹着另一个 Agent 的评估,线就断开;两个 Agent 交替评估时,图上一条线都画不出来。+现在每个系列都是穿过自身各点的一条线。两个仅 owner 可用的操作不再提供给 Project 成员,+创建失败的 Benchmark 也不再让成员去删除它,英文界面里被截断的标签都能完整显示。++## 分数曲线++- 每个系列按记分板顺序,穿过自身的各条评估,从其他系列占据的槽位上方直接连过去;+ 每个点仍停在它在时间轴上的槽位。+- `benchmark-metrics.ts` 中的 `seriesPoints` 负责生成一个系列的点,由 `segmentPath` 连线。+ 它取代了 `seriesValues`;`lineSegments` 会在系列不占据的每个槽位处把线切开,+ 已连同其测试从 `chart-geom.ts` 中移除。++## 仅 owner 可用的操作++- 评估中心的「手动创建」只提供给 Project 的 owner,页头与空态同样如此。+ 成员仍有「用 AI 创建」,第一张步骤卡也不再向成员提及手动路径。+ 服务端对成员的 `POST /api/projects/:projectId/benchmarks` 返回 403;+ 删除 Benchmark 在页面上本就只对 owner 显示。+- 「系统设置」›「通用」中的「导入 Trace」一行只列出当前用户是 owner 的 Project,+ 当前打开的 Project 属于其名下时默认选中它;名下没有任何 Project 的用户看不到这一行。+ 导入接口 `POST /api/projects/:projectId/agents/:agentId/traces/import` 只允许 owner 调用。+- 创建失败的 Benchmark 在卡片与它自己的页面上提示 owner 删除后重新创建;+ 成员没有删除按钮,只会看到难度校准没有完成。++## 英文标签++- Benchmark 卡片的分数列在最小宽度之外随标签变宽,「first evaluation」不再被截断,+ 「Not evaluated yet」也保持在一行。中文卡片的布局不变。+- 题目详情弹窗里的文件树在英文界面下宽 330px,+ 「Scoring rubric」能与旁边的「Hidden from Target Agent」徽标一起完整显示;中文界面仍是 240px。+ 宽度按语言固定,展开或收起文件夹不会挪动旁边的预览区。+- 组织图上,CEO 的卡片不再在名称旁佩戴「CEO」徽标:CEO 是树的根,头衔本就写着「CEO」。+ CEO 的名称(创建时为 `<组织名> CEO`)因此与其他员工一样占满整行;+ 名称长到固定尺寸的卡片仍放不下时,卡片的悬停提示给出全文。diff --git a/packages/web/src/features/benchmark/benchmark-case-browser.tsx b/packages/web/src/features/benchmark/benchmark-case-browser.tsxindex e0d3b55c..ed86d7a9 100644--- a/packages/web/src/features/benchmark/benchmark-case-browser.tsx+++ b/packages/web/src/features/benchmark/benchmark-case-browser.tsx@@ -22,6 +22,7 @@ import { apiErrorText } from "../../lib/api-error";import { joinWorkspacePath } from "../../lib/file-path";import { formatBytes } from "../../lib/format";import { S } from "../../lib/strings";+import { useLocale } from "../../state/locale";import {ancestorDirs,baseName,@@ -137,6 +138,7 @@ interface Props {}export function BenchmarkCaseBrowser({ projectId, benchmarkId, caseSummary }: Props) {+ const { locale } = useLocale();/** Listings by tree path; a missing key means "not fetched yet". */const [listings, setListings] = useState<Listings>(() => new Map());/** Both materials start open, so the case's files are in view without a click. */@@ -334,6 +336,10 @@ export function BenchmarkCaseBrowser({ projectId, benchmarkId, caseSummary }: Pr);};+ // One fixed width per language, so opening or closing a folder never moves the preview beside+ // the tree. It is sized to the rubric folder's row, whose name shares the row with the+ // hidden-from-agent badge: the English pair takes about 320px at the default 18px root and the+ // Chinese pair about 230px. A longer file name is cut, and its row's tooltip holds the path.return (<FileBrowserrows={caseTreeRows(materials, listings, expanded)}@@ -349,7 +355,7 @@ export function BenchmarkCaseBrowser({ projectId, benchmarkId, caseSummary }: Prpreview={preview}emptyPreview={S.benchmark.caseFileUnavailable}resolveRef={resolveRef}- treeWidth={240}+ treeWidth={locale === "en" ? 330 : 240}treeMaxHeight={53}previewHeight={52}minHeight={58}diff --git a/packages/web/src/features/benchmark/benchmark-detail-page.tsx b/packages/web/src/features/benchmark/benchmark-detail-page.tsxindex ac59350d..ce765d9c 100644--- a/packages/web/src/features/benchmark/benchmark-detail-page.tsx+++ b/packages/web/src/features/benchmark/benchmark-detail-page.tsx@@ -26,12 +26,32 @@ import { UseBenchmarkModal } from "./use-benchmark-modal";/** Back to the list: the arrow-left every detail page's back button carries. */const BACK_ICON = "M15 18l-6-6 6-6M9 12h12";+/**+ * What stands in place of the detail for a Benchmark that is not published: still being built,+ * or creation failed. Deleting and creating again is a failed Benchmark's only way out, and only+ * the owner may delete, so a member is told what happened without being sent to that step.+ */+export function UnpublishedNotice({ failed, isOwner }: { failed: boolean; isOwner: boolean }) {+ if (!failed) {+ return <EmptyState title={S.benchmark.building} description={S.benchmark.buildingDetail} />;+ }+ return (+ <EmptyState+ title={S.benchmark.creationFailed}+ description={+ isOwner ? S.benchmark.creationFailedDetail : S.benchmark.creationFailedDetailMember+ }+ />+ );+}+export function BenchmarkDetailPage() {const params = useParams<{ benchmarkId: string }>();const benchmarkId = params.benchmarkId ?? "";const navigate = useNavigate();const { currentProject, agents } = useProject();const projectId = currentProject?.projectId ?? null;+ const isOwner = currentProject?.role === "owner";const [benchmark, setBenchmark] = useState<BenchmarkSummary | null>(null);const [error, setError] = useState<string | null>(null);@@ -103,14 +123,7 @@ export function BenchmarkDetailPage() {</div>);} else if (masked) {- body = failed ? (- <EmptyState- title={S.benchmark.creationFailed}- description={S.benchmark.creationFailedDetail}- />- ) : (- <EmptyState title={S.benchmark.building} description={S.benchmark.buildingDetail} />- );+ body = <UnpublishedNotice failed={failed} isOwner={isOwner} />;} else {body = <BenchmarkDetail projectId={projectId} benchmark={benchmark} />;}diff --git a/packages/web/src/features/benchmark/benchmark-detail.tsx b/packages/web/src/features/benchmark/benchmark-detail.tsxindex d0d404ec..73e2a4d9 100644--- a/packages/web/src/features/benchmark/benchmark-detail.tsx+++ b/packages/web/src/features/benchmark/benchmark-detail.tsx@@ -28,7 +28,7 @@ import { GlyphIcon } from "../../components/ui/glyph-icon";import { MAGIC_WAND_ICON } from "../../components/ui/icons";import { Modal } from "../../components/ui/modal";import { NEUTRAL_SERIES, seriesColor } from "../../lib/category-colors";-import { lineSegments, makeRangeGeom, segmentPath } from "../usage/chart-geom";+import { makeRangeGeom, segmentPath } from "../usage/chart-geom";import { ChartFrame, useChartWidth } from "../usage/chart-svg";import { AskAiModal } from "./ask-ai-modal";import { BenchmarkCaseBrowser } from "./benchmark-case-browser";@@ -37,7 +37,7 @@ import {labelSeries,scoreScale,scoreValues,- seriesValues,+ seriesPoints,} from "./benchmark-metrics";import type { EvaluationSeries } from "./benchmark-metrics";import { askCaseExamples, askCaseTail } from "./benchmark-prompts";@@ -49,7 +49,9 @@ import { EvaluationDetailModal } from "./evaluation-detail-modal";* timestamp. Scores remain valid on 0..100, while the visible y-axis is padded around the* observed range and clamped to those limits. Evaluations are grouped by label, so a change of* tested Agent or of runtime starts its own series instead of bending one, while a new Agent- * State version of the same agent continues the line and names its version in the bubble.+ * State version of the same agent continues the line and names its version in the bubble. Each+ * series is one line through its own points (seriesPoints): the slots other series hold in+ * between do not break it.*/function ScoreTrendChart({evaluations,@@ -100,37 +102,31 @@ function ScoreTrendChart({}}>{series.map((s, si) => {- const segments = lineSegments(seriesValues(evaluations, s));+ const points = seriesPoints(evaluations, s);return (<gkey={s.unlabeled ? "unlabeled" : s.key}className={(s.unlabeled ? NEUTRAL_SERIES : seriesColor(si)).text}>- {segments.map((seg, k) => {- return (- <g key={k}>- {seg.length > 1 && (- <path- d={segmentPath(geom, seg)}- fill="none"- stroke="currentColor"- strokeWidth={2}- opacity={hover !== null ? 0.35 : 1}- />- )}- {seg.map((p) => (- <circle- key={p.index}- cx={geom.x(p.index)}- cy={geom.y(p.value)}- r={hover === p.index ? 4 : 2.5}- className="fill-current"- opacity={hover !== null && hover !== p.index ? 0.25 : 1}- />- ))}- </g>- );- })}+ {points.length > 1 && (+ <path+ d={segmentPath(geom, points)}+ fill="none"+ stroke="currentColor"+ strokeWidth={2}+ opacity={hover !== null ? 0.35 : 1}+ />+ )}+ {points.map((p) => (+ <circle+ key={p.index}+ cx={geom.x(p.index)}+ cy={geom.y(p.value)}+ r={hover === p.index ? 4 : 2.5}+ className="fill-current"+ opacity={hover !== null && hover !== p.index ? 0.25 : 1}+ />+ ))}</g>);})}diff --git a/packages/web/src/features/benchmark/benchmark-metrics.ts b/packages/web/src/features/benchmark/benchmark-metrics.tsindex 9491921e..c6a808b1 100644--- a/packages/web/src/features/benchmark/benchmark-metrics.ts+++ b/packages/web/src/features/benchmark/benchmark-metrics.ts@@ -7,13 +7,14 @@* runtime are the trend the loop exists to show, so they stay on one line, and each point* carries its version in the chart's hover label and in the evaluation table's own column.*/+import type { LinePoint } from "../usage/chart-geom";/** Minimal Evaluation shape needed to read Score (BenchmarkEvaluation is a superset). */export interface MetricSourceLike {score: number;}-/** Each Evaluation's authoritative stored Score; non-finite malformed values become chart gaps. */+/** Each Evaluation's authoritative stored Score; a non-finite malformed value is null. */export function scoreValues(evaluations: readonly MetricSourceLike[]): (number | null)[] {return evaluations.map((e) => {return typeof e.score === "number" && Number.isFinite(e.score) ? e.score : null;@@ -130,13 +131,18 @@ export function labelSeries(evaluations: readonly EvaluationLabelLike[]): Evaluareturn [...all.filter((x) => !x.unlabeled), ...all.filter((x) => x.unlabeled)];}-/** A series' Score sequence; indices outside this series are null, keeping the global time axis. */-export function seriesValues(- evaluations: readonly (MetricSourceLike & EvaluationLabelLike)[],+/**+ * The points one series' line is drawn through: its own evaluations, in scoreboard order, each+ * at its own slot on the time axis every series shares. The line joins each point to the next+ * and does not break between them. Where another label's evaluation holds the slot between two+ * points, that slot is the other series' point, not a gap in this one. A series with a single+ * evaluation is a lone point.+ */+export function seriesPoints(+ evaluations: readonly MetricSourceLike[],series: EvaluationSeries,-): (number | null)[] {- const own = new Set(series.indices);- return scoreValues(evaluations).map((v, i) => (own.has(i) ? v : null));+): LinePoint[] {+ return series.indices.map((index) => ({ index, value: evaluations[index]!.score }));}/** Minimal evaluation shape for the list rows: the stored Score and when it was recorded. */diff --git a/packages/web/src/features/benchmark/benchmark-page.tsx b/packages/web/src/features/benchmark/benchmark-page.tsxindex a3d884c9..50d2223f 100644--- a/packages/web/src/features/benchmark/benchmark-page.tsx+++ b/packages/web/src/features/benchmark/benchmark-page.tsx@@ -58,15 +58,35 @@ function deltaTone(delta: number | null): string {return delta > 0 ? toneInk.success : toneInk.danger;}+/**+ * The page's pair of create entry points, in its header and in its empty state alike. Creating+ * with AI opens a conversation, which any member of the Project may start; creating by hand posts+ * the cases for the server to write under the Project's `benchmarks/`, which only the owner may+ * do (the route answers anyone else with 403). So a member is offered the AI button by itself,+ * the way the scheduled-tasks tab offers it.+ */+export function BenchmarkCreateButtons({+ isOwner,+ onAi,+ onManual,+}: {+ isOwner: boolean;+ onAi: () => void;+ onManual: () => void;+}) {+ return <CreateButtons size="sm" onAi={onAi} {...(isOwner ? { onManual } : {})} />;+}+/*** The three steps of the loop, a card each: three across from `md` up, stacked below. Every card* names its step and says where on this page to do it — the create buttons at the top right,* Use → Evaluate and Use → Optimize on a Benchmark — and nothing else stands above or beside* them: the maintainer wants the three stages alone, without a how-to line or the Skill names* in grey. Nothing is drawn between the cards — the numbers already carry the order, and an- * arrow would only survive one of the two layouts.+ * arrow would only survive one of the two layouts. A member's first card leaves out Create+ * manually, since the header does not offer it to them.*/-function GuideSteps() {+function GuideSteps({ isOwner }: { isOwner: boolean }) {return (<div className="mt-3 grid md:grid-cols-3 gap-3">{S.benchmark.guideFlow.map((step, i) => (@@ -78,7 +98,9 @@ function GuideSteps() {<span className="font-mono tabular-nums text-gray-400 dark:text-gray-500">{i + 1}</span><span className="font-semibold text-gray-900 dark:text-gray-100">{step.title}</span></span>- <p className="mt-1 leading-relaxed">{step.text}</p>+ <p className="mt-1 leading-relaxed">+ {i === 0 && !isOwner ? S.benchmark.guideCreateMember : step.text}+ </p></div>))}</div>@@ -130,7 +152,7 @@ function TestedAgents({* draft, creation failed for a Benchmark whose calibration never finished — with only the delete* icon left live.*/-function BenchmarkCard({+export function BenchmarkCard({benchmark,locale,nameOf,@@ -154,6 +176,11 @@ function BenchmarkCard({// away. Only the owner's delete stays above the mask, which is how either is cleaned up.const masked = benchmark.status !== "published";const failed = benchmark.status === "failed";+ // Deleting and creating again is a failed Benchmark's only way out, and the hint names that+ // step only to a viewer who has the delete button beside it.+ const failedHint = canDelete+ ? S.benchmark.creationFailedHint+ : S.benchmark.creationFailedHintMember;return (<div className="relative flex flex-wrap items-center gap-x-6 gap-y-2 rounded-md border border-gray-200 bg-white px-5 py-4 dark:border-gray-800 dark:bg-gray-900"><button@@ -192,7 +219,10 @@ function BenchmarkCard({<ScoreSparkline values={series} label={S.benchmark.sparklineLabel(series.length)} /></div>)}- <div className="w-16 shrink-0 text-right">+ {/* At least a score's width, and as wide as its label beyond that: the label is a phrase+ ("first evaluation", "Not evaluated yet") that runs longer than a score in English,+ and cut short or broken over lines it stops reading as one. */}+ <div className="min-w-16 shrink-0 text-right">{latest ? (<><span@@ -201,7 +231,9 @@ function BenchmarkCard({>{formatScore(latest.score)}</span>- <span className={`block truncate text-[11px] tabular-nums ${deltaTone(latest.delta)}`}>+ <span+ className={`block whitespace-nowrap text-[11px] tabular-nums ${deltaTone(latest.delta)}`}+ >{latest.delta === null? S.benchmark.firstEvaluation: latest.delta === 0@@ -210,7 +242,7 @@ function BenchmarkCard({</span></>) : (- <span className="block text-xs text-gray-400 dark:text-gray-500">+ <span className="block whitespace-nowrap text-xs text-gray-400 dark:text-gray-500">{S.benchmark.notEvaluated}</span>)}@@ -240,7 +272,7 @@ function BenchmarkCard({{masked && (<divrole="note"- title={failed ? S.benchmark.creationFailedHint : S.benchmark.buildingHint}+ title={failed ? failedHint : S.benchmark.buildingHint}className="absolute inset-0 flex cursor-not-allowed flex-col items-center justify-center gap-1 rounded-md bg-white/75 px-4 text-center backdrop-blur-[1px] dark:bg-gray-900/75">{/* A failed creation is the one thing here the user has to act on, so its title takes@@ -251,7 +283,7 @@ function BenchmarkCard({{failed ? S.benchmark.creationFailed : S.benchmark.building}</span><span className="text-xs text-gray-500 dark:text-gray-400">- {failed ? S.benchmark.creationFailedHint : S.benchmark.buildingHint}+ {failed ? failedHint : S.benchmark.buildingHint}</span></div>)}@@ -397,7 +429,13 @@ export function BenchmarkPage() {<EmptyStatetitle={S.benchmark.emptyTitle}description={S.benchmark.emptyDescription}- action={<CreateButtons size="sm" onAi={openAi} onManual={() => setManualOpen(true)} />}+ action={+ <BenchmarkCreateButtons+ isOwner={isOwner}+ onAi={openAi}+ onManual={() => setManualOpen(true)}+ />+ }/>);} else if (rows.length === 0) {@@ -442,10 +480,14 @@ export function BenchmarkPage() {onChange={(e) => setQuery(e.target.value)}/></div>- <CreateButtons size="sm" onAi={openAi} onManual={() => setManualOpen(true)} />+ <BenchmarkCreateButtons+ isOwner={isOwner}+ onAi={openAi}+ onManual={() => setManualOpen(true)}+ /></div></div>- <GuideSteps />+ <GuideSteps isOwner={isOwner} /></div>{/* What the address is filtering by, and the way out of it: the list is narrowed by adiff --git a/packages/web/src/features/company/chart-card.tsx b/packages/web/src/features/company/chart-card.tsxindex 1babd653..90ff32df 100644--- a/packages/web/src/features/company/chart-card.tsx+++ b/packages/web/src/features/company/chart-card.tsx@@ -4,8 +4,9 @@* The face carries no primary action: it is a plain card that reads, and the personnel menu —* opening the desk session and every personnel action — is the one thing it can do. A* whole-card link would promise one of those many actions and steal the click from the rest.- * Three rows: avatar with the name and title (the CEO wears a chip); the live state dot and- * its label, the workspace tail, this period's spend against the budget; a thin ratio bar.+ * Three rows: avatar with the name and title; the live state dot and its label, the workspace+ * tail, this period's spend against the budget; a thin ratio bar. The CEO's card carries no mark of+ * its own: the CEO is the tree's root, and an organization is created with the CEO titled "CEO".* The state the dot draws is passed in rather than read off the employee: the chart is a* snapshot re-read on organization events, and no event says a run ended (org-sessions.ts,* liveEmployeeStates).@@ -42,7 +43,6 @@ import { ICON_SIZE } from "../../lib/icon-scale";import { toneDot, toneInk } from "../../lib/tone";import type { Currency } from "../../state/theme";import { AgentAvatar } from "../../components/ui/agent-avatar";-import { Badge } from "../../components/ui/badge";import { Dropdown } from "../../components/ui/dropdown";import { GlyphIcon } from "../../components/ui/glyph-icon";import { ELLIPSIS_ICON } from "../../components/ui/session-row-menu";@@ -92,7 +92,6 @@ export function ChartLegend() {export function ChartCard({employee,state,- isCeo,currency,x,y,@@ -103,7 +102,6 @@ export function ChartCard({employee: OrgEmployeeItem;/** The state the dot draws — the live one, which the chart's own `state` cannot be. */state: OrgEmployeeState;- isCeo: boolean;currency: Currency;/** Top-left corner inside the drawing. */x: number;@@ -170,11 +168,8 @@ export function ChartCard({className="shrink-0 rounded-md"/><span className="min-w-0 flex-1">- <span className="flex items-center gap-1.5">- <span className="min-w-0 truncate text-[13px] leading-4 font-semibold text-gray-900 dark:text-gray-100">- {employee.name}- </span>- {isCeo && <Badge tone="brand">{S.company.ceo}</Badge>}+ <span className="block truncate text-[13px] leading-4 font-semibold text-gray-900 dark:text-gray-100">+ {employee.name}</span><span className="block truncate text-[11px] leading-4 text-gray-500 dark:text-gray-400">{employee.title}diff --git a/packages/web/src/features/company/org-chart-page.tsx b/packages/web/src/features/company/org-chart-page.tsxindex ea0f44ef..42ebe0ee 100644--- a/packages/web/src/features/company/org-chart-page.tsx+++ b/packages/web/src/features/company/org-chart-page.tsx@@ -533,7 +533,6 @@ export function OrgChartPage() {key={node.id}employee={employee}state={employeeStates.get(employee.agentId) ?? employee.state}- isCeo={isCeo}currency={currency}x={node.x}y={node.y}diff --git a/packages/web/src/features/settings/trace-import-row.tsx b/packages/web/src/features/settings/trace-import-row.tsxindex f76303bf..076f5c56 100644--- a/packages/web/src/features/settings/trace-import-row.tsx+++ b/packages/web/src/features/settings/trace-import-row.tsx@@ -8,7 +8,9 @@* inherited because this dialog does not show which one is current — every other row in it* belongs to the account or the server — and an import that silently landed in whichever* Project the sidebar happened to have selected would be a hard mistake to notice. It also- * means a Trace can be imported into a Project other than the open one.+ * means a Trace can be imported into a Project other than the open one, as long as the viewer+ * owns it: importing is the owner's, so the picker lists owned Projects only, and a viewer who+ * owns none gets no row.** The row sits beside the CLI-sessions filter because both decide what the conversation* list holds. Export is deliberately not here: a Trace is downloaded from the conversation@@ -16,7 +18,7 @@*/import { useEffect, useState } from "react";import type { ChangeEvent } from "react";-import type { AgentSummary } from "@prismshadow/penguin-server/api";+import type { AgentSummary, ProjectSummary } from "@prismshadow/penguin-server/api";import * as api from "../../api/endpoints";import { S } from "../../lib/strings";import { apiErrorText } from "../../lib/api-error";@@ -31,6 +33,29 @@ import { PrefRow } from "./setting-row";/** Client-side pre-check before reading the picked file (the same cap as the server's import route). */const MAX_TRACE_BYTES = 14 * 1024 * 1024;+/**+ * The Projects the row offers, and the one it is on. The import route answers anyone but the+ * Project's owner with 403, so a Project the viewer is only a member of is left out rather than+ * offered for an import that can only fail. The pick stands while it is still one of them;+ * otherwise the open Project, when the viewer owns it, and then the first Project they own. With+ * none owned, `projects` is empty and `projectId` is "".+ */+export function traceImportTargets(+ projects: readonly ProjectSummary[],+ currentProjectId: string | null,+ picked: string,+): { projects: ProjectSummary[]; projectId: string } {+ const owned = projects.filter((p) => p.role === "owner");+ const isOwned = (id: string | null): id is string =>+ id !== null && owned.some((p) => p.projectId === id);+ const projectId = isOwned(picked)+ ? picked+ : isOwned(currentProjectId)+ ? currentProjectId+ : (owned[0]?.projectId ?? "");+ return { projects: owned, projectId };+}+export function TraceImportRow() {const { projects, currentProject } = useProject();const { reload } = useSessions();@@ -40,11 +65,12 @@ export function TraceImportRow() {const [agents, setAgents] = useState<readonly AgentSummary[]>([]);const [importing, setImporting] = useState(false);- /** Destination Project: the explicit pick, else the open one (which may still be resolving). */- const projectId =- pickedProject !== ""- ? pickedProject- : (currentProject?.projectId ?? projects[0]?.projectId ?? "");+ /** Destination Project, derived like the Agent below: only owned Projects are offered at all. */+ const { projects: ownedProjects, projectId } = traceImportTargets(+ projects,+ currentProject?.projectId ?? null,+ pickedProject,+ );/*** Destination Agent, derived rather than stored: a pick that the selected Project has no* Agent for falls back on its own, so switching Project cannot leave a stale id behind.@@ -79,7 +105,7 @@ export function TraceImportRow() {setImporting(true);try {await api.importAgentTrace(projectId, agentId, { dataBase64 });- const project = projects.find((p) => p.projectId === projectId);+ const project = ownedProjects.find((p) => p.projectId === projectId);const target = `${project ? projectDisplayName(project) : projectId} · ${agents.find((a) => a.agentId === agentId)?.name ?? agentId}`;@@ -113,6 +139,10 @@ export function TraceImportRow() {reader.readAsDataURL(file);};+ // Nowhere the viewer may import into: no row, rather than pickers for an import that the+ // server would refuse.+ if (ownedProjects.length === 0) return null;+return (<PrefRow label={S.settings.importTrace} info={S.settings.importTraceInfo}>{/* Each picker is boxed to a fixed width — a Select fills its container, and three@@ -131,7 +161,7 @@ export function TraceImportRow() {}}aria-label={S.settings.importTraceProject}>- {projects.map((p) => (+ {ownedProjects.map((p) => (<option key={p.projectId} value={p.projectId}>{projectDisplayName(p)}</option>diff --git a/packages/web/src/features/usage/chart-geom.ts b/packages/web/src/features/usage/chart-geom.tsindex 0f47ebc4..9641a55f 100644--- a/packages/web/src/features/usage/chart-geom.ts+++ b/packages/web/src/features/usage/chart-geom.ts@@ -5,11 +5,10 @@* stack, the cost line) share one coordinate system — canvas width, padding,* the x()/y() mapping, SVG paths, x-axis label indices. Bars fit the* container (fitBarWidth — no horizontal scrolling), per-segment geometry- * (including per-segment hit bands) is produced by barSegments, a series with- * holes in it is split by lineSegments so no stroke bridges an interval that- * has no value, and every line on the page — cost, cache hit rate,- * success rate — is drawn by linePath as straight segments between its points,- * with no smoothing anywhere; there's also hover-bubble placement (pointer+ * (including per-segment hit bands) is produced by barSegments, and every line+ * on the page — cost, cache hit rate, success rate — is drawn by linePath as+ * straight segments between its points, with no smoothing anywhere; there's+ * also hover-bubble placement (pointer* lower-right, flipping at the edges). See chart-svg.tsx for the render* skeleton.*@@ -114,34 +113,13 @@ export function areaPath(geom: ChartGeom, values: number[]): string {/** Path coordinates keep 2 decimal places: the path string stays short and readable, and is easy to assert on in unit tests. */const rnd = (v: number): number => Math.round(v * 100) / 100;-/** A value-bearing point of a gapped series: its index on the shared x axis, and its value. */+/** A point of a line on an x axis several series share: the slot it sits in, and its value. */export interface LinePoint {index: number;value: number;}-/**- * Split a value sequence with gaps into **contiguous value-bearing** segments- * (each holding at least one point): points inside a segment are connected,- * segments are drawn apart, and a segment of one point draws only a point —- * a line must never bridge an interval where the series has no value.- */-export function lineSegments(values: readonly (number | null)[]): LinePoint[][] {- const segments: LinePoint[][] = [];- let current: LinePoint[] = [];- values.forEach((value, index) => {- if (value === null) {- if (current.length > 0) segments.push(current);- current = [];- return;- }- current.push({ index, value });- });- if (current.length > 0) segments.push(current);- return segments;-}--/** Straight-line path through one gap-free segment (`M` + `L`s); a one-point segment yields a bare `M` that strokes nothing, so callers draw its dot instead. */+/** Straight-line path through the given points in order (`M` + `L`s), whatever slots lie between them; a single point yields a bare `M` that strokes nothing, so callers draw its dot instead. */export function segmentPath(geom: ChartGeom, segment: readonly LinePoint[]): string {return segment.map((p, i) => `${i === 0 ? "M" : "L"}${rnd(geom.x(p.index))},${rnd(geom.y(p.value))}`)diff --git a/packages/web/src/lib/strings-en.ts b/packages/web/src/lib/strings-en.tsindex 38a7ad4e..4622f340 100644--- a/packages/web/src/lib/strings-en.ts+++ b/packages/web/src/lib/strings-en.ts@@ -3007,6 +3007,9 @@ Scenarios:text: "Pick a Benchmark, press Use → Optimize, set a target score and send; a new version is kept only when the score strictly improves.",},],+ /** The first step card's text for a Project member: no Create manually, which is the owner's. */+ guideCreateMember:+ "Press Create with AI at the top right to have AI write a set of cases for an agent and take its baseline score.",searchPlaceholder: "Search titles, descriptions or tested agents",noMatches: "No Benchmark matches",filterByAgent: (agentId: string): string => `Benchmarks that evaluated ${agentId}`,@@ -3029,6 +3032,10 @@ Scenarios:"The cases' difficulty could not be calibrated; delete this Benchmark and create it again",creationFailedDetail:"Calibration of this Benchmark never completed, so it cannot be evaluated or optimized; delete it and create it again.",+ /** The two lines above for a Project member: no delete step, since deleting is the owner's. */+ creationFailedHintMember: "The cases' difficulty could not be calibrated",+ creationFailedDetailMember:+ "Calibration of this Benchmark never completed, so it cannot be evaluated or optimized.",testedAgents: "Tested agents",lastEvaluated: (when: string): string => `last evaluated ${when}`,sparklineLabel: (n: number): string => `Score trend over ${n} evaluation${n === 1 ? "" : "s"}`,diff --git a/packages/web/src/lib/strings.ts b/packages/web/src/lib/strings.tsindex f38ed039..acebfa21 100644--- a/packages/web/src/lib/strings.ts+++ b/packages/web/src/lib/strings.ts@@ -2988,6 +2988,8 @@ Benchmark:text: "选一个 Benchmark,点「使用」→「优化」,设定目标分数后在新对话中发送;分数严格提升才保留新版本。",},],+ /** The first step card's text for a Project member: no Create manually, which is the owner's. */+ guideCreateMember: "点右上角「用 AI 创建」,让 AI 为某个智能体出一套题并取得基线分。",searchPlaceholder: "搜索标题、描述或被测智能体",noMatches: "没有匹配的 Benchmark",/** The chip shown when the address filters the list to one Agent's Benchmarks. */@@ -3008,6 +3010,9 @@ Benchmark:creationFailedHint: "题目难度未能校准完成,请删除后重新创建",creationFailedDetail:"这套题的难度校准没有完成,无法评估或优化;请删除这个 Benchmark,然后重新创建。",+ /** The two lines above for a Project member: no delete step, since deleting is the owner's. */+ creationFailedHintMember: "题目难度未能校准完成",+ creationFailedDetailMember: "这套题的难度校准没有完成,无法评估或优化。",/** The avatars on a card: which Agents this Benchmark has scored so far. */testedAgents: "被测过的智能体",lastEvaluated: (when: string): string => `最近评估 ${when}`,diff --git a/packages/web/test/benchmark-metrics.test.ts b/packages/web/test/benchmark-metrics.test.tsindex 2c117990..f0791066 100644--- a/packages/web/test/benchmark-metrics.test.ts+++ b/packages/web/test/benchmark-metrics.test.ts@@ -3,8 +3,8 @@* dynamic y-axis range, and label grouping — the tested Agent, the model and the thinking* level, which is also what a score change is measured within. The Agent State version and the* provider are on the record and outside the key, so successive versions of one agent stay on- * one line. The gap segmentation these series are drawn with is shared chart geometry- * (chart-geom's lineSegments, covered in usage-charts.test.ts).+ * one line — and that line is drawn through the series' own points, over the slots other series+ * hold between them (seriesPoints, stroked by chart-geom's segmentPath).*/import { describe, expect, it } from "vitest";import {@@ -16,15 +16,16 @@ import {matchesBenchmarkQuery,scoreScale,scoreValues,- seriesValues,+ seriesPoints,sparklineSeries,} from "../src/features/benchmark/benchmark-metrics";import type { EvaluationLabelLike } from "../src/features/benchmark/benchmark-metrics";+import { makeRangeGeom, segmentPath } from "../src/features/usage/chart-geom";const evaluations = [{ score: 60 }, { score: 75.25 }, { score: 85.5 }];describe("scoreValues", () => {- it("extracts stored Scores and treats non-finite input as a gap", () => {+ it("extracts stored Scores and reads non-finite input as missing", () => {expect(scoreValues(evaluations)).toEqual([60, 75.25, 85.5]);expect(scoreValues([{ score: Number.NaN }, { score: Infinity }])).toEqual([null, null]);});@@ -127,7 +128,7 @@ describe("evaluationLabel", () => {});});-describe("labelSeries / seriesValues (curves split by label)", () => {+describe("labelSeries (curves split by label)", () => {const runtime = { provider: "deepseek", modelId: "deepseek-v4-pro", thinkingLevel: "xhigh" };// Annotated: an untagged `{ score }` shares no property with the all-optional label type,// so the inferred union would trip the weak-type check when handed to labelSeries.@@ -174,12 +175,6 @@ describe("labelSeries / seriesValues (curves split by label)", () => {expect(series[0]!.indices).toEqual([0, 1]);});- it("seriesValues: indexes outside the series are null (skipped points), keeping the global time axis", () => {- const series = labelSeries(mixed);- expect(seriesValues(mixed, series[0]!)).toEqual([6, null, 7.5, 8.5, null]);- expect(seriesValues(mixed, series[2]!)).toEqual([null, 7, null, null, null]);- });-it("all untagged defensive input forms one unnamed series", () => {const series = labelSeries([{}, {}]);expect(series).toHaveLength(1);@@ -188,6 +183,59 @@ describe("labelSeries / seriesValues (curves split by label)", () => {});});+describe("seriesPoints (one line per series on the shared time axis)", () => {+ const runtime = { provider: "deepseek", modelId: "deepseek-v4-pro", thinkingLevel: "xhigh" };+ const writer = { agentId: "report-writer", ...runtime };+ const support = { agentId: "support", ...runtime };+ // Scored on 0..100, so the geometry below maps each Score straight onto the chart's own scale.+ const geomFor = (n: number) => makeRangeGeom(n, 0, 100, 640);+ /** A path vertex as segmentPath writes it: both coordinates rounded to 2 decimals. */+ const at = (n: number, index: number, value: number) => {+ const g = geomFor(n);+ return `${Math.round(g.x(index) * 100) / 100},${Math.round(g.y(value) * 100) / 100}`;+ };++ it("joins a series' consecutive points across another agent's evaluations, each at its own slot", () => {+ const interleaved: Array<{ score: number } & EvaluationLabelLike> = [+ { score: 60, ...writer, version: 1 },+ { score: 40, ...support, version: 1 },+ { score: 70, ...writer, version: 2 },+ { score: 45, ...support, version: 2 },+ { score: 80, ...writer, version: 3 },+ ];+ const [writerSeries, supportSeries] = labelSeries(interleaved);+ const writerPoints = seriesPoints(interleaved, writerSeries!);+ const supportPoints = seriesPoints(interleaved, supportSeries!);+ // The x slot of every point is its position in the scoreboard, not in its series.+ expect(writerPoints).toEqual([+ { index: 0, value: 60 },+ { index: 2, value: 70 },+ { index: 4, value: 80 },+ ]);+ expect(supportPoints).toEqual([+ { index: 1, value: 40 },+ { index: 3, value: 45 },+ ]);+ // One unbroken stroke per series, straight over the slots the other series holds.+ const g = geomFor(interleaved.length);+ expect(segmentPath(g, writerPoints)).toBe(`M${at(5, 0, 60)} L${at(5, 2, 70)} L${at(5, 4, 80)}`);+ expect(segmentPath(g, supportPoints)).toBe(`M${at(5, 1, 40)} L${at(5, 3, 45)}`);+ });++ it("a series with a single evaluation is a lone point with no stroke", () => {+ const evaluations: Array<{ score: number } & EvaluationLabelLike> = [+ { score: 60, ...writer, version: 1 },+ { score: 72, ...writer, version: 2 },+ { score: 58, ...support, version: 1 },+ ];+ const [, supportSeries] = labelSeries(evaluations);+ const points = seriesPoints(evaluations, supportSeries!);+ expect(points).toEqual([{ index: 2, value: 58 }]);+ // A bare move: the chart draws this point's dot and strokes nothing.+ expect(segmentPath(geomFor(evaluations.length), points)).toBe(`M${at(3, 2, 58)}`);+ });+});+describe("row helpers: latestWithDelta / latestScoreOfAgent / sparklineSeries / defaultTargetScore", () => {const label = { agentId: "report-writer", version: 1, provider: "deepseek", modelId: "m" };const timed = [diff --git a/packages/web/test/owner-only-actions.test.ts b/packages/web/test/owner-only-actions.test.tsnew file mode 100644index 00000000..488cc049--- /dev/null+++ b/packages/web/test/owner-only-actions.test.ts@@ -0,0 +1,145 @@+/**+ * Owner-only writes are offered to the Project's owner alone. The server refuses three of them to+ * anyone else with 403 (`requireProjectOwner`): creating a Benchmark by hand+ * (`POST /api/projects/:projectId/benchmarks`), deleting one+ * (`DELETE /api/projects/:projectId/benchmarks/:benchmarkId`) and importing a Trace+ * (`POST /api/projects/:projectId/agents/:agentId/traces/import`). A member offered one could+ * only fill in the form, or pick the file, for a refusal at the end, and copy that names one of+ * these steps sends a member to a button they do not have.+ *+ * vitest runs node-only here, so the Evaluation Center's buttons and a failed Benchmark's notices+ * are rendered to static markup, and the Trace import row is checked through the function its+ * Project picker is derived from — the row draws nothing when that function offers no Project.+ */+import { createElement } from "react";+import { renderToStaticMarkup } from "react-dom/server";+import { describe, expect, it } from "vitest";+import type { BenchmarkSummary, ProjectSummary } from "@prismshadow/penguin-server/api";+import { UnpublishedNotice } from "../src/features/benchmark/benchmark-detail-page";+import { BenchmarkCard, BenchmarkCreateButtons } from "../src/features/benchmark/benchmark-page";+import { traceImportTargets } from "../src/features/settings/trace-import-row";+import { S, zh } from "../src/lib/strings";+import { en } from "../src/lib/strings-en";++const noop = () => {};++describe("the Evaluation Center's create entry points", () => {+ const render = (isOwner: boolean) =>+ renderToStaticMarkup(+ createElement(BenchmarkCreateButtons, { isOwner, onAi: noop, onManual: noop }),+ );++ it("offer the owner both ways to create a Benchmark", () => {+ const html = render(true);+ expect(html).toContain(S.aiCreate.withAi);+ expect(html).toContain(S.aiCreate.manual);+ expect(html.match(/<button/g)).toHaveLength(2);+ });++ it("offer a member Create with AI alone: the conversation is theirs to start, the write is not", () => {+ const html = render(false);+ expect(html).toContain(S.aiCreate.withAi);+ expect(html).not.toContain(S.aiCreate.manual);+ expect(html.match(/<button/g)).toHaveLength(1);+ });+});++describe("a failed Benchmark's notices", () => {+ const failed: BenchmarkSummary = {+ id: "report-writing-v1",+ title: "Report writing under conflicting sources",+ status: "failed",+ caseCount: 3,+ evaluations: [],+ agentIds: [],+ };+ /** The card on the Evaluation Center, whose delete button is the owner's alone. */+ const card = (canDelete: boolean) =>+ renderToStaticMarkup(+ createElement(BenchmarkCard, {+ benchmark: failed,+ locale: "zh",+ nameOf: (agentId: string) => agentId,+ canDelete,+ onOpen: noop,+ onUse: noop,+ onDelete: noop,+ }),+ );+ /** The notice on the Benchmark's own page, which stands in place of its detail. */+ const page = (isOwner: boolean) =>+ renderToStaticMarkup(createElement(UnpublishedNotice, { failed: true, isOwner }));++ it("tell the owner to delete it and create it again, beside the delete button", () => {+ const html = card(true);+ expect(html).toContain(S.benchmark.creationFailedHint);+ expect(html).toContain(`aria-label="${S.benchmark.deleteBenchmark}"`);+ expect(page(true)).toContain(S.benchmark.creationFailedDetail);+ });++ it("tell a member what happened without the delete step, since the member has no delete button", () => {+ const html = card(false);+ expect(html).toContain(S.benchmark.creationFailedHintMember);+ expect(html).not.toContain(S.benchmark.creationFailedHint);+ expect(html).not.toContain(S.benchmark.deleteBenchmark);+ const detail = page(false);+ expect(detail).toContain(S.benchmark.creationFailedDetailMember);+ expect(detail).not.toContain(S.benchmark.creationFailedDetail);+ // Neither dictionary words a member's line with the step.+ for (const line of [+ zh.benchmark.creationFailedHintMember,+ zh.benchmark.creationFailedDetailMember,+ ]) {+ expect(line).not.toContain("删除");+ }+ for (const line of [+ en.benchmark.creationFailedHintMember,+ en.benchmark.creationFailedDetailMember,+ ]) {+ expect(line).not.toMatch(/delete/i);+ }+ });+});++describe("traceImportTargets (the Trace import row's Projects)", () => {+ const project = (projectId: string, role: ProjectSummary["role"]): ProjectSummary => ({+ projectId,+ role,+ ownerUserId: role === "owner" ? "bob" : "alice",+ createdAt: "2026-09-17T00:00:00.000Z",+ });+ /** Alice's Project, shared with Bob as a member. */+ const shared = project("alice-default_project", "member");+ const own = project("bob-default_project", "owner");+ const lab = project("bob-lab", "owner");++ it("offers only the Projects the viewer owns, in the list's order", () => {+ expect(traceImportTargets([shared, own, lab], null, "").projects).toEqual([own, lab]);+ });++ it("starts on the open Project when the viewer owns it, else on the first Project they own", () => {+ expect(traceImportTargets([shared, own, lab], "bob-lab", "").projectId).toBe("bob-lab");+ // Bob is looking at Alice's Project: the row starts on his own rather than on a refusal.+ expect(traceImportTargets([shared, own, lab], "alice-default_project", "").projectId).toBe(+ "bob-default_project",+ );+ });++ it("keeps a pick among the owned Projects, and falls back from one the viewer does not own", () => {+ expect(traceImportTargets([shared, own, lab], "bob-default_project", "bob-lab").projectId).toBe(+ "bob-lab",+ );+ // A pick that is no longer owned (the list reloaded under it) is not kept.+ expect(+ traceImportTargets([shared, own], "bob-default_project", "alice-default_project").projectId,+ ).toBe("bob-default_project");+ });++ it("gives a viewer who owns no Project nothing to import into, which leaves the row undrawn", () => {+ expect(traceImportTargets([shared], "alice-default_project", "")).toEqual({+ projects: [],+ projectId: "",+ });+ expect(traceImportTargets([], null, "")).toEqual({ projects: [], projectId: "" });+ });+});diff --git a/packages/web/test/usage-charts.test.ts b/packages/web/test/usage-charts.test.tsindex a1e33fb2..798b3c4b 100644--- a/packages/web/test/usage-charts.test.ts+++ b/packages/web/test/usage-charts.test.ts@@ -1,7 +1,7 @@/*** Cost Center chart pure-function unit tests (chart-geom.ts): coordinate mapping, SVG path- * assembly (straight and gap-split paths — every line on the page is straight segments,- * nothing is smoothed), container-fitting bar width (charts never scroll), stacked-bar+ * assembly (straight paths through the points given — every line on the page is straight+ * segments, nothing is smoothed), container-fitting bar width (charts never scroll), stacked-bar* segment geometry and per-segment hit bands, and hover-bubble placement (pointer lower-right, flipping at the edges; the cache hit rate* shown in the cacheRead bubble is lib/format's shared cacheHitRate, tested in* format.test.ts). Component interaction isn't covered here (vitest runs in a node@@ -18,7 +18,6 @@ import {makeRangeGeom,linePath,areaPath,- lineSegments,segmentPath,sparseLabelIdx,autoLabelIdx,@@ -85,46 +84,30 @@ describe("linePath / areaPath", () => {});});-describe("lineSegments / segmentPath (gap segmentation)", () => {- it("no gaps: one segment with everything (consecutive indexes)", () => {- expect(lineSegments([60, 75.25, 85.5])).toEqual([- [- { index: 0, value: 60 },- { index: 1, value: 75.25 },- { index: 2, value: 85.5 },- ],- ]);- });-- it("a middle gap breaks into two segments (a lone point still forms a segment: point drawn, no line)", () => {- expect(lineSegments([0.12, null, 0.2])).toEqual([- [{ index: 0, value: 0.12 }],- [{ index: 2, value: 0.2 }],- ]);- expect(lineSegments([null, 1, 2, null, 3])).toEqual([- [- { index: 1, value: 1 },- { index: 2, value: 2 },- ],- [{ index: 4, value: 3 }],- ]);- });+describe("segmentPath", () => {+ const g = makeRangeGeom(3, 0, 100, 640);+ /** Path coordinates are rounded to 2 decimals (see chart-geom's rnd). */+ const at = (i: number, v: number) => `${Math.round(g.x(i) * 100) / 100},${g.y(v)}`;- it("all missing / empty list: no segments", () => {- expect(lineSegments([null, null])).toEqual([]);- expect(lineSegments([])).toEqual([]);+ it("a lone point is a bare move that strokes nothing, and no points is no path", () => {+ expect(segmentPath(g, [{ index: 2, value: 0 }])).toBe(`M${at(2, 0)}`);+ expect(segmentPath(g, [])).toBe("");});- it("a segment strokes only its own indexes, so nothing bridges the hole between two segments", () => {- const g = makeRangeGeom(3, 0, 100, 640);- /** Path coordinates are rounded to 2 decimals (see chart-geom's rnd). */- const at = (i: number, v: number) => `${Math.round(g.x(i) * 100) / 100},${g.y(v)}`;- const [first, second] = lineSegments([100, null, 0]);- expect(segmentPath(g, first!)).toBe(`M${at(0, 100)}`);- expect(segmentPath(g, second!)).toBe(`M${at(2, 0)}`);- expect(segmentPath(g, [])).toBe("");- // A two-point run is one straight stroke between exactly those two indexes.- expect(segmentPath(g, lineSegments([100, 0, null])[0]!)).toBe(`M${at(0, 100)} L${at(1, 0)}`);+ it("strokes straight from each point to the next, over any slot between them", () => {+ expect(+ segmentPath(g, [+ { index: 0, value: 100 },+ { index: 1, value: 0 },+ ]),+ ).toBe(`M${at(0, 100)} L${at(1, 0)}`);+ // Slot 1 belongs to another series: the stroke joins slots 0 and 2 directly.+ expect(+ segmentPath(g, [+ { index: 0, value: 100 },+ { index: 2, value: 0 },+ ]),+ ).toBe(`M${at(0, 100)} L${at(2, 0)}`);});});