-
Notifications
You must be signed in to change notification settings - Fork 254
Add gallery prompt templates #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add gallery prompt templates #52
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new “category” field for prompt entries, separates default and user prompts in the gallery tree, and adds several default .poml templates.
- Add
category: 'user'to commands that create or update user prompts - Refactor
PromptGalleryProviderto show two collapsible categories (“Default Prompts” and “My Prompts”) - Update context menu in
package.jsonso only user prompts offer edit/delete actions - Add seven new default prompt templates under
gallery/
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/poml-vscode/command/promptGallery.ts | Include category: 'user' when adding or updating prompts |
| packages/poml-vscode/chat/gallery.ts | Refactor provider to handle default vs user categories |
| package.json | Restrict edit/delete context menu to user prompts only |
| gallery/*.poml | Add new default prompt templates for code, LaTeX, PDF, table, etc. |
Comments suppressed due to low confidence (2)
packages/poml-vscode/chat/gallery.ts:23
- [nitpick] The constant name
MY_PROMPTS_LABELcould be renamed toUSER_PROMPTS_LABELto align with the'user'category value and improve consistency.
const MY_PROMPTS_LABEL = 'My Prompts';
packages/poml-vscode/chat/gallery.ts:40
- Add unit tests for
getChildrento verify that both default and user categories load the correct prompt lists, and that leaf nodes return an empty array.
getChildren(element?: TreeNode): TreeNode[] {
| { type: 'category', label: DEFAULT_PROMPTS_LABEL }, | ||
| { type: 'category', label: MY_PROMPTS_LABEL }, | ||
| ]; | ||
| } | ||
| if (isCategory(element)) { | ||
| return element.label === DEFAULT_PROMPTS_LABEL |
Copilot
AI
Jul 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comparing against the display label can be brittle; consider adding a separate key or id field to PromptCategory so logic doesn’t rely on UI text.
| { type: 'category', label: DEFAULT_PROMPTS_LABEL }, | |
| { type: 'category', label: MY_PROMPTS_LABEL }, | |
| ]; | |
| } | |
| if (isCategory(element)) { | |
| return element.label === DEFAULT_PROMPTS_LABEL | |
| { type: 'category', key: 'default', label: DEFAULT_PROMPTS_LABEL }, | |
| { type: 'category', key: 'user', label: MY_PROMPTS_LABEL }, | |
| ]; | |
| } | |
| if (isCategory(element)) { | |
| return element.key === 'default' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Missing Data Migration Causes Type Violations
The PromptEntry interface was updated to require a category field, but no data migration was implemented for existing user prompts stored in globalState. This causes type violations and runtime errors when old entries are loaded and their missing category property is accessed (e.g., in getTreeItem), breaking the extension for users with previously saved prompts.
packages/poml-vscode/chat/gallery.ts#L30-L33
poml/packages/poml-vscode/chat/gallery.ts
Lines 30 to 33 in 2ee701a
| private get userEntries(): PromptEntry[] { | |
| return this.context.globalState.get<PromptEntry[]>(STORAGE_KEY, []); | |
| } |
Was this report helpful? Give feedback by reacting with 👍 or 👎
Summary
Testing
npm run build-webviewnpm run build-clinpm run lintnpm testpython -m pytest python/testsxvfb-run -a npm run compile && xvfb-run -a npm run test-vscodehttps://chatgpt.com/codex/tasks/task_e_6874d99b1664832ead07907876f5e3d4