Skip to content

Support per-resource options for prompts#62

Merged
ultmaster merged 2 commits intomainfrom
codex/refactor-resourceoptions-handling-in-settings
Jul 29, 2025
Merged

Support per-resource options for prompts#62
ultmaster merged 2 commits intomainfrom
codex/refactor-resourceoptions-handling-in-settings

Conversation

@ultmaster
Copy link
Contributor

Summary

  • manage contexts and stylesheets per resource in SettingsManager
  • use the central resource options store from POMLWebviewPanel
  • honor configured resource options in test command

Testing

  • npm run build-webview
  • npm run build-cli
  • npm run lint
  • npm test
  • 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_68886c324158832eb716cae990bb7119

Copilot AI review requested due to automatic review settings July 29, 2025 07:53
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 centralizes resource options management by moving contexts and stylesheets handling from individual webview panels to a shared SettingsManager. The change enables consistent per-resource configuration across the extension and properly honors these settings in test commands.

  • Migrated resource options storage from POMLWebviewPanel to SettingsManager for centralized management
  • Implemented automatic detection and loading of associated context and stylesheet files
  • Updated test command to use the centralized resource options instead of empty arrays

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/poml-vscode/settings.ts Added ResourceOptions interface and centralized storage/loading logic in SettingsManager
packages/poml-vscode/panel/panel.ts Removed local resource options management and integrated with central SettingsManager
packages/poml-vscode/command/testCommand.ts Updated to use centralized resource options instead of hardcoded empty arrays

Comment on lines +157 to +167
const addIfExists = (arr: string[], file: string) => {
if (fs.existsSync(file)) {
arr.push(file);
return true;
}
return false;
};

let changed = false;
changed = addIfExists(contexts, `${base}.context.json`) || changed;
changed = addIfExists(stylesheets, `${base}.stylesheet.json`) || changed;
Copy link

Copilot AI Jul 29, 2025

Choose a reason for hiding this comment

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

Using synchronous file operations (fs.existsSync) in the main thread can block the VS Code extension host. Consider using fs.promises.access() with proper error handling for better performance.

Suggested change
const addIfExists = (arr: string[], file: string) => {
if (fs.existsSync(file)) {
arr.push(file);
return true;
}
return false;
};
let changed = false;
changed = addIfExists(contexts, `${base}.context.json`) || changed;
changed = addIfExists(stylesheets, `${base}.stylesheet.json`) || changed;
const addIfExists = async (arr: string[], file: string): Promise<boolean> => {
try {
await fs.promises.access(file, fs.constants.F_OK);
arr.push(file);
return true;
} catch {
return false;
}
};
let changed = false;
changed = await addIfExists(contexts, `${base}.context.json`) || changed;
changed = await addIfExists(stylesheets, `${base}.stylesheet.json`) || changed;

Copilot uses AI. Check for mistakes.
// If we have changed resources, cancel any pending updates
const isResourceChange = resource.fsPath !== this._pomlUri.fsPath;
if (isResourceChange) {
if (isResourceChange || this.firstUpdate) {
Copy link

Copilot AI Jul 29, 2025

Choose a reason for hiding this comment

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

The variable 'this.firstUpdate' is referenced but not defined in the visible code context. This will cause a runtime error if firstUpdate is not a class property.

Copilot uses AI. Check for mistakes.
@ultmaster ultmaster merged commit 3458d35 into main Jul 29, 2025
3 checks passed
@ultmaster ultmaster deleted the codex/refactor-resourceoptions-handling-in-settings branch August 27, 2025 00:53
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