@crowandraven/evalkeeper 0.10.0 → 0.11.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 (241) hide show
  1. package/README.md +1 -2
  2. package/dist/ai-sdk/decide.d.ts +35 -0
  3. package/dist/ai-sdk/decide.js +36 -0
  4. package/dist/ai-sdk/decide.js.map +1 -0
  5. package/dist/ai-sdk/hash.d.ts +50 -0
  6. package/dist/ai-sdk/hash.js +59 -0
  7. package/dist/ai-sdk/hash.js.map +1 -0
  8. package/dist/ai-sdk/index.d.ts +15 -0
  9. package/dist/ai-sdk/index.js +16 -0
  10. package/dist/ai-sdk/index.js.map +1 -0
  11. package/dist/ai-sdk/judge.d.ts +69 -0
  12. package/dist/ai-sdk/judge.js +105 -0
  13. package/dist/ai-sdk/judge.js.map +1 -0
  14. package/dist/ai-sdk/usage.d.ts +18 -0
  15. package/dist/ai-sdk/usage.js +19 -0
  16. package/dist/ai-sdk/usage.js.map +1 -0
  17. package/dist/board.d.ts +5 -0
  18. package/dist/cli/addPages.d.ts +6 -1
  19. package/dist/cli/addPages.js +14 -8
  20. package/dist/cli/addPages.js.map +1 -1
  21. package/dist/cli/main.d.ts +19 -5
  22. package/dist/cli/main.js +100 -4
  23. package/dist/cli/main.js.map +1 -1
  24. package/dist/cli/migration.d.ts +95 -0
  25. package/dist/cli/migration.js +247 -0
  26. package/dist/cli/migration.js.map +1 -0
  27. package/dist/feedback.d.ts +1 -1
  28. package/dist/glossary.d.ts +8 -1
  29. package/dist/glossary.js +8 -1
  30. package/dist/glossary.js.map +1 -1
  31. package/dist/inInstructions.d.ts +1 -1
  32. package/dist/inInstructions.js +1 -1
  33. package/dist/next/RefreshWhile.d.ts +11 -0
  34. package/dist/next/RefreshWhile.js +28 -0
  35. package/dist/next/RefreshWhile.js.map +1 -0
  36. package/dist/next/actions.d.ts +14 -0
  37. package/dist/next/actions.js +332 -0
  38. package/dist/next/actions.js.map +1 -0
  39. package/dist/next/components.d.ts +9 -0
  40. package/dist/next/components.js +27 -0
  41. package/dist/next/components.js.map +1 -0
  42. package/dist/next/cron.d.ts +9 -0
  43. package/dist/next/cron.js +17 -0
  44. package/dist/next/cron.js.map +1 -0
  45. package/dist/next/index.d.ts +15 -0
  46. package/dist/next/index.js +16 -0
  47. package/dist/next/index.js.map +1 -0
  48. package/dist/next/pages.d.ts +70 -0
  49. package/dist/next/pages.js +77 -0
  50. package/dist/next/pages.js.map +1 -0
  51. package/dist/next/route.d.ts +19 -0
  52. package/dist/next/route.js +31 -0
  53. package/dist/next/route.js.map +1 -0
  54. package/dist/next/weekly.d.ts +20 -0
  55. package/dist/next/weekly.js +55 -0
  56. package/dist/next/weekly.js.map +1 -0
  57. package/dist/next/wiring.d.ts +19 -0
  58. package/dist/next/wiring.js +2 -0
  59. package/dist/next/wiring.js.map +1 -0
  60. package/dist/prisma/contracts.d.ts +74 -0
  61. package/dist/prisma/contracts.js +178 -0
  62. package/dist/prisma/contracts.js.map +1 -0
  63. package/dist/prisma/index.d.ts +423 -0
  64. package/dist/prisma/index.js +622 -0
  65. package/dist/prisma/index.js.map +1 -0
  66. package/dist/prisma/mapping.d.ts +63 -0
  67. package/dist/prisma/mapping.js +111 -0
  68. package/dist/prisma/mapping.js.map +1 -0
  69. package/dist/prisma/moveIn.d.ts +106 -0
  70. package/dist/prisma/moveIn.js +299 -0
  71. package/dist/prisma/moveIn.js.map +1 -0
  72. package/dist/prune.d.ts +45 -0
  73. package/dist/prune.js +32 -0
  74. package/dist/prune.js.map +1 -1
  75. package/dist/react/AddCase.d.ts +10 -0
  76. package/dist/react/AddCase.js +19 -0
  77. package/dist/react/AddCase.js.map +1 -0
  78. package/dist/react/AnswerKey.d.ts +22 -0
  79. package/dist/react/AnswerKey.js +83 -0
  80. package/dist/react/AnswerKey.js.map +1 -0
  81. package/dist/react/CaseMenu.d.ts +17 -0
  82. package/dist/react/CaseMenu.js +41 -0
  83. package/dist/react/CaseMenu.js.map +1 -0
  84. package/dist/react/CompareView.d.ts +14 -0
  85. package/dist/react/CompareView.js +51 -0
  86. package/dist/react/CompareView.js.map +1 -0
  87. package/dist/react/ConfirmAnswer.d.ts +13 -0
  88. package/dist/react/ConfirmAnswer.js +27 -0
  89. package/dist/react/ConfirmAnswer.js.map +1 -0
  90. package/dist/react/DisagreementChip.d.ts +10 -0
  91. package/dist/react/DisagreementChip.js +21 -0
  92. package/dist/react/DisagreementChip.js.map +1 -0
  93. package/dist/react/FeedbackView.d.ts +10 -0
  94. package/dist/react/FeedbackView.js +26 -0
  95. package/dist/react/FeedbackView.js.map +1 -0
  96. package/dist/react/Fields.d.ts +32 -0
  97. package/dist/react/Fields.js +33 -0
  98. package/dist/react/Fields.js.map +1 -0
  99. package/dist/react/HubSections.d.ts +78 -0
  100. package/dist/react/HubSections.js +124 -0
  101. package/dist/react/HubSections.js.map +1 -0
  102. package/dist/react/ModelMenu.d.ts +16 -0
  103. package/dist/react/ModelMenu.js +38 -0
  104. package/dist/react/ModelMenu.js.map +1 -0
  105. package/dist/react/RateView.d.ts +18 -0
  106. package/dist/react/RateView.js +30 -0
  107. package/dist/react/RateView.js.map +1 -0
  108. package/dist/react/ReadableOutput.d.ts +3 -0
  109. package/dist/react/ReadableOutput.js +50 -0
  110. package/dist/react/ReadableOutput.js.map +1 -0
  111. package/dist/react/RollBack.d.ts +17 -0
  112. package/dist/react/RollBack.js +26 -0
  113. package/dist/react/RollBack.js.map +1 -0
  114. package/dist/react/RunView.d.ts +9 -0
  115. package/dist/react/RunView.js +41 -0
  116. package/dist/react/RunView.js.map +1 -0
  117. package/dist/react/SettingsHistory.d.ts +33 -0
  118. package/dist/react/SettingsHistory.js +79 -0
  119. package/dist/react/SettingsHistory.js.map +1 -0
  120. package/dist/react/SideBySideView.d.ts +14 -0
  121. package/dist/react/SideBySideView.js +67 -0
  122. package/dist/react/SideBySideView.js.map +1 -0
  123. package/dist/react/SuiteSections.d.ts +111 -0
  124. package/dist/react/SuiteSections.js +224 -0
  125. package/dist/react/SuiteSections.js.map +1 -0
  126. package/dist/react/Tabs.d.ts +15 -0
  127. package/dist/react/Tabs.js +18 -0
  128. package/dist/react/Tabs.js.map +1 -0
  129. package/dist/react/Thumbs.d.ts +13 -0
  130. package/dist/react/Thumbs.js +54 -0
  131. package/dist/react/Thumbs.js.map +1 -0
  132. package/dist/react/WeeklyCheck.d.ts +11 -0
  133. package/dist/react/WeeklyCheck.js +19 -0
  134. package/dist/react/WeeklyCheck.js.map +1 -0
  135. package/dist/react/app.d.ts +118 -0
  136. package/dist/react/app.js +87 -0
  137. package/dist/react/app.js.map +1 -0
  138. package/dist/react/format.d.ts +27 -0
  139. package/dist/react/format.js +38 -0
  140. package/dist/react/format.js.map +1 -0
  141. package/dist/react/index.d.ts +31 -0
  142. package/dist/react/index.js +32 -0
  143. package/dist/react/index.js.map +1 -0
  144. package/dist/react/pieces.d.ts +191 -0
  145. package/dist/react/pieces.js +191 -0
  146. package/dist/react/pieces.js.map +1 -0
  147. package/dist/readCheck.d.ts +1 -1
  148. package/dist/runner.d.ts +62 -2
  149. package/dist/runner.js +123 -3
  150. package/dist/runner.js.map +1 -1
  151. package/dist/settings.d.ts +1 -1
  152. package/dist/store.d.ts +1 -1
  153. package/dist/suggest.d.ts +1 -1
  154. package/dist/suggest.js +7 -7
  155. package/dist/suggest.js.map +1 -1
  156. package/dist/suiteContract.d.ts +3 -3
  157. package/dist/suiteContract.js +20 -16
  158. package/dist/suiteContract.js.map +1 -1
  159. package/dist/testing.d.ts +2 -2
  160. package/dist/testing.js +1 -1
  161. package/dist/types.js +1 -1
  162. package/dist/types.js.map +1 -1
  163. package/package.json +56 -6
  164. package/schema/evalkeeper.prisma +196 -0
  165. package/src/ai-sdk/decide.ts +57 -0
  166. package/src/ai-sdk/hash.ts +74 -0
  167. package/src/ai-sdk/index.ts +15 -0
  168. package/src/ai-sdk/judge.ts +163 -0
  169. package/src/ai-sdk/usage.ts +31 -0
  170. package/src/board.ts +5 -0
  171. package/src/cli/addPages.ts +15 -7
  172. package/src/cli/main.ts +135 -9
  173. package/src/cli/migration.ts +349 -0
  174. package/src/feedback.ts +1 -1
  175. package/src/glossary.ts +16 -2
  176. package/src/inInstructions.ts +1 -1
  177. package/{templates/components/evalkeeper → src/next}/RefreshWhile.tsx +2 -2
  178. package/src/next/actions.ts +389 -0
  179. package/src/next/components.ts +31 -0
  180. package/{templates/lib/evalkeeper/cronAuth.ts → src/next/cron.ts} +3 -0
  181. package/src/next/index.ts +15 -0
  182. package/src/next/pages.tsx +106 -0
  183. package/src/next/route.ts +35 -0
  184. package/src/next/weekly.ts +70 -0
  185. package/src/next/wiring.ts +18 -0
  186. package/src/prisma/contracts.ts +249 -0
  187. package/src/prisma/index.ts +1169 -0
  188. package/src/prisma/mapping.ts +147 -0
  189. package/src/prisma/moveIn.ts +502 -0
  190. package/src/prune.ts +77 -0
  191. package/{templates/components/evalkeeper → src/react}/AddCase.tsx +6 -6
  192. package/{templates/components/evalkeeper → src/react}/AnswerKey.tsx +92 -61
  193. package/{templates/components/evalkeeper → src/react}/CaseMenu.tsx +9 -8
  194. package/src/react/CompareView.tsx +270 -0
  195. package/{templates/components/evalkeeper → src/react}/ConfirmAnswer.tsx +6 -3
  196. package/{templates/components/evalkeeper → src/react}/DisagreementChip.tsx +2 -3
  197. package/src/react/FeedbackView.tsx +230 -0
  198. package/{templates/components/evalkeeper → src/react}/Fields.tsx +6 -6
  199. package/src/react/HubSections.tsx +446 -0
  200. package/src/react/ModelMenu.tsx +89 -0
  201. package/src/react/RateView.tsx +143 -0
  202. package/{templates/components/evalkeeper → src/react}/ReadableOutput.tsx +1 -1
  203. package/{templates/components/evalkeeper → src/react}/RollBack.tsx +9 -10
  204. package/src/react/RunView.tsx +151 -0
  205. package/{templates/components/evalkeeper → src/react}/SettingsHistory.tsx +16 -9
  206. package/src/react/SideBySideView.tsx +307 -0
  207. package/src/react/SuiteSections.tsx +925 -0
  208. package/src/react/Tabs.tsx +61 -0
  209. package/{templates/components/evalkeeper → src/react}/Thumbs.tsx +7 -6
  210. package/{templates/components/evalkeeper → src/react}/WeeklyCheck.tsx +31 -20
  211. package/src/react/app.ts +173 -0
  212. package/src/react/format.ts +45 -0
  213. package/src/react/index.ts +31 -0
  214. package/src/react/pieces.tsx +412 -0
  215. package/src/readCheck.ts +1 -1
  216. package/src/runner.ts +167 -3
  217. package/src/settings.ts +1 -1
  218. package/src/store.ts +1 -1
  219. package/src/suggest.ts +7 -7
  220. package/src/suiteContract.ts +35 -28
  221. package/src/testing.ts +2 -2
  222. package/src/types.ts +2 -2
  223. package/starter/index.ts +22 -8
  224. package/templates/app/api/cron/evals-weekly/route.ts +5 -15
  225. package/templates/app/evals/[suite]/compare/page.tsx +6 -383
  226. package/templates/app/evals/[suite]/page.tsx +7 -685
  227. package/templates/app/evals/[suite]/rate/page.tsx +6 -151
  228. package/templates/app/evals/[suite]/runs/[runId]/page.tsx +6 -174
  229. package/templates/app/evals/[suite]/side-by-side/page.tsx +6 -318
  230. package/templates/app/evals/feedback/page.tsx +6 -227
  231. package/templates/app/evals/layout.tsx +10 -0
  232. package/templates/app/evals/page.tsx +7 -397
  233. package/templates/lib/evalkeeper/actions.ts +34 -317
  234. package/templates/lib/evalkeeper/appComponents.tsx +21 -0
  235. package/templates/lib/evalkeeper/evals.ts +14 -0
  236. package/templates/lib/evalkeeper/paths.ts +2 -7
  237. package/templates/components/evalkeeper/Submit.tsx +0 -67
  238. package/templates/components/evalkeeper/Tip.tsx +0 -98
  239. package/templates/components/evalkeeper/ui.tsx +0 -105
  240. package/templates/lib/evalkeeper/time.ts +0 -4
  241. package/templates/lib/evalkeeper/weekly.ts +0 -74
