refactor(viewer): extract shared viewer_core.js to reduce site/server divergence#804
Merged
thinkingfish merged 1 commit intoiopsystems:mainfrom Apr 18, 2026
Conversation
…wer_core.js
Consolidate duplicated code between server and site viewer script.js
files into a shared symlinked module (viewer_core.js). This reduces
the divergent surface area and prevents future drift.
Extracted:
- Group component (via createGroupComponent factory)
- getCachedSectionMeta helper
- buildClientOnlySectionView helper
Also aligns site viewer with server viewer patterns:
- Import expandLink/selectButton from chart_controls.js
- Import isHistogramPlot/buildHistogramHeatmapSpec from metric_types.js
- Import formatSize from layout.js instead of duplicating formatBytes
- Use chartsState.hasActiveSelection() instead of manual check
- Add initTheme(), MetadataView, section-switch zoom reset,
changeInstance, getHasFileMetadata
- Fix title separator (': ' not ' / ')
- Fix clearViewerCaches to include chartsState.clear()
- Fix expandLink href to use m.route.prefix for hash-based routing
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
getCachedSectionMeta, andbuildClientOnlySectionViewinto a new sharedviewer_core.jsmodule (symlinked to site viewer)chart_controls.js,metric_types.js,layout.js) instead of inlining, adds MetadataView, section-switch zoom reset,changeInstance,initTheme(), and fixes (chartsState.clear()in cache clear,hasActiveSelection(), title separator)expandLinkhref to usem.route.prefixso hash-based routing works correctly in the site viewerTest plan
#prefix, heatmap toggle works🤖 Generated with Claude Code