Skip to content

Conversation

@ultmaster
Copy link
Contributor

Summary

  • add commands to add/remove context and stylesheet files for the active preview
  • display selected files as removable chips in the toolbar
  • persist context and stylesheet selections for each previewed document
  • update webview when selections change
  • register commands for activation and fix command registration test

Testing

  • npm run compile
  • npm run build-extension
  • xvfb-run -a npm run test-vscode

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

cursor[bot]

This comment was marked as outdated.

…dd-buttons-to-add-context-and-stylesheet
cursor[bot]

This comment was marked as outdated.

…dd-buttons-to-add-context-and-stylesheet
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@cursor
Copy link

cursor bot commented Jul 1, 2025

🚨 BugBot couldn't run

BugBot is experiencing high demand right now. Try again in a few minutes by commenting "bugbot run" (requestId: serverGenReqId_723c49c3-1556-46e3-8f40-c96a856d1099).

@cursor
Copy link

cursor bot commented Jul 1, 2025

🚨 BugBot couldn't run

BugBot 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
@cursor
Copy link

cursor bot commented Jul 1, 2025

🚨 BugBot couldn't run

BugBot is experiencing high demand right now. Try again in a few minutes by commenting "bugbot run" (requestId: serverGenReqId_f9fbc9d1-867f-4297-bd5a-3708b6586d55).

@cursor
Copy link

cursor bot commented Jul 1, 2025

🚨 BugBot couldn't run

BugBot is experiencing high demand right now. Try again in a few minutes by commenting "bugbot run" (requestId: serverGenReqId_7d0452ec-60d0-4ce2-8cd9-24b0cdebcd70).

@ultmaster ultmaster added the v0.1 label Jul 3, 2025
@ultmaster ultmaster requested a review from Copilot July 8, 2025 08:05
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

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 contexts and stylesheets fields in preview parameters, panel state, and tests
  • Persist per-resource selections in POMLWebviewPanel and 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 className instead of class for element attributes. Replace class="main-container" with className="main-container".
      result = <div class="main-container"><CodeBlock content={ir} /></div>;

Comment on lines 79 to 92
$('#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 () {
Copy link

Copilot AI Jul 8, 2025

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().

Suggested change
$('#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 () {

Copilot uses AI. Check for mistakes.
let context: { [key: string]: any } = {};
for (const c of params.contexts ?? []) {
try {
context = { ...context, ...parseJsonWithBuffers(readFileSync(c, 'utf-8')) };
Copy link

Copilot AI Jul 8, 2025

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.

Suggested change
context = { ...context, ...parseJsonWithBuffers(readFileSync(c, 'utf-8')) };
context = { ...context, ...parseJsonWithBuffers(await fsPromises.readFile(c, 'utf-8')) };

Copilot uses AI. Check for mistakes.
<ButtonContent icon="check" content={item.content} />

<div
className={`button onoff ${props.contexts.length + props.stylesheets.length ? 'active' : ''}`} id="context-stylesheet"
Copy link

Copilot AI Jul 8, 2025

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.

Suggested change
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}

Copilot uses AI. Check for mistakes.
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: 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

- master
pull_request:
workflow_dispatch:

Fix in CursorFix in Web


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

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',

Fix in CursorFix in Web


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

@ultmaster ultmaster merged commit 2ee85fa into main Jul 8, 2025
4 checks passed
@ultmaster ultmaster deleted the codex/add-buttons-to-add-context-and-stylesheet branch August 27, 2025 00:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants