refactor(webview): extract pure HTML template functions for testability#405
Conversation
## Background Quality review detected a11y issues and architecture improvements in webview.ts. ## Changes - Extract VS Code-independent pure functions to htmlTemplates.ts - buildCspString, buildDocumentHtml, buildLoadingHtml, buildErrorHtml - getBaseStyles for shared CSS across templates - Reduce webview.ts from 376 to 107 lines (thin VS Code wrapper) - Add lang="en" to loading/error HTML (WCAG 2.1 SC 3.1.1) - Add aria-hidden="true" to spinner, role="status" to loading text - Change nav-bar div to <nav> with aria-label - Change div.footer to <footer> element - Add 12 unit tests for htmlTemplates.ts (100% coverage) - Use ErrorType alias instead of inline literal (SSOT) 🖥️ IDE: [Cursor](https://cursor.sh) 🔌 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 |
🐰 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] |
🦥 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] |
🕊️ 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] |
Combine separate `import type` and `import` statements from the same module into a single import to fix no-duplicate-imports lint error. 🖥️ IDE: [Cursor](https://cursor.sh) 🔌 Extension: [Claude Code](https://claude.ai/download) Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Model-Raw: claude-opus-4-6
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |



Summary
webview.tstohtmlTemplates.tsfor unit testabilitylangattribute (WCAG 2.1 SC 3.1.1), ARIA attributes on spinner/status, semantic<nav>and<footer>elementswebview.tsfrom 376 to 107 lines (thin wrapper delegating to pure functions)Test plan
npx tsc --noEmit— no compile errorsnpm run lint— 0 errors (63 pre-existing warnings)npm run test:unit— all tests pass including 12 new htmlTemplates testsnpm run test:coverage— statement coverage 100% maintained, htmlTemplates.ts 100/100/100/100🤖 Generated with Claude Code