niceeval 0.6.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (378) hide show
  1. package/INDEX.md +23 -23
  2. package/README.zh.md +6 -6
  3. package/dist/agents/types.d.ts +69 -7
  4. package/dist/context/types.d.ts +32 -12
  5. package/dist/i18n/en.d.ts +54 -0
  6. package/dist/i18n/zh-CN.d.ts +57 -3
  7. package/dist/o11y/types.d.ts +16 -2
  8. package/dist/report/aggregate.d.ts +32 -24
  9. package/dist/report/aggregate.js +158 -50
  10. package/dist/report/built-in/index.d.ts +2 -0
  11. package/dist/report/built-in/index.js +8 -0
  12. package/dist/report/components.d.ts +93 -160
  13. package/dist/report/components.js +377 -114
  14. package/dist/report/compute.d.ts +87 -81
  15. package/dist/report/compute.js +597 -417
  16. package/dist/report/flag.d.ts +32 -6
  17. package/dist/report/flag.js +92 -4
  18. package/dist/report/format.d.ts +19 -11
  19. package/dist/report/format.js +30 -13
  20. package/dist/report/index.d.ts +16 -16
  21. package/dist/report/index.js +20 -21
  22. package/dist/report/load.js +3 -2
  23. package/dist/report/locale.d.ts +57 -33
  24. package/dist/report/locale.js +122 -56
  25. package/dist/report/metrics.d.ts +23 -4
  26. package/dist/report/metrics.js +110 -25
  27. package/dist/report/primitives.d.ts +48 -15
  28. package/dist/report/primitives.js +135 -26
  29. package/dist/report/react/AttemptList.d.ts +9 -7
  30. package/dist/report/react/AttemptList.js +17 -10
  31. package/dist/report/react/DeltaTable.js +19 -18
  32. package/dist/report/react/EvalList.d.ts +4 -4
  33. package/dist/report/react/EvalList.js +0 -0
  34. package/dist/report/react/ExperimentComparison.d.ts +10 -0
  35. package/dist/report/react/ExperimentComparison.js +12 -0
  36. package/dist/report/react/ExperimentList.d.ts +4 -3
  37. package/dist/report/react/ExperimentList.js +17 -18
  38. package/dist/report/react/MetricBars.js +5 -4
  39. package/dist/report/react/MetricLine.js +12 -5
  40. package/dist/report/react/MetricMatrix.js +1 -1
  41. package/dist/report/react/MetricScatter.js +59 -28
  42. package/dist/report/react/MetricTable.js +2 -12
  43. package/dist/report/react/ScopeSummary.d.ts +10 -0
  44. package/dist/report/react/ScopeSummary.js +17 -0
  45. package/dist/report/react/Scoreboard.js +6 -6
  46. package/dist/report/react/cell.js +2 -2
  47. package/dist/report/react/chart-math.d.ts +23 -6
  48. package/dist/report/react/chart-math.js +71 -19
  49. package/dist/report/react/fixtures.d.ts +5 -9
  50. package/dist/report/react/fixtures.js +110 -147
  51. package/dist/report/react/index.d.ts +15 -5
  52. package/dist/report/react/index.js +18 -7
  53. package/dist/report/report.d.ts +137 -16
  54. package/dist/report/report.js +259 -28
  55. package/dist/report/text/faces.d.ts +17 -19
  56. package/dist/report/text/faces.js +253 -184
  57. package/dist/report/text/plot.js +1 -1
  58. package/dist/report/text/table.js +38 -7
  59. package/dist/report/tree.d.ts +90 -40
  60. package/dist/report/tree.js +252 -94
  61. package/dist/report/types.d.ts +247 -284
  62. package/dist/report/types.js +4 -3
  63. package/dist/report/web.d.ts +21 -5
  64. package/dist/report/web.js +42 -16
  65. package/dist/results/select.d.ts +38 -16
  66. package/dist/results/select.js +73 -25
  67. package/dist/results/types.d.ts +49 -14
  68. package/dist/runner/feedback/sink.d.ts +110 -0
  69. package/dist/runner/types.d.ts +513 -22
  70. package/dist/sandbox/docker.d.ts +23 -2
  71. package/dist/sandbox/e2b.d.ts +15 -1
  72. package/dist/sandbox/errors.d.ts +30 -3
  73. package/dist/sandbox/io-retry.d.ts +17 -0
  74. package/dist/sandbox/registry.d.ts +2 -0
  75. package/dist/sandbox/resolve.d.ts +18 -5
  76. package/dist/sandbox/retry.d.ts +11 -1
  77. package/dist/sandbox/types.d.ts +39 -5
  78. package/dist/sandbox/vercel.d.ts +7 -1
  79. package/dist/scoring/coverage.d.ts +30 -0
  80. package/dist/scoring/display.d.ts +21 -0
  81. package/dist/scoring/display.js +120 -0
  82. package/dist/scoring/types.d.ts +103 -20
  83. package/dist/shared/aggregate.d.ts +4 -2
  84. package/dist/shared/aggregate.js +8 -7
  85. package/dist/shared/types.d.ts +28 -0
  86. package/dist/tty-line.d.ts +0 -4
  87. package/dist/util.d.ts +23 -0
  88. package/docs-site/zh/README.md +44 -0
  89. package/docs-site/zh/examples/ai-agent-application.mdx +63 -0
  90. package/docs-site/zh/examples/coding-agent-extensions.mdx +57 -0
  91. package/docs-site/zh/examples/index.mdx +50 -0
  92. package/docs-site/zh/{concepts → explanation}/adapter.mdx +31 -13
  93. package/docs-site/zh/{concepts → explanation}/assert.mdx +7 -7
  94. package/docs-site/zh/{concepts → explanation}/drive.mdx +8 -8
  95. package/docs-site/zh/{concepts → explanation}/evals.mdx +4 -4
  96. package/docs-site/zh/{concepts → explanation}/experiment.mdx +8 -8
  97. package/docs-site/zh/{concepts → explanation}/hitl.mdx +8 -8
  98. package/docs-site/zh/{concepts → explanation}/judge.mdx +5 -5
  99. package/docs-site/zh/{concepts → explanation}/overview.mdx +11 -11
  100. package/docs-site/zh/{guides → explanation}/runner.mdx +18 -8
  101. package/docs-site/zh/{concepts → explanation}/tier.mdx +6 -6
  102. package/docs-site/zh/{guides → how-to}/agent-feedback-loop.mdx +35 -33
  103. package/docs-site/zh/{guides → how-to}/authoring.mdx +35 -2
  104. package/docs-site/zh/{guides → how-to}/ci-integration.mdx +23 -12
  105. package/docs-site/zh/{guides → how-to}/connect-otel.mdx +6 -6
  106. package/docs-site/zh/{guides → how-to}/connect-your-agent.mdx +47 -21
  107. package/docs-site/zh/{guides → how-to}/custom-reports.mdx +34 -39
  108. package/docs-site/zh/{guides → how-to}/dataset-fanout.mdx +25 -3
  109. package/docs-site/zh/{guides → how-to}/experiments.mdx +12 -5
  110. package/docs-site/zh/how-to/publish-report.mdx +105 -0
  111. package/docs-site/zh/{guides → how-to}/reporters.mdx +2 -2
  112. package/docs-site/zh/{guides → how-to}/sandbox-agent.mdx +56 -7
  113. package/docs-site/zh/how-to/sandbox-providers.mdx +350 -0
  114. package/docs-site/zh/{guides → how-to}/scoring-guide.mdx +4 -4
  115. package/docs-site/zh/{guides → how-to}/viewing-results.mdx +82 -39
  116. package/docs-site/zh/{guides → how-to}/write-experiment.mdx +6 -4
  117. package/docs-site/zh/{guides → how-to}/write-send.mdx +30 -14
  118. package/docs-site/zh/index.mdx +24 -26
  119. package/docs-site/zh/introduction.mdx +8 -8
  120. package/docs-site/zh/reference/builtin-agents.mdx +32 -5
  121. package/docs-site/zh/reference/capabilities.mdx +8 -8
  122. package/docs-site/zh/reference/cli.mdx +40 -12
  123. package/docs-site/zh/reference/define-agent.mdx +58 -5
  124. package/docs-site/zh/reference/define-config.mdx +1 -1
  125. package/docs-site/zh/reference/define-eval.mdx +42 -9
  126. package/docs-site/zh/reference/events.mdx +3 -3
  127. package/docs-site/zh/reference/expect.mdx +26 -1
  128. package/docs-site/zh/{guides → reference}/official-adapters.mdx +32 -8
  129. package/docs-site/zh/{guides → reference}/report-components.mdx +45 -33
  130. package/docs-site/zh/{guides → reference}/results-data.mdx +21 -13
  131. package/docs-site/zh/troubleshooting/debug-sandbox.mdx +57 -0
  132. package/docs-site/zh/troubleshooting/debugging.mdx +212 -0
  133. package/docs-site/zh/{quickstart.mdx → tutorials/quickstart.mdx} +5 -17
  134. package/package.json +10 -2
  135. package/src/agents/ai-sdk-otel.test.ts +1 -0
  136. package/src/agents/ai-sdk.test.ts +3 -0
  137. package/src/agents/ai-sdk.ts +3 -0
  138. package/src/agents/bub-install-spec.test.ts +34 -0
  139. package/src/agents/bub-install-spec.ts +32 -0
  140. package/src/agents/bub.ts +31 -32
  141. package/src/agents/claude-code.test.ts +130 -9
  142. package/src/agents/claude-code.ts +76 -4
  143. package/src/agents/codex.test.ts +189 -40
  144. package/src/agents/codex.ts +155 -14
  145. package/src/agents/coding-cli-versions.test.ts +15 -0
  146. package/src/agents/coding-cli-versions.ts +3 -0
  147. package/src/agents/index.ts +13 -2
  148. package/src/agents/langgraph.test.ts +204 -0
  149. package/src/agents/langgraph.ts +495 -0
  150. package/src/agents/marketplace.ts +85 -0
  151. package/src/agents/native-config.test.ts +179 -0
  152. package/src/agents/native-config.ts +267 -0
  153. package/src/agents/openai-compat.test.ts +1 -0
  154. package/src/agents/openai-compat.ts +1 -1
  155. package/src/agents/openclaw.test.ts +31 -0
  156. package/src/agents/openclaw.ts +171 -0
  157. package/src/agents/plugin-config.test.ts +1 -0
  158. package/src/agents/sdk-streams.test.ts +79 -0
  159. package/src/agents/sdk-streams.ts +55 -10
  160. package/src/agents/skills.test.ts +1 -0
  161. package/src/agents/streaming.test.ts +3 -9
  162. package/src/agents/streaming.ts +2 -2
  163. package/src/agents/types.ts +71 -8
  164. package/src/agents/ui-message-stream.test.ts +3 -0
  165. package/src/cli.ts +446 -124
  166. package/src/context/context.test.ts +51 -12
  167. package/src/context/context.ts +162 -30
  168. package/src/context/session.test.ts +2 -1
  169. package/src/context/session.ts +115 -7
  170. package/src/context/types.ts +30 -12
  171. package/src/define.test.ts +13 -8
  172. package/src/define.ts +25 -4
  173. package/src/expect/index.ts +53 -23
  174. package/src/i18n/en.ts +81 -17
  175. package/src/i18n/zh-CN.ts +80 -17
  176. package/src/o11y/cost.test.ts +1 -0
  177. package/src/o11y/execution-tree.test.ts +1 -20
  178. package/src/o11y/otlp/mappers/claude-code.test.ts +1 -0
  179. package/src/o11y/otlp/parse.test.ts +1 -0
  180. package/src/o11y/otlp/turn-otel.test.ts +1 -0
  181. package/src/o11y/parsers/bub.test.ts +1 -0
  182. package/src/o11y/parsers/claude-code.test.ts +1 -34
  183. package/src/o11y/parsers/openclaw.test.ts +154 -0
  184. package/src/o11y/parsers/openclaw.ts +310 -0
  185. package/src/o11y/prices.json +746 -311
  186. package/src/o11y/tool-names.test.ts +1 -0
  187. package/src/o11y/types.ts +16 -2
  188. package/src/report/aggregate.ts +178 -61
  189. package/src/report/built-in/index.tsx +9 -0
  190. package/src/report/components.tsx +625 -279
  191. package/src/report/compute.ts +723 -491
  192. package/src/report/dual-render.test.tsx +741 -1024
  193. package/src/report/flag.ts +104 -12
  194. package/src/report/format.ts +32 -12
  195. package/src/report/index.ts +119 -46
  196. package/src/report/load.ts +3 -2
  197. package/src/report/locale.ts +136 -65
  198. package/src/report/metrics.ts +108 -25
  199. package/src/report/primitives.tsx +196 -45
  200. package/src/report/react/AttemptList.tsx +30 -43
  201. package/src/report/react/DeltaTable.tsx +63 -45
  202. package/src/report/react/EvalList.tsx +0 -0
  203. package/src/report/react/ExperimentComparison.tsx +73 -0
  204. package/src/report/react/ExperimentList.tsx +50 -32
  205. package/src/report/react/MetricBars.tsx +5 -4
  206. package/src/report/react/MetricLine.tsx +13 -8
  207. package/src/report/react/MetricMatrix.tsx +2 -2
  208. package/src/report/react/MetricScatter.tsx +86 -34
  209. package/src/report/react/MetricTable.tsx +4 -76
  210. package/src/report/react/ScopeSummary.tsx +86 -0
  211. package/src/report/react/Scoreboard.tsx +28 -10
  212. package/src/report/react/cell.tsx +2 -2
  213. package/src/report/react/chart-math.test.ts +85 -0
  214. package/src/report/react/chart-math.ts +101 -22
  215. package/src/report/react/enhance.js +89 -5
  216. package/src/report/react/fixtures.ts +114 -154
  217. package/src/report/react/index.tsx +24 -39
  218. package/src/report/react/render.test.tsx +138 -158
  219. package/src/report/react/styles.css +243 -82
  220. package/src/report/report.test.ts +779 -841
  221. package/src/report/report.ts +423 -41
  222. package/src/report/text/faces.ts +290 -193
  223. package/src/report/text/plot.ts +1 -1
  224. package/src/report/text/table.ts +44 -7
  225. package/src/report/tree.ts +362 -104
  226. package/src/report/types.ts +261 -271
  227. package/src/report/web.ts +63 -20
  228. package/src/results/annotated-source.test.ts +62 -9
  229. package/src/results/annotated-source.ts +64 -6
  230. package/src/results/attempt-evidence.test.ts +13 -11
  231. package/src/results/attempt-evidence.ts +20 -13
  232. package/src/results/attempt-source.ts +6 -3
  233. package/src/results/copy.ts +150 -60
  234. package/src/results/host-equivalence.test.ts +34 -20
  235. package/src/results/index.ts +12 -4
  236. package/src/results/locator.test.ts +1 -22
  237. package/src/results/open.ts +15 -5
  238. package/src/results/publish.ts +149 -0
  239. package/src/results/results.test.ts +89 -54
  240. package/src/results/select.ts +104 -34
  241. package/src/results/truncate.ts +90 -0
  242. package/src/results/types.ts +43 -14
  243. package/src/results/writer.ts +31 -13
  244. package/src/runner/attempt.test.ts +138 -7
  245. package/src/runner/attempt.ts +603 -104
  246. package/src/runner/discover.test.ts +47 -0
  247. package/src/runner/discover.ts +36 -2
  248. package/src/runner/eval-source.test.ts +1 -27
  249. package/src/runner/feedback/agent.test.ts +504 -0
  250. package/src/runner/feedback/agent.ts +409 -0
  251. package/src/runner/feedback/ci.test.ts +562 -0
  252. package/src/runner/feedback/ci.ts +401 -0
  253. package/src/runner/feedback/coordinator.test.ts +317 -0
  254. package/src/runner/feedback/coordinator.ts +397 -0
  255. package/src/runner/feedback/failure.ts +40 -0
  256. package/src/runner/feedback/human.test.ts +616 -0
  257. package/src/runner/feedback/human.ts +535 -0
  258. package/src/runner/feedback/index.ts +66 -0
  259. package/src/runner/feedback/io.ts +78 -0
  260. package/src/runner/feedback/profile.test.ts +50 -0
  261. package/src/runner/feedback/profile.ts +58 -0
  262. package/src/runner/feedback/reducer.test.ts +395 -0
  263. package/src/runner/feedback/reducer.ts +260 -0
  264. package/src/runner/feedback/renderer.ts +82 -0
  265. package/src/runner/feedback/sink.ts +203 -0
  266. package/src/runner/feedback/testing.ts +106 -0
  267. package/src/runner/ledger.test.ts +230 -0
  268. package/src/runner/ledger.ts +329 -0
  269. package/src/runner/report.test.ts +128 -3
  270. package/src/runner/report.ts +33 -9
  271. package/src/runner/reporters/artifacts.ts +8 -2
  272. package/src/runner/reporters/braintrust.test.ts +8 -7
  273. package/src/runner/reporters/braintrust.ts +9 -2
  274. package/src/runner/reporters/index.ts +2 -2
  275. package/src/runner/reporters/json.test.ts +162 -0
  276. package/src/runner/reporters/json.ts +35 -8
  277. package/src/runner/reporters/shared.ts +1 -5
  278. package/src/runner/run.test.ts +760 -3
  279. package/src/runner/run.ts +243 -37
  280. package/src/runner/sandbox-prep.ts +3 -42
  281. package/src/runner/timing.ts +158 -0
  282. package/src/runner/types.ts +518 -22
  283. package/src/sandbox/checkpoint.test.ts +55 -0
  284. package/src/sandbox/checkpoint.ts +29 -8
  285. package/src/sandbox/cli-commands.ts +407 -0
  286. package/src/sandbox/docker.ts +115 -16
  287. package/src/sandbox/e2b-agent-template.test.ts +56 -0
  288. package/src/sandbox/e2b-agent-template.ts +94 -0
  289. package/src/sandbox/e2b.ts +74 -9
  290. package/src/sandbox/errors.ts +111 -4
  291. package/src/sandbox/index.ts +2 -0
  292. package/src/sandbox/io-retry.test.ts +58 -0
  293. package/src/sandbox/io-retry.ts +45 -0
  294. package/src/sandbox/keep-registry.test.ts +86 -0
  295. package/src/sandbox/keep-registry.ts +142 -0
  296. package/src/sandbox/keep.ts +178 -0
  297. package/src/sandbox/paths.test.ts +1 -0
  298. package/src/sandbox/paths.ts +19 -8
  299. package/src/sandbox/registry.ts +20 -3
  300. package/src/sandbox/resolve.ts +76 -11
  301. package/src/sandbox/retry.test.ts +70 -0
  302. package/src/sandbox/retry.ts +46 -4
  303. package/src/sandbox/types.ts +44 -6
  304. package/src/sandbox/vercel.ts +43 -20
  305. package/src/scoring/collector.ts +60 -17
  306. package/src/scoring/coverage.ts +95 -0
  307. package/src/scoring/diff.ts +81 -0
  308. package/src/scoring/display.test.ts +121 -0
  309. package/src/scoring/display.ts +133 -0
  310. package/src/scoring/evidence.test.ts +189 -0
  311. package/src/scoring/judge.test.ts +142 -0
  312. package/src/scoring/judge.ts +15 -18
  313. package/src/scoring/scoped.ts +217 -50
  314. package/src/scoring/types.ts +117 -20
  315. package/src/scoring/verdict.ts +16 -4
  316. package/src/shared/aggregate.ts +8 -6
  317. package/src/shared/types.ts +31 -0
  318. package/src/show/compose.ts +50 -67
  319. package/src/show/index.ts +127 -56
  320. package/src/show/render.ts +662 -131
  321. package/src/show/report-host.test.ts +188 -0
  322. package/src/show/report-host.ts +375 -0
  323. package/src/show/show.test.ts +320 -54
  324. package/src/tty-line.ts +8 -26
  325. package/src/util.test.ts +1 -0
  326. package/src/util.ts +41 -0
  327. package/src/view/app/App.test.tsx +69 -0
  328. package/src/view/app/App.tsx +144 -48
  329. package/src/view/app/components/AttemptModal.tsx +423 -11
  330. package/src/view/app/components/CodeView.tsx +41 -14
  331. package/src/view/app/components/CopyControls.tsx +2 -2
  332. package/src/view/app/i18n.ts +37 -17
  333. package/src/view/app/lib/attempt-route.test.ts +1 -0
  334. package/src/view/app/lib/verdict.ts +7 -9
  335. package/src/view/app/main.tsx +13 -8
  336. package/src/view/app/pages/{RunsPage.tsx → AttemptsPage.tsx} +6 -6
  337. package/src/view/app/types.ts +4 -1
  338. package/src/view/artifact-serving.test.ts +2 -1
  339. package/src/view/client-dist/app.css +1 -1
  340. package/src/view/client-dist/app.js +17 -17
  341. package/src/view/data.test.ts +10 -3
  342. package/src/view/data.ts +155 -49
  343. package/src/view/index.ts +56 -41
  344. package/src/view/server.ts +37 -15
  345. package/src/view/shared/types.ts +34 -5
  346. package/src/view/styles.css +227 -0
  347. package/src/view/view-report.test.ts +167 -62
  348. package/dist/report/built-ins/experiment-comparison.d.ts +0 -1
  349. package/dist/report/built-ins/experiment-comparison.js +0 -13
  350. package/dist/report/built-ins/index.d.ts +0 -1
  351. package/dist/report/built-ins/index.js +0 -2
  352. package/dist/report/react/GroupSummary.d.ts +0 -8
  353. package/dist/report/react/GroupSummary.js +0 -8
  354. package/dist/report/react/RunOverview.d.ts +0 -8
  355. package/dist/report/react/RunOverview.js +0 -12
  356. package/docs-site/zh/example/ai-agent-application.mdx +0 -152
  357. package/docs-site/zh/example/claude-code-codex-plugin.mdx +0 -167
  358. package/docs-site/zh/example/claude-code-codex-skill.mdx +0 -152
  359. package/docs-site/zh/example/showcase.mdx +0 -39
  360. package/docs-site/zh/guides/publish-report.mdx +0 -91
  361. package/docs-site/zh/guides/sandbox-providers.mdx +0 -102
  362. package/src/report/built-in-user-parity.test.tsx +0 -640
  363. package/src/report/built-ins/experiment-comparison.tsx +0 -19
  364. package/src/report/built-ins/index.ts +0 -2
  365. package/src/report/react/GroupSummary.tsx +0 -66
  366. package/src/report/react/RunOverview.tsx +0 -109
  367. package/src/runner/reporters/console.ts +0 -70
  368. package/src/runner/reporters/live.test.ts +0 -56
  369. package/src/runner/reporters/live.ts +0 -247
  370. package/src/runner/reporters/quiet.test.ts +0 -66
  371. package/src/runner/reporters/quiet.ts +0 -49
  372. package/src/runner/reporters/table.ts +0 -277
  373. /package/docs-site/zh/{example/tier1-ai-sdk-v7.mdx → examples/integrations/ai-sdk-v7.mdx} +0 -0
  374. /package/docs-site/zh/{example/tier1-claude-sdk.mdx → examples/integrations/claude-sdk.mdx} +0 -0
  375. /package/docs-site/zh/{example/tier1-codex-sdk.mdx → examples/integrations/codex-sdk.mdx} +0 -0
  376. /package/docs-site/zh/{example/tier1-langgraph.mdx → examples/integrations/langgraph.mdx} +0 -0
  377. /package/docs-site/zh/{example/tier1-pi-sdk.mdx → examples/integrations/pi-sdk.mdx} +0 -0
  378. /package/docs-site/zh/{guides → how-to}/fixtures.mdx +0 -0
