-
Notifications
You must be signed in to change notification settings - Fork 254
Add context and stylesheet support in preview #27
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 context and stylesheet support in preview #27
Conversation
…dd-buttons-to-add-context-and-stylesheet
…dd-buttons-to-add-context-and-stylesheet
🚨 BugBot couldn't runBugBot is experiencing high demand right now. Try again in a few minutes by commenting "bugbot run" (requestId: serverGenReqId_723c49c3-1556-46e3-8f40-c96a856d1099). |
🚨 BugBot couldn't runBugBot is experiencing high demand right now. Try again in a few minutes by commenting "bugbot run" (requestId: serverGenReqId_3b803d19-3bdb-47ff-a409-8067f196d34f). |
…dd-buttons-to-add-context-and-stylesheet
🚨 BugBot couldn't runBugBot is experiencing high demand right now. Try again in a few minutes by commenting "bugbot run" (requestId: serverGenReqId_f9fbc9d1-867f-4297-bd5a-3708b6586d55). |
🚨 BugBot couldn't runBugBot is experiencing high demand right now. Try again in a few minutes by commenting "bugbot run" (requestId: serverGenReqId_7d0452ec-60d0-4ce2-8cd9-24b0cdebcd70). |
…dd-buttons-to-add-context-and-stylesheet
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
Adds the ability for users to attach JSON “context” and “stylesheet” files to each preview, persist their selection, and display them as removable chips in the webview toolbar.
- Introduce
contextsandstylesheetsfields in preview parameters, panel state, and tests - Persist per-resource selections in
POMLWebviewPaneland emit updates to the webview - Add commands/UI for adding/removing context & stylesheet files, and update toolbar HTML/CSS/JS
Reviewed Changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/*.test.ts | Add contexts and stylesheets to test fixtures |
| panel/types.ts | Extend WebviewUserOptions and WebviewMessage for new options |
| panel/panel.ts | Store per-resource options, handle option changes, expose add/remove |
| panel/manager.ts | Expose activePreview for command implementations |
| panel/content.tsx | Render chip container and toggle button in toolbar |
| lsp/server.ts | Load context/stylesheet JSON and pass to read |
| extension.ts | Register four new commands |
| command/addResources.ts | Implement commands to add/remove files |
| vscode-webview/{toolbar.ts,state.ts} | Render chips client-side, sync state, bind toolbar events |
| media/style.css | Style toolbar buttons, badge, chips, tooltips |
| package.json | Declare new commands |
Comments suppressed due to low confidence (1)
packages/poml-vscode/panel/content.tsx:236
- In JSX, use
classNameinstead ofclassfor element attributes. Replaceclass="main-container"withclassName="main-container".
result = <div class="main-container"><CodeBlock content={ir} /></div>;
| $('#add-context').on('click', function () { | ||
| messaging.postCommand('poml.addContextFile', []); | ||
| }); | ||
|
|
||
| $('#add-stylesheet').on('click', function () { | ||
| messaging.postCommand('poml.addStylesheetFile', []); | ||
| }); | ||
|
|
||
| $(document).on('click', '.context .remove', function () { | ||
| const file = $(this).parent().data('file'); | ||
| messaging.postCommand('poml.removeContextFile', [file]); | ||
| }); | ||
|
|
||
| $(document).on('click', '.stylesheet .remove', function () { |
Copilot
AI
Jul 8, 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.
Event handlers inside chipUpdate are reattached on every update, leading to duplicate listeners and potential leaks. Move handler binding outside the update function or call .off() before .on().
| $('#add-context').on('click', function () { | |
| messaging.postCommand('poml.addContextFile', []); | |
| }); | |
| $('#add-stylesheet').on('click', function () { | |
| messaging.postCommand('poml.addStylesheetFile', []); | |
| }); | |
| $(document).on('click', '.context .remove', function () { | |
| const file = $(this).parent().data('file'); | |
| messaging.postCommand('poml.removeContextFile', [file]); | |
| }); | |
| $(document).on('click', '.stylesheet .remove', function () { | |
| $('#add-context').off('click').on('click', function () { | |
| messaging.postCommand('poml.addContextFile', []); | |
| }); | |
| $('#add-stylesheet').off('click').on('click', function () { | |
| messaging.postCommand('poml.addStylesheetFile', []); | |
| }); | |
| $(document).off('click', '.context .remove').on('click', '.context .remove', function () { | |
| const file = $(this).parent().data('file'); | |
| messaging.postCommand('poml.removeContextFile', [file]); | |
| }); | |
| $(document).off('click', '.stylesheet .remove').on('click', '.stylesheet .remove', function () { |
packages/poml-vscode/lsp/server.ts
Outdated
| let context: { [key: string]: any } = {}; | ||
| for (const c of params.contexts ?? []) { | ||
| try { | ||
| context = { ...context, ...parseJsonWithBuffers(readFileSync(c, 'utf-8')) }; |
Copilot
AI
Jul 8, 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.
Using readFileSync in an async handler blocks the event loop. Consider using fs.promises.readFile or other async I/O to avoid blocking the LSP server.
| context = { ...context, ...parseJsonWithBuffers(readFileSync(c, 'utf-8')) }; | |
| context = { ...context, ...parseJsonWithBuffers(await fsPromises.readFile(c, 'utf-8')) }; |
| <ButtonContent icon="check" content={item.content} /> | ||
|
|
||
| <div | ||
| className={`button onoff ${props.contexts.length + props.stylesheets.length ? 'active' : ''}`} id="context-stylesheet" |
Copilot
AI
Jul 8, 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.
Interactive toolbar items should use semantic roles and be keyboard-focusable. Add role="button" and tabIndex={0} to this <div> for better accessibility.
| className={`button onoff ${props.contexts.length + props.stylesheets.length ? 'active' : ''}`} id="context-stylesheet" | |
| className={`button onoff ${props.contexts.length + props.stylesheets.length ? 'active' : ''}`} id="context-stylesheet" | |
| role="button" tabIndex={0} |
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: GitHub Actions CI Runs on All Branches
The GitHub Actions pull_request workflow trigger in test.yml no longer restricts CI runs to main and master branches. The removal of the branches configuration means it now triggers on pull requests to any branch, potentially causing unnecessary CI runs.
.github/workflows/test.yml#L9-L12
poml/.github/workflows/test.yml
Lines 9 to 12 in d80c76a
| - master | |
| pull_request: | |
| workflow_dispatch: |
Bug: Missing Command Tests Reduce Coverage
The expected commands are registered test in packages/poml-vscode/tests/commands.test.ts is missing the newly added commands: 'poml.addContextFile', 'poml.addStylesheetFile', 'poml.removeContextFile', and 'poml.removeStylesheetFile'. This reduces test coverage as the registration and functionality of these commands are not verified.
packages/poml-vscode/tests/commands.test.ts#L8-L18
poml/packages/poml-vscode/tests/commands.test.ts
Lines 8 to 18 in d80c76a
| const cmds = await vscode.commands.getCommands(true); | |
| const expected = [ | |
| 'poml.test', | |
| 'poml.testNonChat', | |
| 'poml.testRerun', | |
| 'poml.testAbort', | |
| 'poml.showPreview', | |
| 'poml.showPreviewToSide', | |
| 'poml.showLockedPreviewToSide', | |
| 'poml.showSource', | |
| 'poml.telemetry.completion', |
Was this report helpful? Give feedback by reacting with 👍 or 👎
Summary
Testing
npm run compilenpm run build-extensionxvfb-run -a npm run test-vscodehttps://chatgpt.com/codex/tasks/task_e_685a906966bc832eaea41e69ca7e38b3