Skip to content

Commit 5e0cc7b

Browse files
thinkingfishclaude
andauthored
feat(wasm-viewer): restore Load Parquet upload affordance (#923)
The static-site WASM viewer's landing page exposed only Demos and Load URL — the dropzone wasn't wired (no `onFile` handler) and the topnav "Load Parquet" button never showed up after a capture loaded (initDashboard was called without `onUploadParquet`). Both surfaces work in the server viewer; the WASM bootstrap was just missing the glue. Add a single `loadFile(file)` helper in `site/viewer/lib/script.js` that reads the File's bytes and runs the existing `loadParquet` flow. Pass it as `onFile` on the FileUpload landing component AND as `onUploadParquet` into `initDashboard`, so the same handler powers the dropzone, the landing's Choose-File button, and the topnav button once a capture is loaded. Drops `?demo` / `?capture` URL params on upload so a refresh doesn't fight the just-uploaded file. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 5a028df commit 5e0cc7b

3 files changed

Lines changed: 41 additions & 2 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ wasm-bindgen = "0.2.120"
2727

2828
[package]
2929
name = "rezolus"
30-
version = "5.13.1-alpha.5"
30+
version = "5.13.1-alpha.6"
3131
description = "High resolution systems performance telemetry agent"
3232
edition = "2021"
3333
license.workspace = true

site/viewer/lib/script.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,47 @@ async function loadParquet(data, filename) {
124124
fileMetadata: state.fileMetadata,
125125
selectionPayload: state.selectionPayload,
126126
reportMode,
127+
// Wire the topnav "Load Parquet" button to the same handler the
128+
// landing-page dropzone uses. The server viewer uploads via
129+
// /api/v1/upload; here we take the File bytes and reuse
130+
// loadParquet directly.
131+
onUploadParquet: loadFile,
127132
});
128133
}
129134

135+
// Shared file-upload entry point: reads the File's bytes and runs the
136+
// usual loadParquet flow. Used by both the landing-page Choose-File /
137+
// drop zone and the topnav "Load Parquet" button after a capture is
138+
// already loaded (which destroys the splash and re-enters loadParquet
139+
// with the new bytes — same lifecycle as `loadCapture`).
140+
async function loadFile(file) {
141+
if (!file) return;
142+
const display = file.name || 'capture.parquet';
143+
splashLabel = display;
144+
splashProgress = -1;
145+
landingError = null;
146+
m.redraw();
147+
try {
148+
const data = new Uint8Array(await file.arrayBuffer());
149+
splashLabel = 'Initializing';
150+
splashProgress = -1;
151+
m.redraw();
152+
await loadParquet(data, display);
153+
// Drop any URL params that pinned the previous capture so a
154+
// refresh doesn't fight the just-uploaded file.
155+
const url = new URL(window.location);
156+
url.searchParams.delete('demo');
157+
url.searchParams.delete('demoA');
158+
url.searchParams.delete('demoB');
159+
url.searchParams.delete('capture');
160+
window.history.replaceState(null, '', url);
161+
} catch (e) {
162+
splashLabel = null;
163+
landingError = `Failed to load ${display}: ${e?.message ?? e ?? 'unknown error'}`;
164+
m.redraw();
165+
}
166+
}
167+
130168
// ── Load demo parquet (with download progress) ──────────────────────
131169

132170
// Fetch a parquet by URL or relative path. Relative paths resolve under
@@ -383,6 +421,7 @@ const Root = {
383421
]));
384422
}
385423
return m('div', m(FileUpload, {
424+
onFile: loadFile,
386425
onDemo: (demo) => {
387426
if (demo && Array.isArray(demo.files) && demo.files.length === 2) {
388427
loadCompareDemo(

0 commit comments

Comments
 (0)