@@ -1,17 +1,17 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { defineComponent } from "./tree.js";
3
- import { localeText } from "./locale.js";
4
- import { indentBlock, joinColumns, wrapDisplay } from "./text/layout.js";
2
+ import { COMPONENT_RAW_CHILDREN, COMPONENT_ROLE, defineComponent } from "./tree.js";
3
+ import { localeText, resolveLocalizedText } from "./locale.js";
4
+ import { indentBlock, joinColumns, stringWidth, wrapDisplay } from "./text/layout.js";
5
5
  import { renderTableText } from "./text/table.js";
6
6
  function childArray(children) {
7
7
  if (children === null || children === undefined || typeof children === "boolean")
8
8
  return [];
9
- return Array.isArray(children) ? children : [children];
9
+ return Array.isArray(children) ? [...children] : [children];
10
10
  }
11
11
  function cx(...parts) {
12
12
  return parts.filter(Boolean).join(" ");
13
13
  }
14
- /** 纵向依次排列:网页是块级堆叠,终端是逐块输出(块间空一行) */
14
+ /** 纵向依次排列:网页是块级堆叠,终端是逐块输出(块间空一行)。两面都按声明序。 */
15
15
  export const Col = defineComponent({
16
16
  web({ children, className }) {
17
17
  return _jsx("div", { className: cx("nre", "nre-col", className), children: children });
@@ -24,10 +24,15 @@ export const Col = defineComponent({
24
24
  },
25
25
  });
26
26
  Col.displayName = "Col";
27
- // Row 的每栏至少留这个宽度,不硬挤;不够就降级纵向
28
- const MIN_COLUMN_WIDTH = 24;
29
27
  const COLUMN_SEPARATOR = " │ ";
30
- /** 并排:网页横向排布,终端字符分栏;终端宽度不够时自动降级为纵向。 */
28
+ /** 一段已渲染文本的自然显示宽度(最长一行)。 */
29
+ function blockWidth(block) {
30
+ return Math.max(...block.split("\n").map((line) => stringWidth(line)), 0);
31
+ }
32
+ /**
33
+ * 并排:web 面横排;text 面在可用宽度装得下全部子块时按显示宽度并排(与 `columns` 工具
34
+ * 同一把尺),装不下时整块退化为纵向堆叠——不截断、不隐藏任何子块。
35
+ */
31
36
  export const Row = defineComponent({
32
37
  web({ children, className }) {
33
38
  return _jsx("div", { className: cx("nre", "nre-row", className), children: children });
@@ -38,44 +43,49 @@ export const Row = defineComponent({
38
43
  return "";
39
44
  if (blocks.length === 1)
40
45
  return ctx.render(blocks[0]);
41
- const columnWidth = Math.floor((ctx.width - COLUMN_SEPARATOR.length * (blocks.length - 1)) / blocks.length);
42
- if (columnWidth < MIN_COLUMN_WIDTH) {
43
- // 宽度不足:降级纵向,与 Col 同一形态
44
- return blocks
45
- .map((child) => ctx.render(child))
46
- .filter((block) => block.length > 0)
47
- .join("\n\n");
46
+ const rendered = blocks.map((child) => ctx.render(child)).filter((block) => block.length > 0);
47
+ if (rendered.length === 0)
48
+ return "";
49
+ const widths = rendered.map(blockWidth);
50
+ const total = widths.reduce((sum, w) => sum + w, 0) + COLUMN_SEPARATOR.length * (rendered.length - 1);
51
+ if (total > ctx.width) {
52
+ // 装不下:整块退化为纵向堆叠,与 Col 同一形态
53
+ return rendered.join("\n\n");
48
54
  }
49
- const rendered = blocks.map((child) => ctx.render(child, columnWidth));
50
- return joinColumns(rendered, rendered.map(() => columnWidth), COLUMN_SEPARATOR);
55
+ return joinColumns(rendered, widths, COLUMN_SEPARATOR);
51
56
  },
52
57
  });
53
58
  Row.displayName = "Row";
54
59
  /** 带标题的块:网页是标题层级,终端是标题行加缩进。 */
55
60
  export const Section = defineComponent({
56
- web({ title, children, className }) {
57
- return (_jsxs("section", { className: cx("nre", "nre-section", className), children: [_jsx("h2", { className: "nre-section-title", children: title }), children] }));
61
+ web({ title, children, className }, ctx) {
62
+ return (_jsxs("section", { className: cx("nre", "nre-section", className), children: [_jsx("h2", { className: "nre-section-title", children: resolveLocalizedText(title, ctx.locale) }), children] }));
58
63
  },
59
64
  text({ title, children }, ctx) {
65
+ const heading = resolveLocalizedText(title, ctx.locale);
60
66
  const body = childArray(children)
61
67
  .map((child) => ctx.render(child, ctx.width - 2))
62
68
  .filter((block) => block.length > 0)
63
69
  .join("\n\n");
64
- return body.length > 0 ? `${title}\n${indentBlock(body, " ")}` : title;
70
+ return body.length > 0 ? `${heading}\n${indentBlock(body, " ")}` : heading;
65
71
  },
66
72
  });
67
73
  Section.displayName = "Section";
68
- /** 说明文字:网页是段落,终端是折行文本。 */
74
+ /** 自由文本的显式载体:web 面负责转义,text 面按显示宽度折行。 */
69
75
  export const Text = defineComponent({
70
76
  web({ children, className }) {
71
77
  return _jsx("p", { className: cx("nre", "nre-text", className), children: children });
72
78
  },
73
79
  text({ children }, ctx) {
74
- return wrapDisplay(ctx.render(children), ctx.width).join("\n");
80
+ return wrapDisplay(String(children), ctx.width).join("\n");
75
81
  },
76
82
  });
77
83
  Text.displayName = "Text";
78
- /** 自定义组件的样式随树带走:web 面吐 <style> 标签,text 面渲染为空。 */
84
+ Text[COMPONENT_RAW_CHILDREN] = true;
85
+ /**
86
+ * 注入页级全局 CSS:树位置只决定声明顺序,不限定作用域;text 面零输出。
87
+ * 配置对象形态的报告要全站样式优先用外壳 styles,两条通道注入同一增强层。
88
+ */
79
89
  export const Style = defineComponent({
80
90
  web({ children }) {
81
91
  return _jsx("style", { children: children });
@@ -85,7 +95,101 @@ export const Style = defineComponent({
85
95
  },
86
96
  });
87
97
  Style.displayName = "Style";
98
+ Style[COMPONENT_RAW_CHILDREN] = true;
99
+ /** Tabs 的直接 Tab 子项(数组 / Fragment 已展平;结构合法性由树校验保证)。 */
100
+ function tabEntries(children) {
101
+ const out = [];
102
+ const visit = (node) => {
103
+ if (node === null || node === undefined || typeof node === "boolean")
104
+ return;
105
+ if (Array.isArray(node)) {
106
+ for (const child of node)
107
+ visit(child);
108
+ return;
109
+ }
110
+ if (typeof node === "object" && node !== null && "props" in node) {
111
+ const element = node;
112
+ if (element.type === Symbol.for("react.fragment")) {
113
+ visit(element.props.children);
114
+ return;
115
+ }
116
+ out.push({
117
+ title: element.props.title ?? "",
118
+ children: element.props.children,
119
+ className: element.props.className,
120
+ });
121
+ }
122
+ };
123
+ visit(children);
124
+ return out;
125
+ }
126
+ /**
127
+ * 页内并列视图的可切换块。tab 是页内浏览状态,不是数据边界,也不是宿主寻址单位——
128
+ * 两个渲染面都输出全部 tab 的完整内容:web 静态 HTML 每 tab 一个 <details>(首个默认展开,
129
+ * 渐进增强升级成单选 tab 条,切换不改变数据);text 面按声明序输出带标题分节,不折成索引
130
+ * 也不省略(tab 没有选择器,索引只能是死路)。
131
+ */
132
+ export const Tabs = defineComponent({
133
+ web({ children, className }, ctx) {
134
+ const tabs = tabEntries(children);
135
+ return (_jsx("div", { className: cx("nre", "nre-tabs", className), "data-nre-tabs": true, children: tabs.map((tab, i) => (_jsxs("details", { className: cx("nre-tab", tab.className), open: i === 0, children: [_jsx("summary", { className: "nre-tab-title", children: resolveLocalizedText(tab.title, ctx.locale) }), _jsx("div", { className: "nre-tab-body", children: tab.children })] }, i))) }));
136
+ },
137
+ text({ children }, ctx) {
138
+ const tabs = tabEntries(children);
139
+ return tabs
140
+ .map((tab) => {
141
+ const heading = resolveLocalizedText(tab.title, ctx.locale);
142
+ const body = childArray(tab.children)
143
+ .map((child) => ctx.render(child, ctx.width - 2))
144
+ .filter((block) => block.length > 0)
145
+ .join("\n\n");
146
+ return body.length > 0 ? `${heading}\n${indentBlock(body, " ")}` : heading;
147
+ })
148
+ .join("\n\n");
149
+ },
150
+ });
151
+ Tabs.displayName = "Tabs";
152
+ Tabs[COMPONENT_ROLE] = "tabs";
153
+ /** 只能直接放在 <Tabs> 下;除通用 children / className 外只有 title。不参与路由,没有 id。 */
154
+ export const Tab = defineComponent({
155
+ web({ children, className }) {
156
+ return _jsx("div", { className: cx("nre", "nre-tab-body", className), children: children });
157
+ },
158
+ text({ children }, ctx) {
159
+ return childArray(children)
160
+ .map((child) => ctx.render(child))
161
+ .filter((block) => block.length > 0)
162
+ .join("\n\n");
163
+ },
164
+ });
165
+ Tab.displayName = "Tab";
166
+ Tab[COMPONENT_ROLE] = "tab";
88
167
  const MISSING_MARK = "—";
168
+ /** 列 key 唯一、行 cells 不携带未声明 key、空列拒绝——无类型 JS 输入在渲染前同样校验。 */
169
+ function validateTableProps(props) {
170
+ if (!Array.isArray(props.columns) || props.columns.length === 0) {
171
+ throw new Error("Table needs at least one column: pass columns: [{ key, header }] — an empty column list renders nothing readable.");
172
+ }
173
+ const keys = new Set();
174
+ for (const column of props.columns) {
175
+ if (keys.has(column.key)) {
176
+ throw new Error(`Table column key "${column.key}" is declared twice — column keys address row.cells and must be unique. Rename one column.`);
177
+ }
178
+ keys.add(column.key);
179
+ }
180
+ const rowKeys = new Set();
181
+ for (const row of props.rows) {
182
+ if (rowKeys.has(row.key)) {
183
+ throw new Error(`Table row key "${row.key}" is declared twice — row keys are the row identity and must be unique.`);
184
+ }
185
+ rowKeys.add(row.key);
186
+ for (const cellKey of Object.keys(row.cells)) {
187
+ if (!keys.has(cellKey)) {
188
+ throw new Error(`Table row "${row.key}" has a cell "${cellKey}" that no column declares. Declare the column in columns, or drop the stray cell.`);
189
+ }
190
+ }
191
+ }
192
+ }
89
193
  /**
90
194
  * 自定义表的标准件:列由报告作者定,格子是算好的显示值,两个面各自排整齐。
91
195
  *
@@ -98,16 +202,21 @@ const MISSING_MARK = "—";
98
202
  * 这个组件上:自定义表和官方表用同一把尺子。
99
203
  */
100
204
  export const Table = defineComponent({
101
- web({ columns, rows, locale, className }, ctx) {
205
+ web(props, ctx) {
206
+ validateTableProps(props);
207
+ const { columns, rows, locale, className } = props;
102
208
  const chrome = locale ?? ctx.locale;
103
209
  const hasLocator = rows.some((row) => row.locator !== undefined);
104
210
  const alignClass = (align) => (align === "right" ? "nre-align-right" : undefined);
105
- return (_jsxs("table", { className: cx("nre", "nre-table", className), children: [_jsx("thead", { children: _jsxs("tr", { children: [columns.map((column) => (_jsx("th", { scope: "col", className: alignClass(column.align), children: column.header }, column.key))), hasLocator ? _jsx("th", { scope: "col", children: localeText(chrome, "table.attempt") }) : null] }) }), _jsx("tbody", { children: rows.map((row) => (_jsxs("tr", { children: [columns.map((column) => {
211
+ return (_jsxs("table", { className: cx("nre", "nre-table", className), children: [_jsx("thead", { children: _jsxs("tr", { children: [columns.map((column) => (_jsx("th", { scope: "col", className: alignClass(column.align), children: resolveLocalizedText(column.header, chrome) }, column.key))), hasLocator ? _jsx("th", { scope: "col", children: localeText(chrome, "table.attempt") }) : null] }) }), _jsx("tbody", { children: rows.map((row) => (_jsxs("tr", { children: [columns.map((column) => {
106
212
  const value = row.cells[column.key];
107
213
  const missing = value === null || value === undefined;
108
214
  return (_jsx("td", { className: alignClass(column.align), children: missing ? _jsx("span", { className: "nre-missing", children: MISSING_MARK }) : value }, column.key));
109
215
  }), hasLocator ? (_jsx("td", { children: row.locator ? (_jsx("a", { className: "nre-locator", href: ctx.attemptHref(row.locator), children: row.locator })) : (_jsx("span", { className: "nre-missing", children: MISSING_MARK })) })) : null] }, row.key))) })] }));
110
216
  },
111
- text: renderTableText,
217
+ text(props, ctx) {
218
+ validateTableProps(props);
219
+ return renderTableText(props, ctx);
220
+ },
112
221
  });
113
222
  Table.displayName = "Table";
@@ -5,19 +5,21 @@ import { type ReportLocale } from "../locale.ts";
5
5
  /** locator + 判定符的普通 <a>,AttemptList/EvalList/ExperimentList 共用。 */
6
6
  export declare function AttemptLocatorBadge({ item, attemptHref, }: {
7
7
  item: Pick<AttemptListItem, "locator" | "verdict">;
8
- attemptHref: (locator: AttemptLocator) => string;
8
+ attemptHref?: (locator: AttemptLocator) => string;
9
9
  }): ReactElement;
10
- /** 一条 Attempt 的完整卡片:AttemptList 自己的一项,也是 EvalList 展开区里的一行。 */
10
+ /** failureSummary + moreFailures 的展示形态:摘要原样,+N 计数由 moreFailures 驱动。 */
11
+ export declare function failureSummaryText(item: Pick<AttemptListItem, "failureSummary" | "moreFailures">, locale: ReportLocale): string | null;
12
+ /** 一条 Attempt 的比较卡片;完整 assertions 通过 locator 下钻,不在列表内展开。 */
11
13
  export declare function AttemptRow({ item, attemptHref, locale, }: {
12
14
  item: AttemptListItem;
13
- attemptHref: (locator: AttemptLocator) => string;
15
+ attemptHref?: (locator: AttemptLocator) => string;
14
16
  locale?: ReportLocale;
15
17
  }): ReactElement;
16
- export declare function AttemptList({ items, total, attemptHref, className, locale, }: {
17
- items: AttemptListItem[];
18
- /** items 被 slice 时的原始数量;如实显示还剩多少条没展示。 */
18
+ export declare function AttemptList({ data, total, attemptHref, className, locale, }: {
19
+ data: readonly AttemptListItem[];
20
+ /** data 被 slice 时的原始数量;如实显示还剩多少条没展示。 */
19
21
  total?: number;
20
- attemptHref: (locator: AttemptLocator) => string;
22
+ attemptHref?: (locator: AttemptLocator) => string;
21
23
  className?: string;
22
24
  locale?: ReportLocale;
23
25
  }): ReactElement;
@@ -1,19 +1,26 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { DEFAULT_REPORT_LOCALE, localeText } from "../locale.js";
2
+ import { DEFAULT_REPORT_LOCALE, countText, localeText } from "../locale.js";
3
3
  import { colorClassForKey } from "./colors.js";
4
4
  import { cx, formatDurationMs, formatUSD, verdictMark } from "./format.js";
5
+ const DEFAULT_ATTEMPT_HREF = (locator) => `#/attempt/${locator}`;
5
6
  /** locator + 判定符的普通 <a>,AttemptList/EvalList/ExperimentList 共用。 */
6
- export function AttemptLocatorBadge({ item, attemptHref, }) {
7
+ export function AttemptLocatorBadge({ item, attemptHref = DEFAULT_ATTEMPT_HREF, }) {
7
8
  return (_jsxs("a", { className: cx("nre-locator", `nre-verdict-${item.verdict}`), href: attemptHref(item.locator), children: [item.locator, _jsx("span", { className: "nre-locator-mark", children: verdictMark(item.verdict) })] }));
8
9
  }
9
- function AssertionRow({ assertion, locale }) {
10
- return (_jsxs("li", { className: cx("nre-assertion", `nre-assertion-${assertion.severity}`, !assertion.passed && "nre-assertion-failed"), children: [_jsx("span", { className: "nre-assertion-severity", children: assertion.severity }), _jsx("span", { className: "nre-assertion-name", children: assertion.name }), _jsx("span", { className: "nre-assertion-score", children: localeText(locale, "attemptList.score", { score: assertion.score }) }), (assertion.detail || assertion.evidence) && (_jsxs("details", { className: "nre-assertion-more", children: [_jsx("summary", { children: localeText(locale, "attemptList.details") }), assertion.detail && _jsx("p", { className: "nre-assertion-detail", children: assertion.detail }), assertion.evidence && _jsx("blockquote", { className: "nre-assertion-evidence", children: assertion.evidence })] }))] }));
10
+ /** failureSummary + moreFailures 的展示形态:摘要原样,+N 计数由 moreFailures 驱动。 */
11
+ export function failureSummaryText(item, locale) {
12
+ if (item.failureSummary === null)
13
+ return null;
14
+ return item.moreFailures > 0
15
+ ? `${item.failureSummary} · ${countText(locale, "entityList.moreFailures", item.moreFailures)}`
16
+ : item.failureSummary;
11
17
  }
12
- /** 一条 Attempt 的完整卡片:AttemptList 自己的一项,也是 EvalList 展开区里的一行。 */
13
- export function AttemptRow({ item, attemptHref, locale = DEFAULT_REPORT_LOCALE, }) {
14
- return (_jsxs("li", { className: cx("nre-attempt", `nre-attempt-${item.verdict}`), children: [_jsxs("div", { className: "nre-attempt-head", children: [_jsx(AttemptLocatorBadge, { item: item, attemptHref: attemptHref }), _jsx("span", { className: "nre-attempt-eval", children: item.evalId }), _jsx("span", { className: "nre-attempt-experiment", children: item.experimentId }), _jsx("span", { className: cx("nre-attempt-agent", "nre-key", colorClassForKey(item.agent)), children: item.agent }), _jsx("span", { className: "nre-attempt-duration", children: formatDurationMs(item.durationMs) }), item.costUSD !== undefined && _jsx("span", { className: "nre-attempt-cost", children: formatUSD(item.costUSD) })] }), item.error && _jsx("p", { className: "nre-attempt-error", children: item.error }), item.assertions.length > 0 && (_jsx("ul", { className: "nre-assertions", children: item.assertions.map((a, i) => (_jsx(AssertionRow, { assertion: a, locale: locale }, i))) }))] }));
18
+ /** 一条 Attempt 的比较卡片;完整 assertions 通过 locator 下钻,不在列表内展开。 */
19
+ export function AttemptRow({ item, attemptHref = DEFAULT_ATTEMPT_HREF, locale = DEFAULT_REPORT_LOCALE, }) {
20
+ const reason = failureSummaryText(item, locale);
21
+ return (_jsxs("li", { className: cx("nre-attempt", `nre-attempt-${item.verdict}`), children: [_jsxs("div", { className: "nre-attempt-head", children: [_jsx(AttemptLocatorBadge, { item: item, attemptHref: attemptHref }), _jsx("span", { className: "nre-attempt-eval", children: item.evalId }), _jsx("span", { className: "nre-attempt-experiment", children: item.experimentId }), _jsx("span", { className: cx("nre-attempt-agent", "nre-key", colorClassForKey(item.agent)), children: item.agent }), _jsx("span", { className: "nre-attempt-duration", children: formatDurationMs(item.durationMs) }), item.costUSD !== null && _jsx("span", { className: "nre-attempt-cost", children: formatUSD(item.costUSD) })] }), reason && _jsx("p", { className: "nre-attempt-result", children: reason })] }));
15
22
  }
16
- export function AttemptList({ items, total, attemptHref, className, locale = DEFAULT_REPORT_LOCALE, }) {
17
- const remaining = (total ?? items.length) - items.length;
18
- return (_jsxs("section", { className: cx("nre", "nre-attempt-list", className), children: [items.length === 0 && _jsx("p", { className: "nre-attempt-list-empty", children: localeText(locale, "attemptList.empty") }), _jsx("ul", { className: "nre-attempts", children: items.map((item) => (_jsx(AttemptRow, { item: item, attemptHref: attemptHref, locale: locale }, item.locator))) }), remaining > 0 && (_jsx("p", { className: "nre-truncated", children: localeText(locale, "attemptList.truncated", { n: remaining }) }))] }));
23
+ export function AttemptList({ data, total, attemptHref = DEFAULT_ATTEMPT_HREF, className, locale = DEFAULT_REPORT_LOCALE, }) {
24
+ const remaining = (total ?? data.length) - data.length;
25
+ return (_jsxs("section", { className: cx("nre", "nre-attempt-list", className), children: [data.length === 0 && _jsx("p", { className: "nre-attempt-list-empty", children: localeText(locale, "attemptList.empty") }), _jsx("ul", { className: "nre-attempts", children: data.map((item) => (_jsx(AttemptRow, { item: item, attemptHref: attemptHref, locale: locale }, item.locator))) }), remaining > 0 && (_jsx("p", { className: "nre-truncated", children: localeText(locale, "attemptList.truncated", { n: remaining }) }))] }));
19
26
  }
@@ -1,24 +1,25 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { DEFAULT_REPORT_LOCALE, localeText, resolveMetricLabel } from "../locale.js";
2
+ import { DEFAULT_REPORT_LOCALE, localeText, resolveLocalizedText, resolveMetricLabel } from "../locale.js";
3
3
  import { MetricCellView } from "./cell.js";
4
4
  import { colorClassForKey } from "./colors.js";
5
5
  import { cx } from "./format.js";
6
- /** Δ 的语义配色 class:好/坏由 better 方向判定,不看正负号本身。 */
7
- function deltaToneClass(delta, better) {
8
- if (delta === null)
9
- return "nre-delta-missing";
10
- if (delta === 0)
11
- return "nre-delta-flat";
12
- if (!better)
13
- return "nre-delta-neutral"; // 指标没表态方向,只显示不评判
14
- const improved = better === "higher" ? delta > 0 : delta < 0;
15
- return improved ? "nre-delta-good" : "nre-delta-bad";
16
- }
6
+ const OUTCOME_CLASS = {
7
+ improved: "nre-delta-good",
8
+ regressed: "nre-delta-bad",
9
+ unchanged: "nre-delta-flat",
10
+ unavailable: "nre-delta-missing",
11
+ };
17
12
  export function DeltaTable({ data, className, locale = DEFAULT_REPORT_LOCALE, }) {
18
- return (_jsxs("table", { className: cx("nre", "nre-delta-table", className), children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { scope: "col", className: "nre-dimension", children: localeText(locale, "delta.pairHeader") }), data.columns.map((col) => (_jsxs("th", { scope: "col", className: "nre-metric-col", children: [resolveMetricLabel(col.label, locale, col.key), col.unit && _jsxs("span", { className: "nre-unit", children: ["(", col.unit, ")"] })] }, col.key)))] }) }), _jsx("tbody", { children: data.rows.map((row) => (_jsxs("tr", { children: [_jsxs("th", { scope: "row", className: "nre-pair", children: [_jsx("span", { className: cx("nre-row-key", "nre-key", colorClassForKey(row.key)), children: row.key }), _jsxs("span", { className: "nre-pair-ids", children: [row.a.experimentId, " \u2192 ", row.b.experimentId] })] }), data.columns.map((col) => {
19
- const cell = row.cells[col.key];
20
- if (!cell)
21
- return _jsx("td", { className: "nre-td-empty" }, col.key);
22
- return (_jsxs("td", { className: "nre-delta-cell", children: [_jsxs("span", { className: "nre-delta-side nre-delta-a", children: [_jsx("span", { className: "nre-delta-tag", children: "A" }), _jsx(MetricCellView, { cell: cell.a, locale: locale })] }), _jsxs("span", { className: "nre-delta-side nre-delta-b", children: [_jsx("span", { className: "nre-delta-tag", children: "B" }), _jsx(MetricCellView, { cell: cell.b, locale: locale })] }), _jsxs("span", { className: cx("nre-delta-side", "nre-delta-d", deltaToneClass(cell.delta, col.better)), children: [_jsx("span", { className: "nre-delta-tag", children: "\u0394" }), cell.delta === null ? _jsx("span", { className: "nre-missing", children: localeText(locale, "cell.missing") }) : cell.display] })] }, col.key));
23
- })] }, row.key))) })] }));
13
+ if (data.rows.length === 0) {
14
+ return (_jsx("div", { className: cx("nre", "nre-delta-table-empty", className), children: _jsx("p", { className: "nre-missing", children: localeText(locale, "delta.empty", { experiments: data.experiments ?? 0 }) }) }));
15
+ }
16
+ return (_jsxs("table", { className: cx("nre", "nre-delta-table", className), children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { scope: "col", className: "nre-dimension", children: localeText(locale, "delta.pairHeader") }), data.columns.map((col) => (_jsxs("th", { scope: "col", className: "nre-metric-col", children: [resolveMetricLabel(col.label, locale, col.key), col.unit && _jsxs("span", { className: "nre-unit", children: ["(", col.unit, ")"] })] }, col.key)))] }) }), _jsx("tbody", { children: data.rows.map((row) => {
17
+ const label = resolveLocalizedText(row.label, locale);
18
+ return (_jsxs("tr", { children: [_jsxs("th", { scope: "row", className: "nre-pair", children: [_jsx("span", { className: cx("nre-row-key", "nre-key", colorClassForKey(label)), children: label }), _jsxs("span", { className: "nre-pair-ids", children: [row.a.key, " \u2192 ", row.b.key] })] }), data.columns.map((col) => {
19
+ const cell = row.cells[col.key];
20
+ if (!cell)
21
+ return _jsx("td", { className: "nre-td-empty" }, col.key);
22
+ return (_jsxs("td", { className: "nre-delta-cell", children: [_jsxs("span", { className: "nre-delta-side nre-delta-a", children: [_jsx("span", { className: "nre-delta-tag", children: "A" }), _jsx(MetricCellView, { cell: cell.a, locale: locale })] }), _jsxs("span", { className: "nre-delta-side nre-delta-b", children: [_jsx("span", { className: "nre-delta-tag", children: "B" }), _jsx(MetricCellView, { cell: cell.b, locale: locale })] }), _jsxs("span", { className: cx("nre-delta-side", "nre-delta-d", OUTCOME_CLASS[cell.outcome]), "data-outcome": cell.outcome, children: [_jsx("span", { className: "nre-delta-tag", children: "\u0394" }), cell.delta === null ? (_jsx("span", { className: "nre-missing", children: localeText(locale, "cell.missing") })) : (resolveLocalizedText(cell.display, locale))] })] }, col.key));
23
+ })] }, row.key));
24
+ }) })] }));
24
25
  }
@@ -1,10 +1,10 @@
1
1
  import type { ReactElement } from "react";
2
- import type { EvalListItem } from "../types.ts";
3
2
  import type { AttemptLocator } from "../../results/locator.ts";
3
+ import type { EvalListItem } from "../types.ts";
4
4
  import { type ReportLocale } from "../locale.ts";
5
- export declare function EvalList({ items, attemptHref, className, locale, }: {
6
- items: EvalListItem[];
7
- attemptHref: (locator: AttemptLocator) => string;
5
+ export declare function EvalList({ data, attemptHref, className, locale, }: {
6
+ data: readonly EvalListItem[];
7
+ attemptHref?: (locator: AttemptLocator) => string;
8
8
  className?: string;
9
9
  locale?: ReportLocale;
10
10
  }): ReactElement;
Binary file
@@ -0,0 +1,10 @@
1
+ import type { ReactElement } from "react";
2
+ import type { ExperimentComparisonData } from "../types.ts";
3
+ import { type ReportLocale } from "../locale.ts";
4
+ import type { AttemptLocator } from "../../results/locator.ts";
5
+ export declare function ExperimentComparisonView({ data, className, locale, attemptHref, }: {
6
+ data: ExperimentComparisonData;
7
+ className?: string;
8
+ locale?: ReportLocale;
9
+ attemptHref?: (locator: AttemptLocator) => string;
10
+ }): ReactElement;
@@ -0,0 +1,12 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { DEFAULT_REPORT_LOCALE, localeText } from "../locale.js";
3
+ import { ScopeSummary } from "./ScopeSummary.js";
4
+ import { MetricScatter } from "./MetricScatter.js";
5
+ import { ExperimentList } from "./ExperimentList.js";
6
+ import { cx } from "./format.js";
7
+ export function ExperimentComparisonView({ data, className, locale = DEFAULT_REPORT_LOCALE, attemptHref, }) {
8
+ if (data.groups.length === 0) {
9
+ return (_jsx("div", { className: cx("nre", "nre-experiment-comparison", className), children: _jsx("p", { className: "nre-experiment-groups-empty", children: localeText(locale, "experimentComparison.empty") }) }));
10
+ }
11
+ return (_jsxs("div", { className: cx("nre", "nre-experiment-comparison", className), "data-nre-experiment-groups": true, children: [_jsx("div", { className: "nre-experiment-group-tabs", role: "tablist", "aria-label": localeText(locale, "experimentComparison.groups"), children: data.groups.map((group, index) => (_jsxs("div", { className: "nre-experiment-group-tab", role: "tab", tabIndex: index === 0 ? 0 : -1, "aria-selected": index === 0 ? "true" : "false", "aria-label": localeText(locale, "experimentComparison.selectGroup", { group: group.key }), "data-nre-experiment-group-select": index, children: [_jsx("strong", { className: "nre-experiment-group-name", children: group.key }), _jsx(ScopeSummary, { data: group.summary, locale: locale })] }, group.key))) }), _jsx("div", { className: "nre-experiment-group-panels", children: data.groups.map((group, index) => (_jsxs("details", { className: "nre-experiment-group-panel", "data-nre-experiment-group-panel": index, role: "tabpanel", open: index === 0, children: [_jsx("summary", { children: group.key }), _jsx(MetricScatter, { data: group.scatter, locale: locale }), _jsx(ExperimentList, { data: group.experiments, filter: true, locale: locale, relativeTo: group.key, attemptHref: attemptHref })] }, group.key))) })] }));
12
+ }
@@ -2,10 +2,11 @@ import type { ReactElement } from "react";
2
2
  import type { AttemptLocator } from "../../results/locator.ts";
3
3
  import type { ExperimentListItem } from "../types.ts";
4
4
  import { type ReportLocale } from "../locale.ts";
5
- export declare function ExperimentList({ items, attemptHref, filter, className, locale, }: {
6
- items: ExperimentListItem[];
7
- attemptHref: (locator: AttemptLocator) => string;
5
+ export declare function ExperimentList({ data, attemptHref, filter, className, locale, relativeTo, }: {
6
+ data: readonly ExperimentListItem[];
7
+ attemptHref?: (locator: AttemptLocator) => string;
8
8
  filter?: boolean;
9
9
  className?: string;
10
10
  locale?: ReportLocale;
11
+ relativeTo?: string;
11
12
  }): ReactElement;
@@ -1,10 +1,11 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { attemptItemReason } from "../format.js";
2
+ import { experimentDisplayName } from "../format.js";
3
3
  import { DEFAULT_REPORT_LOCALE, localeText } from "../locale.js";
4
- import { AttemptLocatorBadge } from "./AttemptList.js";
4
+ import { AttemptLocatorBadge, failureSummaryText } from "./AttemptList.js";
5
5
  import { MetricCellView } from "./cell.js";
6
6
  import { colorClassForKey } from "./colors.js";
7
7
  import { cx, formatDurationMs, formatUSD, verdictMark } from "./format.js";
8
+ const DEFAULT_ATTEMPT_HREF = (locator) => `#/attempt/${locator}`;
8
9
  const verdictOrder = ["passed", "failed", "errored", "skipped"];
9
10
  function passRateTone(value) {
10
11
  if (value === null)
@@ -28,30 +29,28 @@ function formatDate(value, locale) {
28
29
  }
29
30
  function VerdictSummary({ item, locale }) {
30
31
  const parts = verdictOrder
31
- .filter((verdict) => item.verdicts[verdict] > 0)
32
- .map((verdict) => `${item.verdicts[verdict]} ${localeText(locale, `verdict.${verdict}`)}`);
32
+ .filter((verdict) => item.evalVerdicts[verdict] > 0)
33
+ .map((verdict) => `${item.evalVerdicts[verdict]} ${localeText(locale, `verdict.${verdict}`)}`);
33
34
  return _jsx("span", { className: "nre-experiment-pill", children: parts.join(" / ") || "—" });
34
35
  }
35
- function ExperimentAttemptRow({ attempt, last, attemptHref, }) {
36
- const reason = attemptItemReason(attempt);
37
- return (_jsxs("li", { className: cx("nre-experiment-attempt-row", `nre-eval-${attempt.verdict}`), children: [_jsx("span", { className: "nre-attempt-branch", "aria-hidden": "true", children: last ? "└─" : "├─" }), _jsx("span", { className: "nre-eval-attempt-badges", children: _jsx(AttemptLocatorBadge, { item: attempt, attemptHref: attemptHref }) }), _jsxs("span", { className: "nre-eval-attempt-metrics", children: [formatDurationMs(attempt.durationMs), attempt.costUSD !== undefined && _jsxs(_Fragment, { children: [" \u00B7 ", formatUSD(attempt.costUSD)] })] }), _jsx("span", { className: "nre-eval-reason", children: reason ?? "—" })] }));
36
+ function ExperimentAttemptRow({ attempt, last, attemptHref, locale, }) {
37
+ const reason = failureSummaryText(attempt, locale);
38
+ return (_jsxs("li", { className: cx("nre-experiment-attempt-row", `nre-eval-${attempt.verdict}`), children: [_jsx("span", { className: "nre-attempt-branch", "aria-hidden": "true", children: last ? "└─" : "├─" }), _jsx("span", { className: "nre-eval-attempt-badges", children: _jsx(AttemptLocatorBadge, { item: attempt, attemptHref: attemptHref }) }), _jsxs("span", { className: "nre-eval-attempt-metrics", children: [formatDurationMs(attempt.durationMs), attempt.costUSD !== null && _jsxs(_Fragment, { children: [" \u00B7 ", formatUSD(attempt.costUSD)] })] }), _jsx("span", { className: "nre-eval-reason", children: reason ?? "—" })] }));
38
39
  }
39
40
  function EvalAttempts({ row, attemptHref, locale, }) {
40
- return (_jsxs("li", { className: "nre-experiment-eval", children: [_jsxs("div", { className: cx("nre-experiment-eval-header", `nre-eval-${row.verdict}`), children: [_jsx("span", { className: cx("nre-eval-verdict", `nre-verdict-${row.verdict}`), children: verdictMark(row.verdict) }), _jsx("span", { className: "nre-eval-id", children: row.evalId }), _jsx("span", { className: "nre-eval-attempt-count", children: localeText(locale, "overview.attemptsCount", { n: row.attempts.length }) }), _jsx("span", { className: "nre-eval-summary", children: row.verdict === "passed"
41
- ? [formatDurationMs(row.duration.value ?? 0), row.cost.value === null ? undefined : formatUSD(row.cost.value)]
42
- .filter((value) => value !== undefined)
43
- .join(" · ")
44
- : row.reason })] }), _jsx("ul", { className: "nre-experiment-attempts", children: row.attempts.map((attempt, index) => (_jsx(ExperimentAttemptRow, { attempt: attempt, last: index === row.attempts.length - 1, attemptHref: attemptHref }, attempt.locator))) })] }));
41
+ const duration = row.durationMs.value === null ? localeText(locale, "cell.missing") : formatDurationMs(row.durationMs.value);
42
+ const cost = row.costUSD.value === null ? localeText(locale, "cell.missing") : formatUSD(row.costUSD.value);
43
+ return (_jsxs("li", { className: "nre-experiment-eval", children: [_jsxs("div", { className: cx("nre-experiment-eval-header", `nre-eval-${row.verdict}`), children: [_jsx("span", { className: cx("nre-eval-verdict", `nre-verdict-${row.verdict}`), children: verdictMark(row.verdict) }), _jsx("span", { className: "nre-eval-id", children: row.evalId }), _jsx("span", { className: "nre-eval-attempt-count", children: localeText(locale, "overview.attemptsCount", { n: row.attempts.length }) }), _jsxs("span", { className: "nre-eval-rollup", children: [localeText(locale, "entityList.average", { value: duration }), " · ", localeText(locale, "entityList.average", { value: cost })] })] }), _jsx("ul", { className: "nre-experiment-attempts", children: row.attempts.map((attempt, index) => (_jsx(ExperimentAttemptRow, { attempt: attempt, last: index === row.attempts.length - 1, attemptHref: attemptHref, locale: locale }, attempt.locator))) })] }));
45
44
  }
46
45
  function Flags({ flags, locale }) {
47
46
  if (!flags || Object.keys(flags).length === 0)
48
47
  return null;
49
- return (_jsxs("div", { className: "nre-experiment-flags", children: [_jsx("span", { children: localeText(locale, "experimentList.flags") }), Object.entries(flags).map(([key, value]) => (_jsxs("b", { children: [key, "=", String(value)] }, key)))] }));
48
+ return (_jsxs("div", { className: "nre-experiment-flags", children: [_jsx("span", { children: localeText(locale, "experimentList.flags") }), Object.entries(flags).map(([key, value]) => (_jsxs("b", { children: [key, "=", typeof value === "string" ? value : JSON.stringify(value)] }, key)))] }));
50
49
  }
51
- function ExperimentRow({ item, attemptHref, locale, }) {
52
- return (_jsxs("details", { className: "nre-experiment-entry", children: [_jsxs("summary", { className: "nre-experiment-summary", children: [_jsxs("span", { className: "nre-experiment-name", "data-sort-value": item.experimentId, children: [_jsx("b", { className: cx("nre-experiment-id", "nre-key", colorClassForKey(item.experimentId)), children: item.experimentId }), _jsxs("small", { children: [localeText(locale, "overview.evalsCount", { n: item.evals }), item.attempts > item.evals ? ` · ${localeText(locale, "overview.attemptsCount", { n: item.attempts })}` : "", ` · ${formatDate(item.lastRunAt, locale)}`] })] }), _jsx("span", { "data-sort-value": item.model ?? "", children: item.model ?? localeText(locale, "experimentList.defaultModel") }), _jsx("span", { "data-sort-value": item.agent, children: item.agent }), _jsx("span", { className: "nre-num", "data-sort-value": item.duration.value ?? "", children: _jsx(MetricCellView, { cell: item.duration, locale: locale }) }), _jsx("span", { className: cx("nre-num", passRateTone(item.passRate.value)), "data-sort-value": item.passRate.value ?? "", children: _jsx(MetricCellView, { cell: item.passRate, locale: locale }) }), _jsx("span", { className: "nre-num", "data-sort-value": item.tokens.value ?? "", children: _jsx(MetricCellView, { cell: item.tokens, locale: locale }) }), _jsx("span", { className: "nre-num", "data-sort-value": item.cost.value ?? "", children: _jsx(MetricCellView, { cell: item.cost, locale: locale }) }), _jsx("span", { "data-sort-value": item.verdicts.passed, children: _jsx(VerdictSummary, { item: item, locale: locale }) })] }), _jsxs("div", { className: "nre-experiment-detail", children: [_jsx(Flags, { flags: item.flags, locale: locale }), _jsx("ul", { className: "nre-experiment-evals", children: item.evalRows.map((row) => (_jsx(EvalAttempts, { row: row, attemptHref: attemptHref, locale: locale }, row.evalId))) })] })] }));
50
+ function ExperimentRow({ item, attemptHref, locale, relativeTo, }) {
51
+ return (_jsxs("details", { className: "nre-experiment-entry", children: [_jsxs("summary", { className: "nre-experiment-summary", children: [_jsxs("span", { className: "nre-experiment-name", "data-sort-value": item.experimentId, children: [_jsx("b", { className: cx("nre-experiment-id", "nre-key", colorClassForKey(item.experimentId)), children: experimentDisplayName(item.experimentId, relativeTo) }), _jsxs("small", { children: [localeText(locale, "overview.evalsCount", { n: item.evals }), item.attempts > item.evals ? ` · ${localeText(locale, "overview.attemptsCount", { n: item.attempts })}` : "", ` · ${formatDate(item.lastRunAt, locale)}`] })] }), _jsx("span", { "data-sort-value": item.model ?? "", children: item.model ?? localeText(locale, "experimentList.defaultModel") }), _jsx("span", { "data-sort-value": item.agent, children: item.agent }), _jsx("span", { className: "nre-num", "data-sort-value": item.durationMs.value ?? "", children: _jsx(MetricCellView, { cell: item.durationMs, locale: locale }) }), _jsx("span", { className: cx("nre-num", passRateTone(item.endToEndPassRate.value)), "data-sort-value": item.endToEndPassRate.value ?? "", children: _jsx(MetricCellView, { cell: item.endToEndPassRate, locale: locale }) }), _jsx("span", { className: "nre-num", "data-sort-value": item.tokens.value ?? "", children: _jsx(MetricCellView, { cell: item.tokens, locale: locale }) }), _jsx("span", { className: "nre-num", "data-sort-value": item.costUSD.value ?? "", children: _jsx(MetricCellView, { cell: item.costUSD, locale: locale }) }), _jsx("span", { "data-sort-value": item.evalVerdicts.passed, children: _jsx(VerdictSummary, { item: item, locale: locale }) })] }), _jsxs("div", { className: "nre-experiment-detail", children: [_jsx(Flags, { flags: item.flags, locale: locale }), _jsx("ul", { className: "nre-experiment-evals", children: item.evalRows.map((row) => (_jsx(EvalAttempts, { row: row, attemptHref: attemptHref, locale: locale }, row.evalId))) })] })] }));
53
52
  }
54
- export function ExperimentList({ items, attemptHref, filter = false, className, locale = DEFAULT_REPORT_LOCALE, }) {
53
+ export function ExperimentList({ data, attemptHref = DEFAULT_ATTEMPT_HREF, filter = false, className, locale = DEFAULT_REPORT_LOCALE, relativeTo, }) {
55
54
  const labels = [
56
55
  localeText(locale, "experimentList.experiment"),
57
56
  localeText(locale, "table.model"),
@@ -59,9 +58,9 @@ export function ExperimentList({ items, attemptHref, filter = false, className,
59
58
  localeText(locale, "experimentList.avgDuration"),
60
59
  localeText(locale, "experimentList.passRate"),
61
60
  localeText(locale, "experimentList.tokens"),
62
- localeText(locale, "experimentList.estimatedCost"),
61
+ localeText(locale, "experimentList.cost"),
63
62
  localeText(locale, "experimentList.result"),
64
63
  ];
65
- const board = (_jsxs("div", { className: "nre-experiment-table", children: [_jsx("div", { className: "nre-experiment-head", children: labels.map((label, index) => (_jsx("button", { type: "button", "data-nre-experiment-sort": index, className: index === 4 ? "nre-sort-desc" : undefined, children: label }, label))) }), items.length === 0 && _jsx("p", { className: "nre-experiment-list-empty", children: localeText(locale, "attemptList.empty") }), items.map((item) => (_jsx(ExperimentRow, { item: item, attemptHref: attemptHref, locale: locale }, item.experimentId)))] }));
64
+ const board = (_jsxs("div", { className: "nre-experiment-table", children: [_jsx("div", { className: "nre-experiment-head", children: labels.map((label, index) => (_jsx("button", { type: "button", "data-nre-experiment-sort": index, className: index === 4 ? "nre-sort-desc" : undefined, children: label }, label))) }), data.length === 0 && _jsx("p", { className: "nre-experiment-list-empty", children: localeText(locale, "attemptList.empty") }), data.map((item) => (_jsx(ExperimentRow, { item: item, attemptHref: attemptHref, locale: locale, relativeTo: relativeTo }, item.experimentId)))] }));
66
65
  return (_jsxs("div", { className: cx("nre", "nre-experiment-list", filter && "nre-experiment-table-wrap", className), children: [filter && (_jsx("input", { className: "nre-filter", "data-nre-experiment-filter": "", type: "search", placeholder: localeText(locale, "experimentList.filterPlaceholder") })), board] }));
67
66
  }
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { DEFAULT_REPORT_LOCALE, resolveMetricLabel } from "../locale.js";
2
+ import { DEFAULT_REPORT_LOCALE, resolveLocalizedText, resolveMetricLabel } from "../locale.js";
3
3
  import { colorClassForKey, seriesClassForKey } from "./colors.js";
4
4
  import { cx } from "./format.js";
5
5
  const WIDTH = 640;
@@ -26,7 +26,7 @@ export function MetricBars({ data, attemptHref, className, locale = DEFAULT_REPO
26
26
  const groupWidth = (PLOT.right - PLOT.left) / Math.max(1, groupKeys.length);
27
27
  const barWidth = Math.min(36, (groupWidth - 16) / Math.max(1, seriesKeys.length));
28
28
  const plotHeight = PLOT.bottom - PLOT.top;
29
- return (_jsxs("figure", { className: cx("nre", "nre-metric-bars", className), children: [_jsxs("svg", { className: "nre-bars-svg", viewBox: `0 0 ${WIDTH} ${HEIGHT}`, role: "img", "aria-label": `${metricLabel} by ${data.rows} × ${data.columns}`, children: [groupKeys.map((group, gi) => {
29
+ return (_jsxs("figure", { className: cx("nre", "nre-metric-bars", className), children: [_jsxs("svg", { className: "nre-bars-svg", viewBox: `0 0 ${WIDTH} ${HEIGHT}`, role: "img", "aria-label": `${metricLabel} by ${data.rowDimension} × ${data.columnDimension}`, children: [groupKeys.map((group, gi) => {
30
30
  const x0 = PLOT.left + gi * groupWidth;
31
31
  // 组内按值排序,方向随 better(缺数据的系列不画柱)
32
32
  const entries = seriesKeys
@@ -39,10 +39,11 @@ export function MetricBars({ data, attemptHref, className, locale = DEFAULT_REPO
39
39
  const h = Math.max(1, ratioOf(cell.value) * plotHeight);
40
40
  const x = startX + si * barWidth;
41
41
  const y = PLOT.bottom - h;
42
- const title = `${group} · ${series}: ${cell.display}(${cell.samples}/${cell.total})`;
42
+ const display = resolveLocalizedText(cell.display, locale);
43
+ const title = `${group} · ${series}: ${display}(${cell.samples}/${cell.total})`;
43
44
  const rect = (_jsx("rect", { className: cx("nre-bar", seriesClassForKey(series)), x: x + 2, y: y, width: barWidth - 4, height: h, children: _jsx("title", { children: title }) }));
44
45
  const locator = cell.refs[0];
45
- return (_jsxs("g", { children: [attemptHref && locator ? _jsx("a", { href: attemptHref(locator), children: rect }) : rect, _jsx("text", { className: "nre-bar-value", x: x + barWidth / 2, y: y - 4, textAnchor: "middle", children: cell.samples < cell.total ? `${cell.display} ${cell.samples}/${cell.total}` : cell.display })] }, series));
46
+ return (_jsxs("g", { children: [attemptHref && locator ? _jsx("a", { href: attemptHref(locator), children: rect }) : rect, _jsx("text", { className: "nre-bar-value", x: x + barWidth / 2, y: y - 4, textAnchor: "middle", children: cell.samples < cell.total ? `${display} ${cell.samples}/${cell.total}` : display })] }, series));
46
47
  }), _jsx("text", { className: "nre-bars-group-label", x: x0 + groupWidth / 2, y: HEIGHT - 20, textAnchor: "middle", children: group })] }, group));
47
48
  }), _jsx("line", { className: "nre-bars-baseline", x1: PLOT.left, y1: PLOT.bottom, x2: PLOT.right, y2: PLOT.bottom })] }), _jsxs("figcaption", { className: "nre-bars-legend", children: [_jsxs("span", { className: "nre-bars-metric", children: [metricLabel, data.metric.unit && _jsxs("span", { className: "nre-unit", children: ["(", data.metric.unit, ")"] })] }), seriesKeys.map((series) => (_jsx("span", { className: cx("nre-legend-key", "nre-key", colorClassForKey(series)), children: series }, series)))] })] }));
48
49
  }
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { DEFAULT_REPORT_LOCALE, countText, localeText, resolveMetricLabel } from "../locale.js";
2
+ import { DEFAULT_REPORT_LOCALE, countText, localeText, resolveLocalizedText, resolveMetricLabel } from "../locale.js";
3
3
  import { seriesClassForKey } from "./colors.js";
4
4
  import { cx } from "./format.js";
5
5
  const WIDTH = 640;
@@ -22,6 +22,7 @@ export function MetricLine({ data, pointHref, className, locale = DEFAULT_REPORT
22
22
  const missing = data.rows.filter((r) => r.x === null || r.y.value === null);
23
23
  const drawableRows = data.rows.filter((r) => r.x !== null && r.y.value !== null);
24
24
  const yLabel = resolveMetricLabel(data.y.label, locale, data.y.key);
25
+ const xLabel = resolveMetricLabel(data.x.label, locale, data.x.key);
25
26
  const missingNote = missing.length > 0 ? (_jsx("p", { className: "nre-line-missing", title: missing.map((r) => r.key).join(", "), children: countText(locale, "pointsMissing", missing.length) })) : null;
26
27
  if (drawableRows.length === 0) {
27
28
  return (_jsxs("figure", { className: cx("nre", "nre-metric-line", className), children: [_jsx("p", { className: "nre-missing", children: localeText(locale, "cell.missing") }), missingNote] }));
@@ -34,7 +35,7 @@ export function MetricLine({ data, pointHref, className, locale = DEFAULT_REPORT
34
35
  series: r.series,
35
36
  xValue: r.x,
36
37
  yValue: r.y.value,
37
- title: `${r.key}\n${data.x.label}: ${r.xDisplay}\n${yLabel}: ${r.y.display}(${r.y.samples}/${r.y.total})`,
38
+ title: `${r.key}\n${xLabel}: ${resolveLocalizedText(r.xDisplay, locale)}\n${yLabel}: ${resolveLocalizedText(r.y.display, locale)}(${r.y.samples}/${r.y.total})`,
38
39
  px: xScale.scale(r.x),
39
40
  py: yScale.scale(r.y.value),
40
41
  }));
@@ -53,9 +54,15 @@ export function MetricLine({ data, pointHref, className, locale = DEFAULT_REPORT
53
54
  list.sort((a, b) => a.xValue - b.xValue);
54
55
  const xTicks = xScale.lo === xScale.hi ? [xScale.lo] : [xScale.lo, xScale.hi];
55
56
  const yTicks = yScale.lo === yScale.hi ? [yScale.lo] : [yScale.lo, yScale.hi];
56
- const xDisplayFor = (value) => drawableRows.find((r) => r.x === value)?.xDisplay ?? String(value);
57
- const yDisplayFor = (value) => drawableRows.find((r) => r.y.value === value)?.y.display ?? String(value);
58
- return (_jsxs("figure", { className: cx("nre", "nre-metric-line", className), children: [_jsxs("svg", { className: "nre-line-svg", viewBox: `0 0 ${WIDTH} ${HEIGHT}`, role: "img", "aria-label": `${yLabel} by ${data.x.label}`, children: [_jsx("rect", { className: "nre-line-plot", x: PLOT.left, y: PLOT.top, width: PLOT.right - PLOT.left, height: PLOT.bottom - PLOT.top, fill: "none" }), _jsxs("text", { className: "nre-line-xlabel", x: (PLOT.left + PLOT.right) / 2, y: HEIGHT - 8, textAnchor: "middle", children: [data.x.label, data.x.unit ? `(${data.x.unit})` : ""] }), _jsxs("text", { className: "nre-line-ylabel", x: 16, y: (PLOT.top + PLOT.bottom) / 2, textAnchor: "middle", transform: `rotate(-90 16 ${(PLOT.top + PLOT.bottom) / 2})`, children: [yLabel, data.y.unit ? `(${data.y.unit})` : ""] }), xTicks.map((v) => (_jsx("text", { className: "nre-line-tick", x: xScale.scale(v), y: PLOT.bottom + 16, textAnchor: "middle", children: xDisplayFor(v) }, `x${v}`))), yTicks.map((v) => (_jsx("text", { className: "nre-line-tick", x: PLOT.left - 6, y: yScale.scale(v) + 4, textAnchor: "end", children: yDisplayFor(v) }, `y${v}`))), seriesOrder.map((series) => {
57
+ const xDisplayFor = (value) => {
58
+ const row = drawableRows.find((r) => r.x === value);
59
+ return row === undefined ? String(value) : resolveLocalizedText(row.xDisplay, locale);
60
+ };
61
+ const yDisplayFor = (value) => {
62
+ const row = drawableRows.find((r) => r.y.value === value);
63
+ return row === undefined ? String(value) : resolveLocalizedText(row.y.display, locale);
64
+ };
65
+ return (_jsxs("figure", { className: cx("nre", "nre-metric-line", className), children: [_jsxs("svg", { className: "nre-line-svg", viewBox: `0 0 ${WIDTH} ${HEIGHT}`, role: "img", "aria-label": `${yLabel} by ${xLabel}`, children: [_jsx("rect", { className: "nre-line-plot", x: PLOT.left, y: PLOT.top, width: PLOT.right - PLOT.left, height: PLOT.bottom - PLOT.top, fill: "none" }), _jsxs("text", { className: "nre-line-xlabel", x: (PLOT.left + PLOT.right) / 2, y: HEIGHT - 8, textAnchor: "middle", children: [xLabel, data.x.unit ? `(${data.x.unit})` : ""] }), _jsxs("text", { className: "nre-line-ylabel", x: 16, y: (PLOT.top + PLOT.bottom) / 2, textAnchor: "middle", transform: `rotate(-90 16 ${(PLOT.top + PLOT.bottom) / 2})`, children: [yLabel, data.y.unit ? `(${data.y.unit})` : ""] }), xTicks.map((v) => (_jsx("text", { className: "nre-line-tick", x: xScale.scale(v), y: PLOT.bottom + 16, textAnchor: "middle", children: xDisplayFor(v) }, `x${v}`))), yTicks.map((v) => (_jsx("text", { className: "nre-line-tick", x: PLOT.left - 6, y: yScale.scale(v) + 4, textAnchor: "end", children: yDisplayFor(v) }, `y${v}`))), seriesOrder.map((series) => {
59
66
  const list = bySeries.get(series);
60
67
  const seriesClass = series === "" ? "nre-series-none" : seriesClassForKey(series);
61
68
  const labelAt = list.reduce((a, b) => (b.px > a.px ? b : a));
@@ -16,7 +16,7 @@ export function MetricMatrix({ data, attemptHref, className, locale = DEFAULT_RE
16
16
  columnKeys.push(entry.column);
17
17
  byPosition.set(`${entry.row}\u0000${entry.column}`, entry.cell);
18
18
  }
19
- return (_jsxs("table", { className: cx("nre", "nre-metric-matrix", className), children: [_jsxs("caption", { className: "nre-matrix-caption", children: [resolveMetricLabel(data.metric.label, locale, data.metric.key), data.metric.unit && _jsxs("span", { className: "nre-unit", children: ["(", data.metric.unit, ")"] }), _jsxs("span", { className: "nre-matrix-axes", children: [data.rows, " \u00D7 ", data.columns] })] }), _jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { scope: "col", className: "nre-dimension", children: data.rows }), columnKeys.map((column) => (_jsx("th", { scope: "col", className: cx("nre-col-key", "nre-key", colorClassForKey(column)), children: column }, column)))] }) }), _jsx("tbody", { children: rowKeys.map((row) => (_jsxs("tr", { children: [_jsx("th", { scope: "row", className: "nre-row-key", children: row }), columnKeys.map((column) => {
19
+ return (_jsxs("table", { className: cx("nre", "nre-metric-matrix", className), children: [_jsxs("caption", { className: "nre-matrix-caption", children: [resolveMetricLabel(data.metric.label, locale, data.metric.key), data.metric.unit && _jsxs("span", { className: "nre-unit", children: ["(", data.metric.unit, ")"] }), _jsxs("span", { className: "nre-matrix-axes", children: [data.rowDimension, " \u00D7 ", data.columnDimension] })] }), _jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { scope: "col", className: "nre-dimension", children: data.rowDimension }), columnKeys.map((column) => (_jsx("th", { scope: "col", className: cx("nre-col-key", "nre-key", colorClassForKey(column)), children: column }, column)))] }) }), _jsx("tbody", { children: rowKeys.map((row) => (_jsxs("tr", { children: [_jsx("th", { scope: "row", className: "nre-row-key", children: row }), columnKeys.map((column) => {
20
20
  const cell = byPosition.get(`${row}\u0000${column}`);
21
21
  return (_jsx("td", { className: cx("nre-td", !cell && "nre-td-empty"), children: cell ? _jsx(MetricCellView, { cell: cell, attemptHref: attemptHref, locale: locale }) : null }, column));
22
22
  })] }, row))) })] }));