Skip to content

Add firmware config view/download to device pages#13

Merged
bharvey88 merged 8 commits into
mainfrom
feat/3-yaml-view-download
Jul 9, 2026
Merged

Add firmware config view/download to device pages#13
bharvey88 merged 8 commits into
mainfrom
feat/3-yaml-view-download

Conversation

@bharvey88

@bharvey88 bharvey88 commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

What does this change?

Closes #3. Adds a "view / download the firmware config" section to each device page, so users can rebuild or reflash a device from its ESPHome YAML and have it onboard like a factory unit (following the wiki setup steps). This is the reflash/rebuild path, distinct from #4's ESPHome Dashboard "adopt and customize" note.

Feature

  • A collapsible "Build or reflash this firmware yourself" block in step 1 that follows the selected variant. On expand it shows the config YAML, fetched live from raw.githubusercontent.com and rendered via textContent (escaped). It offers a Download .yaml (Blob, with the real filename) and a View on GitHub link derived from the raw URL.
  • On R_PRO-1 / CAST-1 the WiFi and Ethernet configs are different files, so switching the variant swaps the config.

Which config per device

  • The reflash-friendly config that includes improv-ble: _Factory.yaml where a repo has one (MSR-1, MSR-2, MTR-1, AIR-1), else the main per-variant config (R_PRO-1 W/ETH, CAST-1 W/ETH, PUMP-1, BTN-1, TEMP-1_R2, PLT-1). All 10 devices are mapped.

Registry & validator

  • New config map in devices.json mirroring firmware (channel → variant → raw YAML URL). Additive; firmware values untouched.
  • scripts/validate_registry.py now shape-checks and HEAD-checks every config URL, so a broken config link fails CI like a broken manifest. Guarded against a malformed (null/non-dict) config. Offline unit tests added.

Refactor

  • Unified js/views/device.js's three ad-hoc async staleness guards into one render-epoch counter (also covers the new config fetch), so a stale fetch can never overwrite the current selection.

Deploy

  • Live fetch, no cache directory, so the pages.yml cp-list is unchanged.

Note: the battery products TEMP-1B / PLT-1B aren't in devices.json as installable devices — a separate registry-completeness item, out of scope here.

Checklist

  • Playwright tests pass locally (cd tests && npx playwright test) (18 passed, 1 intentional skip)
  • Any new runtime file/dir is added to the cp list in .github/workflows/pages.yml (n/a: no new runtime files; the config is fetched live)
  • No new build step, framework, or runtime CDN dependency
  • If devices.json changed: python scripts/validate_registry.py passes (Registry OK — manifests + all config URLs return 200)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added a new device config section that lets users view ESPHome YAML, open the source on GitHub, and download the file directly.
    • Expanded device data to include per-variant configuration links for supported devices.
  • Bug Fixes

    • Improved page updates so switching device variants no longer shows stale configuration content.
    • Added validation to catch invalid or unreachable configuration links.

bharvey88 added 8 commits July 9, 2026 12:25
docs/superpowers/specs/2026-07-09-yaml-view-download-design.md

Approved design: a parallel `config` map in devices.json (the factory config
where a repo has one, else the main per-variant yaml), a collapsible
view/download block in step 1 that follows the variant selection, a render-epoch
refactor of device.js's three async staleness guards, and validator plus
data-driven Playwright coverage. Live fetch from GitHub raw, so no new deploy
surface.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
docs/superpowers/plans/2026-07-09-yaml-view-download.md

Six TDD tasks: validator config check, registry population (8 devices;
temp-1/plt-1 deferred pending revision decision), render-epoch refactor, the
config view/download block, config tests, and verification/PR. Includes the real
per-variant config URL map probed from the product repos.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
This commit adds a new check_config_shape() function to validate the
optional config map structure, ensuring all config URLs are https and
reachable. The reachability check is integrated into main() to HEAD-test
every config URL. Unit tests verify shape validation works offline and
covers all error conditions.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Replace the three ad-hoc "want" comparisons in renderInstall and
renderReleaseNotes with a single per-renderDevice epoch counter that
increments on every channel/variant change. Async renders capture
their epoch at the start and bail if it no longer matches, giving one
consistent staleness guard instead of three separate ones.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ede8dbce-27c7-4910-aa16-90b7b6437b93

📥 Commits

Reviewing files that changed from the base of the PR and between 75d10f6 and aade8fb.

📒 Files selected for processing (8)
  • css/style.css
  • devices.json
  • docs/superpowers/plans/2026-07-09-yaml-view-download.md
  • docs/superpowers/specs/2026-07-09-yaml-view-download-design.md
  • js/views/device.js
  • scripts/test_validate_registry.py
  • scripts/validate_registry.py
  • tests/installer.spec.js

Walkthrough

Adds optional per-device ESPHome YAML URLs, validates their structure and reachability, and exposes selected configurations in the device UI with safe rendering, GitHub links, downloads, stale-request protection, styling, and Playwright coverage.

Changes

Device YAML configuration

Layer / File(s) Summary
Configuration schema and validation
scripts/validate_registry.py, scripts/test_validate_registry.py, docs/superpowers/specs/..., docs/superpowers/plans/...
Adds optional config shape validation, HTTPS and reachability checks, and unit coverage for valid and malformed mappings.
Per-device configuration mappings
devices.json, docs/superpowers/specs/..., docs/superpowers/plans/...
Adds stable-channel YAML URLs for listed devices and documents variant-to-file mapping rules.
Rendered YAML configuration flow
js/views/device.js, css/style.css, docs/superpowers/specs/..., docs/superpowers/plans/...
Renders selected YAML, derives GitHub links and filenames, supports Blob downloads, styles the configuration section, and guards async updates with a shared epoch.
End-to-end configuration coverage
tests/installer.spec.js, docs/superpowers/plans/..., docs/superpowers/specs/...
Tests initial rendering, variant switching, stale responses, download filenames, GitHub links, and absent configuration sections.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant DevicePage
  participant DeviceRegistry
  participant RawGitHub
  participant Browser
  DevicePage->>DeviceRegistry: read selected variant config URL
  DevicePage->>RawGitHub: fetch YAML configuration
  RawGitHub-->>DevicePage: return YAML text
  DevicePage->>Browser: render YAML and GitHub link
  Browser->>DevicePage: request configuration download
  DevicePage->>Browser: download YAML with derived filename
Loading

Possibly related issues

Poem

I’m a bunny with YAML tucked neat,
Blue-bordered configs make pages complete.
Fetch, show, and download with care,
Stale hops vanish into thin air.
GitHub links sparkle, variants align—
Hop-hop hooray for configuration time!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding firmware config viewing and downloading to device pages.
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.
✨ 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 feat/3-yaml-view-download

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.

@bharvey88 bharvey88 merged commit 2af5615 into main Jul 9, 2026
2 of 3 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.

Add YAML view/download to device pages

1 participant