Skip to content

Add static visualizer demo page and set dim theme as default#887

Open
afritzler wants to merge 1 commit into
mainfrom
enh/vis
Open

Add static visualizer demo page and set dim theme as default#887
afritzler wants to merge 1 commit into
mainfrom
enh/vis

Conversation

@afritzler
Copy link
Copy Markdown
Member

@afritzler afritzler commented May 13, 2026

Proposed Changes

Add static visualizer demo page and set dim theme as default. Add a self-contained static HTML demo of the visualizer with embedded sample data (141 servers, 9 racks) that can be served via VitePress without a running backend. The demo starts in walk mode for an immersive first impression.

Also switch the default theme from dark to dim in the live visualizer.

Summary by CodeRabbit

  • New Features

    • Added --dry-run flag to visualizer command for offline preview without cluster connection
    • Added interactive visualizer demo with walk mode for 3D navigation
    • Expanded demo dataset with comprehensive server inventory examples
  • Documentation

    • Updated installation instructions using go install
    • Added visualizer dry-run usage example and demo link

Review Change Stack

@afritzler afritzler requested a review from a team as a code owner May 13, 2026 12:13
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 13, 2026

📝 Walkthrough

Walkthrough

The PR adds a --dry-run mode to the metalctl visualizer command that operates without a Kubernetes cluster. The visualizer backend, CLI, and frontend are updated to support static demo data, theme defaults are changed, sample data is substantially expanded, and the client library is improved to handle missing kubeconfig gracefully.

Changes

Visualizer dry-run mode with demo data fallback

Layer / File(s) Summary
Visualizer backend dry-run support
internal/cmd/visualizer/visualizer.go
Visualizer struct gains a DryRun boolean field that controls conditional registration of the /api/servers HTTP endpoint during StartAndServe.
CLI dry-run flag and command wiring
cmd/metalctl/app/visualizer.go
Metalctl visualizer command adds a --dry-run flag that skips Kubernetes client creation; when set, the visualizer is constructed with a nil client and DryRun is set to true.
Frontend theme defaults and scene initialization
internal/cmd/visualizer/index.html
Frontend defaults to theme index 1 ("Dim") and uses THEMES[currentTheme] for scene background, fog, ambient light, and floor/grid/ceiling materials instead of hard-coding theme 0.
Frontend demo data fallback and walk mode
internal/cmd/visualizer/index.html
Server fetching switches from fixed setInterval to self-scheduling setTimeout. On API failure, the frontend enters staticMode, renders an embedded DEMO_SERVERS dataset, and enters walk mode with pointer-lock camera control and crosshair.
Client library graceful kubeconfig handling
internal/cmd/client/client.go
CreateClient conditionally configures loading rules only when kubeconfig is non-empty, removing the hard os.Exit(1) on missing kubeconfig and allowing natural error handling.
Demo servers sample data expansion
config/samples/visualizer/servers.yaml
Demo servers YAML expands from approximately 24 to 90 servers across a 3×3 grid of racks with varied metadata, unique systemUUID values, and mixed indicatorLED/powerState/state combinations to exercise more visualizer states.
Documentation and REUSE metadata updates
docs/usage/metalctl.md, docs/public/visualizer-demo.html, REUSE.toml
Installation docs updated to use go module path syntax; visualizer section adds --dry-run example and interactive demo link; REUSE.toml includes demo_data.json in annotations; visualizer-demo.html references the internal index.

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main changes: adding a static visualizer demo page and setting dim theme as default, which are core objectives of this PR.
Description check ✅ Passed The description follows the template structure with a 'Proposed Changes' section clearly outlining the two main changes. However, it lacks specific detail about the implementation scope and does not reference the related issue number.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch enh/vis

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added documentation Improvements or additions to documentation enhancement New feature or request size/XXL labels May 13, 2026
Add static visualizer demo page and set dim theme as default.
Add a self-contained static HTML demo of the visualizer with embedded
sample data (141 servers, 9 racks) that can be served via VitePress
without a running backend. The demo starts in walk mode for an
immersive first impression.

Also switch the default theme from dark to dim in the live visualizer
and fix init() to respect the currentTheme variable instead of
hardcoding THEMES[0].

Signed-off-by: Andreas Fritzler <andreas.fritzler@sap.com>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
internal/cmd/visualizer/visualizer.go (1)

44-50: ⚡ Quick win

