@crowandraven/evalkeeper 0.17.1 → 0.19.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.
- package/dist/decisions.js +1 -1
- package/dist/decisions.js.map +1 -1
- package/dist/drafts.d.ts +2 -0
- package/dist/drafts.js +1 -1
- package/dist/drafts.js.map +1 -1
- package/dist/glossary.d.ts +25 -14
- package/dist/glossary.js +25 -14
- package/dist/glossary.js.map +1 -1
- package/dist/health.js +2 -2
- package/dist/health.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/memoryStore.d.ts +2 -1
- package/dist/memoryStore.js +9 -0
- package/dist/memoryStore.js.map +1 -1
- package/dist/next/actions.js +58 -3
- package/dist/next/actions.js.map +1 -1
- package/dist/prisma/contracts.d.ts +5 -2
- package/dist/prisma/contracts.js +7 -1
- package/dist/prisma/contracts.js.map +1 -1
- package/dist/prisma/index.d.ts +40 -1
- package/dist/prisma/index.js +37 -1
- package/dist/prisma/index.js.map +1 -1
- package/dist/prune.d.ts +43 -10
- package/dist/prune.js +42 -13
- package/dist/prune.js.map +1 -1
- package/dist/react/AddCase.js +11 -5
- package/dist/react/AddCase.js.map +1 -1
- package/dist/react/AnswerKey.js +7 -4
- package/dist/react/AnswerKey.js.map +1 -1
- package/dist/react/CaseMenu.d.ts +2 -2
- package/dist/react/CaseMenu.js +10 -31
- package/dist/react/CaseMenu.js.map +1 -1
- package/dist/react/CompareView.js +3 -3
- package/dist/react/CompareView.js.map +1 -1
- package/dist/react/ConfirmAnswer.js +1 -1
- package/dist/react/ConfirmAnswer.js.map +1 -1
- package/dist/react/Drawer.d.ts +32 -0
- package/dist/react/Drawer.js +60 -0
- package/dist/react/Drawer.js.map +1 -0
- package/dist/react/HubSections.d.ts +34 -30
- package/dist/react/HubSections.js +104 -103
- package/dist/react/HubSections.js.map +1 -1
- package/dist/react/Menu.d.ts +37 -0
- package/dist/react/Menu.js +51 -0
- package/dist/react/Menu.js.map +1 -0
- package/dist/react/ModelMenu.d.ts +1 -1
- package/dist/react/ModelMenu.js +8 -32
- package/dist/react/ModelMenu.js.map +1 -1
- package/dist/react/RunView.js +24 -4
- package/dist/react/RunView.js.map +1 -1
- package/dist/react/Spending.d.ts +25 -0
- package/dist/react/Spending.js +51 -0
- package/dist/react/Spending.js.map +1 -0
- package/dist/react/SuiteSections.d.ts +27 -14
- package/dist/react/SuiteSections.js +227 -61
- package/dist/react/SuiteSections.js.map +1 -1
- package/dist/react/app.d.ts +18 -0
- package/dist/react/app.js.map +1 -1
- package/dist/react/format.d.ts +13 -0
- package/dist/react/format.js +13 -0
- package/dist/react/format.js.map +1 -1
- package/dist/react/index.d.ts +3 -0
- package/dist/react/index.js +3 -0
- package/dist/react/index.js.map +1 -1
- package/dist/react/pieces.d.ts +21 -8
- package/dist/react/pieces.js +44 -14
- package/dist/react/pieces.js.map +1 -1
- package/dist/runner.d.ts +18 -8
- package/dist/runner.js +148 -12
- package/dist/runner.js.map +1 -1
- package/dist/settings.d.ts +12 -0
- package/dist/settings.js +18 -0
- package/dist/settings.js.map +1 -1
- package/dist/spending.d.ts +100 -0
- package/dist/spending.js +133 -0
- package/dist/spending.js.map +1 -0
- package/dist/stats.d.ts +3 -1
- package/dist/stats.js +6 -2
- package/dist/stats.js.map +1 -1
- package/dist/store.d.ts +5 -0
- package/dist/suggest.js +17 -12
- package/dist/suggest.js.map +1 -1
- package/dist/suiteSettings.d.ts +78 -0
- package/dist/suiteSettings.js +142 -0
- package/dist/suiteSettings.js.map +1 -0
- package/dist/suites/crisisRisk.js +3 -3
- package/dist/suites/crisisRisk.js.map +1 -1
- package/dist/suites/hopelessness.js +6 -6
- package/dist/suites/hopelessness.js.map +1 -1
- package/dist/suites/injection.js +2 -2
- package/dist/suites/injection.js.map +1 -1
- package/dist/summary.d.ts +41 -4
- package/dist/summary.js +46 -8
- package/dist/summary.js.map +1 -1
- package/dist/testing.d.ts +19 -0
- package/dist/testing.js +61 -0
- package/dist/testing.js.map +1 -1
- package/dist/todo.d.ts +146 -0
- package/dist/todo.js +198 -0
- package/dist/todo.js.map +1 -0
- package/dist/types.d.ts +46 -7
- package/dist/types.js +28 -4
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
- package/schema/evalkeeper.prisma +13 -0
- package/src/decisions.ts +1 -1
- package/src/drafts.ts +3 -1
- package/src/glossary.ts +35 -14
- package/src/health.ts +3 -2
- package/src/index.ts +3 -0
- package/src/memoryStore.ts +15 -1
- package/src/next/actions.ts +67 -2
- package/src/prisma/contracts.ts +16 -1
- package/src/prisma/index.ts +68 -1
- package/src/prune.ts +71 -14
- package/src/react/AddCase.tsx +13 -11
- package/src/react/AnswerKey.tsx +17 -5
- package/src/react/CaseMenu.tsx +23 -77
- package/src/react/CompareView.tsx +4 -10
- package/src/react/ConfirmAnswer.tsx +1 -1
- package/src/react/Drawer.tsx +130 -0
- package/src/react/HubSections.tsx +180 -414
- package/src/react/Menu.tsx +155 -0
- package/src/react/ModelMenu.tsx +23 -74
- package/src/react/RunView.tsx +46 -3
- package/src/react/Spending.tsx +200 -0
- package/src/react/SuiteSections.tsx +591 -148
- package/src/react/app.ts +18 -0
- package/src/react/format.ts +15 -0
- package/src/react/index.ts +3 -0
- package/src/react/pieces.tsx +57 -18
- package/src/runner.ts +199 -13
- package/src/settings.ts +20 -0
- package/src/spending.ts +209 -0
- package/src/stats.ts +8 -2
- package/src/store.ts +5 -0
- package/src/suggest.ts +21 -14
- package/src/suiteSettings.ts +201 -0
- package/src/suites/crisisRisk.ts +3 -3
- package/src/suites/hopelessness.ts +6 -6
- package/src/suites/injection.ts +2 -2
- package/src/summary.ts +59 -8
- package/src/testing.ts +77 -0
- package/src/todo.ts +318 -0
- package/src/types.ts +63 -9
- package/starter/index.ts +7 -0
- package/templates/lib/evalkeeper/actions.ts +20 -0
package/src/prune.ts
CHANGED
|
@@ -15,22 +15,53 @@ import { at } from "./util.js";
|
|
|
15
15
|
export const EASY_MIN_MODELS = 3;
|
|
16
16
|
/** Split: this many models or more, with 40–60% fully right. */
|
|
17
17
|
export const SPLIT_MIN_MODELS = 4;
|
|
18
|
-
/**
|
|
19
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Retiring easy cases never takes a suite below this many cases in use,
|
|
20
|
+
* and isn't suggested at or under it: a small answer key keeps every case.
|
|
21
|
+
* The default; a suite's own target number of cases replaces it.
|
|
22
|
+
*/
|
|
23
|
+
export const EASY_FLOOR_CASES = 50;
|
|
24
|
+
/**
|
|
25
|
+
* Rounds of testing a case must pass before it can be retired as easy: days
|
|
26
|
+
* on which at least EASY_MIN_MODELS models were tested on it and all got it
|
|
27
|
+
* fully right, counted from its answer's last change. One good round can be
|
|
28
|
+
* luck; a case right about nine times in ten rarely passes four.
|
|
29
|
+
*/
|
|
30
|
+
export const EASY_MIN_ROUNDS = 4;
|
|
20
31
|
/** Drafts unreviewed this long retire. */
|
|
21
32
|
export const STALE_DRAFT_DAYS = 30;
|
|
22
33
|
/** Inputs this similar (shared words) are near-duplicates. */
|
|
23
34
|
export const DUPLICATE_SIMILARITY = 0.9;
|
|
24
35
|
|
|
25
36
|
/** How one case did across the models tested on it. */
|
|
26
|
-
export type CaseResult = {
|
|
37
|
+
export type CaseResult = {
|
|
38
|
+
passed: number;
|
|
39
|
+
models: number;
|
|
40
|
+
/**
|
|
41
|
+
* Compared with other cases by a suite's `gradeTogether` (a ranking):
|
|
42
|
+
* other cases' results depend on it, so it's never easy to retire.
|
|
43
|
+
*/
|
|
44
|
+
ranked?: boolean | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Rounds the case passed (EASY_MIN_ROUNDS): days at least
|
|
47
|
+
* EASY_MIN_MODELS models were tested on it and all got it fully right,
|
|
48
|
+
* since its answer last changed. Counted only when the suite is over
|
|
49
|
+
* EASY_FLOOR_CASES, since nothing can be retired otherwise.
|
|
50
|
+
*/
|
|
51
|
+
rounds?: number | undefined;
|
|
52
|
+
};
|
|
27
53
|
|
|
28
54
|
/**
|
|
29
|
-
* A case every tested model got right (with enough models): it no longer
|
|
55
|
+
* A case every tested model got right (with enough models): it no longer
|
|
56
|
+
* tells them apart. Not one a ranking compares with others: retiring it
|
|
57
|
+
* would take away the comparisons it anchors.
|
|
30
58
|
*/
|
|
31
59
|
export function isEasy(r: CaseResult | undefined): boolean {
|
|
32
60
|
return (
|
|
33
|
-
r !== undefined &&
|
|
61
|
+
r !== undefined &&
|
|
62
|
+
!r.ranked &&
|
|
63
|
+
r.models >= EASY_MIN_MODELS &&
|
|
64
|
+
r.passed === r.models
|
|
34
65
|
);
|
|
35
66
|
}
|
|
36
67
|
|
|
@@ -47,12 +78,14 @@ export function isSplit(r: CaseResult | undefined): boolean {
|
|
|
47
78
|
*/
|
|
48
79
|
export function easyToRetire<
|
|
49
80
|
C extends { id: string; smoke: boolean; createdAt: Date },
|
|
50
|
-
>(easy: C[], inUse: number): C[] {
|
|
51
|
-
|
|
81
|
+
>(easy: C[], inUse: number, floor: number = EASY_FLOOR_CASES): C[] {
|
|
82
|
+
// Never below the floor: with 52 in use, at most 2 go.
|
|
83
|
+
const room = Math.max(0, inUse - floor);
|
|
84
|
+
// The quick set's and the oldest stay longest; newer ones go first.
|
|
52
85
|
const ordered = [...easy].sort(
|
|
53
86
|
(a, b) => Number(b.smoke) - Number(a.smoke) || +a.createdAt - +b.createdAt,
|
|
54
87
|
);
|
|
55
|
-
return ordered.slice(
|
|
88
|
+
return ordered.slice(Math.max(0, ordered.length - room));
|
|
56
89
|
}
|
|
57
90
|
|
|
58
91
|
const words = (input: unknown) =>
|
|
@@ -115,7 +148,10 @@ export type AnswerKeyHealth<C> = {
|
|
|
115
148
|
inUse: number;
|
|
116
149
|
/** Cases in use every current model gets fully right. */
|
|
117
150
|
easy: C[];
|
|
118
|
-
/**
|
|
151
|
+
/**
|
|
152
|
+
* Of the easy ones, those to retire: passed EASY_MIN_ROUNDS rounds, and
|
|
153
|
+
* only as many as keep the suite at EASY_FLOOR_CASES or more.
|
|
154
|
+
*/
|
|
119
155
|
easyToRetire: C[];
|
|
120
156
|
/** Cases in use that models divide about evenly on. */
|
|
121
157
|
split: C[];
|
|
@@ -127,6 +163,19 @@ export type AnswerKeyHealth<C> = {
|
|
|
127
163
|
tags: [string, number][];
|
|
128
164
|
};
|
|
129
165
|
|
|
166
|
+
/** The board's per-case results with the rounds each case passed. */
|
|
167
|
+
export function withRounds(
|
|
168
|
+
caseResults: Readonly<Record<string, CaseResult>>,
|
|
169
|
+
rounds: Readonly<Record<string, number>>,
|
|
170
|
+
): Record<string, CaseResult> {
|
|
171
|
+
return Object.fromEntries(
|
|
172
|
+
Object.entries(caseResults).map(([id, r]) => [
|
|
173
|
+
id,
|
|
174
|
+
{ ...r, rounds: rounds[id] ?? 0 },
|
|
175
|
+
]),
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
130
179
|
/** Whether a person confirmed the case's answer after `at`. */
|
|
131
180
|
function checkedSince(labels: readonly LabelLike[], since: Date): boolean {
|
|
132
181
|
const answer = confirmedLabel(labels);
|
|
@@ -135,17 +184,20 @@ function checkedSince(labels: readonly LabelLike[], since: Date): boolean {
|
|
|
135
184
|
|
|
136
185
|
/**
|
|
137
186
|
* A suite's answer-key health, from its cases (retired ones are ignored)
|
|
138
|
-
* and how each case fared across the board's current tests.
|
|
139
|
-
*
|
|
140
|
-
*
|
|
187
|
+
* and how each case fared across the board's current tests. Easy cases are
|
|
188
|
+
* suggested for retiring only past EASY_FLOOR_CASES, and only once they've
|
|
189
|
+
* passed EASY_MIN_ROUNDS rounds; the quick set's stay longest.
|
|
141
190
|
*
|
|
142
191
|
* @param cases - The suite's cases, with their answers.
|
|
143
192
|
* @param caseResults - Per case, how many current models tested it and
|
|
144
|
-
* got it fully right (the board's
|
|
193
|
+
* got it fully right, and the rounds it passed (the board's
|
|
194
|
+
* `caseResults`, with `rounds` from the runner's `easyRounds`).
|
|
145
195
|
* @param today - Now, for old drafts.
|
|
146
196
|
* @param testedAt - When the newest current test ran. A split case whose
|
|
147
197
|
* answer a person confirmed after it ("the answer is right") isn't
|
|
148
198
|
* listed again until a newer test splits on it.
|
|
199
|
+
* @param floor - The fewest cases retiring may leave: the suite's target
|
|
200
|
+
* number of cases (`targetCasesOf`), EASY_FLOOR_CASES by default.
|
|
149
201
|
* @returns What needs a look: easy, split, and duplicate cases, old
|
|
150
202
|
* drafts, and how the tags spread.
|
|
151
203
|
*/
|
|
@@ -154,6 +206,7 @@ export function answerKeyHealth<C extends HealthCase>(
|
|
|
154
206
|
caseResults: Readonly<Record<string, CaseResult>>,
|
|
155
207
|
today = new Date(),
|
|
156
208
|
testedAt: Date | null = null,
|
|
209
|
+
floor: number = EASY_FLOOR_CASES,
|
|
157
210
|
): AnswerKeyHealth<C> {
|
|
158
211
|
const live = cases.filter((c) => c.status !== "RETIRED");
|
|
159
212
|
const inUse = live.filter((c) => confirmedLabel(c.labels));
|
|
@@ -164,10 +217,14 @@ export function answerKeyHealth<C extends HealthCase>(
|
|
|
164
217
|
),
|
|
165
218
|
);
|
|
166
219
|
const easy = inUse.filter((c) => isEasy(caseResults[c.id]));
|
|
220
|
+
const proven = easy.filter(
|
|
221
|
+
(c) => (caseResults[c.id]?.rounds ?? 0) >= EASY_MIN_ROUNDS,
|
|
222
|
+
);
|
|
167
223
|
const retire = new Set(
|
|
168
224
|
easyToRetire(
|
|
169
|
-
|
|
225
|
+
proven.map((c) => ({ ...c, smoke: quick.has(c.id) })),
|
|
170
226
|
inUse.length,
|
|
227
|
+
floor,
|
|
171
228
|
).map((c) => c.id),
|
|
172
229
|
);
|
|
173
230
|
return {
|
package/src/react/AddCase.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import { Button, Card } from "./pieces.js";
|
|
|
4
4
|
import { QUIET_BUTTON } from "./format.js";
|
|
5
5
|
import { useEffect, useState, useSyncExternalStore } from "react";
|
|
6
6
|
import { Plus } from "lucide-react";
|
|
7
|
+
import { CloseButton } from "./InfoPopover.js";
|
|
7
8
|
|
|
8
9
|
/** The address's hash, kept current; "" on the server. */
|
|
9
10
|
const hashNow = () => window.location.hash;
|
|
@@ -41,13 +42,20 @@ export function AddCaseHeader({
|
|
|
41
42
|
? decodeURIComponent(hash.slice("#add-case=".length))
|
|
42
43
|
: null;
|
|
43
44
|
const shown = open || topic !== null;
|
|
44
|
-
// A topic from the link goes into the new case's tags
|
|
45
|
+
// A topic from the link goes into the new case's tags; with none
|
|
46
|
+
// ("#add-case="), the form just opens, in view.
|
|
45
47
|
useEffect(() => {
|
|
46
|
-
if (
|
|
48
|
+
if (topic === null) return;
|
|
47
49
|
const tags = document.getElementById("new-tags");
|
|
48
|
-
if (
|
|
50
|
+
if (
|
|
51
|
+
topic &&
|
|
52
|
+
tags instanceof HTMLInputElement &&
|
|
53
|
+
!tags.value.includes(topic)
|
|
54
|
+
)
|
|
49
55
|
tags.value = tags.value ? `${tags.value}, ${topic}` : topic;
|
|
50
|
-
tags
|
|
56
|
+
(tags ?? document.getElementById("answer-key"))?.scrollIntoView({
|
|
57
|
+
block: "center",
|
|
58
|
+
});
|
|
51
59
|
}, [topic]);
|
|
52
60
|
const close = () => {
|
|
53
61
|
setOpen(false);
|
|
@@ -109,13 +117,7 @@ export function AddCaseHeader({
|
|
|
109
117
|
) : (
|
|
110
118
|
<h3 className="font-medium">New case</h3>
|
|
111
119
|
)}
|
|
112
|
-
<
|
|
113
|
-
type="button"
|
|
114
|
-
onClick={close}
|
|
115
|
-
className="text-sm text-muted hover:text-ink"
|
|
116
|
-
>
|
|
117
|
-
Cancel
|
|
118
|
-
</Button>
|
|
120
|
+
<CloseButton onClick={close} />
|
|
119
121
|
</div>
|
|
120
122
|
{draft && tab === "describe" ? draft : form}
|
|
121
123
|
</Card>
|
package/src/react/AnswerKey.tsx
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
EXPERT_REVIEWED,
|
|
20
20
|
FROM_BASE_CASE,
|
|
21
21
|
isShippedReview,
|
|
22
|
+
replacedStarters,
|
|
22
23
|
} from "../index.js";
|
|
23
24
|
import { Check, ChevronRight, CircleAlert, Eye, X } from "lucide-react";
|
|
24
25
|
import type { EvalAppConfig } from "./app.js";
|
|
@@ -108,6 +109,11 @@ export async function AnswerKey({
|
|
|
108
109
|
byCase.set(o.caseId, list);
|
|
109
110
|
}
|
|
110
111
|
const fields = suite.fields;
|
|
112
|
+
// Starters a starter update replaced: marked, so nobody retires the
|
|
113
|
+
// current ones by mistake.
|
|
114
|
+
const replaced = new Set(
|
|
115
|
+
readOnly ? [] : replacedStarters(suite, cases).map((c) => c.id),
|
|
116
|
+
);
|
|
111
117
|
|
|
112
118
|
return (
|
|
113
119
|
<div className="space-y-4">
|
|
@@ -243,6 +249,7 @@ export async function AnswerKey({
|
|
|
243
249
|
suite={suite}
|
|
244
250
|
c={c}
|
|
245
251
|
results={byCase.get(c.id) ?? []}
|
|
252
|
+
replaced={replaced.has(c.id)}
|
|
246
253
|
/>
|
|
247
254
|
))}
|
|
248
255
|
{!cases.length && <p className="text-sm text-muted">No cases yet.</p>}
|
|
@@ -257,11 +264,14 @@ function CaseItem({
|
|
|
257
264
|
suite,
|
|
258
265
|
c,
|
|
259
266
|
results,
|
|
267
|
+
replaced = false,
|
|
260
268
|
}: {
|
|
261
269
|
app: EvalAppConfig;
|
|
262
270
|
readOnly: boolean;
|
|
263
271
|
suite: AnySuite;
|
|
264
272
|
c: CaseRecord;
|
|
273
|
+
/** A starter a starter update replaced (`replacedStarters`). */
|
|
274
|
+
replaced?: boolean;
|
|
265
275
|
results: {
|
|
266
276
|
model: string;
|
|
267
277
|
output: { scores: unknown; error: string | null; output?: unknown };
|
|
@@ -393,7 +403,7 @@ function CaseItem({
|
|
|
393
403
|
>
|
|
394
404
|
{/* The chips keep their place on the right; a long title wraps
|
|
395
405
|
beside them (below them only on a phone). */}
|
|
396
|
-
<summary className="flex cursor-pointer list-none flex-wrap items-start justify-between gap-2 p-3 text-sm sm:flex-nowrap">
|
|
406
|
+
<summary className="flex cursor-pointer list-none flex-wrap [&::-webkit-details-marker]:hidden items-start justify-between gap-2 p-3 text-sm sm:flex-nowrap">
|
|
397
407
|
<span className="flex min-w-0 flex-1 items-start pt-0.5 font-medium">
|
|
398
408
|
<ChevronRight
|
|
399
409
|
aria-hidden
|
|
@@ -408,14 +418,16 @@ function CaseItem({
|
|
|
408
418
|
confirmed={CONFIRMED_STATUS}
|
|
409
419
|
id={`status-${c.id}`}
|
|
410
420
|
/>
|
|
421
|
+
{replaced && (
|
|
422
|
+
<Tip term="replacedStarter" id={`replaced-${c.id}`} align="end">
|
|
423
|
+
<Chip tone="warn">No longer a starter</Chip>
|
|
424
|
+
</Tip>
|
|
425
|
+
)}
|
|
411
426
|
{shipped && (
|
|
412
|
-
<Tip term={shipped.term} id={`reviewed-${c.id}`}>
|
|
427
|
+
<Tip term={shipped.term} id={`reviewed-${c.id}`} align="end">
|
|
413
428
|
<Chip tone="neutral">{shipped.text}</Chip>
|
|
414
429
|
</Tip>
|
|
415
430
|
)}
|
|
416
|
-
<Tip term={c.split === "TEST" ? "test" : "dev"} id={`split-${c.id}`}>
|
|
417
|
-
<Chip tone="neutral">{c.split === "TEST" ? "Test" : "Dev"}</Chip>
|
|
418
|
-
</Tip>
|
|
419
431
|
{results.length > 0 && (
|
|
420
432
|
<Tip
|
|
421
433
|
text={`Right on ${right} of ${results.length} models' latest tests.`}
|
package/src/react/CaseMenu.tsx
CHANGED
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
import { QUIET_BUTTON } from "./format.js";
|
|
4
4
|
|
|
5
5
|
import { Button } from "./pieces.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { useState } from "react";
|
|
7
|
+
import { Menu, MenuButton, MenuForm } from "./Menu.js";
|
|
8
|
+
import { CloseButton } from "./InfoPopover.js";
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* A case's menu, in the top right of the open case: edit its answer (the
|
|
11
|
-
* form opens below the menu's row) and retire it.
|
|
12
|
-
*
|
|
12
|
+
* form opens below the menu's row) and retire it. The eval pages' one
|
|
13
|
+
* `Menu`.
|
|
13
14
|
*/
|
|
14
15
|
export function CaseMenu({
|
|
15
16
|
suite,
|
|
@@ -36,79 +37,28 @@ export function CaseMenu({
|
|
|
36
37
|
*/
|
|
37
38
|
review?: React.ReactNode;
|
|
38
39
|
}) {
|
|
39
|
-
const [open, setOpen] = useState(false);
|
|
40
40
|
const [editing, setEditing] = useState(startEditing);
|
|
41
|
-
const ref = useRef<HTMLDivElement>(null);
|
|
42
|
-
|
|
43
|
-
useEffect(() => {
|
|
44
|
-
if (!open) return;
|
|
45
|
-
const close = (e: MouseEvent | KeyboardEvent) => {
|
|
46
|
-
if (
|
|
47
|
-
e instanceof KeyboardEvent
|
|
48
|
-
? e.key === "Escape"
|
|
49
|
-
: !ref.current?.contains(e.target as Node)
|
|
50
|
-
)
|
|
51
|
-
setOpen(false);
|
|
52
|
-
};
|
|
53
|
-
document.addEventListener("mousedown", close);
|
|
54
|
-
document.addEventListener("keydown", close);
|
|
55
|
-
return () => {
|
|
56
|
-
document.removeEventListener("mousedown", close);
|
|
57
|
-
document.removeEventListener("keydown", close);
|
|
58
|
-
};
|
|
59
|
-
}, [open]);
|
|
60
|
-
|
|
61
|
-
const item =
|
|
62
|
-
"block w-full rounded px-3 py-1.5 text-left text-sm hover:bg-tint";
|
|
63
41
|
|
|
64
42
|
return (
|
|
65
43
|
<>
|
|
66
|
-
<
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
className="inline-flex h-8 w-8 items-center justify-center rounded-md text-muted hover:bg-tint hover:text-ink"
|
|
77
|
-
>
|
|
78
|
-
<EllipsisVertical aria-hidden className="h-4 w-4" />
|
|
79
|
-
</Button>
|
|
80
|
-
{open && (
|
|
81
|
-
<div
|
|
82
|
-
role="menu"
|
|
83
|
-
className="absolute right-0 mt-1 w-44 rounded-md border border-line bg-card p-1 shadow-lg"
|
|
44
|
+
<Menu
|
|
45
|
+
label="Case actions"
|
|
46
|
+
width="w-44"
|
|
47
|
+
className="absolute right-3 top-0 z-10"
|
|
48
|
+
>
|
|
49
|
+
{editLabel && (
|
|
50
|
+
<MenuButton
|
|
51
|
+
onSelect={() => {
|
|
52
|
+
setEditing(true);
|
|
53
|
+
}}
|
|
84
54
|
>
|
|
85
|
-
{editLabel
|
|
86
|
-
|
|
87
|
-
type="button"
|
|
88
|
-
role="menuitem"
|
|
89
|
-
className={item}
|
|
90
|
-
onClick={() => {
|
|
91
|
-
setEditing(true);
|
|
92
|
-
setOpen(false);
|
|
93
|
-
}}
|
|
94
|
-
>
|
|
95
|
-
{editLabel}
|
|
96
|
-
</Button>
|
|
97
|
-
)}
|
|
98
|
-
<form action={retire}>
|
|
99
|
-
<input type="hidden" name="suite" value={suite} />
|
|
100
|
-
<input type="hidden" name="case" value={caseId} />
|
|
101
|
-
<Button
|
|
102
|
-
type="submit"
|
|
103
|
-
role="menuitem"
|
|
104
|
-
className={`${item} text-bad`}
|
|
105
|
-
>
|
|
106
|
-
Retire case
|
|
107
|
-
</Button>
|
|
108
|
-
</form>
|
|
109
|
-
</div>
|
|
55
|
+
{editLabel}
|
|
56
|
+
</MenuButton>
|
|
110
57
|
)}
|
|
111
|
-
|
|
58
|
+
<MenuForm action={retire} fields={{ suite, case: caseId }} danger>
|
|
59
|
+
Retire case
|
|
60
|
+
</MenuForm>
|
|
61
|
+
</Menu>
|
|
112
62
|
{review && !editing && (
|
|
113
63
|
<div className="flex flex-wrap items-center gap-2">
|
|
114
64
|
{review}
|
|
@@ -129,15 +79,11 @@ export function CaseMenu({
|
|
|
129
79
|
<div className="space-y-3 rounded-md bg-tint p-3">
|
|
130
80
|
<div className="flex items-center justify-between gap-2">
|
|
131
81
|
<h4 className="text-sm font-medium">{editLabel}</h4>
|
|
132
|
-
<
|
|
133
|
-
type="button"
|
|
82
|
+
<CloseButton
|
|
134
83
|
onClick={() => {
|
|
135
84
|
setEditing(false);
|
|
136
85
|
}}
|
|
137
|
-
|
|
138
|
-
>
|
|
139
|
-
Cancel
|
|
140
|
-
</Button>
|
|
86
|
+
/>
|
|
141
87
|
</div>
|
|
142
88
|
{edit}
|
|
143
89
|
</div>
|
|
@@ -3,7 +3,7 @@ import { evalsPath, type EvalAppConfig } from "./app.js";
|
|
|
3
3
|
import {
|
|
4
4
|
BackLink,
|
|
5
5
|
Card,
|
|
6
|
-
|
|
6
|
+
SeverityChip,
|
|
7
7
|
InfoTip,
|
|
8
8
|
Link,
|
|
9
9
|
Tip,
|
|
@@ -177,8 +177,8 @@ export async function CompareView({
|
|
|
177
177
|
</Tip>
|
|
178
178
|
</th>
|
|
179
179
|
<th className="p-3 font-normal">
|
|
180
|
-
<Tip term="
|
|
181
|
-
|
|
180
|
+
<Tip term="aim" side="bottom" align="end">
|
|
181
|
+
Aim
|
|
182
182
|
</Tip>
|
|
183
183
|
</th>
|
|
184
184
|
</tr>
|
|
@@ -199,13 +199,7 @@ export async function CompareView({
|
|
|
199
199
|
id={`severity-${c.key}`}
|
|
200
200
|
side="bottom"
|
|
201
201
|
>
|
|
202
|
-
<
|
|
203
|
-
tone={
|
|
204
|
-
c.severity === "serious" ? "serious" : "neutral"
|
|
205
|
-
}
|
|
206
|
-
>
|
|
207
|
-
{c.severity}
|
|
208
|
-
</Chip>
|
|
202
|
+
<SeverityChip severity={c.severity} />
|
|
209
203
|
</Tip>
|
|
210
204
|
</span>
|
|
211
205
|
</td>
|
|
@@ -53,7 +53,7 @@ export function CaseStatusChip({
|
|
|
53
53
|
}) {
|
|
54
54
|
const now = useConfirmedHere(labelId ?? "") && labelId ? confirmed : status;
|
|
55
55
|
return (
|
|
56
|
-
<Tip term={now.term} id={id}>
|
|
56
|
+
<Tip term={now.term} id={id} align="end">
|
|
57
57
|
<Chip tone={now.tone}>{now.text}</Chip>
|
|
58
58
|
</Tip>
|
|
59
59
|
);
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useRef, useState, type ReactNode } from "react";
|
|
4
|
+
import { CloseButton } from "./InfoPopover.js";
|
|
5
|
+
import { Menu, MenuButton } from "./Menu.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A panel that slides in from the right over the page, for a form that
|
|
9
|
+
* belongs to the whole page (Suite settings, Spending and daily limits):
|
|
10
|
+
* one form, one primary Save. Closes with its X, Escape, or a click on
|
|
11
|
+
* the page behind it, and returns focus to what opened it.
|
|
12
|
+
*/
|
|
13
|
+
export function Drawer({
|
|
14
|
+
title,
|
|
15
|
+
open,
|
|
16
|
+
onClose,
|
|
17
|
+
children,
|
|
18
|
+
}: {
|
|
19
|
+
/** The drawer's heading, and its accessible name. */
|
|
20
|
+
title: string;
|
|
21
|
+
open: boolean;
|
|
22
|
+
onClose: () => void;
|
|
23
|
+
children: ReactNode;
|
|
24
|
+
}) {
|
|
25
|
+
const panel = useRef<HTMLDivElement>(null);
|
|
26
|
+
// The latest onClose, so a parent's new function each render doesn't
|
|
27
|
+
// move focus back to the panel.
|
|
28
|
+
const close = useRef(onClose);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
close.current = onClose;
|
|
31
|
+
});
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (!open) return;
|
|
34
|
+
const back =
|
|
35
|
+
document.activeElement instanceof HTMLElement
|
|
36
|
+
? document.activeElement
|
|
37
|
+
: null;
|
|
38
|
+
panel.current?.focus();
|
|
39
|
+
const onKey = (e: KeyboardEvent) => {
|
|
40
|
+
if (e.key === "Escape") close.current();
|
|
41
|
+
};
|
|
42
|
+
document.addEventListener("keydown", onKey);
|
|
43
|
+
return () => {
|
|
44
|
+
document.removeEventListener("keydown", onKey);
|
|
45
|
+
back?.focus();
|
|
46
|
+
};
|
|
47
|
+
}, [open]);
|
|
48
|
+
if (!open) return null;
|
|
49
|
+
return (
|
|
50
|
+
<div className="fixed inset-0 z-40">
|
|
51
|
+
<div
|
|
52
|
+
aria-hidden
|
|
53
|
+
className="absolute inset-0 bg-ink/30"
|
|
54
|
+
onClick={onClose}
|
|
55
|
+
/>
|
|
56
|
+
<div
|
|
57
|
+
ref={panel}
|
|
58
|
+
role="dialog"
|
|
59
|
+
aria-modal="true"
|
|
60
|
+
aria-label={title}
|
|
61
|
+
tabIndex={-1}
|
|
62
|
+
// Saved: the page shows the new values, so the drawer goes.
|
|
63
|
+
onSubmit={() =>
|
|
64
|
+
setTimeout(() => {
|
|
65
|
+
close.current();
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
className="absolute inset-y-0 right-0 flex w-full max-w-md flex-col overflow-y-auto border-l border-line bg-card shadow-xl focus:outline-none"
|
|
69
|
+
>
|
|
70
|
+
<div className="flex items-start justify-between gap-3 p-4 pb-0">
|
|
71
|
+
<h2 className="text-lg font-semibold">{title}</h2>
|
|
72
|
+
<CloseButton onClick={onClose} />
|
|
73
|
+
</div>
|
|
74
|
+
<div className="space-y-4 p-4 text-sm">{children}</div>
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** One entry in a page's menu: its words, and the drawer it opens. */
|
|
81
|
+
export type PageMenuEntry = {
|
|
82
|
+
/** A stable name, for the drawer's state. */
|
|
83
|
+
key: string;
|
|
84
|
+
/** The menu item's words, and the drawer's title. */
|
|
85
|
+
label: string;
|
|
86
|
+
/** What the drawer holds: a form, usually. */
|
|
87
|
+
body: ReactNode;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* The menu beside a page's title: each entry opens its own drawer.
|
|
92
|
+
* Renders nothing without entries.
|
|
93
|
+
*/
|
|
94
|
+
export function PageMenu({
|
|
95
|
+
label,
|
|
96
|
+
entries,
|
|
97
|
+
}: {
|
|
98
|
+
/** The menu button's accessible name. */
|
|
99
|
+
label: string;
|
|
100
|
+
entries: readonly PageMenuEntry[];
|
|
101
|
+
}) {
|
|
102
|
+
const [open, setOpen] = useState<string | null>(null);
|
|
103
|
+
if (!entries.length) return null;
|
|
104
|
+
const shown = entries.find((e) => e.key === open);
|
|
105
|
+
return (
|
|
106
|
+
<>
|
|
107
|
+
<Menu label={label}>
|
|
108
|
+
{entries.map((e) => (
|
|
109
|
+
<MenuButton
|
|
110
|
+
key={e.key}
|
|
111
|
+
onSelect={() => {
|
|
112
|
+
setOpen(e.key);
|
|
113
|
+
}}
|
|
114
|
+
>
|
|
115
|
+
{e.label}
|
|
116
|
+
</MenuButton>
|
|
117
|
+
))}
|
|
118
|
+
</Menu>
|
|
119
|
+
<Drawer
|
|
120
|
+
title={shown?.label ?? ""}
|
|
121
|
+
open={shown !== undefined}
|
|
122
|
+
onClose={() => {
|
|
123
|
+
setOpen(null);
|
|
124
|
+
}}
|
|
125
|
+
>
|
|
126
|
+
{shown?.body}
|
|
127
|
+
</Drawer>
|
|
128
|
+
</>
|
|
129
|
+
);
|
|
130
|
+
}
|