Commit 4b96022
feat: Complete Phase 4 - Template Browser UI (v1.44.0) (#88)
* feat: Complete Phase 4 - Template Browser UI (v1.44.0)
Implemented visual template browser with comprehensive template management:
Features:
- Visual webview interface with grid/list view toggle
- Real-time search by name, description, or tags
- Category-based filtering (All, Built-in, Custom, etc.)
- Statistics dashboard showing template counts by type
- Template cards displaying metadata (version, usage, author)
- Quick actions: Create, Edit, Duplicate, Export, Delete
- Support for JSON templates, legacy .txt/.md, and built-in templates
- Similar architecture to existing webviews (graph, calendar, activity)
Commands:
- noted.showTemplateBrowser - Opens template browser panel
Implementation:
- Created src/templates/templateBrowserView.ts with full webview UI
- Registered command in extension.ts and package.json
- Updated all documentation (CLAUDE.md, notes.md, plan.md)
Community Support:
- Added prominent community support message to README
- Encourages users to rate and review on VS Code Marketplace
- Emphasizes importance of community feedback for growth
All code compiles successfully with pnpm run compile.
* fix: Security and bug fixes for Template Browser
Applied code review feedback addressing critical security and functionality issues:
Security Fixes:
- Added HTML escaping (escapeHtml) to prevent XSS attacks in webview
- All dynamic template data (name, description, tags, etc.) now properly escaped
- Protects against malicious template files with HTML/JS injection
Functionality Fixes:
- Fixed handleCreateFromTemplate to pass templateId to command
(Previously showed template picker again, now directly uses selected template)
- Added findTemplateFile() helper function to check both .txt and .md files
(Fixed bug where only configured fileFormat was checked)
- Extracted refreshWebviewTemplates() helper to eliminate code duplication
- Used helper in all functions (edit, delete, duplicate, export)
Error Handling Improvements:
- Added vscode.window.showWarningMessage() for user-facing errors
- Shows warnings when template parsing fails
- Shows warnings when template loading fails
- Kept console.error for developer debugging
Code Quality:
- Reduced duplication across 4 handler functions
- More maintainable with centralized template file finding logic
- Consistent error handling pattern throughout
All code compiles successfully with zero errors.
* fix: TypeScript compilation error in templateBrowserView
Fixed TypeScript error on line 333:
- Added explicit type annotation to filters variable
- Type: { [name: string]: string[] }
- Resolves union type inference issue that caused CI failure
Error was: Type '{ JSON: string[]; Text?: undefined; } | { Text: string[]; JSON?: undefined; }'
is not assignable to type '{ [name: string]: string[]; } | undefined'.
The conditional expression created a union type where each branch had optional
properties, which TypeScript couldn't reconcile with the showSaveDialog expected type.
Explicit type annotation tells TypeScript to treat both branches as the same type,
resolving the incompatibility.
Verified with:
- pnpm run compile (esbuild) ✅
- npx tsc -p ./ --noEmit (TypeScript) ✅
* test: Add comprehensive unit tests for Template Browser
Added 15 new unit tests for templateBrowserView covering:
Test Coverage:
- Command registration verification (showTemplateBrowser)
- Template display info structure (built-in, JSON, legacy)
- File type handling (json, txt, md, builtin)
- Template actions (create, edit, duplicate, export, delete)
- HTML escaping for XSS prevention
- Filter save dialog types
- View modes (grid, list)
- Category filtering (all, built-in, custom)
- Search functionality (name, description, tags)
- Statistics calculation (total, custom, built-in counts)
- Message commands (all 6 webview commands)
Security:
- XSS prevention tests with malicious input
- HTML escaping validation
- Safe handling of user-provided template data
Results:
- Total tests: 533 (all passing)
- New tests: 15 for Template Browser
- Zero failures
docs: Update documentation with Template Browser features
Website Documentation (docs/_posts/2025-10-24-templates.md):
- Added comprehensive Template Browser section
- Documented view modes (grid/list)
- Search and filter capabilities
- Template card display features
- Quick actions per template
- Benefits and pro tips
- Integration with existing template guide
README.md:
- Added "Browse templates visually" feature section
- Highlighted key capabilities
- Positioned before bundles section for logical flow
- Emphasizes visual management and search features
All documentation updated to reflect v1.44.0 Template Browser implementation.
---------
Co-authored-by: Claude <[email protected]>1 parent 46fb1c3 commit 4b96022
File tree
9 files changed
+1327
-13
lines changed- docs/_posts
- src
- templates
- test/unit
9 files changed
+1327
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
| 67 | + | |
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| 71 | + | |
71 | 72 | | |
72 | 73 | | |
73 | 74 | | |
| |||
320 | 321 | | |
321 | 322 | | |
322 | 323 | | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
323 | 338 | | |
324 | 339 | | |
325 | 340 | | |
| |||
369 | 384 | | |
370 | 385 | | |
371 | 386 | | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
372 | 390 | | |
373 | 391 | | |
374 | 392 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
3 | 5 | | |
4 | 6 | | |
5 | 7 | | |
| |||
85 | 87 | | |
86 | 88 | | |
87 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
88 | 94 | | |
89 | 95 | | |
90 | 96 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
115 | 165 | | |
116 | 166 | | |
117 | 167 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
41 | 54 | | |
42 | 55 | | |
43 | 56 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
273 | 273 | | |
274 | 274 | | |
275 | 275 | | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
276 | 281 | | |
277 | 282 | | |
278 | 283 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | | - | |
| 123 | + | |
124 | 124 | | |
125 | | - | |
| 125 | + | |
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
| |||
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
189 | | - | |
190 | | - | |
| 189 | + | |
| 190 | + | |
191 | 191 | | |
192 | 192 | | |
193 | 193 | | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
201 | 203 | | |
202 | 204 | | |
203 | 205 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
1805 | 1806 | | |
1806 | 1807 | | |
1807 | 1808 | | |
| 1809 | + | |
| 1810 | + | |
| 1811 | + | |
| 1812 | + | |
| 1813 | + | |
1808 | 1814 | | |
1809 | 1815 | | |
1810 | 1816 | | |
| |||
2089 | 2095 | | |
2090 | 2096 | | |
2091 | 2097 | | |
2092 | | - | |
| 2098 | + | |
2093 | 2099 | | |
2094 | 2100 | | |
2095 | 2101 | | |
| |||
0 commit comments