cursorless
cursorless copied to clipboard
Cheat sheet doesn't work with remote vscode window focused
When I do "cursorless cheat sheet", I get the below stacktrace and nothing shows up.
Do I need to generate the sheet first?
I'm at 1b30ce6f5efc725822af75e9d964c677b8dfe307 from Aug 4.
12022-08-08 19:57:04 ERROR 10: talon/scripting/talon_script.py:589|
9: talon/scripting/talon_script.py:297|
8: talon/scripting/talon_script.py:556|
7: talon/scripting/actions.py:85 |
6: talon/scripting/types.py:411|
5: user/cursorless-talon/src/cheatsheet_html/cheat_sheet.py:25 | actions.user.vscode_with_plugin_and_wa..
4: talon/scripting/actions.py:85 |
3: talon/scripting/types.py:411|
2: user/knausj_talon/apps/vscode/command_client/command_client.py:331| run_vscode_command(
1: user/knausj_talon/apps/vscode/command_client/command_client.py:204| raise Exception(decoded_contents["error"])
Exception: A system error occurred (ENOENT: no such file or directory, open '/var/folders/rv/79wntgzj54x17mxdtl_jp62h0020y5/T/tmpvtu9y125/cheatsheet.html')
[The below error was raised while handling the above exception(s)]
2022-08-08 19:57:04 ERROR cb error topic="phrase" cb=<bound method SpeechSystem.engine_event of <talon.scripting.speech_system.SpeechSystem object at 0x109629630>>
30: lib/python3.9/threading.py:937* # cron thread
29: lib/python3.9/threading.py:980*
28: lib/python3.9/threading.py:917*
27: talon/cron.py:155|
26: talon/cron.py:106|
25: talon/vad.py:21 |
24: talon/scripting/speech_system.py:356|
23: talon/engines/w2l.py:709|
22: talon/scripting/dispatch.py:105|
21: talon/scripting/dispatch.py:144|
20: talon/scripting/dispatch.py:133|
19: talon/scripting/rctx.py:233| # 'phrase' main:_redispatch()
18: talon/scripting/speech_system.py:63 |
17: talon/scripting/dispatch.py:105|
16: talon/scripting/dispatch.py:144|
15: talon/scripting/dispatch.py:133|
14: ------------------------------------# [stack splice]
13: talon/scripting/rctx.py:233| # 'phrase' main:engine_event()
12: talon/scripting/speech_system.py:410|
11: talon/scripting/actions.py:85 |
10: talon/scripting/types.py:411|
9: talon/scripting/core/core.py:103|
8: talon/scripting/actions.py:85 |
7: talon/scripting/types.py:411|
6: talon/scripting/core/core.py:132|
5: talon/scripting/actions.py:85 |
4: talon/scripting/types.py:411|
3: talon/scripting/core/core.py:139|
2: talon/scripting/talon_script.py:690|
1: talon/scripting/talon_script.py:593|
talon.scripting.talon_script.TalonScriptError:
in script at /Users/dgrogan/.talon/user/cursorless-talon/src/cursorless.talon:26:
> user.cursorless_cheat_sheet_show_html()
Exception: A system error occurred (ENOENT: no such file or directory, open '/var/folders/rv/79wntgzj54x17mxdtl_jp62h0020y5/T/tmpvtu9y125/cheatsheet.html')
Strange. What does it say in dev tools in VSCode?
Oh. I had been trying to the show the cheatsheet from a vscode window connected to a remote workspace. The cheatsheet shows up awesomely when a local workspace vscode window is focused.
Sorry for the noise!
(devtools didn't show anything)
Ohh right. Hmm. Will have to think about this one. Worth keeping open
The problem
The problem here is that Cursorless prefers to run on the remote machine, so any filesystem references will be there.
Possible solutions
A couple possible approaches:
Local HTTP server
One possibility is to switch to using a local HTTP server, and then rely on VSCode port forwarding (via asExternalUri). This approach would also address #875.
The HTTP server code would look something like the following:
import http from "http";
const requestListener = function (req, res) {
fs.readFile("~/.cursorless/cheatsheet/index.html")
.then(contents => {
res.setHeader("Content-Type", "text/html");
res.writeHead(200);
res.end(contents);
})
};
const server = http.createServer(requestListener);
server.listen(0, "localhost");
I don't think a server this simple should present a security risk
Separate cheatsheet extension
We could create a separate extension upon which Cursorless depends, that is just used for the cheatsheet. This extension would only be allowed to run on the local machine.
We could also combine the above approaches and have a separate extension that always runs locally, and uses a local http server
Is there a reason to prefer Cursorless runs where the workspace is? Can we move it to the UI side only as a solution?
Good call @auscompgeek that seems like the easiest solution. Updated the description with solution based on that suggestion