@milabench/bujang 0.1.15 → 0.1.17

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.
@@ -17,17 +17,15 @@ import {
17
17
  Wrap,
18
18
  } from '@chakra-ui/react';
19
19
  import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
20
- import { LuCopy, LuPlus, LuRefreshCw } from 'react-icons/lu';
20
+ import { LuPlus, LuRefreshCw } from 'react-icons/lu';
21
21
  import {
22
22
  getJobData,
23
23
  getJobDataRows,
24
24
  getJobOverviewLayout,
25
- jobDataRowsUrl,
26
25
  saveOverviewLayout,
27
26
  updateSettings,
28
27
  } from '../api';
29
- import type { ApiError, JobData, JobDataField, JobOverviewLayout, OverviewLayout, OverviewPanel } from '../types';
30
- import { MonacoEditor } from '../components/MonacoEditor';
28
+ import type { ApiError, JobData, JobDataField, JobOverviewLayout, OverviewBlock, OverviewLayout } from '../types';
31
29
  import { toaster } from '../toast';
32
30
  import {
33
31
  AGGREGATES,
@@ -37,6 +35,7 @@ import {
37
35
  MARKS,
38
36
  ROLE_ORDER,
39
37
  ROW_LIMIT,
38
+ fileRanks,
40
39
  VegaChart,
41
40
  buildSpec,
42
41
  filesWithEvent,
@@ -45,7 +44,7 @@ import {
45
44
  panelOfBuilder,
46
45
  specFields,
47
46
  } from './dataCharts';
48
- import { LayoutBar, LayoutPanels } from './OverviewPanels';
47
+ import { LayoutBar, LayoutPanels, layoutKeyOf, type OverviewView } from './OverviewPanels';
49
48
 
50
49
  const FieldSelect: React.FC<{
51
50
  label: string;
@@ -78,21 +77,69 @@ const formatRange = (f: JobDataField) => {
78
77
  return '';
79
78
  };
80
79
 
80
+ /** ms between two reads of the data of a running job (the server syncs it at most that often), and how long after its end */
81
+ const REFRESH = 30_000;
82
+ const SETTLE = 100_000;
83
+
81
84
  /**
82
85
  * The Overview tab of a job: the panels of its layout (the log view, charts: GET
83
- * /jobs/<jr>/overview/layout), then an explorer of the JSONL files of its artifact folders (output/,
84
- * runs/, results/) plotted with Vega-Lite. Its builder writes the spec; the spec can be edited by hand,
85
- * is shown with the rows URL as an Altair snippet, and can be added to the layout.
86
+ * /jobs/<jr>/overview/layout), or the "explore data" layout: the JSONL files of its artifact folders
87
+ * (output/, runs/, results/) plotted with a chart builder, whose charts can be added to the layout of the job.
86
88
  */
87
- export const JobDataOverview: React.FC<{ jrJobId: string }> = ({ jrJobId }) => {
88
- const { data, isLoading, error, refetch, isFetching } = useQuery<JobData, ApiError>({
89
+ export const JobDataOverview: React.FC<{
90
+ jrJobId: string;
91
+ /** the job is running (or waiting): its data is followed */
92
+ live?: boolean;
93
+ }> = ({ jrJobId, live = false }) => {
94
+ const queryClient = useQueryClient();
95
+ // the last files come back with the syncs after the end of the job: followed a little longer
96
+ const [settling, setSettling] = useState(false);
97
+ const wasLive = useRef(live);
98
+ useEffect(() => {
99
+ const ended = wasLive.current && !live;
100
+ wasLive.current = live;
101
+ if (!ended) return undefined;
102
+ setSettling(true);
103
+ const timer = window.setTimeout(() => setSettling(false), SETTLE);
104
+ return () => window.clearTimeout(timer);
105
+ }, [live]);
106
+ const { data, dataUpdatedAt, isLoading, error, refetch, isFetching } = useQuery<JobData, ApiError>({
89
107
  queryKey: ['bujang-job-data', jrJobId],
90
108
  queryFn: () => getJobData(jrJobId),
91
109
  staleTime: 30_000,
110
+ refetchInterval: live || settling ? REFRESH : false,
92
111
  retry: false,
93
112
  });
113
+ // the files changed (a sync): their rows and the layout again
114
+ const version = useMemo(() => (data?.files || []).map((f) => `${f.path}:${f.mtime}:${f.size}`).join('|'), [data]);
115
+ const known = useRef<string | null>(null);
116
+ useEffect(() => {
117
+ if (!data) return;
118
+ if (known.current !== null && known.current !== version) {
119
+ queryClient.invalidateQueries({ queryKey: ['bujang-job-data-rows', jrJobId] });
120
+ queryClient.invalidateQueries({ queryKey: ['bujang-overview-layout', jrJobId] });
121
+ }
122
+ // the images, ... are not in `data`: asked again with it
123
+ if (known.current !== null) queryClient.invalidateQueries({ queryKey: ['bujang-job-artifacts', jrJobId] });
124
+ known.current = version;
125
+ }, [data, dataUpdatedAt, version, jrJobId, queryClient]);
94
126
 
95
127
  const files = useMemo(() => (data?.files || []).filter((f) => !f.error), [data]);
128
+ // a job of several processes, each with its files: the panels show one of them, the first by default
129
+ const ranks = useMemo(() => fileRanks(files), [files]);
130
+ const rankList = useMemo(
131
+ () => [...new Set([...ranks.values()].filter((r): r is number => r !== null))].sort((a, b) => a - b),
132
+ [ranks],
133
+ );
134
+ const [pickedRank, setPickedRank] = useState<number | 'all' | null>(null);
135
+ const rank = rankList.length < 2
136
+ ? 'all'
137
+ : pickedRank === 'all' || (pickedRank !== null && rankList.includes(pickedRank)) ? pickedRank : rankList[0];
138
+ const rankFiles = useMemo(
139
+ // the files of no rank are always there
140
+ () => (rank === 'all' ? files : files.filter((f) => (ranks.get(f.path) ?? rank) === rank)),
141
+ [files, ranks, rank],
142
+ );
96
143
  const [selectedFiles, setSelectedFiles] = useState<string[] | null>(null);
97
144
  const activeFiles = useMemo(
98
145
  () => files.filter((f) => selectedFiles === null || selectedFiles.includes(f.path)),
@@ -119,9 +166,9 @@ export const JobDataOverview: React.FC<{ jrJobId: string }> = ({ jrJobId }) => {
119
166
  const fieldMap = useMemo(() => new Map([...fields, ...FILE_FIELDS].map((f) => [f.name, f])), [fields]);
120
167
  const fieldOptions = useMemo(() => [...fields, ...FILE_FIELDS], [fields]);
121
168
 
122
- // builder: guessed again when the event or the files change, until edited
169
+ // builder: guessed again when the event or the picked files change (not for the files a sync adds)
123
170
  const [builder, setBuilder] = useState<Builder>(EMPTY_BUILDER);
124
- const guessKey = `${activeEvent}|${activeFiles.map((f) => f.path).join(',')}`;
171
+ const guessKey = `${activeEvent}|${selectedFiles === null ? '*' : selectedFiles.join(',')}`;
125
172
  const lastGuess = useRef<string>('');
126
173
  useEffect(() => {
127
174
  if (fields.length && lastGuess.current !== guessKey) {
@@ -130,33 +177,15 @@ export const JobDataOverview: React.FC<{ jrJobId: string }> = ({ jrJobId }) => {
130
177
  }
131
178
  }, [guessKey, fields, activeFiles, activeEvent]);
132
179
 
133
- // the spec: from the builder, or edited by hand
134
- const builtSpec = useMemo(() => buildSpec(builder, fieldMap), [builder, fieldMap]);
135
- const [specText, setSpecText] = useState<string | null>(null);
136
- const { spec, specError } = useMemo(() => {
137
- if (specText === null) return { spec: builtSpec, specError: null };
138
- try {
139
- return { spec: JSON.parse(specText) as Record<string, unknown>, specError: null };
140
- } catch (err) {
141
- return { spec: null, specError: err instanceof Error ? err.message : String(err) };
142
- }
143
- }, [specText, builtSpec]);
144
- // the chart keeps the last valid spec while the one typed does not parse
145
- const [lastSpec, setLastSpec] = useState<Record<string, unknown> | null>(null);
146
- useEffect(() => { if (spec) setLastSpec(spec); }, [spec]);
180
+ const spec = useMemo(() => buildSpec(builder, fieldMap), [builder, fieldMap]);
147
181
 
148
- // rows: only the fields of the builder's spec; a spec edited by hand gets whole rows (its
149
- // transforms may read any field)
182
+ // rows: only the fields of the spec
150
183
  const rowsQuery = useMemo(() => {
151
- const byBuilder = specText === null;
152
184
  // the fields of the data (not the ones the spec computes: time_date)
153
- const wanted = byBuilder && lastSpec
154
- ? [...specFields(lastSpec)].filter((f) => !f.startsWith('_') && fieldMap.has(f))
155
- : [];
185
+ const wanted = [...specFields(spec)].filter((f) => !f.startsWith('_') && fieldMap.has(f));
156
186
  // only the rows with the x and y of the builder: the others (gpudata, ...) would fill the limit
157
- const required = byBuilder
158
- ? [builder.x, builder.yAggregate === 'count' ? '' : builder.y].filter((f) => f && !f.startsWith('_') && fieldMap.has(f))
159
- : [];
187
+ const required = [builder.x, builder.yAggregate === 'count' ? '' : builder.y]
188
+ .filter((f) => f && !f.startsWith('_') && fieldMap.has(f));
160
189
  return {
161
190
  files: selectedFiles === null ? undefined : activeFiles.map((f) => f.path),
162
191
  events: activeEvent ? [activeEvent] : undefined,
@@ -164,38 +193,18 @@ export const JobDataOverview: React.FC<{ jrJobId: string }> = ({ jrJobId }) => {
164
193
  require: required.length ? required : undefined,
165
194
  limit: ROW_LIMIT,
166
195
  };
167
- }, [lastSpec, specText, builder, fieldMap, selectedFiles, activeFiles, activeEvent]);
196
+ }, [spec, builder, fieldMap, selectedFiles, activeFiles, activeEvent]);
168
197
  const { data: rows, isFetching: rowsLoading, error: rowsError } = useQuery<Record<string, unknown>[], ApiError>({
169
198
  queryKey: ['bujang-job-data-rows', jrJobId, rowsQuery],
170
199
  queryFn: () => getJobDataRows(jrJobId, rowsQuery),
171
- enabled: !!data && activeFiles.length > 0 && !!lastSpec,
200
+ enabled: !!data && activeFiles.length > 0,
172
201
  staleTime: 30_000,
173
202
  placeholderData: (previous) => previous,
174
203
  });
175
204
 
176
- const rowsUrl = useMemo(() => new URL(jobDataRowsUrl(jrJobId, rowsQuery), window.location.href).toString(), [jrJobId, rowsQuery]);
177
- const altair = useMemo(() => {
178
- if (!lastSpec) return '';
179
- const { datasets: _datasets, ...rest } = lastSpec as Record<string, unknown>;
180
- const forAltair = { ...rest, data: { url: rowsUrl, format: { type: 'json' } } };
181
- return `import altair as alt\n\nchart = alt.Chart.from_dict(${JSON.stringify(forAltair, null, 4)
182
- .replace(/\btrue\b/g, 'True').replace(/\bfalse\b/g, 'False').replace(/\bnull\b/g, 'None')})\nchart`;
183
- }, [lastSpec, rowsUrl]);
184
-
185
- const copy = (text: string, what: string) => {
186
- navigator.clipboard?.writeText(text).then(
187
- () => toaster.create({ title: `${what} copied`, type: 'success', duration: 2000 }),
188
- () => toaster.create({ title: `Could not copy ${what}`, type: 'error' }),
189
- );
190
- };
191
-
192
- const setB = (patch: Partial<Builder>) => {
193
- setSpecText(null);
194
- setBuilder((b) => ({ ...b, ...patch }));
195
- };
205
+ const setB = (patch: Partial<Builder>) => setBuilder((b) => ({ ...b, ...patch }));
196
206
 
197
207
  // the layout: the server's, or the one being edited (`draft`, until saved or discarded)
198
- const queryClient = useQueryClient();
199
208
  const layoutKey = ['bujang-overview-layout', jrJobId];
200
209
  const { data: found, error: layoutError } = useQuery<JobOverviewLayout, ApiError>({
201
210
  queryKey: layoutKey,
@@ -206,7 +215,22 @@ export const JobDataOverview: React.FC<{ jrJobId: string }> = ({ jrJobId }) => {
206
215
  });
207
216
  const [draft, setDraft] = useState<OverviewLayout | null>(null);
208
217
  const [editing, setEditing] = useState(false);
209
- const layout = draft ?? found?.layout ?? null;
218
+ const [view, setView] = useState<OverviewView>('job');
219
+ // the layout picked in the list; the one of the job when none (or when it is gone)
220
+ const [picked, setPicked] = useState<string | null>(null);
221
+ const shown = found?.layouts.find((entry) => layoutKeyOf(entry.source) === picked) ?? found;
222
+ // the layout while an editor is open: a refresh that changes it would close the editor
223
+ const [frozen, setFrozen] = useState<OverviewLayout | null>(null);
224
+ const layout = draft ?? frozen ?? shown?.layout ?? null;
225
+ const changeView = (next: OverviewView, key?: string) => {
226
+ if (key !== undefined && shown && key !== layoutKeyOf(shown.source)) {
227
+ if (draft && !window.confirm('Discard the changes of this layout?')) return;
228
+ setDraft(null);
229
+ setEditing(false);
230
+ setPicked(key);
231
+ }
232
+ setView(next);
233
+ };
210
234
  const changeLayout = (next: OverviewLayout) => {
211
235
  setDraft(next);
212
236
  setEditing(true);
@@ -220,20 +244,33 @@ export const JobDataOverview: React.FC<{ jrJobId: string }> = ({ jrJobId }) => {
220
244
  onSuccess: (_, { target, layout: value }) => {
221
245
  setDraft(null);
222
246
  setEditing(false);
247
+ setPicked(null);
223
248
  queryClient.invalidateQueries({ queryKey: ['bujang-overview-layout'] });
224
249
  const what = target === 'default' ? 'the default layout' : `the ${target} ${target === 'experiment' ? found?.keys.experiment : found?.keys.script}`;
225
250
  toaster.create({ title: value ? `Layout saved for ${what}` : `Layout of ${what} removed`, type: 'success', duration: 3000 });
226
251
  },
227
252
  onError: (err) => toaster.create({ title: 'Could not save the layout', description: err.message, type: 'error' }),
228
253
  });
254
+ // where the explorer adds its chart: the end of the layout, or a column ("<panel>.<column>")
255
+ const [target, setTarget] = useState('');
256
+ const columnTargets = (layout?.panels || []).flatMap((p, i) => (
257
+ p.kind === 'columns' ? p.columns.map((_, c) => ({ value: `${i}.${c}`, label: `row ${i + 1}, column ${c + 1}` })) : []
258
+ ));
229
259
  const addToLayout = () => {
230
260
  const base = layout ?? { panels: [] };
231
261
  const chosen = selectedFiles === null ? {} : { files: activeFiles.map((f) => f.path).join(',') };
232
- const panel: OverviewPanel = specText !== null && lastSpec
233
- ? { kind: 'chart', title: activeEvent || 'records', event: activeEvent, spec: lastSpec, ...chosen }
234
- : { ...panelOfBuilder(builder, activeEvent), ...chosen };
235
- changeLayout({ panels: [...base.panels, panel] });
236
- toaster.create({ title: 'Chart added to the layout', description: 'Save the layout to keep it.', type: 'info', duration: 3000 });
262
+ const panel: OverviewBlock = { ...panelOfBuilder(builder, activeEvent), ...chosen };
263
+ const [row, col] = columnTargets.some((t) => t.value === target) ? target.split('.').map(Number) : [-1, -1];
264
+ changeLayout({
265
+ panels: row < 0
266
+ ? [...base.panels, panel]
267
+ : base.panels.map((p, i) => (
268
+ i === row && p.kind === 'columns'
269
+ ? { ...p, columns: p.columns.map((blocks, c) => (c === col ? [...blocks, panel] : blocks)) }
270
+ : p
271
+ )),
272
+ });
273
+ toaster.create({ title: 'Chart added to the job layout', description: 'Save the layout to keep it.', type: 'info', duration: 3000 });
237
274
  };
238
275
 
239
276
  if (isLoading) {
@@ -252,37 +289,38 @@ export const JobDataOverview: React.FC<{ jrJobId: string }> = ({ jrJobId }) => {
252
289
  </Alert.Root>
253
290
  );
254
291
  }
255
- if (!files.length) {
256
- return (
257
- <Card.Root bg="var(--color-bg-card)" border="1px solid" borderColor="var(--color-border)">
258
- <Card.Body p={3}>
259
- <Text color="var(--color-text-muted)">
260
- No JSONL data (*.jsonl, *.ndjson, *.data) in {(data?.folders || ['output']).map((f) => `${f}/`).join(', ')} of this job.
261
- A job writes its results in <Code>output/</Code>.
262
- </Text>
263
- <Button mt={3} size="sm" variant="outline" onClick={() => refetch()} loading={isFetching} alignSelf="start">
264
- <LuRefreshCw /> Check again
265
- </Button>
266
- </Card.Body>
267
- </Card.Root>
268
- );
269
- }
270
-
271
292
  const cardProps = { bg: 'var(--color-bg-card)', border: '1px solid', borderColor: 'var(--color-border)' } as const;
272
293
 
273
294
  return (
274
295
  <VStack align="stretch" gap={4} pb={6}>
275
- {/* The layout and its panels */}
296
+ {!files.length && (
297
+ <Card.Root {...cardProps}>
298
+ <Card.Body p={3}>
299
+ <Text color="var(--color-text-muted)">
300
+ No JSONL data (*.jsonl, *.ndjson, *.data) in {(data?.folders || ['output']).map((f) => `${f}/`).join(', ')} of this job.
301
+ A job writes its results in <Code>output/</Code>.
302
+ </Text>
303
+ <Button mt={3} size="sm" variant="outline" onClick={() => refetch()} loading={isFetching} alignSelf="start">
304
+ <LuRefreshCw /> Check again
305
+ </Button>
306
+ </Card.Body>
307
+ </Card.Root>
308
+ )}
309
+
310
+ {/* The layout and its panels (a job without data may have media) */}
276
311
  {layoutError && (
277
312
  <Alert.Root status="error">
278
313
  <Alert.Indicator />
279
314
  <Alert.Description>Could not read the layout: {layoutError.message}</Alert.Description>
280
315
  </Alert.Root>
281
316
  )}
282
- {found && layout && (
317
+ {found && shown && layout && (
283
318
  <>
284
319
  <LayoutBar
285
320
  found={found}
321
+ source={shown.source}
322
+ view={view}
323
+ onView={changeView}
286
324
  dirty={draft !== null}
287
325
  editing={editing}
288
326
  saving={saveLayout.isPending}
@@ -290,17 +328,36 @@ export const JobDataOverview: React.FC<{ jrJobId: string }> = ({ jrJobId }) => {
290
328
  onSave={(target) => saveLayout.mutate({ target, layout })}
291
329
  onDiscard={() => { setDraft(null); setEditing(false); }}
292
330
  onReset={() => {
293
- const { kind, name } = found.source;
331
+ const { kind, name } = shown.source;
294
332
  if ((kind === 'experiment' || kind === 'script') && window.confirm(`Remove the layout saved for the ${kind} ${name}?`)) {
295
333
  saveLayout.mutate({ target: kind, layout: null });
296
334
  }
297
335
  }}
298
336
  />
299
- <LayoutPanels jrJobId={jrJobId} files={files} layout={layout} editing={editing} onChange={changeLayout} />
337
+ {view === 'job' && rankList.length > 1 && (
338
+ <HStack gap={2} justify="flex-end">
339
+ <Text fontSize="xs" color="var(--color-text-muted)">Rank</Text>
340
+ <NativeSelect.Root size="xs" w="110px" title="The process whose data the panels show">
341
+ <NativeSelect.Field
342
+ aria-label="Rank"
343
+ value={String(rank)}
344
+ onChange={(e) => setPickedRank(e.target.value === 'all' ? 'all' : Number(e.target.value))}
345
+ >
346
+ {rankList.map((r) => <option key={r} value={r}>rank {r}</option>)}
347
+ <option value="all">all ranks</option>
348
+ </NativeSelect.Field>
349
+ <NativeSelect.Indicator />
350
+ </NativeSelect.Root>
351
+ </HStack>
352
+ )}
353
+ {view === 'job' && (
354
+ <LayoutPanels jrJobId={jrJobId} files={rankFiles} oneRank={rank !== 'all'} layout={layout} available={found.blocks ?? []} editing={editing} onChange={setDraft} onEditor={(open) => setFrozen(open ? layout : null)} />
355
+ )}
300
356
  </>
301
357
  )}
302
358
 
303
- <Text fontSize="sm" fontWeight="semibold" pt={2}>Explore the data</Text>
359
+ {/* The explorer, also when the layout cannot be read */}
360
+ {files.length > 0 && (view === 'explore' || layoutError) && (<>
304
361
  {/* Files and event */}
305
362
  <Card.Root {...cardProps}>
306
363
  <Card.Body px={3} py={2}>
@@ -348,7 +405,7 @@ export const JobDataOverview: React.FC<{ jrJobId: string }> = ({ jrJobId }) => {
348
405
  key={name || '(none)'}
349
406
  size="xs"
350
407
  variant={name === activeEvent ? 'solid' : 'outline'}
351
- onClick={() => { setEvent(name); setSpecText(null); }}
408
+ onClick={() => setEvent(name)}
352
409
  >
353
410
  {name || '(records)'} <Badge size="xs" variant="subtle">{count}</Badge>
354
411
  </Button>
@@ -404,10 +461,18 @@ export const JobDataOverview: React.FC<{ jrJobId: string }> = ({ jrJobId }) => {
404
461
  <HStack gap={3} mb={2} fontSize="xs" color="var(--color-text-muted)">
405
462
  {rowsLoading && <Spinner size="xs" />}
406
463
  {rows && <Text>{rows.length}{rows.length >= ROW_LIMIT ? '+ (first rows only)' : ''} rows</Text>}
407
- {specText !== null && <Badge size="xs" colorPalette="orange">spec edited by hand</Badge>}
408
- <Button size="2xs" variant="outline" ml="auto" onClick={addToLayout} disabled={!lastSpec}
409
- title="Add this chart to the layout above (then save the layout)">
410
- <LuPlus /> Add to layout
464
+ {columnTargets.length > 0 && (
465
+ <NativeSelect.Root size="xs" w="150px" ml="auto">
466
+ <NativeSelect.Field value={target} onChange={(e) => setTarget(e.target.value)} aria-label="Where to add the chart">
467
+ <option value="">end of the layout</option>
468
+ {columnTargets.map((t) => <option key={t.value} value={t.value}>{t.label}</option>)}
469
+ </NativeSelect.Field>
470
+ <NativeSelect.Indicator />
471
+ </NativeSelect.Root>
472
+ )}
473
+ <Button size="2xs" variant="outline" ml={columnTargets.length ? undefined : 'auto'} onClick={addToLayout} disabled={!layout}
474
+ title="Add this chart to the layout of the job (then save the layout)">
475
+ <LuPlus /> Add to job layout
411
476
  </Button>
412
477
  </HStack>
413
478
  {rowsError && (
@@ -416,57 +481,10 @@ export const JobDataOverview: React.FC<{ jrJobId: string }> = ({ jrJobId }) => {
416
481
  <Alert.Description>{rowsError.message}</Alert.Description>
417
482
  </Alert.Root>
418
483
  )}
419
- {lastSpec && rows && <VegaChart spec={lastSpec} rows={rows} />}
484
+ {rows && <VegaChart spec={spec} rows={rows} />}
420
485
  </Card.Body>
421
486
  </Card.Root>
422
487
 
423
- {/* Spec + Altair */}
424
- <Flex gap={4} direction={{ base: 'column', xl: 'row' }}>
425
- <Card.Root {...cardProps} flex="1" minW={0}>
426
- <Card.Header px={3} py={2}>
427
- <HStack justify="space-between">
428
- <Text fontSize="sm" fontWeight="semibold">Vega-Lite spec (data: the dataset "rows")</Text>
429
- <HStack gap={1}>
430
- {specText !== null && (
431
- <Button size="xs" variant="ghost" onClick={() => setSpecText(null)}>
432
- back to the builder
433
- </Button>
434
- )}
435
- <Button size="xs" variant="ghost" onClick={() => copy(specText ?? JSON.stringify(builtSpec, null, 2), 'Spec')}>
436
- <LuCopy />
437
- </Button>
438
- </HStack>
439
- </HStack>
440
- {specError && <Text fontSize="xs" color="red.500">{specError}</Text>}
441
- </Card.Header>
442
- <Card.Body px={3} pt={0} pb={3}>
443
- <MonacoEditor
444
- value={specText ?? JSON.stringify(builtSpec, null, 2)}
445
- onChange={(value) => setSpecText(value)}
446
- language="json"
447
- height="320px"
448
- />
449
- </Card.Body>
450
- </Card.Root>
451
- <Card.Root {...cardProps} flex="1" minW={0}>
452
- <Card.Header px={3} py={2}>
453
- <HStack justify="space-between">
454
- <Text fontSize="sm" fontWeight="semibold">Altair</Text>
455
- <HStack gap={1}>
456
- <Button size="xs" variant="ghost" onClick={() => copy(rowsUrl, 'Rows URL')}>rows URL</Button>
457
- <Button size="xs" variant="ghost" onClick={() => copy(altair, 'Altair code')}><LuCopy /></Button>
458
- </HStack>
459
- </HStack>
460
- </Card.Header>
461
- <Card.Body px={3} pt={0} pb={3}>
462
- <Box as="pre" fontFamily="mono" fontSize="xs" overflow="auto" maxH="320px" p={2}
463
- bg="var(--color-bg)" border="1px solid" borderColor="var(--color-border)" borderRadius="md">
464
- {altair}
465
- </Box>
466
- </Card.Body>
467
- </Card.Root>
468
- </Flex>
469
-
470
488
  {/* Fields */}
471
489
  <Card.Root {...cardProps}>
472
490
  <Card.Header px={3} py={2}>
@@ -502,6 +520,7 @@ export const JobDataOverview: React.FC<{ jrJobId: string }> = ({ jrJobId }) => {
502
520
  </Table.Root>
503
521
  </Card.Body>
504
522
  </Card.Root>
523
+ </>)}
505
524
  </VStack>
506
525
  );
507
526
  };