@crowandraven/evalkeeper 0.13.0 → 0.15.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 (105) hide show
  1. package/dist/drafts.d.ts +2 -0
  2. package/dist/drafts.js +3 -1
  3. package/dist/drafts.js.map +1 -1
  4. package/dist/failures.d.ts +16 -0
  5. package/dist/failures.js +40 -0
  6. package/dist/failures.js.map +1 -0
  7. package/dist/health.js +2 -1
  8. package/dist/health.js.map +1 -1
  9. package/dist/index.d.ts +1 -0
  10. package/dist/index.js +1 -0
  11. package/dist/index.js.map +1 -1
  12. package/dist/legs.d.ts +4 -1
  13. package/dist/legs.js +6 -2
  14. package/dist/legs.js.map +1 -1
  15. package/dist/next/actions.js +53 -9
  16. package/dist/next/actions.js.map +1 -1
  17. package/dist/next/route.js +2 -1
  18. package/dist/next/route.js.map +1 -1
  19. package/dist/next/weekly.d.ts +7 -2
  20. package/dist/next/weekly.js +5 -3
  21. package/dist/next/weekly.js.map +1 -1
  22. package/dist/prune.d.ts +4 -1
  23. package/dist/prune.js +11 -2
  24. package/dist/prune.js.map +1 -1
  25. package/dist/react/AddCase.d.ts +12 -2
  26. package/dist/react/AddCase.js +70 -8
  27. package/dist/react/AddCase.js.map +1 -1
  28. package/dist/react/AnswerKey.js +11 -5
  29. package/dist/react/AnswerKey.js.map +1 -1
  30. package/dist/react/CaseMenu.d.ts +6 -1
  31. package/dist/react/CaseMenu.js +5 -2
  32. package/dist/react/CaseMenu.js.map +1 -1
  33. package/dist/react/CompareView.js +4 -4
  34. package/dist/react/CompareView.js.map +1 -1
  35. package/dist/react/FeedbackView.js +3 -3
  36. package/dist/react/FeedbackView.js.map +1 -1
  37. package/dist/react/HubSections.js +3 -4
  38. package/dist/react/HubSections.js.map +1 -1
  39. package/dist/react/InfoPopover.d.ts +19 -0
  40. package/dist/react/InfoPopover.js +46 -0
  41. package/dist/react/InfoPopover.js.map +1 -0
  42. package/dist/react/PriorityPicker.d.ts +21 -0
  43. package/dist/react/PriorityPicker.js +33 -0
  44. package/dist/react/PriorityPicker.js.map +1 -0
  45. package/dist/react/RunView.js +21 -5
  46. package/dist/react/RunView.js.map +1 -1
  47. package/dist/react/SettingsHistory.d.ts +2 -1
  48. package/dist/react/SettingsHistory.js +34 -26
  49. package/dist/react/SettingsHistory.js.map +1 -1
  50. package/dist/react/ShowEarlier.d.ts +11 -0
  51. package/dist/react/ShowEarlier.js +19 -0
  52. package/dist/react/ShowEarlier.js.map +1 -0
  53. package/dist/react/SuiteSections.d.ts +10 -8
  54. package/dist/react/SuiteSections.js +99 -55
  55. package/dist/react/SuiteSections.js.map +1 -1
  56. package/dist/react/WeeklyCheck.js +4 -8
  57. package/dist/react/WeeklyCheck.js.map +1 -1
  58. package/dist/react/app.d.ts +2 -0
  59. package/dist/react/app.js.map +1 -1
  60. package/dist/react/format.d.ts +2 -2
  61. package/dist/react/format.js +4 -2
  62. package/dist/react/format.js.map +1 -1
  63. package/dist/react/pieces.d.ts +11 -0
  64. package/dist/react/pieces.js +17 -2
  65. package/dist/react/pieces.js.map +1 -1
  66. package/dist/runner.d.ts +7 -2
  67. package/dist/runner.js +12 -3
  68. package/dist/runner.js.map +1 -1
  69. package/dist/suggest.js +25 -7
  70. package/dist/suggest.js.map +1 -1
  71. package/dist/types.d.ts +2 -1
  72. package/dist/types.js.map +1 -1
  73. package/dist/weekly.js +4 -2
  74. package/dist/weekly.js.map +1 -1
  75. package/package.json +10 -10
  76. package/src/drafts.ts +6 -1
  77. package/src/failures.ts +50 -0
  78. package/src/health.ts +2 -1
  79. package/src/index.ts +1 -0
  80. package/src/legs.ts +8 -2
  81. package/src/next/actions.ts +54 -9
  82. package/src/next/route.ts +2 -1
  83. package/src/next/weekly.ts +15 -4
  84. package/src/prune.ts +15 -1
  85. package/src/react/AddCase.tsx +98 -11
  86. package/src/react/AnswerKey.tsx +74 -14
  87. package/src/react/CaseMenu.tsx +24 -0
  88. package/src/react/CompareView.tsx +19 -4
  89. package/src/react/FeedbackView.tsx +13 -3
  90. package/src/react/HubSections.tsx +10 -5
  91. package/src/react/InfoPopover.tsx +100 -0
  92. package/src/react/PriorityPicker.tsx +122 -0
  93. package/src/react/RunView.tsx +41 -6
  94. package/src/react/SettingsHistory.tsx +114 -76
  95. package/src/react/ShowEarlier.tsx +57 -0
  96. package/src/react/SuiteSections.tsx +318 -260
  97. package/src/react/WeeklyCheck.tsx +26 -9
  98. package/src/react/app.ts +2 -0
  99. package/src/react/format.ts +4 -2
  100. package/src/react/pieces.tsx +34 -1
  101. package/src/runner.ts +18 -5
  102. package/src/suggest.ts +26 -7
  103. package/src/types.ts +2 -1
  104. package/src/weekly.ts +7 -2
  105. package/templates/lib/evalkeeper/actions.ts +4 -0
@@ -3,6 +3,7 @@ import {
3
3
  InfoTip,
4
4
  Select,
5
5
  Submit,
6
+ TextArea,
6
7
  TextInput,
7
8
  Tip,
8
9
  type ChipTone,
@@ -22,7 +23,7 @@ import {
22
23
  import { Check, ChevronRight, CircleAlert, X } from "lucide-react";
23
24
  import type { EvalAppConfig } from "./app.js";
24
25
  import { AnswerInput, FieldValues, Fields } from "./Fields.js";
25
- import { AddCaseHeader } from "./AddCase.js";
26
+ import { AddCaseHeader, OpenLinkedCase } from "./AddCase.js";
26
27
  import { CaseMenu } from "./CaseMenu.js";
27
28
  import { ConfirmAnswer } from "./ConfirmAnswer.js";
28
29
 
@@ -97,9 +98,62 @@ export async function AnswerKey({
97
98
 
98
99
  return (
99
100
  <div className="space-y-4">
101
+ <OpenLinkedCase />
100
102
  <AddCaseHeader
101
103
  heading={heading}
102
104
  tools={tools}
105
+ draft={
106
+ !readOnly &&
107
+ suite.draftMore &&
108
+ app.actions.draftMore && (
109
+ <form action={app.actions.draftMore} className="space-y-4">
110
+ <input type="hidden" name="suite" value={suite.key} />
111
+ <div className="space-y-1">
112
+ <label
113
+ htmlFor="draft-request"
114
+ className="block text-sm font-medium"
115
+ >
116
+ Describe the cases you want
117
+ </label>
118
+ <TextArea
119
+ id="draft-request"
120
+ name="focus"
121
+ required
122
+ rows={3}
123
+ maxLength={500}
124
+ placeholder="e.g. three guardrail cases where the person states a salary floor"
125
+ className="w-full rounded-md border border-line bg-card px-3 py-2 text-sm focus:border-accent focus:outline-none"
126
+ />
127
+ </div>
128
+ <div className="space-y-1">
129
+ <label
130
+ htmlFor="draft-count"
131
+ className="block text-sm font-medium"
132
+ >
133
+ How many
134
+ </label>
135
+ <Select
136
+ id="draft-count"
137
+ name="count"
138
+ defaultValue="3"
139
+ className="rounded-md border border-line bg-card px-3 py-2 text-sm"
140
+ >
141
+ {[1, 2, 3, 5, 10].map((n) => (
142
+ <option key={n} value={n}>
143
+ {n}
144
+ </option>
145
+ ))}
146
+ </Select>
147
+ </div>
148
+ <p className="readable text-xs text-muted">
149
+ A model writes them from your description and the cases you
150
+ have. They arrive as drafts: nothing counts until you confirm
151
+ each one.
152
+ </p>
153
+ <Submit>Draft them</Submit>
154
+ </form>
155
+ )
156
+ }
103
157
  form={
104
158
  !readOnly &&
105
159
  fields &&
@@ -237,15 +291,17 @@ function CaseItem({
237
291
  // Where ConfirmAnswer moves on to after confirming the case above.
238
292
  data-pending={answer?.status === "PENDING" ? "true" : undefined}
239
293
  >
240
- <summary className="flex cursor-pointer list-none flex-wrap items-center justify-between gap-2 p-3 text-sm">
241
- <span className="font-medium">
294
+ {/* The chips keep their place on the right; a long title wraps
295
+ beside them (below them only on a phone). */}
296
+ <summary className="flex cursor-pointer list-none flex-wrap items-start justify-between gap-2 p-3 text-sm sm:flex-nowrap">
297
+ <span className="flex min-w-0 flex-1 items-start pt-0.5 font-medium">
242
298
  <ChevronRight
243
299
  aria-hidden
244
- className="mr-1.5 inline-block h-4 w-4 align-[-3px] text-muted transition-transform group-open:rotate-90"
300
+ className="mr-1.5 mt-0.5 h-4 w-4 shrink-0 text-muted transition-transform group-open:rotate-90"
245
301
  />
246
- {suite.title(input)}
302
+ <span className="readable min-w-0">{suite.title(input)}</span>
247
303
  </span>
248
- <span className="flex items-center gap-1.5">
304
+ <span className="flex shrink-0 items-center gap-1.5">
249
305
  <Tip term={status.term} id={`status-${c.id}`}>
250
306
  <Chip tone={status.tone}>{status.text}</Chip>
251
307
  </Tip>
@@ -366,20 +422,24 @@ function CaseItem({
366
422
  </section>
367
423
  )}
368
424
 
369
- {!readOnly && answer?.status === "PENDING" && (
370
- <ConfirmAnswer
371
- action={app.actions.confirmAnswer}
372
- suite={suite.key}
373
- labelId={answer.id}
374
- />
375
- )}
376
-
377
425
  {!readOnly && (
378
426
  <CaseMenu
379
427
  suite={suite.key}
380
428
  caseId={c.id}
381
429
  retire={app.actions.retireCase}
382
430
  startEditing={!answer}
431
+ // Pending or provisional: confirm it as it is, or change it.
432
+ review={
433
+ answer &&
434
+ (answer.status === "PENDING" ||
435
+ answer.status === "PROVISIONAL") && (
436
+ <ConfirmAnswer
437
+ action={app.actions.confirmAnswer}
438
+ suite={suite.key}
439
+ labelId={answer.id}
440
+ />
441
+ )
442
+ }
383
443
  editLabel={
384
444
  suite.fields &&
385
445
  (suite.labelFromForm || app.answerEditors[suite.key])
@@ -1,5 +1,7 @@
1
1
  "use client";
2
2
 
3
+ import { QUIET_BUTTON } from "./format.js";
4
+
3
5
  import { Button } from "./pieces.js";
4
6
  import { useEffect, useRef, useState } from "react";
5
7
  import { EllipsisVertical } from "lucide-react";
@@ -16,6 +18,7 @@ export function CaseMenu({
16
18
  edit,
17
19
  retire,
18
20
  startEditing = false,
21
+ review,
19
22
  }: {
20
23
  suite: string;
21
24
  caseId: string;
@@ -27,6 +30,11 @@ export function CaseMenu({
27
30
  retire: (form: FormData) => Promise<void>;
28
31
  /** Open the form from the start, for a case with no answer yet. */
29
32
  startEditing?: boolean;
33
+ /**
34
+ * For an answer nobody has confirmed yet (pending or provisional): the
35
+ * confirm button, shown with **Edit answer** beside it, in plain sight.
36
+ */
37
+ review?: React.ReactNode;
30
38
  }) {
31
39
  const [open, setOpen] = useState(false);
32
40
  const [editing, setEditing] = useState(startEditing);
@@ -101,6 +109,22 @@ export function CaseMenu({
101
109
  </div>
102
110
  )}
103
111
  </div>
112
+ {review && !editing && (
113
+ <div className="flex flex-wrap items-center gap-2">
114
+ {review}
115
+ {editLabel && (
116
+ <Button
117
+ type="button"
118
+ onClick={() => {
119
+ setEditing(true);
120
+ }}
121
+ className={`rounded-md px-3 py-1.5 text-sm ${QUIET_BUTTON}`}
122
+ >
123
+ {editLabel}
124
+ </Button>
125
+ )}
126
+ </div>
127
+ )}
104
128
  {editing && (
105
129
  <div className="space-y-3 rounded-md bg-tint p-3">
106
130
  <div className="flex items-center justify-between gap-2">
@@ -1,6 +1,15 @@
1
+ import type { ReactNode } from "react";
1
2
  import { evalsPath, type EvalAppConfig } from "./app.js";
2
- import { BackLink, Card, Chip, InfoTip, Link, Tip } from "./pieces.js";
3
- import { pct, momentOf, LINK } from "./format.js";
3
+ import {
4
+ BackLink,
5
+ Card,
6
+ Chip,
7
+ InfoTip,
8
+ Link,
9
+ Tip,
10
+ LocalDate,
11
+ } from "./pieces.js";
12
+ import { pct, LINK } from "./format.js";
4
13
  import {
5
14
  checkBar,
6
15
  perAnswer,
@@ -17,11 +26,17 @@ const one = (v: string | string[] | undefined) =>
17
26
  typeof v === "string" && v ? v : null;
18
27
 
19
28
  /** A test's name: its model, reasoning setting, set, and when it ran. */
20
- function testName(models: ModelCatalog, r: RunRecord): string {
29
+ function testName(models: ModelCatalog, r: RunRecord): ReactNode {
21
30
  const model = models[r.model]?.label ?? r.model;
22
31
  const effort = r.reasoningEffort ? `, ${r.reasoningEffort} reasoning` : "";
23
32
  const set = r.set === "ALL" ? "" : `, ${r.set.toLowerCase()} set`;
24
- return `${model}${effort}${set} · ${momentOf(r.startedAt)}`;
33
+ return (
34
+ <>
35
+ {model}
36
+ {effort}
37
+ {set} · <LocalDate date={r.startedAt} time />
38
+ </>
39
+ );
25
40
  }
26
41
 
27
42
  /** A pass rate as "80% (8/10)", or a dash when the check never applied. */
@@ -8,8 +8,16 @@ import {
8
8
  type FeedbackRecord,
9
9
  } from "../index.js";
10
10
  import { FieldValues } from "./Fields.js";
11
- import { BackLink, Card, Chip, InfoTip, Submit, Tip } from "./pieces.js";
12
- import { pct, momentOf } from "./format.js";
11
+ import {
12
+ BackLink,
13
+ Card,
14
+ Chip,
15
+ InfoTip,
16
+ Submit,
17
+ Tip,
18
+ LocalDate,
19
+ } from "./pieces.js";
20
+ import { pct } from "./format.js";
13
21
  import { ThumbsDown, ThumbsUp } from "lucide-react";
14
22
 
15
23
  /**
@@ -167,7 +175,9 @@ function Rating({
167
175
  </Chip>
168
176
  <span className="font-medium">{feature}</span>
169
177
  </span>
170
- <span className="text-xs text-muted">{momentOf(f.updatedAt)}</span>
178
+ <span className="text-xs text-muted">
179
+ <LocalDate date={f.updatedAt} time />
180
+ </span>
171
181
  </div>
172
182
  {f.reason && <p className="readable">&ldquo;{f.reason}&rdquo;</p>}
173
183
  <div className="grid gap-4 md:grid-cols-2">
@@ -12,8 +12,8 @@ import {
12
12
  type Settings,
13
13
  type SettingsVersion,
14
14
  } from "../index.js";
15
- import { Link, Card, InfoTip, HealthChips } from "./pieces.js";
16
- import { pct, dayOf } from "./format.js";
15
+ import { Link, Card, InfoTip, HealthChips, LocalDate } from "./pieces.js";
16
+ import { pct } from "./format.js";
17
17
  import { HistoryEntries } from "./SettingsHistory.js";
18
18
  import {
19
19
  daysAgo,
@@ -259,7 +259,6 @@ function Stat({
259
259
 
260
260
  type Board = Awaited<ReturnType<Runner["board"]>>;
261
261
 
262
- const day = dayOf;
263
262
  /** Green at 95% and up, amber from 80%, red below. */
264
263
  const scoreTone = (rate: number) =>
265
264
  rate >= 0.95 ? "text-good" : rate >= 0.8 ? "text-warn" : "text-bad";
@@ -405,8 +404,14 @@ function SuiteCard({
405
404
  <span className="font-medium text-ink">
406
405
  v{version?.number ?? 1}
407
406
  </span>{" "}
408
- {since ? `live since ${day(since)}` : "defaults from code"} ·{" "}
409
- {versions} version{versions === 1 ? "" : "s"}
407
+ {since ? (
408
+ <>
409
+ live since <LocalDate date={since} />
410
+ </>
411
+ ) : (
412
+ "defaults from code"
413
+ )}{" "}
414
+ · {versions} version{versions === 1 ? "" : "s"}
410
415
  <ChevronDown
411
416
  aria-hidden
412
417
  className="h-4 w-4 transition-transform group-open/history:rotate-180"
@@ -0,0 +1,100 @@
1
+ "use client";
2
+
3
+ import { useEffect, useRef, useState, type RefObject } from "react";
4
+ import { Info, X } from "lucide-react";
5
+ import { Button } from "./pieces.js";
6
+
7
+ /**
8
+ * Closes a popup on Escape or a click outside `ref`, while it's open.
9
+ */
10
+ export function useDismiss(
11
+ open: boolean,
12
+ setOpen: (open: boolean) => void,
13
+ ref: RefObject<HTMLElement | null>,
14
+ ) {
15
+ useEffect(() => {
16
+ if (!open) return;
17
+ const onEvent = (e: MouseEvent | KeyboardEvent) => {
18
+ if (
19
+ e instanceof KeyboardEvent
20
+ ? e.key === "Escape"
21
+ : !ref.current?.contains(e.target as Node)
22
+ )
23
+ setOpen(false);
24
+ };
25
+ document.addEventListener("mousedown", onEvent);
26
+ document.addEventListener("keydown", onEvent);
27
+ return () => {
28
+ document.removeEventListener("mousedown", onEvent);
29
+ document.removeEventListener("keydown", onEvent);
30
+ };
31
+ }, [open, setOpen, ref]);
32
+ }
33
+
34
+ /** The X that closes a popup. */
35
+ export function CloseButton({ onClick }: { onClick: () => void }) {
36
+ return (
37
+ <Button
38
+ type="button"
39
+ aria-label="Close"
40
+ title="Close"
41
+ onClick={onClick}
42
+ className="-mr-1 -mt-1 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted hover:bg-tint hover:text-ink"
43
+ >
44
+ <X aria-hidden className="h-4 w-4" />
45
+ </Button>
46
+ );
47
+ }
48
+
49
+ /**
50
+ * An info button that opens more than a tooltip holds: a list, steps, a
51
+ * guide. Opens on press, closes with its X, Escape, or a click outside.
52
+ * For a sentence or two, use InfoTip.
53
+ */
54
+ export function InfoPopover({
55
+ label,
56
+ children,
57
+ }: {
58
+ /** What the popup is, for screen readers: "About the answer key". */
59
+ label: string;
60
+ children: React.ReactNode;
61
+ }) {
62
+ const [open, setOpen] = useState(false);
63
+ const ref = useRef<HTMLDivElement>(null);
64
+ useDismiss(open, setOpen, ref);
65
+ return (
66
+ <div
67
+ ref={ref}
68
+ className="relative ml-1 inline-flex align-middle text-sm font-normal"
69
+ >
70
+ <Button
71
+ type="button"
72
+ aria-haspopup="dialog"
73
+ aria-expanded={open}
74
+ aria-label={label}
75
+ onClick={() => {
76
+ setOpen(!open);
77
+ }}
78
+ className="inline-flex h-4 w-4 items-center justify-center rounded-full text-muted hover:text-ink"
79
+ >
80
+ <Info aria-hidden className="h-3.5 w-3.5" />
81
+ </Button>
82
+ {open && (
83
+ <div
84
+ role="dialog"
85
+ aria-label={label}
86
+ className="absolute left-0 top-full z-20 mt-2 max-h-[70vh] w-[min(28rem,calc(100vw-2rem))] overflow-y-auto rounded-md border border-line bg-card p-4 shadow-lg"
87
+ >
88
+ <div className="flex items-start gap-3">
89
+ <div className="min-w-0 flex-1 space-y-3">{children}</div>
90
+ <CloseButton
91
+ onClick={() => {
92
+ setOpen(false);
93
+ }}
94
+ />
95
+ </div>
96
+ </div>
97
+ )}
98
+ </div>
99
+ );
100
+ }
@@ -0,0 +1,122 @@
1
+ "use client";
2
+
3
+ import { useRef, useState } from "react";
4
+ import { ChevronDown } from "lucide-react";
5
+ import { CloseButton, useDismiss } from "./InfoPopover.js";
6
+ import { Button, Select, Submit, TextInput } from "./pieces.js";
7
+ import type { FormAction } from "./app.js";
8
+ import type { SuitePriority } from "../types.js";
9
+
10
+ type Favor = SuitePriority["favor"];
11
+
12
+ /** The choices when changing it: accuracy is always held. */
13
+ const CHOICES = {
14
+ quality: "Accuracy alone",
15
+ speed: "Speed",
16
+ cost: "Cost",
17
+ } as const;
18
+
19
+ /**
20
+ * The "Favors …" chip as a button: it opens what the priority means and
21
+ * a form to change it, saved as a new settings version with an optional
22
+ * reason, so it shows under Versions and can be rolled back. Closes with
23
+ * its X, Escape, or a click outside.
24
+ */
25
+ export function PriorityPicker({
26
+ action,
27
+ suite,
28
+ favor,
29
+ own,
30
+ label,
31
+ why,
32
+ }: {
33
+ action: FormAction;
34
+ suite: string;
35
+ favor: Favor;
36
+ /** The suite's own priority, from its code. */
37
+ own: Favor;
38
+ /** The chip's words: "Favors speed". */
39
+ label: string;
40
+ /** What the priority means for the suggestion, as a sentence. */
41
+ why: string;
42
+ }) {
43
+ const [open, setOpen] = useState(false);
44
+ const ref = useRef<HTMLDivElement>(null);
45
+
46
+ useDismiss(open, setOpen, ref);
47
+
48
+ return (
49
+ <div ref={ref} className="relative text-sm font-normal">
50
+ <Button
51
+ type="button"
52
+ aria-haspopup="dialog"
53
+ aria-expanded={open}
54
+ onClick={() => {
55
+ setOpen(!open);
56
+ }}
57
+ className="inline-flex h-6 items-center gap-1 whitespace-nowrap rounded-full bg-tint px-2.5 text-xs font-medium leading-none text-muted hover:text-ink"
58
+ >
59
+ {label}
60
+ <ChevronDown aria-hidden className="h-3 w-3" />
61
+ </Button>
62
+ {open && (
63
+ <div
64
+ role="dialog"
65
+ aria-label="What this feature favors"
66
+ className="absolute left-0 z-20 mt-2 w-80 rounded-md border border-line bg-card p-4 shadow-lg"
67
+ >
68
+ <div className="flex items-start justify-between gap-3">
69
+ <p className="text-muted">{why}</p>
70
+ <CloseButton
71
+ onClick={() => {
72
+ setOpen(false);
73
+ }}
74
+ />
75
+ </div>
76
+ <form
77
+ action={action}
78
+ // Closes once saved (after the submit is read).
79
+ onSubmit={() =>
80
+ setTimeout(() => {
81
+ setOpen(false);
82
+ })
83
+ }
84
+ className="mt-4 space-y-3"
85
+ >
86
+ <input type="hidden" name="suite" value={suite} />
87
+ <div>
88
+ <label htmlFor="favor" className="block font-medium">
89
+ Once accuracy holds, favor
90
+ </label>
91
+ <Select
92
+ id="favor"
93
+ name="favor"
94
+ defaultValue={favor}
95
+ className="mt-1 w-full rounded-md border border-line bg-card px-3 py-2"
96
+ >
97
+ {(["quality", "speed", "cost"] as const).map((f) => (
98
+ <option key={f} value={f}>
99
+ {CHOICES[f]}
100
+ {f === own ? " (the suite's own)" : ""}
101
+ </option>
102
+ ))}
103
+ </Select>
104
+ </div>
105
+ <div>
106
+ <label htmlFor="favor-reason" className="block font-medium">
107
+ Why? <span className="font-normal text-muted">(optional)</span>
108
+ </label>
109
+ <TextInput
110
+ id="favor-reason"
111
+ name="reason"
112
+ maxLength={300}
113
+ className="mt-1 w-full rounded-md border border-line bg-card px-3 py-2"
114
+ />
115
+ </div>
116
+ <Submit>Save as a new version</Submit>
117
+ </form>
118
+ </div>
119
+ )}
120
+ </div>
121
+ );
122
+ }
@@ -1,10 +1,10 @@
1
1
  import { evalsPath, type EvalAppConfig } from "./app.js";
2
- import { Link } from "./pieces.js";
3
- import { allPassed, money, summarize } from "../index.js";
2
+ import { Link, LocalDate } from "./pieces.js";
3
+ import { allPassed, failureHints, money, summarize } from "../index.js";
4
4
  import { FieldValues } from "./Fields.js";
5
5
  import { ReadableOutput } from "./ReadableOutput.js";
6
6
  import { BackLink, Card } from "./pieces.js";
7
- import { pct, momentOf, LINK } from "./format.js";
7
+ import { pct, LINK } from "./format.js";
8
8
 
9
9
  /** One test: every answer, with what each check found. */
10
10
 
@@ -32,6 +32,21 @@ export async function RunView({
32
32
  };
33
33
  const metrics = run.metrics;
34
34
  const summary = metrics ? summarize(metrics, suite.checks) : null;
35
+ // Answers that never came back first, then wrong ones, then right ones,
36
+ // so what needs a look is at the top.
37
+ const rank = (o: (typeof outputs)[number]) =>
38
+ o.error ? 0 : allPassed(o.scores ?? null) ? 2 : 1;
39
+ const ordered = [...outputs].sort((a, b) => rank(a) - rank(b));
40
+ const failed = outputs.filter((o) => o.error);
41
+ // Why they failed, counted: "timed out after 60s (3)".
42
+ const reasons = [
43
+ ...failed
44
+ .reduce((m, o) => {
45
+ const why = (o.error ?? "").split("\n")[0]?.slice(0, 120) ?? "";
46
+ return m.set(why, (m.get(why) ?? 0) + 1);
47
+ }, new Map<string, number>())
48
+ .entries(),
49
+ ];
35
50
  const label = (k: string) =>
36
51
  suite.checks.find((c) => c.key === k)?.label ?? k;
37
52
  type Check = {
@@ -50,7 +65,7 @@ export async function RunView({
50
65
  {app.models[run.model]?.label ?? run.model} on {suite.label}
51
66
  </h1>
52
67
  <p className="text-sm text-muted">
53
- {momentOf(run.startedAt)} · {run.status.toLowerCase()}
68
+ <LocalDate date={run.startedAt} time /> · {run.status.toLowerCase()}
54
69
  {metrics && ` · spent ${money(metrics.costUsd)}`}
55
70
  </p>
56
71
  {run.error && <p className="readable text-bad">{run.error}</p>}
@@ -62,6 +77,21 @@ export async function RunView({
62
77
  {pct(summary.total ? summary.right / summary.total : 0)})
63
78
  </p>
64
79
  <p className="readable text-sm text-muted">{summary.trust}</p>
80
+ {failed.length > 0 && (
81
+ <p className="readable text-sm text-bad">
82
+ {failed.length} {failed.length === 1 ? "answer" : "answers"}{" "}
83
+ didn&apos;t come back:{" "}
84
+ {reasons.map(([why, n]) => `${why} (${n})`).join("; ")}.{" "}
85
+ <a href="#failed" className={LINK}>
86
+ See {failed.length === 1 ? "it" : "them"}
87
+ </a>
88
+ </p>
89
+ )}
90
+ {failureHints(failed.map((o) => o.error)).map((hint) => (
91
+ <p key={hint} className="readable text-sm text-muted">
92
+ {hint}
93
+ </p>
94
+ ))}
65
95
  {summary.problems.length > 0 && (
66
96
  <ul className="readable list-disc pl-5 text-sm">
67
97
  {summary.problems.map((p) => (
@@ -74,11 +104,16 @@ export async function RunView({
74
104
  </Card>
75
105
  )}
76
106
  <Card className="space-y-3">
77
- {outputs.map((o) => {
107
+ {ordered.map((o, i) => {
78
108
  const checks = (o.scores as Check[] | null) ?? null;
79
109
  const ok = allPassed(checks);
80
110
  return (
81
- <div key={o.id} className="rounded-md bg-tint p-3 text-sm">
111
+ <div
112
+ key={o.id}
113
+ // The summary's "See them" lands on the first failed answer.
114
+ id={o.error && i === 0 ? "failed" : undefined}
115
+ className="scroll-mt-4 rounded-md bg-tint p-3 text-sm"
116
+ >
82
117
  <div className="flex justify-between gap-4">
83
118
  <span className="font-medium">{titleOf(o.caseId)}</span>
84
119
  <span