Skip to content

Add selective alias disable and version check#53

Merged
ultmaster merged 3 commits intomainfrom
codex/add-support-for-meta-tags-in-poml
Jul 25, 2025
Merged

Add selective alias disable and version check#53
ultmaster merged 3 commits intomainfrom
codex/add-support-for-meta-tags-in-poml

Conversation

@ultmaster
Copy link
Contributor

@ultmaster ultmaster commented Jul 16, 2025

Summary

  • store disabled component aliases in PomlFile
  • allow getComponent to take a disabled set
  • skip disabled aliases when searching and suggesting
  • expand meta tag tests to cover alias-only disabling
  • Support minVersion and maxVersion check

Testing

  • npm run build-webview
  • npm run build-cli
  • npm run lint (with warnings)
  • npm test
  • python -m pytest python/tests

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

Copilot AI review requested due to automatic review settings July 16, 2025 10:10

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: Autocomplete Includes Disabled Components

Autocomplete suggestions generated by findComponentWithPrefix (called within handleElementNameCloseCompletion) incorrectly include disabled components. This creates inconsistent behavior, as other component lookup methods correctly filter based on the disabledComponents set.

packages/poml/file.tsx#L976-L977

poml/packages/poml/file.tsx

Lines 976 to 977 in bbf0867

if (prefix) {
candidates.push(...this.findComponentWithPrefix(prefix, true, excludedComponents));

packages/poml/file.tsx#L1072-L1132

poml/packages/poml/file.tsx

Lines 1072 to 1132 in bbf0867

}
private findComponentWithPrefix(
prefix: string | undefined,
publicOnly: boolean,
excludedComponents?: string[]
): string[] {
const candidates: string[] = [];
for (const component of listComponents()) {
if (publicOnly && !component.isPublic()) {
continue;
}
if (excludedComponents && excludedComponents.includes(component.name)) {
continue;
}
let nameMatch: string | undefined = undefined;
if (!prefix || component.name.toLowerCase().startsWith(prefix.toLowerCase())) {
nameMatch = component.name;
} else {
const candidates: string[] = [];
for (const alias of component.getAliases()) {
if (alias.toLowerCase().startsWith(prefix.toLowerCase())) {
candidates.push(alias);
// One component can have at most one alias match.
break;
}
}
// Match hyphen case.
for (const alias of component.getAliases(false)) {
const aliasHyphen = camelToHyphenCase(alias);
if (aliasHyphen.startsWith(prefix.toLowerCase())) {
candidates.push(aliasHyphen);
break;
}
}
// Try to see if there is a match in the exact case.
for (const candidate of candidates) {
if (candidate.startsWith(prefix)) {
nameMatch = candidate;
break;
}
}
if (!nameMatch && candidates) {
nameMatch = candidates[0];
}
}
if (nameMatch) {
candidates.push(nameMatch);
}
}
return candidates;
}
}
/**
* XML utility functions.
*/
const evalWithVariables = (text: string, context: { [key: string]: any }): any => {
const variableNames = Object.keys(context);
const variableValues = Object.values(context);

Fix in CursorFix in Web


BugBot free trial expires on July 22, 2025
Learn more in the Cursor dashboard.

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

@ultmaster ultmaster changed the title Add selective alias disable in Poml Add selective alias disable and version check Jul 25, 2025
@ultmaster ultmaster requested a review from Copilot July 25, 2025 08:30
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 selective component alias disabling and version checking functionality to the POML system. It enables fine-grained control over which components are available during parsing and provides version compatibility checks.

  • Implements version range validation with minVersion and maxVersion checks
  • Adds selective component/alias disabling through meta tag configuration
  • Expands component lookup functions to respect disabled component sets

Reviewed Changes

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

File Description
packages/poml/version.ts Exports POML version constant for version checking
packages/poml/tests/meta.test.tsx Comprehensive test coverage for version checks and component disabling
packages/poml/file.tsx Core implementation of meta tag handling, version validation, and disabled component tracking
packages/poml/base.tsx Updates component registry to support disabled component filtering

}
const op = token[0];
const name = token.slice(1).toLowerCase();
if (!name) {
Copy link

Copilot AI Jul 25, 2025

Choose a reason for hiding this comment

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

The component name should be validated to ensure it's not empty after trimming and slicing. Consider adding a check for empty names after the slice operation.

Suggested change
if (!name) {
if (!name.trim()) {

Copilot uses AI. Check for mistakes.
@@ -1090,6 +1151,22 @@ const camelToHyphenCase = (text: string): string => {
return text.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
};

Copy link

Copilot AI Jul 25, 2025

Choose a reason for hiding this comment

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

The compareVersions function lacks documentation explaining its return values (-1, 0, 1) and expected input format. Consider adding a JSDoc comment to clarify the semantic version comparison behavior.

Suggested change
/**
* Compares two semantic version strings (e.g., "1.2.3").
*
* @param a - The first version string in the format "x.y.z".
* @param b - The second version string in the format "x.y.z".
* @returns -1 if `a` is less than `b`, 1 if `a` is greater than `b`, and 0 if they are equal.
*/

Copilot uses AI. Check for mistakes.
Comment on lines 776 to 787
public getComponent(
name: string,
returnReasonIfNotFound: boolean = false
returnReasonIfNotFound: boolean | Set<string> = false,
disabled: Set<string> | undefined = undefined
): PomlComponent | string | undefined {
if (returnReasonIfNotFound instanceof Set) {
disabled = returnReasonIfNotFound;
returnReasonIfNotFound = false;
}

const hyphenToCamelCase = (s: string) => {
return s.toLowerCase().replace(/-([a-z])/g, g => g[1].toUpperCase());
Copy link

Copilot AI Jul 25, 2025

Choose a reason for hiding this comment

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

The parameter overloading pattern with returnReasonIfNotFound accepting both boolean and Set creates an unclear API. Consider using separate method overloads or a clearer parameter structure to improve type safety and readability.

Copilot uses AI. Check for mistakes.
Comment on lines 1155 to 1156
const pa = a.split('.').map(n => parseInt(n));
const pb = b.split('.').map(n => parseInt(n));
Copy link

Copilot AI Jul 25, 2025

Choose a reason for hiding this comment

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

parseInt without a radix parameter can lead to unexpected behavior with leading zeros. Use parseInt(n, 10) to ensure decimal parsing, or consider using Number() for cleaner conversion.

Suggested change
const pa = a.split('.').map(n => parseInt(n));
const pb = b.split('.').map(n => parseInt(n));
const pa = a.split('.').map(n => parseInt(n, 10));
const pb = b.split('.').map(n => parseInt(n, 10));

Copilot uses AI. Check for mistakes.
@ultmaster ultmaster merged commit 945db27 into main Jul 25, 2025
3 checks passed
@ultmaster ultmaster deleted the codex/add-support-for-meta-tags-in-poml 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