-
Notifications
You must be signed in to change notification settings - Fork 711
live-preview: Turn the live preview into a separate process #8836
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
3f02da3
to
114a5ab
Compare
It is slowly coming back together: Screencast.From.2025-07-04.13-20-38.mp4Still todo: The WASM side of the story. |
9292b55
to
828b154
Compare
This PR supports the WASM-based LSP together with the WASM-based preview and the native LSP together with the native preview. It does not support native LSP with WASM preview. I doubt anyone is using the WASM preview if not needed due to running in the web -- it is noticeably slower. So I would prefer to just add a PR that just removes this mixed mode entirely over adding a commit that unbreaks mixed mode. |
0a174f8
to
c365fb0
Compare
The Mac-specific code also needs adaptation: The "Quit hides the UI" hack is no longer needed, the rest might be able to exist in a normal Slint-based Menu bar. |
c365fb0
to
ddf7285
Compare
Ah great, so if I quit it, the LSP will automatically restart it the next time I choose "Show Preview"? |
@tronical: That is the idea, yes. I did remove some Mac-specific code -- to make the PR compile. I am not sure I am doing the right thing though. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!
Just a bit of polishing to do, especially with regards to error reporting.
[...] It does not support native LSP with WASM preview.
Why not?
I doubt anyone is using the WASM preview if not needed due to running in the web
I sometimes do, and other people use the "provided by editor" setting.
Also, this is required to work on code space or everywhere the LSP is running remote.
The Mac-specific code also needs adaptation: The "Quit hides the UI" hack is no longer needed, the rest might be able to exist in a normal Slint-based Menu bar.
@tronical will have to comment on that.
I noticed that the apple specific code is not called anymore, so I commented it out for the moment -- just to see whether the CI goes green :-) I need to reenable it -- maybe as a normal Slint Menu? We probably want to hide that in Slintpad though, so that needs to be configurable. |
ddf7285
to
c01ca76
Compare
The latest version mostly ignored @ogoffart's comments... Sorry. But it has two new commits:
Up next: Fix @ogoffart's comments. |
ec82cf6
to
8fbeb63
Compare
I think this is all :-) What shall we do about the menu though? I have now unconditionally added a menu that has "Reload" and "Always on top" -- like the Mac had. I assume the Mac will add in its standard menu items? I am not happy with that approach though: For starters "Always on top" does not work for me on wayland, so I'd love to hide that. Then the menu wastes vertical screen space (not an issue ion the mac) and will also look strange in slintpad. Any chance to make the menu conditional in slint? So that I can show/hide it programmatically? Or should I remove it entirely and hope for Simon to create a new menu from Rust code using Muda? I can port the old muda-based menu into something that might work, but I have no mac to fix it on. |
06ac412
to
236162e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried it and it works well, almost transparently, we don't see there is any other process. Good job!
A few bug i noticed while trying:
- then the preview crash, it is not reported to the crash reporter
- Clicking on "show preview" reset the style to native
- When lsp process crashes, the live-preview process doesn't quit.
let communication_handle = std::thread::spawn(move || -> Result<(), String> { | ||
let reader = std::io::BufReader::new(from_child); | ||
for line in reader.lines() { | ||
let line = line.map_err(|e| e.to_string())?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd still like to see error reporting.
I've just tried it: When the preview crashes, nothing happens (just that the preview stderr is piped to the lsp stderr which is is shown in the output tab.
But there should be a telemetry or error event sent back to the vscode extension so that we can send the panic message to our crash reporter.
(i didn't mean to approve it already, see previous message, sorry about that)
@tronical will have to chime in about that.
I think that's cool, because we will probably end up adding more stuff in that menu, don't we?
That's the other option. |
I tried the code in the PR and the behaviour of "Quit" looks correct to me (window disappears, no error message). I see two issues:
I advise against putting hope into me ;-). What's the motivation of creating a new menu? |
@tronical: I do not want that bar in Slintpad. It is also pretty useless on Linux: The Always on top does not work and the reload is right there as a button anyway... and there is nothing else in there. But with slint's |
@ogoffart: That used to be the case with the version from yesterday, but with todays I specifically tested killing the LSP ( |
Conditional MenuBar shouldn't be too hard: #8282 (comment) |
I tried the PR. Without our own menu bar we get the winit menu bar and "Quit" works as expected. However, we loose the Window -> Keep On Top feature. That's a regression. |
I confirm that then the lsp crashes, the preview also closes now. 👍 However, when killing vscode, both process are kept open.
Looks like thread 1 is waiting on thread 2 which is blocked in trying to read. Edit: Thread 1 is blocked waiting on thread 2 which is waiting on the UI process. The UI process is still running fine (and the window is still visible). But closing the window do stop the deadlock. |
f664b10
to
0d3adba
Compare
All but the menu items are now fixed. |
... and into preview/connector. This is just a intermediary step to separate them even more strongly from each other.
... in native mode.
The UI is always visible while the live preview runs.
... the wasm preview still does not work though.
Probably a bit over-engineered, but this works for me.
... by quitting the application.
Make the extension set SLINT_LSP_PANIC_LOG_DIR (instead of setting a file). Have the Lsp/live preview create panic logs in that folder as panics happen. Make the extension watch that folder and upload any file it sees getting created there Delete the file after upload
Simplify style selection, now that we are "always up": All we need to do is change the style when the configuration changes. That is a part of the initial state request we send when the preview starts up, so we set the style properly and then we do not need to do anything anymore till somebody configures a new style.
1f56c60
to
cb3c225
Compare
@tronical: The one thing left to do is to fix up the menu on mac. Would you please do the honors? |
Todo:
Checkable Menu itemsConditional MenuBarI removed the change again that changes the MUDA menu on the mac to a Slint menu bar.