package/src/prune.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { confirmedLabel, type LabelLike } from "./labels.js";
2
+ import { pickQuickSet } from "./quickSet.js";
1
3
  import { stableJson } from "./stableJson.js";
2
4
  import { at } from "./util.js";
3
5
 
@@ -93,3 +95,78 @@ export function tagCounts(cases: { tags: string[] }[]): [string, number][] {
93
95
  for (const t of c.tags) counts.set(t, (counts.get(t) ?? 0) + 1);
94
96
  return [...counts].sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]));
95
97
  }
98
+
99
+ /** A case as answer-key health reads it. */
100
+ type HealthCase = {
101
+ id: string;
102
+ input: unknown;
103
+ tags: string[];
104
+ status: string;
105
+ createdAt: Date;
106
+ labels: readonly LabelLike[];
107
+ };
108
+
109
+ /**
110
+ * A suite's answer key, sorted for upkeep: what the feature's page shows
111
+ * under "Answer key health". Only what needs a look is non-empty.
112
+ */
113
+ export type AnswerKeyHealth<C> = {
114
+ /** Cases in use: not retired, with a confirmed or provisional answer. */
115
+ inUse: number;
116
+ /** Cases in use every current model gets fully right. */
117
+ easy: C[];
118
+ /** Of the easy ones, those to retire; the rest stay as a floor. */
119
+ easyToRetire: C[];
120
+ /** Cases in use that models divide about evenly on. */
121
+ split: C[];
122
+ /** Pairs of cases in use whose inputs share nearly all their words. */
123
+ duplicates: [C, C][];
124
+ /** Drafts nobody has reviewed in STALE_DRAFT_DAYS. */
125
+ staleDrafts: C[];
126
+ /** How many cases in use carry each tag, most first. */
127
+ tags: [string, number][];
128
+ };
129
+
130
+ /**
131
+ * A suite's answer-key health, from its cases (retired ones are ignored)
132
+ * and how each case fared across the board's current tests. The floor of
133
+ * easy cases keeps the quick set's first, so the weekly check still
134
+ * catches a regression on the basics.
135
+ *
136
+ * @param cases - The suite's cases, with their answers.
137
+ * @param caseResults - Per case, how many current models tested it and
138
+ * got it fully right (the board's `caseResults`).
139
+ * @param today - Now, for old drafts.
140
+ * @returns What needs a look: easy, split, and duplicate cases, old
141
+ * drafts, and how the tags spread.
142
+ */
143
+ export function answerKeyHealth<C extends HealthCase>(
144
+ cases: readonly C[],
145
+ caseResults: Readonly<Record<string, CaseResult>>,
146
+ today = new Date(),
147
+ ): AnswerKeyHealth<C> {
148
+ const live = cases.filter((c) => c.status !== "RETIRED");
149
+ const inUse = live.filter((c) => confirmedLabel(c.labels));
150
+ const drafts = live.filter((c) => !confirmedLabel(c.labels));
151
+ const quick = new Set(
152
+ pickQuickSet(inUse.map((c) => ({ ...c, confirmed: true }))).map(
153
+ (c) => c.id,
154
+ ),
155
+ );
156
+ const easy = inUse.filter((c) => isEasy(caseResults[c.id]));
157
+ const retire = new Set(
158
+ easyToRetire(
159
+ easy.map((c) => ({ ...c, smoke: quick.has(c.id) })),
160
+ inUse.length,
161
+ ).map((c) => c.id),
162
+ );
163
+ return {
164
+ inUse: inUse.length,
165
+ easy,
166
+ easyToRetire: easy.filter((c) => retire.has(c.id)),
167
+ split: inUse.filter((c) => isSplit(caseResults[c.id])),
168
+ duplicates: nearDuplicates(inUse),
169
+ staleDrafts: drafts.filter((c) => isStaleDraft(c.createdAt, today)),
170
+ tags: tagCounts(inUse),
171
+ };
172
+ }
@@ -1,9 +1,9 @@
1
1
  "use client";
2
2
 
3
+ import { Button, Card } from "./pieces.js";
4
+ import { QUIET_BUTTON } from "./format.js";
3
5
  import { useState } from "react";
4
6
  import { Plus } from "lucide-react";
5
- import { QUIET_BUTTON } from "./Submit";
6
- import { Card } from "./ui";
7
7
 
8
8
  /**
9
9
  * A section's header row with an "Add a case" button at the top right,
@@ -26,7 +26,7 @@ export function AddCaseHeader({
26
26
  {heading}
27
27
  <div className="flex items-center gap-2">
28
28
  {form && (
29
- <button
29
+ <Button
30
30
  type="button"
31
31
  aria-expanded={open}
32
32
  onClick={() => {
@@ -36,7 +36,7 @@ export function AddCaseHeader({
36
36
  >
37
37
  <Plus aria-hidden className="h-4 w-4" />
38
38
  Add a case
39
- </button>
39
+ </Button>
40
40
  )}
41
41
  {tools}
42
42
  </div>
@@ -45,7 +45,7 @@ export function AddCaseHeader({
45
45
  <Card className="space-y-4">
46
46
  <div className="flex items-center justify-between gap-2">
47
47
  <h3 className="font-medium">New case</h3>
48
- <button
48
+ <Button
49
49
  type="button"
50
50
  onClick={() => {
51
51
  setOpen(false);
@@ -53,7 +53,7 @@ export function AddCaseHeader({
53
53
  className="text-sm text-muted hover:text-ink"
54
54
  >
55
55
  Cancel
56
- </button>
56
+ </Button>
57
57
  </div>
58
58
  {form}
59
59
  </Card>
@@ -1,3 +1,12 @@
1
+ import {
2
+ Chip,
3
+ InfoTip,
4
+ Select,
5
+ Submit,
6
+ TextInput,
7
+ Tip,
8
+ type ChipTone,
9
+ } from "./pieces.js";
1
10
  import {
2
11
  allPassed,
3
12
  type CaseRecord,
@@ -9,21 +18,20 @@ import {
9
18
  EXPERT_REVIEWED,
10
19
  FROM_BASE_CASE,
11
20
  isShippedReview,
12
- } from "@crowandraven/evalkeeper";
13
- import { addCase, editAnswer, retireCase } from "@/lib/evalkeeper/actions";
21
+ } from "../index.js";
14
22
  import { Check, ChevronRight, CircleAlert, X } from "lucide-react";
15
- import { answerEditors, store } from "@/lib/evalkeeper";
16
- import { AnswerInput, FieldValues, Fields } from "./Fields";
17
- import { AddCaseHeader } from "./AddCase";
18
- import { CaseMenu } from "./CaseMenu";
19
- import { ConfirmAnswer } from "./ConfirmAnswer";
20
- import { Submit } from "./Submit";
21
- import { Chip, type ChipTone } from "./ui";
22
- import { InfoTip, Tip } from "./Tip";
23
+ import type { EvalAppConfig } from "./app.js";
24
+ import { AnswerInput, FieldValues, Fields } from "./Fields.js";
25
+ import { AddCaseHeader } from "./AddCase.js";
26
+ import { CaseMenu } from "./CaseMenu.js";
27
+ import { ConfirmAnswer } from "./ConfirmAnswer.js";
23
28
 
24
29
  /** A suite's cases in use, with each case's answers newest first. */
25
- async function loadCases(suite: string): Promise<CaseRecord[]> {
26
- return (await store.listCases(suite)).map((c) => ({
30
+ async function loadCases(
31
+ app: EvalAppConfig,
32
+ suite: string,
33
+ ): Promise<CaseRecord[]> {
34
+ return (await app.store.listCases(suite)).map((c) => ({
27
35
  ...c,
28
36
  labels: [...c.labels].sort((a, b) => +b.updatedAt - +a.updatedAt),
29
37
  }));
@@ -44,6 +52,8 @@ const STATUS: Record<
44
52
  * case, edit an answer, or retire a case.
45
53
  */
46
54
  export async function AnswerKey({
55
+ app,
56
+ readOnly = false,
47
57
  suite,
48
58
  rows,
49
59
  heading,
@@ -55,8 +65,15 @@ export async function AnswerKey({
55
65
  heading: React.ReactNode;
56
66
  /** More buttons beside "Add a case" (rescore). */
57
67
  tools?: React.ReactNode;
68
+ /** Your screens' configuration. */
69
+ app: EvalAppConfig;
70
+ /**
71
+ * Cases made by Evalkeeper (an injection suite's attack cases), shown
72
+ * without adding, editing, confirming, or retiring.
73
+ */
74
+ readOnly?: boolean;
58
75
  }) {
59
- const cases = await loadCases(suite.key);
76
+ const cases = await loadCases(app, suite.key);
60
77
  // Each model's latest test (at the operation's setting), by case.
61
78
  const modelByRun = new Map(
62
79
  rows.flatMap((r) =>
@@ -66,9 +83,9 @@ export async function AnswerKey({
66
83
  // One query where the store can: one per test is slow on a remote
67
84
  // database.
68
85
  const runIds = [...modelByRun.keys()];
69
- const outputs = store.listOutputsFor
70
- ? await store.listOutputsFor(runIds)
71
- : (await Promise.all(runIds.map((id) => store.listOutputs(id)))).flat();
86
+ const outputs = app.store.listOutputsFor
87
+ ? await app.store.listOutputsFor(runIds)
88
+ : (await Promise.all(runIds.map((id) => app.store.listOutputs(id)))).flat();
72
89
  const byCase = new Map<string, { model: string; output: OutputRecord }[]>();
73
90
  for (const o of outputs) {
74
91
  byCase.set(o.caseId, [
@@ -84,9 +101,10 @@ export async function AnswerKey({
84
101
  heading={heading}
85
102
  tools={tools}
86
103
  form={
104
+ !readOnly &&
87
105
  fields &&
88
- (suite.labelFromForm || answerEditors[suite.key]) && (
89
- <form action={addCase} className="space-y-4">
106
+ (suite.labelFromForm || app.answerEditors[suite.key]) && (
107
+ <form action={app.actions.addCase} className="space-y-4">
90
108
  <input type="hidden" name="suite" value={suite.key} />
91
109
  <Fields fields={fields.input} prefix="new-" />
92
110
  <p className="readable text-sm text-muted">
@@ -94,7 +112,7 @@ export async function AnswerKey({
94
112
  </p>
95
113
  <AnswerInput
96
114
  fields={fields.label}
97
- editor={answerEditors[suite.key]}
115
+ editor={app.answerEditors[suite.key]}
98
116
  prefix="new-"
99
117
  />
100
118
  <div className="grid gap-4 sm:grid-cols-2">
@@ -106,7 +124,7 @@ export async function AnswerKey({
106
124
  Tags
107
125
  <InfoTip term="tags" id="new-tags" />
108
126
  </label>
109
- <input
127
+ <TextInput
110
128
  id="new-tags"
111
129
  name="tags"
112
130
  placeholder="e.g. billing, money now"
@@ -128,7 +146,7 @@ export async function AnswerKey({
128
146
  id="new-split"
129
147
  />
130
148
  </label>
131
- <select
149
+ <Select
132
150
  id="new-split"
133
151
  name="split"
134
152
  defaultValue="DEV"
@@ -138,7 +156,7 @@ export async function AnswerKey({
138
156
  <option value="TEST">
139
157
  TEST: check only, never tune against
140
158
  </option>
141
- </select>
159
+ </Select>
142
160
  </div>
143
161
  </div>
144
162
  <div className="flex gap-2">
@@ -152,6 +170,8 @@ export async function AnswerKey({
152
170
  <div className="space-y-2">
153
171
  {cases.map((c) => (
154
172
  <CaseItem
173
+ app={app}
174
+ readOnly={readOnly}
155
175
  key={c.id}
156
176
  suite={suite}
157
177
  c={c}
@@ -165,10 +185,14 @@ export async function AnswerKey({
165
185
  }
166
186
 
167
187
  function CaseItem({
188
+ app,
189
+ readOnly,
168
190
  suite,
169
191
  c,
170
192
  results,
171
193
  }: {
194
+ app: EvalAppConfig;
195
+ readOnly: boolean;
172
196
  suite: AnySuite;
173
197
  c: CaseRecord;
174
198
  results: {
@@ -342,47 +366,54 @@ function CaseItem({
342
366
  </section>
343
367
  )}
344
368
 
345
- {answer?.status === "PENDING" && (
346
- <ConfirmAnswer suite={suite.key} labelId={answer.id} />
369
+ {!readOnly && answer?.status === "PENDING" && (
370
+ <ConfirmAnswer
371
+ action={app.actions.confirmAnswer}
372
+ suite={suite.key}
373
+ labelId={answer.id}
374
+ />
347
375
  )}
348
376
 
349
- <CaseMenu
350
- suite={suite.key}
351
- caseId={c.id}
352
- retire={retireCase}
353
- startEditing={!answer}
354
- editLabel={
355
- suite.fields && (suite.labelFromForm || answerEditors[suite.key])
356
- ? answer
357
- ? "Edit answer"
358
- : "Write the answer"
359
- : null
360
- }
361
- edit={
362
- suite.fields && (
363
- <form
364
- key={answer?.updatedAt.toISOString() ?? "none"}
365
- action={editAnswer}
366
- className="space-y-4"
367
- >
368
- <input type="hidden" name="suite" value={suite.key} />
369
- <input type="hidden" name="case" value={c.id} />
370
- <AnswerInput
371
- fields={suite.fields.label}
372
- editor={answerEditors[suite.key]}
373
- input={c.input}
374
- values={answer?.value}
375
- prefix={`${c.id}-`}
376
- />
377
- <p className="readable text-xs text-muted">
378
- Saves a new confirmed answer and keeps the old one in the
379
- history. Tests are rescored for free.
380
- </p>
381
- <Submit>Save answer</Submit>
382
- </form>
383
- )
384
- }
385
- />
377
+ {!readOnly && (
378
+ <CaseMenu
379
+ suite={suite.key}
380
+ caseId={c.id}
381
+ retire={app.actions.retireCase}
382
+ startEditing={!answer}
383
+ editLabel={
384
+ suite.fields &&
385
+ (suite.labelFromForm || app.answerEditors[suite.key])
386
+ ? answer
387
+ ? "Edit answer"
388
+ : "Write the answer"
389
+ : null
390
+ }
391
+ edit={
392
+ suite.fields && (
393
+ <form
394
+ key={answer?.updatedAt.toISOString() ?? "none"}
395
+ action={app.actions.editAnswer}
396
+ className="space-y-4"
397
+ >
398
+ <input type="hidden" name="suite" value={suite.key} />
399
+ <input type="hidden" name="case" value={c.id} />
400
+ <AnswerInput
401
+ fields={suite.fields.label}
402
+ editor={app.answerEditors[suite.key]}
403
+ input={c.input}
404
+ values={answer?.value}
405
+ prefix={`${c.id}-`}
406
+ />
407
+ <p className="readable text-xs text-muted">
408
+ Saves a new confirmed answer and keeps the old one in the
409
+ history. Tests are rescored for free.
410
+ </p>
411
+ <Submit>Save answer</Submit>
412
+ </form>
413
+ )
414
+ }
415
+ />
416
+ )}
386
417
  </div>
387
418
  </details>
388
419
  );
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
 
3
+ import { Button } from "./pieces.js";
3
4
  import { useEffect, useRef, useState } from "react";
4
5
  import { EllipsisVertical } from "lucide-react";
5
6
 
@@ -55,7 +56,7 @@ export function CaseMenu({
55
56
  return (
56
57
  <>
57
58
  <div ref={ref} className="absolute right-3 top-0 z-10">
58
- <button
59
+ <Button
59
60
  type="button"
60
61
  aria-label="Case actions"
61
62
  title="Case actions"
@@ -67,14 +68,14 @@ export function CaseMenu({
67
68
  className="inline-flex h-8 w-8 items-center justify-center rounded-md text-muted hover:bg-tint hover:text-ink"
68
69
  >
69
70
  <EllipsisVertical aria-hidden className="h-4 w-4" />
70
- </button>
71
+ </Button>
71
72
  {open && (
72
73
  <div
73
74
  role="menu"
74
75
  className="absolute right-0 mt-1 w-44 rounded-md border border-line bg-card p-1 shadow-lg"
75
76
  >
76
77
  {editLabel && (
77
- <button
78
+ <Button
78
79
  type="button"
79
80
  role="menuitem"
80
81
  className={item}
@@ -84,18 +85,18 @@ export function CaseMenu({
84
85
  }}
85
86
  >
86
87
  {editLabel}
87
- </button>
88
+ </Button>
88
89
  )}
89
90
  <form action={retire}>
90
91
  <input type="hidden" name="suite" value={suite} />
91
92
  <input type="hidden" name="case" value={caseId} />
92
- <button
93
+ <Button
93
94
  type="submit"
94
95
  role="menuitem"
95
96
  className={`${item} text-bad`}
96
97
  >
97
98
  Retire case
98
- </button>
99
+ </Button>
99
100
  </form>
100
101
  </div>
101
102
  )}
@@ -104,7 +105,7 @@ export function CaseMenu({
104
105
  <div className="space-y-3 rounded-md bg-tint p-3">
105
106
  <div className="flex items-center justify-between gap-2">
106
107
  <h4 className="text-sm font-medium">{editLabel}</h4>
107
- <button
108
+ <Button
108
109
  type="button"
109
110
  onClick={() => {
110
111
  setEditing(false);
@@ -112,7 +113,7 @@ export function CaseMenu({
112
113
  className="text-sm text-muted hover:text-ink"
113
114
  >
114
115
  Cancel
115
- </button>
116
+ </Button>
116
117
  </div>
117
118
  {edit}
118
119
  </div>