Skip to content

refactor(viewer): extract shared viewer_core.js to reduce site/server divergence#804

Merged
thinkingfish merged 1 commit intoiopsystems:mainfrom
thinkingfish:refactor-viewer-shared-core
Apr 18, 2026
Merged

refactor(viewer): extract shared viewer_core.js to reduce site/server divergence#804
thinkingfish merged 1 commit intoiopsystems:mainfrom
thinkingfish:refactor-viewer-shared-core

Conversation

@thinkingfish
Copy link
Copy Markdown
Member

@thinkingfish thinkingfish commented Apr 18, 2026

Summary

  • Extract duplicated Group component, getCachedSectionMeta, and buildClientOnlySectionView into a new shared viewer_core.js module (symlinked to site viewer)
  • Align site viewer with server viewer patterns: imports shared modules (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)
  • Fix expandLink href to use m.route.prefix so hash-based routing works correctly in the site viewer

Test plan

  • Verify server viewer renders dashboards, chart expand links, heatmap toggle, and section navigation
  • Verify site viewer renders dashboards, chart expand links open in new tab with # prefix, heatmap toggle works
  • Verify multi-node switching works in both viewers
  • Verify MetadataView now appears in site viewer sidebar

🤖 Generated with Claude Code

…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>
@thinkingfish thinkingfish marked this pull request as ready for review April 18, 2026 17:28
@thinkingfish thinkingfish merged commit 67b35e4 into iopsystems:main Apr 18, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant