Skip to content

Conversation

@ultmaster
Copy link
Contributor

Summary

  • create PromptGalleryProvider to manage prompt files
  • register gallery and add slash commands to poml chat participant
  • show gallery in VS Code activity bar and provide context menus

Testing

  • npm run build-webview
  • npm run build-cli
  • npm run lint
  • npm test
  • python -m pip install -e .[dev]
  • python -m pytest python/tests
  • xvfb-run -a npm run compile
  • npm run build-extension
  • xvfb-run -a npm run test-vscode

https://chatgpt.com/codex/tasks/task_e_686e4109f910832e81ed48e4f2b20f33

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@ultmaster ultmaster requested a review from Copilot July 14, 2025 07:55
Copy link
Contributor

Copilot AI left a 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 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 PromptGalleryProvider for persisting, listing, and updating prompt entries
  • Register a new activity-bar view with Add/Edit/Delete prompt commands
  • Enhance chat participant to handle /promptName prefixes 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 prompts getter is an alias for entries, 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, or updatePrompt. Adding tests will help guard against regressions.
  addPrompt(entry: PromptEntry) {

packages/poml-vscode/gallery/promptGallery.ts:10

  • [nitpick] Public API PromptGalleryProvider would benefit from a brief JSDoc comment explaining its purpose and the meaning of its key methods.
export class PromptGalleryProvider implements vscode.TreeDataProvider<PromptEntry> {

Comment on lines +24 to +26
const matchedPrompt = gallery.prompts.find(p => promptText.match(new RegExp(`^/${p.name}\\b`)));
if (matchedPrompt) {
promptText = promptText.replace(new RegExp(`^/${matchedPrompt.name}\\b`), '').trimStart();
Copy link

Copilot AI Jul 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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();

Copilot uses AI. Check for mistakes.
cursor[bot]

This comment was marked as outdated.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

}
if (this.provider.hasPrompt(name)) {
vscode.window.showErrorMessage(
`A prompt with the name "${name}" already exists.`
);
continue;
}

Fix in CursorFix in Web


Was this report helpful? Give feedback by reacting with 👍 or 👎

@ultmaster ultmaster merged commit 9098ec5 into chat-sample Jul 14, 2025
4 checks passed
@ultmaster ultmaster deleted the codex/add-prompt-gallery-to-left-sidebar branch August 27, 2025 00:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants