@adcops/autocore-react 3.3.72 → 3.3.75
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/assets/HomeMotor.d.ts +4 -0
- package/dist/assets/HomeMotor.d.ts.map +1 -0
- package/dist/assets/HomeMotor.js +1 -0
- package/dist/assets/svg/home_motor.svg +57 -0
- package/dist/components/ValueInput.d.ts +1 -1
- package/dist/components/ValueInput.d.ts.map +1 -1
- package/dist/components/tis/ResultHistoryTable.d.ts.map +1 -1
- package/dist/components/tis/ResultHistoryTable.js +1 -1
- package/dist/components/tis/TestDataView.d.ts.map +1 -1
- package/dist/components/tis/TestDataView.js +1 -1
- package/dist/components/tis/TestRawDataView.d.ts.map +1 -1
- package/dist/components/tis/TestRawDataView.js +1 -1
- package/dist/components/tis/TestSetupForm.d.ts +7 -0
- package/dist/components/tis/TestSetupForm.d.ts.map +1 -1
- package/dist/components/tis/TestSetupForm.js +1 -1
- package/dist/themes/adc-dark/blue/theme.css +9 -0
- package/dist/themes/adc-dark/blue/theme.css.map +1 -1
- package/package.json +5 -1
- package/src/assets/HomeMotor.tsx +37 -0
- package/src/assets/svg/home_motor.svg +57 -0
- package/src/components/ValueInput.tsx +2 -2
- package/src/components/tis/ResultHistoryTable.tsx +155 -42
- package/src/components/tis/TestDataView.tsx +160 -14
- package/src/components/tis/TestRawDataView.tsx +118 -8
- package/src/components/tis/TestSetupForm.tsx +42 -1
- package/src/themes/adc-dark/_extensions.scss +9 -0
|
@@ -24,40 +24,98 @@ export interface ResultHistoryTableProps {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* Column order: `t` first if present (it's the canonical x-axis in every
|
|
32
|
-
* current test schema), then the remaining keys in their JSON order. Each
|
|
33
|
-
* cell is quoted only when it contains a comma, quote, or newline — matching
|
|
34
|
-
* RFC 4180.
|
|
27
|
+
* Peel a tis.read_raw response. The wire shape may be either a per-cycle
|
|
28
|
+
* envelope `{ cycle_index, cycle_fields, context, data }` or the legacy
|
|
29
|
+
* flat `{ col: number[] }` blob. CSV builders only want the columnar
|
|
30
|
+
* `{ col: number[] }` part.
|
|
35
31
|
*/
|
|
36
|
-
const
|
|
37
|
-
if (!blob || typeof blob !== 'object') return
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
32
|
+
const unwrapEnvelope = (blob: any): Record<string, any[]> => {
|
|
33
|
+
if (!blob || typeof blob !== 'object') return {};
|
|
34
|
+
if ('data' in blob && blob.data && typeof blob.data === 'object'
|
|
35
|
+
&& Object.values(blob.data).some(v => Array.isArray(v))) {
|
|
36
|
+
return blob.data as Record<string, any[]>;
|
|
37
|
+
}
|
|
38
|
+
return blob as Record<string, any[]>;
|
|
39
|
+
};
|
|
42
40
|
|
|
43
|
-
|
|
41
|
+
/**
|
|
42
|
+
* RFC 4180 escape: quote only when the value contains comma, quote, or newline.
|
|
43
|
+
*/
|
|
44
|
+
const escapeCsv = (v: any): string => {
|
|
45
|
+
if (v === null || v === undefined) return '';
|
|
46
|
+
const s = String(v);
|
|
47
|
+
return /[",\n\r]/.test(s) ? `"${s.replace(/"/g, '""')}"` : s;
|
|
48
|
+
};
|
|
44
49
|
|
|
45
|
-
|
|
46
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Build the canonical column order for a set of cycle blobs: `t` first
|
|
52
|
+
* (canonical x-axis in every current schema), then the union of remaining
|
|
53
|
+
* array-valued keys in first-seen order across cycles.
|
|
54
|
+
*/
|
|
55
|
+
const unifyColumns = (blobs: Record<string, any[]>[]): string[] => {
|
|
56
|
+
const seen = new Set<string>();
|
|
57
|
+
const out: string[] = [];
|
|
58
|
+
for (const blob of blobs) {
|
|
59
|
+
for (const [k, v] of Object.entries(blob)) {
|
|
60
|
+
if (Array.isArray(v) && !seen.has(k)) {
|
|
61
|
+
seen.add(k);
|
|
62
|
+
out.push(k);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
out.sort((a, b) => (a === 't' ? -1 : b === 't' ? 1 : 0));
|
|
67
|
+
return out;
|
|
68
|
+
};
|
|
47
69
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
70
|
+
/**
|
|
71
|
+
* Concatenate one or more cycle envelopes into a single CSV. Adds a leading
|
|
72
|
+
* `cycle_index` column so downstream consumers can split groups apart again.
|
|
73
|
+
* Missing columns in a given cycle become empty cells.
|
|
74
|
+
*/
|
|
75
|
+
const cyclesToCsv = (cycles: Array<{ cycleIndex: number; blob: any }>): string => {
|
|
76
|
+
if (cycles.length === 0) return '';
|
|
77
|
+
const unwrapped = cycles.map(c => ({
|
|
78
|
+
cycleIndex: c.cycleIndex,
|
|
79
|
+
blob: unwrapEnvelope(c.blob),
|
|
80
|
+
}));
|
|
81
|
+
const columns = unifyColumns(unwrapped.map(u => u.blob));
|
|
82
|
+
if (columns.length === 0) return '';
|
|
53
83
|
|
|
54
|
-
const lines: string[] = [columns.join(',')];
|
|
55
|
-
for (
|
|
56
|
-
|
|
84
|
+
const lines: string[] = [['cycle_index', ...columns].join(',')];
|
|
85
|
+
for (const { cycleIndex, blob } of unwrapped) {
|
|
86
|
+
const nRows = columns.reduce(
|
|
87
|
+
(min, c) => Array.isArray(blob[c]) ? Math.min(min, blob[c].length) : min,
|
|
88
|
+
Infinity,
|
|
89
|
+
);
|
|
90
|
+
const finite = Number.isFinite(nRows) ? (nRows as number) : 0;
|
|
91
|
+
for (let i = 0; i < finite; i++) {
|
|
92
|
+
const row = [escapeCsv(cycleIndex)];
|
|
93
|
+
for (const c of columns) {
|
|
94
|
+
const arr = blob[c];
|
|
95
|
+
row.push(escapeCsv(Array.isArray(arr) ? arr[i] : ''));
|
|
96
|
+
}
|
|
97
|
+
lines.push(row.join(','));
|
|
98
|
+
}
|
|
57
99
|
}
|
|
58
100
|
return lines.join('\n');
|
|
59
101
|
};
|
|
60
102
|
|
|
103
|
+
/**
|
|
104
|
+
* Single-blob CSV — kept for the filtered-data download path, which is
|
|
105
|
+
* not (yet) per-cycle on the server.
|
|
106
|
+
*/
|
|
107
|
+
const rawBlobToCsv = (blob: any): string => {
|
|
108
|
+
const unwrapped = unwrapEnvelope(blob);
|
|
109
|
+
return cyclesToCsv([{ cycleIndex: 0, blob: unwrapped }])
|
|
110
|
+
// Strip the synthetic cycle_index column for the legacy single-blob path.
|
|
111
|
+
.split('\n')
|
|
112
|
+
.map(line => {
|
|
113
|
+
const idx = line.indexOf(',');
|
|
114
|
+
return idx >= 0 ? line.slice(idx + 1) : '';
|
|
115
|
+
})
|
|
116
|
+
.join('\n');
|
|
117
|
+
};
|
|
118
|
+
|
|
61
119
|
/**
|
|
62
120
|
* Browser download shim: turn a string into a transient blob URL, click it,
|
|
63
121
|
* and clean up. Works without any extra libraries.
|
|
@@ -126,37 +184,86 @@ export const ResultHistoryTable: React.FC<ResultHistoryTableProps> = (props) =>
|
|
|
126
184
|
const rowMethodId = rowData?.method_id ?? methodId;
|
|
127
185
|
if (!runId || !rowMethodId) return;
|
|
128
186
|
|
|
129
|
-
// raw_data/
|
|
130
|
-
//
|
|
131
|
-
//
|
|
187
|
+
// raw_data/ is per-cycle on disk; filtered_data/ is still a single
|
|
188
|
+
// file per test. The raw path lists cycles via tis.list_raw and
|
|
189
|
+
// concatenates them into one CSV with a leading cycle_index
|
|
190
|
+
// column. Filtered keeps its one-shot tis.read_filtered.
|
|
132
191
|
const topic = kind === 'raw' ? 'tis.read_raw' : 'tis.read_filtered';
|
|
133
192
|
const label = kind === 'raw' ? 'raw trace' : 'filtered trace';
|
|
134
193
|
const suffix = kind === 'raw' ? 'raw' : 'filtered';
|
|
135
194
|
|
|
136
195
|
setDownloading({ runId, kind });
|
|
137
196
|
try {
|
|
138
|
-
|
|
139
|
-
project_id: projectId,
|
|
140
|
-
method_id: rowMethodId,
|
|
141
|
-
run_id: runId,
|
|
142
|
-
name: 'trace',
|
|
143
|
-
} as any);
|
|
197
|
+
let csv = '';
|
|
144
198
|
|
|
145
|
-
if (
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
199
|
+
if (kind === 'raw') {
|
|
200
|
+
// List every cycle on disk for this run/blob.
|
|
201
|
+
const listResp: any = await invoke(
|
|
202
|
+
'tis.list_raw' as any, MessageType.Request, {
|
|
203
|
+
project_id: projectId, method_id: rowMethodId, run_id: runId,
|
|
204
|
+
} as any,
|
|
150
205
|
);
|
|
151
|
-
|
|
206
|
+
const cycleEntries: any[] = listResp?.data?.cycles ?? [];
|
|
207
|
+
const cycleIdxs = cycleEntries
|
|
208
|
+
.filter(c => c?.name === 'trace' && typeof c?.cycle_index === 'number')
|
|
209
|
+
.map(c => c.cycle_index as number)
|
|
210
|
+
.sort((a, b) => a - b);
|
|
211
|
+
|
|
212
|
+
if (cycleIdxs.length === 0) {
|
|
213
|
+
// Legacy run with a single un-cycled file → fall back
|
|
214
|
+
// to a one-shot read (server resolves the legacy path).
|
|
215
|
+
const resp: any = await invoke(topic as any, MessageType.Request, {
|
|
216
|
+
project_id: projectId, method_id: rowMethodId,
|
|
217
|
+
run_id: runId, name: 'trace',
|
|
218
|
+
} as any);
|
|
219
|
+
if (!resp?.success || !resp.data) {
|
|
220
|
+
console.warn(`${topic} returned no data for`, runId, resp?.error_message);
|
|
221
|
+
alert(`No ${label} available for ${runId}` +
|
|
222
|
+
(resp?.error_message ? `: ${resp.error_message}` : ''));
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
csv = rawBlobToCsv(resp.data);
|
|
226
|
+
} else {
|
|
227
|
+
// Fetch each cycle's envelope in parallel; concat into
|
|
228
|
+
// one CSV with a leading cycle_index column.
|
|
229
|
+
const fetched = await Promise.all(cycleIdxs.map(async (ci) => {
|
|
230
|
+
const r: any = await invoke('tis.read_raw' as any, MessageType.Request, {
|
|
231
|
+
project_id: projectId, method_id: rowMethodId,
|
|
232
|
+
run_id: runId, name: 'trace', cycle_index: ci,
|
|
233
|
+
} as any);
|
|
234
|
+
return r?.success ? { cycleIndex: ci, blob: r.data } : null;
|
|
235
|
+
}));
|
|
236
|
+
const good = fetched.filter((x): x is { cycleIndex: number; blob: any } => x !== null);
|
|
237
|
+
if (good.length === 0) {
|
|
238
|
+
alert(`No ${label} cycles readable for ${runId}.`);
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
csv = cyclesToCsv(good);
|
|
242
|
+
}
|
|
243
|
+
} else {
|
|
244
|
+
const resp: any = await invoke(topic as any, MessageType.Request, {
|
|
245
|
+
project_id: projectId, method_id: rowMethodId,
|
|
246
|
+
run_id: runId, name: 'trace',
|
|
247
|
+
} as any);
|
|
248
|
+
if (!resp?.success || !resp.data) {
|
|
249
|
+
console.warn(`${topic} returned no data for`, runId, resp?.error_message);
|
|
250
|
+
alert(`No ${label} available for ${runId}` +
|
|
251
|
+
(resp?.error_message ? `: ${resp.error_message}` : ''));
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
csv = rawBlobToCsv(resp.data);
|
|
152
255
|
}
|
|
153
256
|
|
|
154
|
-
const csv = rawBlobToCsv(resp.data);
|
|
155
257
|
if (!csv) {
|
|
156
258
|
alert(`${label} for ${runId} is empty or has no array columns.`);
|
|
157
259
|
return;
|
|
158
260
|
}
|
|
159
|
-
|
|
261
|
+
// sample_id is required for every run, so it always belongs in
|
|
262
|
+
// the filename. Sanitize to match the on-disk filename rules
|
|
263
|
+
// applied server-side in tis_servelet::sanitize_for_filename.
|
|
264
|
+
const sampleId = sanitizeForFilename(sampleIdOf(rowData));
|
|
265
|
+
const sampleSeg = sampleId ? `${sampleId}_` : '';
|
|
266
|
+
downloadCsv(`${projectId}_${rowMethodId}_${sampleSeg}${runId}_${suffix}.csv`, csv);
|
|
160
267
|
} catch (err) {
|
|
161
268
|
console.error(`Failed to download ${label}`, err);
|
|
162
269
|
alert(`Download failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -179,6 +286,12 @@ export const ResultHistoryTable: React.FC<ResultHistoryTableProps> = (props) =>
|
|
|
179
286
|
return '';
|
|
180
287
|
};
|
|
181
288
|
|
|
289
|
+
// Mirrors tis_servelet::sanitize_for_filename on the server. Keeping
|
|
290
|
+
// the rules aligned means the SampleID segment in download names
|
|
291
|
+
// matches the on-disk raw_data/<sample_id>_<name>.json file.
|
|
292
|
+
const sanitizeForFilename = (s: string): string =>
|
|
293
|
+
s.replace(/[\/\\:*?"<>|\0\x00-\x1f]/g, '_');
|
|
294
|
+
|
|
182
295
|
return (
|
|
183
296
|
// Outer wrapper pins the whole component to its container's width.
|
|
184
297
|
// `overflow: hidden` keeps a wide row from pushing the table past the
|
|
@@ -109,7 +109,12 @@ export const TestDataView: React.FC<TestDataViewProps> = (props) => {
|
|
|
109
109
|
|
|
110
110
|
// Lazy-loaded blobs for the View Raw Data dialog. Fetched only
|
|
111
111
|
// when the dialog opens, and re-fetched if the operator pins a
|
|
112
|
-
// different run while the dialog is closed.
|
|
112
|
+
// different run / cycle while the dialog is closed.
|
|
113
|
+
//
|
|
114
|
+
// Wire format (post per-cycle change) is an envelope:
|
|
115
|
+
// { cycle_index, cycle_fields, context, data: { col: number[] } }
|
|
116
|
+
// The legacy flat `{ col: number[] }` shape is still tolerated for
|
|
117
|
+
// runs written before the change — see unwrapEnvelope() below.
|
|
113
118
|
const [rawBlob, setRawBlob] = useState<any | null>(null);
|
|
114
119
|
const [rawError, setRawError] = useState<string | null>(null);
|
|
115
120
|
const [rawLoading, setRawLoading] = useState(false);
|
|
@@ -117,6 +122,12 @@ export const TestDataView: React.FC<TestDataViewProps> = (props) => {
|
|
|
117
122
|
const [filteredError, setFilteredError] = useState<string | null>(null);
|
|
118
123
|
const [filteredLoading, setFilteredLoading] = useState(false);
|
|
119
124
|
|
|
125
|
+
// Per-test cycle listing for the raw dialog's cycle picker. Loaded
|
|
126
|
+
// once when the dialog opens. selectedCycle is null until the list
|
|
127
|
+
// arrives; we default it to the latest cycle.
|
|
128
|
+
const [availableCycles, setAvailableCycles] = useState<number[]>([]);
|
|
129
|
+
const [selectedCycle, setSelectedCycle] = useState<number | null>(null);
|
|
130
|
+
|
|
120
131
|
// Scatter-capable views only — raw_trace lives in <TestRawDataView>.
|
|
121
132
|
const scatterViews = useMemo(() => {
|
|
122
133
|
const out: { name: string; view: ChartView }[] = [];
|
|
@@ -295,14 +306,42 @@ export const TestDataView: React.FC<TestDataViewProps> = (props) => {
|
|
|
295
306
|
// download in <ResultHistoryTable> pulls.
|
|
296
307
|
// -----------------------------------------------------------------
|
|
297
308
|
const blobName = schema?.raw_data?.blob_name ?? 'trace';
|
|
298
|
-
const fetchKeyRef = useRef<string>(''); // last (project, method, run, blob) we fetched
|
|
309
|
+
const fetchKeyRef = useRef<string>(''); // last (project, method, run, blob, cycle) we fetched
|
|
310
|
+
|
|
311
|
+
// Discover which cycles have raw_data on disk so we can present a
|
|
312
|
+
// picker. tis.list_raw returns the flat name list (back-compat) AND
|
|
313
|
+
// a per-cycle list; we want the cycles for the selected blob name.
|
|
314
|
+
const loadCycleList = useCallback(async (): Promise<number[]> => {
|
|
315
|
+
if (!projectId || !methodId || !runId) return [];
|
|
316
|
+
try {
|
|
317
|
+
const resp: any = await invoke(
|
|
318
|
+
'tis.list_raw' as any, MessageType.Request,
|
|
319
|
+
{ project_id: projectId, method_id: methodId, run_id: runId } as any,
|
|
320
|
+
);
|
|
321
|
+
if (!resp?.success) return [];
|
|
322
|
+
const cycles: any[] = resp.data?.cycles ?? [];
|
|
323
|
+
const indices = cycles
|
|
324
|
+
.filter(c => c?.name === blobName && typeof c?.cycle_index === 'number')
|
|
325
|
+
.map(c => c.cycle_index as number)
|
|
326
|
+
.sort((a, b) => a - b);
|
|
327
|
+
return indices;
|
|
328
|
+
} catch {
|
|
329
|
+
return [];
|
|
330
|
+
}
|
|
331
|
+
}, [projectId, methodId, runId, blobName, invoke]);
|
|
299
332
|
|
|
300
|
-
const loadBlobs = useCallback(async () => {
|
|
333
|
+
const loadBlobs = useCallback(async (cycleIndex: number | null) => {
|
|
301
334
|
if (!projectId || !methodId || !runId) return;
|
|
302
|
-
const key = `${projectId}|${methodId}|${runId}|${blobName}`;
|
|
303
|
-
if (fetchKeyRef.current === key) return; // already loaded for this
|
|
335
|
+
const key = `${projectId}|${methodId}|${runId}|${blobName}|${cycleIndex ?? 'latest'}`;
|
|
336
|
+
if (fetchKeyRef.current === key) return; // already loaded for this slice
|
|
304
337
|
fetchKeyRef.current = key;
|
|
305
338
|
|
|
339
|
+
const baseArgs: Record<string, any> = {
|
|
340
|
+
project_id: projectId, method_id: methodId,
|
|
341
|
+
run_id: runId, name: blobName,
|
|
342
|
+
};
|
|
343
|
+
if (cycleIndex != null) baseArgs.cycle_index = cycleIndex;
|
|
344
|
+
|
|
306
345
|
// Raw — must succeed for the dialog to be useful, but a
|
|
307
346
|
// missing file is logged and surfaced rather than aborted.
|
|
308
347
|
setRawLoading(true);
|
|
@@ -310,8 +349,7 @@ export const TestDataView: React.FC<TestDataViewProps> = (props) => {
|
|
|
310
349
|
setRawBlob(null);
|
|
311
350
|
try {
|
|
312
351
|
const resp: any = await invoke(
|
|
313
|
-
'tis.read_raw' as any, MessageType.Request,
|
|
314
|
-
{ project_id: projectId, method_id: methodId, run_id: runId, name: blobName } as any,
|
|
352
|
+
'tis.read_raw' as any, MessageType.Request, baseArgs as any,
|
|
315
353
|
);
|
|
316
354
|
if (resp?.success) {
|
|
317
355
|
setRawBlob(resp.data ?? {});
|
|
@@ -327,6 +365,8 @@ export const TestDataView: React.FC<TestDataViewProps> = (props) => {
|
|
|
327
365
|
// Filtered is optional. The 'no filtered data' case is the
|
|
328
366
|
// common one (only the post-processing pipeline writes it),
|
|
329
367
|
// and we render a friendly message rather than an error tone.
|
|
368
|
+
// Filtered files are not per-cycle (yet); cycle_index is
|
|
369
|
+
// ignored on the filtered side.
|
|
330
370
|
setFilteredLoading(true);
|
|
331
371
|
setFilteredError(null);
|
|
332
372
|
setFilteredBlob(null);
|
|
@@ -347,18 +387,34 @@ export const TestDataView: React.FC<TestDataViewProps> = (props) => {
|
|
|
347
387
|
}
|
|
348
388
|
}, [projectId, methodId, runId, blobName, invoke]);
|
|
349
389
|
|
|
350
|
-
// When the run changes,
|
|
351
|
-
// open refetches. Don't auto-fetch — that's wasteful if the
|
|
352
|
-
// operator never opens the dialog.
|
|
390
|
+
// When the run / blob changes, reset cycle picker and cache key.
|
|
353
391
|
useEffect(() => {
|
|
354
392
|
fetchKeyRef.current = '';
|
|
393
|
+
setAvailableCycles([]);
|
|
394
|
+
setSelectedCycle(null);
|
|
355
395
|
}, [projectId, methodId, runId, blobName]);
|
|
356
396
|
|
|
357
|
-
const openRawDialog = () => {
|
|
397
|
+
const openRawDialog = async () => {
|
|
358
398
|
setRawOpen(true);
|
|
359
|
-
|
|
399
|
+
// Resolve cycle list lazily — first open after a run change.
|
|
400
|
+
let cycles = availableCycles;
|
|
401
|
+
if (cycles.length === 0) {
|
|
402
|
+
cycles = await loadCycleList();
|
|
403
|
+
setAvailableCycles(cycles);
|
|
404
|
+
}
|
|
405
|
+
const latest = cycles.length > 0 ? cycles[cycles.length - 1] : null;
|
|
406
|
+
const initial = selectedCycle ?? latest;
|
|
407
|
+
if (selectedCycle !== initial) setSelectedCycle(initial);
|
|
408
|
+
await loadBlobs(initial);
|
|
360
409
|
};
|
|
361
410
|
|
|
411
|
+
// Re-fetch when the operator picks a different cycle from the dialog.
|
|
412
|
+
useEffect(() => {
|
|
413
|
+
if (rawOpen && selectedCycle != null) {
|
|
414
|
+
void loadBlobs(selectedCycle);
|
|
415
|
+
}
|
|
416
|
+
}, [rawOpen, selectedCycle, loadBlobs]);
|
|
417
|
+
|
|
362
418
|
// -----------------------------------------------------------------
|
|
363
419
|
// Render
|
|
364
420
|
// -----------------------------------------------------------------
|
|
@@ -436,10 +492,16 @@ export const TestDataView: React.FC<TestDataViewProps> = (props) => {
|
|
|
436
492
|
style={{ width: '90vw', height: '80vh' }}
|
|
437
493
|
maximizable
|
|
438
494
|
>
|
|
495
|
+
<CyclePickerBar
|
|
496
|
+
cycles={availableCycles}
|
|
497
|
+
selected={selectedCycle}
|
|
498
|
+
onChange={setSelectedCycle}
|
|
499
|
+
/>
|
|
500
|
+
<RawEnvelopeHeader envelope={rawBlob} />
|
|
439
501
|
<TabView style={{ height: '100%' }}>
|
|
440
502
|
<TabPanel header="Raw Data">
|
|
441
503
|
<DataBlobTable
|
|
442
|
-
blob={rawBlob}
|
|
504
|
+
blob={unwrapEnvelope(rawBlob)}
|
|
443
505
|
loading={rawLoading}
|
|
444
506
|
error={rawError}
|
|
445
507
|
rawData={schema.raw_data}
|
|
@@ -447,7 +509,7 @@ export const TestDataView: React.FC<TestDataViewProps> = (props) => {
|
|
|
447
509
|
</TabPanel>
|
|
448
510
|
<TabPanel header="Filtered Data">
|
|
449
511
|
<DataBlobTable
|
|
450
|
-
blob={filteredBlob}
|
|
512
|
+
blob={unwrapEnvelope(filteredBlob)}
|
|
451
513
|
loading={filteredLoading}
|
|
452
514
|
error={filteredError}
|
|
453
515
|
rawData={schema.raw_data}
|
|
@@ -567,6 +629,90 @@ const ConfigList: React.FC<{ config: any }> = ({ config }) => {
|
|
|
567
629
|
);
|
|
568
630
|
};
|
|
569
631
|
|
|
632
|
+
// -------------------------------------------------------------------------
|
|
633
|
+
// unwrapEnvelope — `tis.read_raw` returns one of:
|
|
634
|
+
// - the per-cycle envelope `{ cycle_index, cycle_fields, context, data }`
|
|
635
|
+
// - the legacy flat columnar blob `{ col: number[] }` (pre per-cycle)
|
|
636
|
+
// Downstream consumers (DataBlobTable, chart datasets, CSV) only care
|
|
637
|
+
// about the columnar payload — peel off the envelope when present so
|
|
638
|
+
// both shapes render identically.
|
|
639
|
+
// -------------------------------------------------------------------------
|
|
640
|
+
const unwrapEnvelope = (blob: any): any => {
|
|
641
|
+
if (!blob || typeof blob !== 'object') return blob;
|
|
642
|
+
if ('data' in blob && blob.data && typeof blob.data === 'object'
|
|
643
|
+
&& Object.values(blob.data).some(v => Array.isArray(v))) {
|
|
644
|
+
return blob.data;
|
|
645
|
+
}
|
|
646
|
+
return blob;
|
|
647
|
+
};
|
|
648
|
+
|
|
649
|
+
// -------------------------------------------------------------------------
|
|
650
|
+
// CyclePickerBar — dropdown of available cycle indices for the raw_data
|
|
651
|
+
// dialog. Hidden when only one (or zero) cycles exist; rendered as a
|
|
652
|
+
// labelled selector otherwise.
|
|
653
|
+
// -------------------------------------------------------------------------
|
|
654
|
+
const CyclePickerBar: React.FC<{
|
|
655
|
+
cycles: number[];
|
|
656
|
+
selected: number | null;
|
|
657
|
+
onChange: (idx: number) => void;
|
|
658
|
+
}> = ({ cycles, selected, onChange }) => {
|
|
659
|
+
if (cycles.length <= 1) return null;
|
|
660
|
+
return (
|
|
661
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: '0.5rem',
|
|
662
|
+
padding: '0.25rem 0.5rem 0.5rem' }}>
|
|
663
|
+
<label htmlFor="raw-cycle-picker"
|
|
664
|
+
style={{ color: 'var(--text-secondary-color)' }}>Cycle:</label>
|
|
665
|
+
<Dropdown
|
|
666
|
+
inputId="raw-cycle-picker"
|
|
667
|
+
value={selected}
|
|
668
|
+
options={cycles.map(c => ({ label: `Cycle ${c}`, value: c }))}
|
|
669
|
+
onChange={(e) => onChange(Number(e.value))}
|
|
670
|
+
style={{ minWidth: '8rem' }}
|
|
671
|
+
/>
|
|
672
|
+
<span style={{ color: 'var(--text-secondary-color)' }}>
|
|
673
|
+
({cycles.length} cycles recorded)
|
|
674
|
+
</span>
|
|
675
|
+
</div>
|
|
676
|
+
);
|
|
677
|
+
};
|
|
678
|
+
|
|
679
|
+
// -------------------------------------------------------------------------
|
|
680
|
+
// RawEnvelopeHeader — small key/value strip showing the metadata embedded
|
|
681
|
+
// in the on-disk envelope (cycle_index, schema-declared cycle_fields,
|
|
682
|
+
// capture context). Renders nothing for legacy flat blobs.
|
|
683
|
+
// -------------------------------------------------------------------------
|
|
684
|
+
const RawEnvelopeHeader: React.FC<{ envelope: any }> = ({ envelope }) => {
|
|
685
|
+
if (!envelope || typeof envelope !== 'object') return null;
|
|
686
|
+
const cycleIndex = envelope.cycle_index;
|
|
687
|
+
const cycleFields = envelope.cycle_fields;
|
|
688
|
+
const context = envelope.context;
|
|
689
|
+
if (cycleIndex == null && !cycleFields && !context) return null;
|
|
690
|
+
|
|
691
|
+
const renderKV = (obj: any) => {
|
|
692
|
+
if (!obj || typeof obj !== 'object') return null;
|
|
693
|
+
const entries = Object.entries(obj).filter(([, v]) =>
|
|
694
|
+
v !== null && typeof v !== 'object');
|
|
695
|
+
if (entries.length === 0) return null;
|
|
696
|
+
return entries.map(([k, v]) => (
|
|
697
|
+
<span key={k} style={{ marginRight: '1rem' }}>
|
|
698
|
+
<span style={{ color: 'var(--text-secondary-color)' }}>{k}: </span>
|
|
699
|
+
<span>{String(v)}</span>
|
|
700
|
+
</span>
|
|
701
|
+
));
|
|
702
|
+
};
|
|
703
|
+
|
|
704
|
+
return (
|
|
705
|
+
<div style={{ padding: '0.5rem', borderBottom: '1px solid var(--surface-border)',
|
|
706
|
+
fontSize: '0.9rem' }}>
|
|
707
|
+
{cycleIndex != null && (
|
|
708
|
+
<div><strong>Cycle {cycleIndex}</strong></div>
|
|
709
|
+
)}
|
|
710
|
+
{cycleFields && <div style={{ marginTop: '0.25rem' }}>{renderKV(cycleFields)}</div>}
|
|
711
|
+
{context && <div style={{ marginTop: '0.25rem' }}>{renderKV(context)}</div>}
|
|
712
|
+
</div>
|
|
713
|
+
);
|
|
714
|
+
};
|
|
715
|
+
|
|
570
716
|
// -------------------------------------------------------------------------
|
|
571
717
|
// DataBlobTable — tabular display of a columnar JSON blob
|
|
572
718
|
// (`{ col_name: number[] }`). Used by the View Raw Data dialog for both
|