Refactor viewer JS into domain subdirectories#932
Merged
Conversation
Group the flat module files under src/viewer/assets/lib/ into selection/, sections/, events/, ui/, and features/ subdirectories. Core orchestration files (app.js, data.js, viewer_core.js, viewer_api.js) and the script.js entry point stay at the lib root since they are referenced by index.html and have standalone site-viewer counterparts. All relative imports were rewritten by path resolution, the site/viewer/lib symlink tree regenerated to mirror the new layout, and test import paths plus the site standalone script.js entry updated accordingly.
5 tasks
thinkingfish
added a commit
that referenced
this pull request
Jun 1, 2026
* feat(dashboard): SubGroup::histogram_rate_mean helper (rate|mean pair) * refactor(dashboard): derive mean unit-system internally; doc RateSource * feat(dashboard): rate|mean pair for blockio latency + size histograms * feat(dashboard): syscall rate|mean pair (replace standalone rate, add mean) * test(dashboard): anchor syscall overall-mean assertion to avoid per-op prefix match * feat(dashboard): from-histogram rate|mean pair for scheduler histograms * feat(dashboard): from-histogram rate|mean pair for tcp_packet_latency * fix(dashboard): lowercase-kebab ids for syscall per-op rate|mean pair * chore: bump version to 5.13.1-alpha.13 * docs: backlog — customizable report title + browser tab title * test(viewer): update smoke script for lib/ subdir refactor selection.js moved to lib/selection/selection.js in #932; the smoke assertion was still curling /lib/selection.js and 404'ing. * feat(dashboard): use histogram_irate for from-histogram rate cards Bump metriken-query 0.10.5 → 0.10.6 for histogram_irate(m). Replaces the spec'd irate(histogram_count(m)[5m]) form, which doesn't parse: PromQL grammar disallows range vectors on function-call results. histogram_irate returns an instant vector — composes with sum(...) directly and sidesteps the grammar problem. * style: cargo fmt * feat(viewer): Mean/Total toggle on histogram_mean cards Bumps metriken-query 0.10.7 → 0.10.8 for histogram_sum(m). Dashboard's histogram_rate_mean helper now renames the Mean card to Mean/Total and stashes histogram_sum(<selector>) on the spec as promql_query_total. The line-chart configure path renders an inline checkbox top-right that fetches and swaps to the total series on click; tooltip series label substitutes Mean ↔ Total to match the active view. Per-chart state, no persistence; pattern mirrors scatter.js's spectrum-controls. * fix(wasm-viewer): clear stale caches when Load Parquet swaps captures initWasmViewer replaces the WASM TSDB but sectionResponseCache, chartsState, heatmapDataCache, and data.js's metadata cache survived across loads. The new capture's sections short-circuited to the old file's cached responses, rendering empty. First load was unaffected because the caches start empty. * Revert "fix(wasm-viewer): clear stale caches when Load Parquet swaps captures" This reverts commit abbe1be. * fix(wasm-viewer): strip stale hash on landing-page mount Reloading /viewer/#/overview with no ?demo/?capture param lands on the FileUpload page but the URL still showed #/overview. Drop the hash via history.replaceState when there's no capture in the URL, so the location bar matches what's rendered. * fix(wasm-viewer): refresh state when Load Parquet swaps captures Three things were stale across captures: - data.js's cachedMetadata held the previous file's {minTime, maxTime}, so fresh PromQL queries against the new TSDB ran on a window outside it and returned empty. - The active section's cached payload (and therefore the topnav's time-range bar) wasn't refetched, because m.route's same-path short-circuit suppressed onmatch. - The cachedView placeholder spins on a splash until loadSection resolves, so the eviction needs an explicit refetch kick rather than relying on a redraw to do it. clearMetadataCache() + evict the visible section + loadSection(...) + m.redraw() covers all three without touching chartsState or the rest of sectionResponseCache (both of which spun in earlier attempts). * fix(viewer): position Mean/Total toggle below title, grid-left aligned Place it where scatter.js's spectrum-controls sit — under the title, left edge aligned with the echarts plot grid (past the y-axis gutter). Previous top-right placement collided with the expand/select-pin icons and read as right-aligned on half-width Mean cards.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Organizes the ~25 flat module files under
src/viewer/assets/lib/into domain subdirectories, mirroring the existingcharts/convention:selection/—selection.js,selection_migration.jssections/—section_views.js,section_cache.js,section_notes.jsevents/—events_store.js,event_form.jsui/—navigation.js,layout.js,controls.js,chart_controls.js,overlays.js,theme.js,landing.js,markdown.jsfeatures/—topology.js,cgroup_selector.js,service.js,explorers.js,group_utils.jsFiles that stay at the
lib/root:script.js(entry point hardcoded in bothindex.htmlfiles),mithril.js(vendor), and the core orchestration filesapp.js/data.js/viewer_api.js/viewer_core.js. This follows the heuristic that anything not symlinked intosite/viewer/lib/(the standalonescript.js/viewer_api.js) stays at root, plus keeping the core graph flat to avoid churn in the site-viewer counterparts.Details
import/export ... fromspecifiers rewritten by path resolution against the new layout (git tracked the moves as 99–100% renames).site/viewer/lib/symlink tree regenerated to mirror the new structure; standalonescript.js/viewer_api.jsand theembed//lit/directory symlinks preserved.site/viewer/lib/script.jsimports updated for the movedlanding.js/selection.js.Test plan
../pkg/wasm_viewer.jsis absent without a WASM build).node --test tests/*.mjs— 121/122 pass; the single failure iswasm_viewer_histogram_kpiswhich requiressite/viewer/pkg/(WASM not built in this environment, pre-existing and unrelated).tests/viewer_smoke.shand a static-site load in CI/locally).Generated by Claude Code