continue icon indicating copy to clipboard operation
continue copied to clipboard

Fix: getPlatform to return "unknown" when environment isWeb

Open etherandrius opened this issue 9 months ago • 7 comments
trafficstars

Description

When running VS Code web users will see wrong shortcuts if the remote system is a Linux box while the user is using a Mac.

See example: The hint on the right is showing CTRL while the text box on the left is showing the CMD key. image

When running VS Code remotely it's not possible to determine users platform and node.os.platform should not be trusted.

The change explicitly marks platform as unknown if vscode.env.uiKind === Web. This is relevant in remote workspaces such as Coder/Github codespaces/Project IDX etc.

If the platform is unknown show both CMD and CTRL keys.

VS Code extension API does not provide a way to identify the actual users platform.

  • See https://github.com/microsoft/vscode/issues/106525 (the api is not provided)
  • And https://github.com/microsoft/vscode/issues/10471 (getContext API which would solve this has not been implemented)

I appreciate this solution is not-ideal. Not sure what the proper solution the code probably needs to leverage the when api.

Checklist

  • [x] The relevant docs, if any, have been updated or created
  • [x] The relevant tests, if any, have been updated or created

Screenshots

Hint SVG formatting is still sane after the changes image

^ Platform detected as unknown

image

^ Platform detected as linux

Testing instructions

Install continue extension inside github codespaces you will always see linux based shortcuts even when running on a Mac.

etherandrius avatar Feb 04 '25 14:02 etherandrius

Deploy Preview for continuedev canceled.

Name Link
Latest commit 78a102246f799ce8ecfad113e0e0ea9e63097181
Latest deploy log https://app.netlify.com/sites/continuedev/deploys/67a325815391b30008ac9801

netlify[bot] avatar Feb 04 '25 14:02 netlify[bot]

After the merge image

@RomneyDa let me know if you prefer something other than Ctrl/⌘

etherandrius avatar Feb 05 '25 09:02 etherandrius

@etherandrius we should be able to request the platform from the webview, which knows the correct one. Can we do this and then remove the "+" sign?

sestinj avatar Feb 05 '25 21:02 sestinj

@sestinj sure thing.

Could you point me to how the webview could send this kind of information to the node process? If you could link me the types used to communicate between the two that should be enough

etherandrius avatar Feb 06 '25 10:02 etherandrius

@sestinj Thinking about this a bit more sending this information might not be possible? The webView is not loaded until users open the chat interface. Meaning we have to handle the edge case of users never opening the webView.

Please correct me if I have the wrong understanding.

etherandrius avatar Feb 06 '25 14:02 etherandrius

@sestinj @RomneyDa friendly bump

etherandrius avatar Feb 11 '25 13:02 etherandrius

✨ No issues found! Your code is sparkling clean! ✨

recurseml[bot] avatar Jun 13 '25 21:06 recurseml[bot]

Closing because stale, @etherandrius if you make updates would like to merge, also making note to look into reimplementing

RomneyDa avatar Jul 10 '25 01:07 RomneyDa