Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds a prompt gallery feature to the VS Code extension, allowing users to manage and invoke custom POML prompt files via a dedicated view and slash commands in the chat participant.
- Introduce
PromptGalleryProviderfor persisting, listing, and updating prompt entries - Register a new activity-bar view with Add/Edit/Delete prompt commands
- Enhance chat participant to handle
/promptNameprefixes and load custom prompt files
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/poml-vscode/gallery/promptGallery.ts | New PromptGalleryProvider class and storage logic |
| packages/poml-vscode/extension.ts | Registered gallery provider and wired commands |
| packages/poml-vscode/command/promptGallery.ts | Add/Edit/Delete prompt command implementations |
| packages/poml-vscode/command/index.ts | Exported new gallery commands |
| packages/poml-vscode/chat/participant.ts | Chat handler updated to support slash‐invoked prompts |
| package.json | Contributions for view container, views, and commands |
Comments suppressed due to low confidence (3)
packages/poml-vscode/gallery/promptGallery.ts:51
- [nitpick] The
promptsgetter is an alias forentries, which may be redundant. Consider consolidating to a single public getter to reduce confusion.
get prompts(): PromptEntry[] {
packages/poml-vscode/gallery/promptGallery.ts:37
- New behavior for adding prompts is introduced here but there are no unit tests covering
addPrompt,removePrompt, orupdatePrompt. Adding tests will help guard against regressions.
addPrompt(entry: PromptEntry) {
packages/poml-vscode/gallery/promptGallery.ts:10
- [nitpick] Public API
PromptGalleryProviderwould benefit from a brief JSDoc comment explaining its purpose and the meaning of its key methods.
export class PromptGalleryProvider implements vscode.TreeDataProvider<PromptEntry> {
| const matchedPrompt = gallery.prompts.find(p => promptText.match(new RegExp(`^/${p.name}\\b`))); | ||
| if (matchedPrompt) { | ||
| promptText = promptText.replace(new RegExp(`^/${matchedPrompt.name}\\b`), '').trimStart(); |
There was a problem hiding this comment.
Since p.name is user-provided, unescaped regex special characters can lead to unexpected behavior. Consider escaping p.name before constructing the RegExp or use a plain string startsWith check and boundary test.
| const matchedPrompt = gallery.prompts.find(p => promptText.match(new RegExp(`^/${p.name}\\b`))); | |
| if (matchedPrompt) { | |
| promptText = promptText.replace(new RegExp(`^/${matchedPrompt.name}\\b`), '').trimStart(); | |
| const escapeRegex = (str: string) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); | |
| const matchedPrompt = gallery.prompts.find(p => promptText.match(new RegExp(`^/${escapeRegex(p.name)}\\b`))); | |
| if (matchedPrompt) { | |
| promptText = promptText.replace(new RegExp(`^/${escapeRegex(matchedPrompt.name)}\\b`), '').trimStart(); |
There was a problem hiding this comment.
Bug: Prompt Name Validation Fails During Edit
In EditPromptCommand, the hasPrompt(name) validation incorrectly prevents users from keeping the same name when editing an existing prompt. The check fails because it does not exclude the current prompt being edited, leading to the error "A prompt with the name already exists". This prevents legitimate edits where only the file path is changed while the prompt name remains the same.
packages/poml-vscode/command/promptGallery.ts#L79-L85
poml/packages/poml-vscode/command/promptGallery.ts
Lines 79 to 85 in a73660e
Was this report helpful? Give feedback by reacting with 👍 or 👎
Summary
Testing
npm run build-webviewnpm run build-clinpm run lintnpm testpython -m pip install -e .[dev]python -m pytest python/testsxvfb-run -a npm run compilenpm run build-extensionxvfb-run -a npm run test-vscodehttps://chatgpt.com/codex/tasks/task_e_686e4109f910832e81ed48e4f2b20f33