Skip to content

refactor(git-id-switcher): extract buildHtmlShell helper#447

Merged
nullvariant merged 1 commit into
mainfrom
refactor/00186-webview-html-shell-extraction
Apr 7, 2026
Merged

refactor(git-id-switcher): extract buildHtmlShell helper#447
nullvariant merged 1 commit into
mainfrom
refactor/00186-webview-html-shell-extraction

Conversation

@nullvariant
Copy link
Copy Markdown
Owner

Summary

  • Extract private buildHtmlShell(opts) to own the shared <!DOCTYPE>...</head>...<body> skeleton previously duplicated across the document / loading / error template builders
  • Add <title> to loading and error templates (only document had one before), keeping tab labels and SR announcements consistent
  • Extend the lang-attribute test to lock <title> presence, uniqueness, in-head placement, and dynamic errorType reflection

Motivation

The 3 template builders each repeated the HTML skeleton — a textbook case of the "3+ duplicates must be abstracted" guardrail. The duplication also caused a real regression (missing <title> in 2 of 3 templates) that would have been impossible if the skeleton lived in one place.

Test plan

  • npx tsc --noEmit
  • npm run lint (0 warnings)
  • npm run test:coverage — htmlTemplates.ts statements/branches/functions/lines all 100%
  • New regression test fails if any template drops its <title> or errorType title construction breaks

The 3 template builders (document/loading/error) each duplicated the
<!DOCTYPE>...</head>...<body>...</html> skeleton, triggering the
"3+ duplicates must be abstracted" guardrail. loading/error also
lacked <title>, producing inconsistent tab labels and degraded screen
reader announcements.
- Add private buildHtmlShell(opts) owning the shared skeleton (CSP
  meta, viewport, charset, nonced <style>, <title>)
- Rewrite 3 templates to provide only their styles + body content
- Add <title> to loading and error templates
- Extend lang-attribute test to assert <title> lives inside <head>,
  appears exactly once, and reflects errorType dynamically
Signed-off-by: Null;Variant <null@nullvariant.com>

🖥️ IDE: [VS Code](https://code.visualstudio.com/)
🔌 Extension: [Claude Code](https://claude.ai/download)

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Model-Raw: claude-opus-4-6
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 7, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Snapshot Warnings

⚠️: No snapshots were found for the head SHA 331ab4a.
Ensure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice.

Scanned Files

None

@nullvariant-slow
Copy link
Copy Markdown
Contributor

🦥 Slow's Code Review 😩

...yawn... Do I really have to review this?

⚠️ TOO LONG... I can barely keep my eyes open reading these:

File Lines

| extensions/git-id-switcher/src/test/htmlTemplates.test.ts | 650 |
| extensions/git-id-switcher/src/ui/htmlTemplates.ts | 428 |

Split it up... reading long files is exhausting.


働きたくないでござる

This review was reluctantly filed by nullvariant-slow[bot]

@nullvariant-mimi
Copy link
Copy Markdown
Contributor

🐰 Mimi's Validation Report ✅

All checks are looking good! Great job! 🎉

⏳ Some checks are still running. I will keep watching!


バリデーターを通してくださいね

This report was carefully prepared by nullvariant-mimi[bot]

@nullvariant-ciel
Copy link
Copy Markdown
Contributor

nullvariant-ciel Bot commented Apr 7, 2026

🕊️ Ciel's Mediation 🌤️

*~~ floating down from the clouds ~~ The zoo seems a bit noisy today...*

2 zoo members have reviewed this PR.

Zoo Member Status
🦥 Slow Commented
🐰 Mimi Commented

⚖️ The zoo has mixed opinions. Some are concerned, some are fine with it. Please review each comment carefully and make the final call.


まあまあ、ほどほどに。

This mediation was peacefully delivered by nullvariant-ciel[bot]

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

@nullvariant-justice nullvariant-justice Bot left a comment

Choose a reason for hiding this comment

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

⚖️ Justice grants passage. CI checks passed — this code meets the garden's standards.

@nullvariant nullvariant merged commit 2a8aee9 into main Apr 7, 2026
34 of 35 checks passed
@nullvariant nullvariant deleted the refactor/00186-webview-html-shell-extraction branch April 7, 2026 05:34
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