Consider adding defensive validation for the Client/DryRun invariant.

The conditional registration logic correctly gates the /api/servers endpoint based on DryRun. However, there's no validation to enforce that when DryRun is false, Client must be non-nil. If a future caller misconfigures the visualizer (e.g., forgets to set DryRun = true after passing a nil client), the server will panic when the API endpoint is accessed at line 89.

🛡️ Proposed defensive check
 func (v *Visualizer) StartAndServe() error {
+	if !v.DryRun && v.Client == nil {
+		return fmt.Errorf("client must not be nil when dry-run is disabled")
+	}
+
 	url := fmt.Sprintf("http://%s", v.Address)
 
 	http.HandleFunc("/", serveFrontend)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/cmd/visualizer/visualizer.go` around lines 44 - 50, In
StartAndServe, add a defensive validation enforcing the invariant between DryRun
and Client: if v.DryRun is false then ensure v.Client is non-nil and return a
descriptive error (instead of registering the handler that would later panic);
perform this check before calling http.HandleFunc("/api/servers",
v.handleGetServers()) so the function returns early if v.Client == nil.
Reference: Visualizer.StartAndServe, Visualizer.Client, Visualizer.DryRun, and
handleGetServers().
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@REUSE.toml`:
- Line 31: REUSE.toml contains a nonexistent file reference
"internal/cmd/visualizer/demo_data.json" which breaks REUSE checks; open
REUSE.toml and remove that exact entry (the string
"internal/cmd/visualizer/demo_data.json") from the listed files so only existing
assets (e.g., index.html and visualizer.go) remain referenced, then run the
REUSE compliance check to confirm the failure is resolved.

---

Nitpick comments:
In `@internal/cmd/visualizer/visualizer.go`:
- Around line 44-50: In StartAndServe, add a defensive validation enforcing the
invariant between DryRun and Client: if v.DryRun is false then ensure v.Client
is non-nil and return a descriptive error (instead of registering the handler
that would later panic); perform this check before calling
http.HandleFunc("/api/servers", v.handleGetServers()) so the function returns
early if v.Client == nil. Reference: Visualizer.StartAndServe,
Visualizer.Client, Visualizer.DryRun, and handleGetServers().
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f0d20da0-172f-4ad5-9d8f-942ae19a16b8

📥 Commits

Reviewing files that changed from the base of the PR and between bf8e075 and a1d68ef.

📒 Files selected for processing (8)
  • REUSE.toml
  • cmd/metalctl/app/visualizer.go
  • config/samples/visualizer/servers.yaml
  • docs/public/visualizer-demo.html
  • docs/usage/metalctl.md
  • internal/cmd/client/client.go
  • internal/cmd/visualizer/index.html
  • internal/cmd/visualizer/visualizer.go

Comment thread REUSE.toml
"test/data/*.yaml",
"api/v1alpha1/zz_generated.deepcopy.go"
"api/v1alpha1/zz_generated.deepcopy.go",
"internal/cmd/visualizer/demo_data.json"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Verify demo_data.json existence

# Check if demo_data.json exists
if [ -f "internal/cmd/visualizer/demo_data.json" ]; then
  echo "✓ demo_data.json exists"
  ls -lh internal/cmd/visualizer/demo_data.json
else
  echo "✗ demo_data.json not found"
  echo "Demo data appears to be embedded in index.html instead"
fi

# Show what's actually in the visualizer directory
echo -e "\nFiles in internal/cmd/visualizer/:"
ls -lh internal/cmd/visualizer/

Repository: ironcore-dev/metal-operator

Length of output: 322


Remove the non-existent demo_data.json reference from REUSE.toml line 31.

The annotation references internal/cmd/visualizer/demo_data.json, but this file does not exist. The visualizer directory only contains index.html (which embeds demo data inline) and visualizer.go. This incorrect annotation will cause REUSE compliance check failures.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@REUSE.toml` at line 31, REUSE.toml contains a nonexistent file reference
"internal/cmd/visualizer/demo_data.json" which breaks REUSE checks; open
REUSE.toml and remove that exact entry (the string
"internal/cmd/visualizer/demo_data.json") from the listed files so only existing
assets (e.g., index.html and visualizer.go) remain referenced, then run the
REUSE compliance check to confirm the failure is resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/metal-automation documentation Improvements or additions to documentation enhancement New feature or request size/XXL

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants