Skip to content

feat: add expression evaluation codelens#72

Merged
ultmaster merged 7 commits intomainfrom
v772xr-codex/implement-evaluation-result-display-in-lsp-server
Aug 5, 2025
Merged

feat: add expression evaluation codelens#72
ultmaster merged 7 commits intomainfrom
v772xr-codex/implement-evaluation-result-display-in-lsp-server

Conversation

@ultmaster
Copy link
Contributor

Summary

  • log all evaluations for expressions and return latest result by index
  • track evaluations per token range to disambiguate duplicate expressions
  • verify expression evaluation recording with new tests

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
  • xvfb-run -a npm run test-vscode (failed: module load errors, 8 tests failed)

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

Copilot AI review requested due to automatic review settings August 5, 2025 07:09

This comment was marked as outdated.

@ultmaster ultmaster requested a review from Copilot August 5, 2025 09:57
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 expression evaluation codelens functionality to provide interactive evaluation of expressions in POML files. The change enables users to see evaluation results directly in the editor through codelens commands.

  • Tracks expression evaluations per token range to handle duplicate expressions separately
  • Implements codelens provider to show "Evaluate" commands for each expression
  • Records evaluation history for each expression with position-based tracking

Reviewed Changes

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

File Description
packages/poml/file.tsx Adds expression token extraction, evaluation tracking, and recording mechanisms
packages/poml/tests/file.test.tsx Adds tests to verify expression evaluation recording functionality
packages/poml-vscode/lsp/server.ts Implements codelens provider and execute command handler for expression evaluation
packages/poml-vscode/tests/lsp.test.ts Adds commented test case for expression evaluation command
Comments suppressed due to low confidence (1)

packages/poml-vscode/lsp/server.ts:238

  • Missing semicolon after the vscodeRange object assignment.
      }

Comment on lines 37 to 44
export interface PomlToken {
type: 'element' | 'attribute' | 'attributeValue';
type: 'element' | 'attribute' | 'attributeValue' | 'expression';
range: Range;
element: string;
element?: string;
attribute?: string; // specified only if it's an attribute
value?: string; // specified only if it's an attribute value
expression?: string; // specified only if it's an expression
}
Copy link

Copilot AI Aug 5, 2025

Choose a reason for hiding this comment

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

The PomlToken interface change makes the 'element' property optional while adding 'expression' as optional. This creates ambiguity about which properties should be present for different token types. Consider using a discriminated union type or separate interfaces for different token types to ensure type safety.

Copilot uses AI. Check for mistakes.
if (range) {
this.recordEvaluation(range, errMessage);
}
this.reportError(errMessage, range, e);
Copy link

Copilot AI Aug 5, 2025

Choose a reason for hiding this comment

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

The error handling logic has been restructured but the return statement is now outside the catch block. This means the function will always return an empty string even when evaluation succeeds, which breaks the expression evaluation functionality.

Copilot uses AI. Check for mistakes.
type: 'expression',
range: {
start: range.start + match.index,
end: range.start + match.index + match[0].length - 1,
Copy link

Copilot AI Aug 5, 2025

Choose a reason for hiding this comment

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

The end position calculation subtracts 1, but this may cause inconsistency with how ranges are handled elsewhere. The range should likely end at the exact position after the last character, not one position before it.

Suggested change
end: range.start + match.index + match[0].length - 1,
end: range.start + match.index + match[0].length,

Copilot uses AI. Check for mistakes.
type: 'expression',
range: {
start: pos.start + match.index,
end: pos.start + match.index + match[0].length - 1,
Copy link

Copilot AI Aug 5, 2025

Choose a reason for hiding this comment

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

Same issue as above - the end position calculation subtracts 1, which may cause range inconsistency.

Suggested change
end: pos.start + match.index + match[0].length - 1,
end: pos.start + match.index + match[0].length,

Copilot uses AI. Check for mistakes.
@ultmaster ultmaster enabled auto-merge (squash) August 5, 2025 10:39
@ultmaster ultmaster merged commit ff497a2 into main Aug 5, 2025
3 checks passed
@ultmaster ultmaster deleted the v772xr-codex/implement-evaluation-result-display-in-lsp-server 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