refactor(git-id-switcher): extract buildHtmlShell helper#447
Conversation
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
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Snapshot WarningsEnsure 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 FilesNone |
🦥 Slow's Code Review 😩...yawn... Do I really have to review this?
| Split it up... reading long files is exhausting.
This review was reluctantly filed by nullvariant-slow[bot] |
🐰 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] |
🕊️ Ciel's Mediation 🌤️*~~ floating down from the clouds ~~ The zoo seems a bit noisy today...* 2 zoo members have reviewed this PR.
⚖️ 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 Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|



Summary
buildHtmlShell(opts)to own the shared<!DOCTYPE>...</head>...<body>skeleton previously duplicated across the document / loading / error template builders<title>to loading and error templates (only document had one before), keeping tab labels and SR announcements consistent<title>presence, uniqueness, in-head placement, and dynamic errorType reflectionMotivation
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 --noEmitnpm run lint(0 warnings)npm run test:coverage— htmlTemplates.ts statements/branches/functions/lines all 100%<title>or errorType title construction breaks