Commit 06983e0
Review and align template implementation plan (#85)
* feat: Implement Phase 1 AI-powered template creation
Implements Phase 1 of the template system modernization plan with AI-powered
template generation and enhancement.
**New Features:**
- AI-powered template generation from natural language descriptions
- AI-powered template enhancement for existing templates
- Template metadata system with comprehensive type definitions
- Integration with GitHub Copilot (gpt-4o) via VS Code LLM API
**New Commands:**
- `noted.createTemplateWithAI` - Generate templates from descriptions
- `noted.enhanceTemplate` - Enhance existing templates with AI suggestions
**New Configuration:**
- `noted.templates.useAI` - Enable/disable AI template features
- `noted.templates.defaultCategory` - Default category for templates
- `noted.templates.enableBundles` - Enable bundle support (Phase 2)
- `noted.templates.showBrowser` - Enable template browser (Phase 4)
- `noted.templates.aiModel` - Select AI model (gpt-4o/gpt-3.5-turbo)
- `noted.templates.defaultAuthor` - Default author name
**New Files:**
- `src/templates/TemplateMetadata.ts` - TypeScript interfaces
- `src/templates/TemplateGenerator.ts` - AI generation service
- `src/commands/templateCommands.ts` - Command handlers
**Documentation Updates:**
- Fixed TemplateMetadata vs Template naming inconsistency
- Added missing commands to registration examples
- Aligned storage structure between research and implementation docs
**Technical Details:**
- Follows TagGenerator pattern for Copilot integration
- Uses caching with SHA-256 hashing for performance
- Supports backward compatibility with plain text templates
- Comprehensive error handling with user-friendly messages
* feat: Add dynamic AI model selection with smart fallback
Enhances template system with intelligent model selection that supports
all available AI models (Claude, GPT, Gemini, etc.) instead of hardcoded options.
**Key Improvements:**
- Dynamic model discovery from VS Code LLM API
- User-selectable AI models via new command
- Smart fallback: Claude > GPT > Gemini > any available
- Fixed bug: config setting now actually used
**New Command:**
- `noted.selectAIModel` - Interactive picker showing all available models
- Displays model vendor, name, and description
- Shows current selection with checkmark
- "Automatic (Recommended)" option for smart selection
- Saves preference to global config
**Configuration Changes:**
- Removed: `noted.templates.aiModel` (hardcoded enum)
- Added: `noted.templates.preferredModel` (stores model ID or empty for auto)
**TemplateGenerator Enhancements:**
- `selectModel()` - Intelligent model selection with preference support
- `getAvailableModels()` - Query all available models with metadata
- `getModelDescription()` - User-friendly model descriptions
- Smart priority: Claude (best for structured output) > GPT > Gemini
**Benefits:**
- Future-proof (works with any model user has access to)
- Better UX (users pick from their actual available models)
- No vendor lock-in (supports Copilot, Claude, Gemini, etc.)
- Automatic fallback ensures reliability
- Fixes unused config setting bug
**Technical Details:**
- Uses `vscode.lm.selectChatModels({})` for all models
- Stores model ID in config, not vendor-specific enum
- Icon: `$(settings-gear)` for model selection command
- Interactive quick pick with descriptions and selection state
* fix: Update tasks.json with proper esbuild watch detection
Fixes the 'Waiting for preLaunchTask' issue when debugging extension.
**Problem:**
- Default task configuration didn't properly detect when esbuild watch completes
- Caused debugger to hang waiting for preLaunchTask 'watch'
**Solution:**
- Added custom problemMatcher with background patterns for esbuild
- Detects '[build] build started' and '[build] build finished' messages
- Properly signals task completion to VS Code debugger
**Now:**
- F5 debug works without manual intervention
- Watch mode properly integrates with launch configuration
* fix: Register preferredModel configuration setting
The previous edit didn't save properly - the old aiModel config was still present
instead of the new preferredModel setting.
**Fixed:**
- Removed: noted.templates.aiModel (hardcoded enum)
- Added: noted.templates.preferredModel (stores model ID, empty for auto)
**User must reload VS Code** for the new configuration to be recognized.
* feat: Integrate JSON templates with existing template system
Makes AI-generated JSON templates work seamlessly with the existing
template workflow. Users can now create templates with AI and use them
immediately.
**templateService.ts:**
- Import Template type from TemplateMetadata
- Try JSON format first, fall back to legacy .txt/.md
- Parse JSON templates and extract content field
- Support both formats in parallel (backward compatible)
- Remove duplicates when same template exists in multiple formats
**TemplatesTreeProvider:**
- Add AI template actions to "Manage" section
- ✨ Create with AI
- ✨ Enhance with AI
- ⚙️ Select AI Model
- Makes AI features discoverable in sidebar
- JSON templates now show in Templates panel automatically
**User Experience:**
1. Create template with AI → Saves as .json
2. Template appears in Templates panel
3. Click to use with "Open with Template" command
4. Works exactly like legacy templates
**Backward Compatible:**
- Legacy .txt/.md templates still work
- JSON takes priority if both formats exist
- All existing templates continue to function
**What Works Now:**
✅ JSON templates appear in Templates panel
✅ JSON templates work with "Open with Template"
✅ AI management actions in sidebar
✅ Seamless integration with existing workflows
* feat: Improve template preview and discovery UX
Fixes issues with oversized preview dialogs and unclear template locations.
**Preview Improvements:**
- Replace modal dialog with proper editor preview
- Opens in side-by-side view with markdown formatting
- Fully scrollable and readable
- Better formatted with headers, sections, and code blocks
- Cleaner accept/cancel flow
**After Generation:**
- Better success messages with ✅ emoji
- Three action buttons:
- "Open Template File" - View the JSON
- "Open Templates Folder" - Browse all templates
- "Create Note from Template" - Use it immediately
- Makes generated templates easily discoverable
**Preview Format:**
Before: Cramped modal with plain text
```
Name: template-name
Description: ...
Content:
---
(content)
---
```
After: Proper markdown document with formatting
```markdown
# Template Preview: template-name
**Description:** ...
**Category:** ...
**Tags:** ...
## Template Variables
- **var1** (string) *required*
- Prompt text
## Template Content
(formatted markdown)
```
**User Benefits:**
✅ Can read full template content before accepting
✅ Knows exactly where template was saved
✅ Can immediately use generated template
✅ Better visual formatting and organization
* fix: Eliminate confusing modal dialogs and save prompts
Fixes UX issues where preview flow was blocking and confusing.
**Problems Fixed:**
1. Modal dialog blocked preview - couldn't read before deciding
2. Duplicate "Cancel" buttons appeared (VS Code modal bug)
3. Unwanted save prompt when closing preview
4. No clear instructions on what's happening
**New Flow:**
1. AI generates template
2. Preview opens in side-by-side view (non-blocking)
3. Non-modal notification appears: "📄 Review the template preview on the right"
4. User can scroll and read the FULL preview
5. Click "Accept & Save Template" or "Cancel" when ready
6. Preview closes cleanly without save prompts
**Preview Improvements:**
- Added instructional header at top
- Clear "Next Steps" section at bottom
- Explains what each button does
- Shows where template will be saved
- Better visual hierarchy with emojis
**Before:**
```
[MODAL BLOCKING SCREEN]
Template preview is open. Accept?
[Accept & Save] [Cancel] [Cancel] <- Confusing!
[Can't read preview behind modal]
```
**After:**
```
[PREVIEW FULLY VISIBLE AND SCROLLABLE]
📄 Review the template preview on the right, then choose:
[Accept & Save Template] [Cancel] <- Clear!
```
No more unwanted "Save changes?" prompts!
* fix: Eliminate confusing modal dialogs and save prompts
Fixes bug where clicking on preview to read it caused the Accept/Save
notification to disappear.
**Problem:**
- Non-modal notifications auto-dismiss when clicking elsewhere
- User couldn't read full preview before notification disappeared
- Modal dialogs showed duplicate Cancel buttons (VS Code bug)
- Preview documents triggered unwanted save prompts
**Solution:**
Two-stage notification approach:
1. Initial non-blocking message: "Preview opened, take your time"
2. 1-second delay for user to orient
3. Modal decision dialog (won't auto-dismiss)
4. Clean preview closure without save prompts
**Benefits:**
- User can click and read preview without losing notification
- Modal dialog persists until user makes explicit choice
- Clear instructions in modal detail text
- No confusing save prompts when declining template
* fix: Replace obtrusive modal dialog with QuickPick
Fixes regression where modal dialog was blocking the preview.
**Problem:**
- Modal dialog with `modal: true` blocks entire UI
- Shows duplicate "Cancel" buttons (VS Code bug)
- User can't read preview while decision dialog is visible
**Solution:**
Replace modal with QuickPick:
- QuickPick is persistent (won't auto-dismiss)
- QuickPick is non-blocking (user can click preview to read)
- `ignoreFocusOut: true` keeps picker open while reviewing
- Clear visual options with icons: "$(check) Accept" and "$(x) Decline"
**Benefits:**
- User can read full preview without obstruction
- No duplicate buttons
- Persistent decision picker (stays open)
- Better UX with descriptive options and placeholder text
* feat: Improve template preview and discovery UX
Fixes two critical UX issues:
1. Notification disappearing before user can review preview
2. New templates not appearing in Templates panel after save
**Changes:**
**Persistent Bottom-Right Notification:**
- Replaced QuickPick with persistent showInformationMessage
- Notification re-prompts if dismissed without choice (while loop)
- 500ms delay between re-prompts to avoid spam
- User can now freely read preview without losing notification
- Simple buttons: "Accept & Save" and "Decline"/"Keep Original"
**Template Discovery:**
- Added templatesProvider.refresh() after template save
- Wrapped AI template command handlers in extension.ts
- New/enhanced templates now immediately visible in sidebar
- Applied to both createTemplateWithAI and enhanceTemplate commands
**Benefits:**
- User-friendly: read preview at your own pace
- No blocking modals or disappearing notifications
- Immediate visual feedback when templates are created
- Consistent with existing template management UX
* Update src/templates/TemplateGenerator.ts
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
* refactor: Address code review feedback for Phase 1
**Code Review Fixes:**
1. **Version Parsing Validation (TemplateGenerator.ts:505-506)**
- Added NaN validation for version parts
- Prevents invalid versions like "1.NaN.0"
- Falls back to "1.0.0" if any part is not a valid number
2. **Author Fallback (TemplateGenerator.ts:298)**
- Changed from hardcoded 'user' to os.userInfo().username
- Consistent with package.json config description
- Matches legacy template service behavior
3. **File System Operations (templateCommands.ts:398-400)**
- Replaced inline fs.mkdir with createDirectory from fileSystemService
- Maintains consistency with codebase pattern
- Centralizes file system operations
4. **File Naming (TemplateMetadata.ts → TemplateTypes.ts)**
- Renamed to better reflect main export (Template interface)
- Updated all imports in 3 files:
- src/templates/TemplateGenerator.ts
- src/commands/templateCommands.ts
- src/services/templateService.ts
5. **UX Decision Documentation (templateCommands.ts:212-215, 266-269)**
- Added explanatory comments for while loop pattern
- Clarifies intentional design choice:
- Modal dialogs block UI and prevent reading preview
- Non-modal notifications auto-dismiss when clicking preview
- While loop ensures notification stays visible
- User explicitly requested this behavior over modal approach
**All Changes Compile Successfully**
---------
Co-authored-by: Claude <[email protected]>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>1 parent 3390840 commit 06983e0
File tree
10 files changed
+1272
-14
lines changed- .vscode
- src
- commands
- providers
- services
- templates
10 files changed
+1272
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
8 | 15 | | |
9 | 16 | | |
10 | 17 | | |
| |||
17 | 24 | | |
18 | 25 | | |
19 | 26 | | |
20 | | - | |
| 27 | + | |
21 | 28 | | |
22 | 29 | | |
23 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
461 | 461 | | |
462 | 462 | | |
463 | 463 | | |
464 | | - | |
| 464 | + | |
465 | 465 | | |
466 | 466 | | |
467 | 467 | | |
468 | 468 | | |
469 | | - | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
470 | 474 | | |
471 | 475 | | |
472 | 476 | | |
473 | | - | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
474 | 482 | | |
475 | 483 | | |
476 | 484 | | |
| |||
499 | 507 | | |
500 | 508 | | |
501 | 509 | | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
502 | 515 | | |
503 | 516 | | |
504 | 517 | | |
505 | 518 | | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
506 | 524 | | |
507 | 525 | | |
508 | 526 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
368 | 368 | | |
369 | 369 | | |
370 | 370 | | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
377 | 376 | | |
378 | 377 | | |
379 | 378 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
233 | 233 | | |
234 | 234 | | |
235 | 235 | | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
236 | 251 | | |
237 | 252 | | |
238 | 253 | | |
| |||
1223 | 1238 | | |
1224 | 1239 | | |
1225 | 1240 | | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
1226 | 1271 | | |
1227 | 1272 | | |
1228 | 1273 | | |
| |||
0 commit comments