Skip to content

Vscode extension#43

Merged
Bastacyclop merged 18 commits into
mainfrom
vscode-extension
Jun 30, 2026
Merged

Vscode extension#43
Bastacyclop merged 18 commits into
mainfrom
vscode-extension

Conversation

@Ultra-MG

@Ultra-MG Ultra-MG commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

This PR adds the initial OptiTrust VS Code extension and integrates it with the in-tree OptiTrust workflow.

Main features:

  • Detect OptiTrust workspaces and project roots.
  • Run OptiTrust view commands from VS Code.
  • Add a dedicated OptiTrust output panel.
  • Support step diff, full trace, step trace, and redo-last-view commands.
  • Support running the current test and rerunning previous tests.
  • Add default configurable keybindings.
  • Add associated-file discovery with a top-right editor button.
  • Open generated/expected files and compare outputs.
  • Register .opti as the OptiLambda file extension.
  • Add OptiLambda syntax highlighting and language configuration.
  • Display generated diff and trace HTML inside VS Code webviews.
  • Support C/C++ and OptiLambda representation switching in diff and trace views.
  • Support OptiLambda Surface, Internal, and Fully-Typed representations.
  • Add a health check for required tools and backend build status.
  • Add README documentation and .vsix packaging support.

Notes:

  • The extension does not replace OCaml-LSP.
  • .ml files remain handled by the normal OCaml extension.
  • .opti remains one language registration.
  • C/C++ remains the default view.

@Ultra-MG Ultra-MG requested review from Bastacyclop and charguer June 9, 2026 08:34
@Bastacyclop

Bastacyclop commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Hey @Ultra-MG ,

I'm currently installing the extension.

I get the following warnings during npm install:

npm WARN EBADENGINE [...]
[...]
npm WARN deprecated [...]
[...]
3 vulnerabilities (1 moderate, 2 high)

It is then impossible to run npm run package:

ReferenceError: File is not defined
    at Object.<anonymous> (/home/thomas/code/optitrust/tools/vscode-optitrust/node_modules/undici/lib/web/webidl/index.js:537:48)
    at Module._compile (node:internal/modules/cjs/loader:1356:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1414:10)
    at Module.load (node:internal/modules/cjs/loader:1197:32)
    at Module._load (node:internal/modules/cjs/loader:1013:12)
    at Module.require (node:internal/modules/cjs/loader:1225:19)
    at require (node:internal/modules/helpers:177:18)
    at Object.<anonymous> (/home/thomas/code/optitrust/tools/vscode-optitrust/node_modules/undici/lib/web/fetch/util.js:12:20)
    at Module._compile (node:internal/modules/cjs/loader:1356:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1414:10)

@Bastacyclop

Copy link
Copy Markdown
Collaborator

I have Node.js v18.19.1 though, and I see that you ask for 20+.

@Bastacyclop

Copy link
Copy Markdown
Collaborator

Re-running with node v24.18.0 (npm v11.16.0):

npm warn allow-scripts 3 packages have install scripts not yet covered by allowScripts:
npm warn allow-scripts   @vscode/vsce-sign@2.0.9 (install: (install scripts present))
npm warn allow-scripts   esbuild@0.28.1 (install: (install scripts present))
npm warn allow-scripts   keytar@7.9.0 (install: node-gyp rebuild)
npm warn allow-scripts
npm warn allow-scripts Run `npm approve-scripts --allow-scripts-pending` to review, or `npm approve-scripts <pkg>` to allow.

@Bastacyclop

Copy link
Copy Markdown
Collaborator

Pressing F6 on lines of the dot.ml script does open the diff as expected, however if I take the diff tab, press "Move into New Window", and then press F6 again on another line, a new diff window is opened instead of updating the previous one as desired.

@Bastacyclop

Copy link
Copy Markdown
Collaborator

If you can address the vulnerabilities being reported and the F6 window update behaviour, then this seems ready to merge and a nice quality-of-life improvement!

@Ultra-MG

Ultra-MG commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator Author

hey @Bastacyclop

For the F6 diff view ,I just tried this on my side, and it seems to work for me. When I press F6 after moving the diff to a new window, the existing window is brought back into focus rather than creating a second diff for the same line.
I initially understood your request as avoiding having two diff windows open for the same line at the same time, which is why I implemented it that way. If what you meant instead is that the existing detached diff window should be updated with the newly selected line rather than opening a new diff, then I didn't implement that behavior. If that's the intended behavior, I'll work on it now.

Regarding the vulnerabilities, I fixed the npm audit warnings by updating @vscode/vsce to a newer version. The reported vulnerabilities came from a transitive dependency of vsce, which is only used for building/packaging the extension and is not part of the extension runtime. After the update, I re-ran npm install, npm audit, and the build/packaging checks to confirm that the warnings were resolved.

@Bastacyclop

Copy link
Copy Markdown
Collaborator

yes, the intended behaviour is that the diff window is updated even if two different lines are queried. one might wonder if it should be updated if two different files are queried. I'm thinking that always updating the same window by default might make sense, if we have a way to disconnect a window from these updates in order to keep it open.

@Bastacyclop Bastacyclop Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

btw, is it normal that this file is so big ? should it be committed ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, this file is generated, not written manually. It is produced by npm run build:webview from tools/web_view/optitrust_syntax_highlight.mjs using esbuild.
it is large because it bundles Shiki and its dependencies
I added this so the diff webview can get syntax highlighting closer to VS Code’s own highlighting instead of relying only on the older Highlight.js styling.
What we can do is remove it from the commit and generate it during packaging.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

yes let's remove it from the commit unless there is a good reason to save its contents

@Ultra-MG

Copy link
Copy Markdown
Collaborator Author

Pressing F6 on lines of the dot.ml script does open the diff as expected, however if I take the diff tab, press "Move into New Window", and then press F6 again on another line, a new diff window is opened instead of updating the previous one as desired.

can you try it again now?

@Bastacyclop Bastacyclop merged commit 41e8c36 into main Jun 30, 2026
1 check passed
@Bastacyclop Bastacyclop deleted the vscode-extension branch June 30, 2026 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants