Skip to content

Commit 06983e0

Browse files
jsonifyclaudegemini-code-assist[bot]
authored
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

10 files changed

+1272
-14
lines changed

.vscode/tasks.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@
44
{
55
"type": "npm",
66
"script": "watch",
7-
"problemMatcher": "$tsc-watch",
7+
"problemMatcher": {
8+
"base": "$tsc-watch",
9+
"background": {
10+
"activeOnStart": true,
11+
"beginsPattern": "^\\[build\\] build started",
12+
"endsPattern": "^\\[build\\] build finished"
13+
}
14+
},
815
"isBackground": true,
916
"presentation": {
1017
"reveal": "never"
@@ -17,7 +24,7 @@
1724
{
1825
"type": "npm",
1926
"script": "compile",
20-
"problemMatcher": "$tsc",
27+
"problemMatcher": [],
2128
"presentation": {
2229
"reveal": "never"
2330
},

TEMPLATE_IMPLEMENTATION_PLAN.md

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
```typescript
2525
// src/templates/TemplateGenerator.ts
2626
export class TemplateGenerator {
27-
async generateFromDescription(description: string): Promise<TemplateMetadata> {
27+
async generateFromDescription(description: string): Promise<Template> {
2828
// Use VS Code LLM API (like TagGenerator does)
2929
const model = await this.selectCopilotModel();
3030
const prompt = this.buildTemplateGenerationPrompt(description);
@@ -461,16 +461,24 @@ export async function handleShowTemplateBrowser() {
461461
### Add to `extension.ts`
462462

463463
```typescript
464-
// Template commands
464+
// Template commands (Phase 1)
465465
context.subscriptions.push(
466466
vscode.commands.registerCommand('noted.createTemplateWithAI',
467467
() => handleCreateTemplateWithAI()),
468468
vscode.commands.registerCommand('noted.enhanceTemplate',
469-
() => handleEnhanceTemplate()),
469+
() => handleEnhanceTemplate())
470+
);
471+
472+
// Template commands (Phase 2)
473+
context.subscriptions.push(
470474
vscode.commands.registerCommand('noted.createBundle',
471475
() => handleCreateBundle()),
472476
vscode.commands.registerCommand('noted.createBundleFromTemplates',
473-
() => handleCreateBundleFromTemplates()),
477+
() => handleCreateBundleFromTemplates())
478+
);
479+
480+
// Template commands (Phase 3-4)
481+
context.subscriptions.push(
474482
vscode.commands.registerCommand('noted.showTemplateBrowser',
475483
() => handleShowTemplateBrowser()),
476484
vscode.commands.registerCommand('noted.migrateTemplates',
@@ -499,10 +507,20 @@ context.subscriptions.push(
499507
"title": "Create Notes from Bundle",
500508
"category": "Noted"
501509
},
510+
{
511+
"command": "noted.createBundleFromTemplates",
512+
"title": "Create Bundle from Templates",
513+
"category": "Noted"
514+
},
502515
{
503516
"command": "noted.showTemplateBrowser",
504517
"title": "Show Template Browser",
505518
"category": "Noted"
519+
},
520+
{
521+
"command": "noted.migrateTemplates",
522+
"title": "Migrate Templates to JSON Format",
523+
"category": "Noted"
506524
}
507525
]
508526
}

TEMPLATE_RESEARCH.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -368,12 +368,11 @@ src/templates/
368368
src/commands/
369369
└── templateCommands.ts # New template commands (split from commands.ts)
370370

371-
.noted-templates/
372-
├── templates/ # Individual templates (JSON)
373-
│ ├── video-tutorial.json
374-
│ └── tutorial-text-guide.json
375-
└── bundles/ # Multi-note bundles
376-
└── video-tutorial-complete.bundle.json
371+
.noted-templates/ # Flat structure, differentiate by file extension
372+
├── video-tutorial.json # Individual template (JSON format)
373+
├── tutorial-text-guide.json # Individual template (JSON format)
374+
├── my-template.md # Legacy template (backward compatible)
375+
└── video-tutorial-complete.bundle.json # Multi-note bundle
377376
```
378377
379378
### Updated Files:

package.json

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,21 @@
233233
"title": "Noted: Open Templates Folder",
234234
"icon": "$(folder-opened)"
235235
},
236+
{
237+
"command": "noted.createTemplateWithAI",
238+
"title": "Noted: Create Template with AI",
239+
"icon": "$(sparkle)"
240+
},
241+
{
242+
"command": "noted.enhanceTemplate",
243+
"title": "Noted: Enhance Template with AI",
244+
"icon": "$(sparkle)"
245+
},
246+
{
247+
"command": "noted.selectAIModel",
248+
"title": "Noted: Select AI Model",
249+
"icon": "$(settings-gear)"
250+
},
236251
{
237252
"command": "noted.showConfig",
238253
"title": "Noted: Show Configuration (Debug)"
@@ -1223,6 +1238,36 @@
12231238
"type": "boolean",
12241239
"default": false,
12251240
"description": "Enable fuzzy matching to find results with typos"
1241+
},
1242+
"noted.templates.useAI": {
1243+
"type": "boolean",
1244+
"default": true,
1245+
"description": "Use AI to enhance template creation and suggestions"
1246+
},
1247+
"noted.templates.defaultCategory": {
1248+
"type": "string",
1249+
"default": "Custom",
1250+
"description": "Default category for new custom templates"
1251+
},
1252+
"noted.templates.enableBundles": {
1253+
"type": "boolean",
1254+
"default": true,
1255+
"description": "Enable multi-note workflow bundles (Phase 2 feature)"
1256+
},
1257+
"noted.templates.showBrowser": {
1258+
"type": "boolean",
1259+
"default": false,
1260+
"description": "Show template browser instead of quick pick (Phase 4 feature)"
1261+
},
1262+
"noted.templates.preferredModel": {
1263+
"type": "string",
1264+
"default": "",
1265+
"description": "Preferred AI model ID for template generation (empty = automatic selection). Use 'Noted: Select AI Model' command to choose from available models."
1266+
},
1267+
"noted.templates.defaultAuthor": {
1268+
"type": "string",
1269+
"default": "",
1270+
"description": "Default author name for generated templates (leave empty to use system username)"
12261271
}
12271272
}
12281273
}

0 commit comments

Comments
 (0)