Tracking PR for the remote viewer #11634
Conversation
…blic API The ResourcePreloader trait and its plumbing through compile_syntax_node, load_root_file, run_passes, build_from_path, and build_from_source broke all downstream callers. Resource preloading should be part of CompilerConfiguration instead, and merged with the URL mapper. For now, revert the compiler and interpreter API changes and leave TODO comments in the remote-viewer where the preloader was used.
Fix licenses, formatting, compilation errors and warnings
The remote mode added to slint-viewer was temporary scaffolding. Revert it so the branch can be merged to master cleanly. Also add a README to tools/remote-viewer explaining what it is.
The command palette entry referenced slint.connectRemotePreview, which was never registered. Point it to slint.selectRemotePreview instead, which opens the connection picker.
| const devBuild = serverModule.includes("/target/debug/"); | ||
| if (devBuild) { | ||
| options.env["RUST_BACKTRACE"] = "1"; | ||
| options.env["RUST_LOG"] = "debug"; |
There was a problem hiding this comment.
This causes the LSP to spam a lot of things in the output panel. Not something i like a lot.
| mod ui; | ||
| mod util; | ||
|
|
||
| #[tokio::main(flavor = "current_thread")] |
There was a problem hiding this comment.
I'm not sure this is correct to use tokio like that.
Add cdylib crate type and android_main entry point so the remote viewer can be built as an Android APK with cargo-apk. Set min_sdk_version to 24 (Android 7.0) so that getifaddrs is available, enabling mDNS discovery and local IP listing on Android. Includes a UDP socket fallback in local_ips() for environments where getifaddrs returns no results, a safe fallback for current_exe(), and a meaningful mDNS hostname when hostname::get() returns "localhost". Build with: cargo apk build -p remote-viewer --lib
Improve showInformationMessage text: use structured fields instead of raw JSON dumps and drop the internal debug info. Narrow #[allow(dead_code)] in switchable.rs to the impl block only, with a comment explaining why it is needed.
LeonMatthes
left a comment
There was a problem hiding this comment.
mostly looks fine, some things need to be moved around, and this should be marked as experimental in the VS Code extension.
| }, | ||
| { | ||
| "command": "slint.selectRemotePreview", | ||
| "title": "Connect to Remote Preview", |
There was a problem hiding this comment.
| "title": "Connect to Remote Preview", | |
| "title": "(Experimental) Connect to Remote Preview", |
| }, | ||
| { | ||
| "command": "slint.disconnectRemotePreview", | ||
| "title": "Disconnect Remote Preview", |
There was a problem hiding this comment.
| "title": "Disconnect Remote Preview", | |
| "title": "(Experimental) Disconnect Remote Preview", |
| #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, serde::Serialize, serde::Deserialize)] | ||
| #[serde(rename_all = "kebab-case")] | ||
| pub enum PreviewTarget { | ||
| #[allow(dead_code)] |
There was a problem hiding this comment.
Why does this need #[allow(dead_code)]?
It's a pub enum, so Rust can't know whether it's dead code anyway.
| }, | ||
| SetContents { | ||
| url: VersionedUrl, | ||
| #[debug("Vec<u8> {{ len: {} }}", contents.len())] |
There was a problem hiding this comment.
Do we really want to pull in a whole new dependency because of this?
There was a problem hiding this comment.
I's not a whole new dependency though.
I think manual implementation is a bit fastidious.
| @@ -0,0 +1,79 @@ | |||
| // Copyright © SixtyFPS GmbH <info@slint.dev> | |||
There was a problem hiding this comment.
Please make this a sub-module under preview/connector/.
There was a problem hiding this comment.
but that's not possible: the preview module is gated behind #[cfg(feature = "preview-engine")], and SwitchableLspToPreview is used in code paths that compile without that feature (main.rs, wasm_main.rs, tests).
| } | ||
|
|
||
| #[cfg(feature = "preview-remote")] | ||
| pub fn connect_remote_preview_command( |
There was a problem hiding this comment.
Please move the connect remote preview commands into the connector/remote module.
| common::spawn_local(futures_util::future::join_all(files.into_iter().map(|url| { | ||
| let to_preview = to_preview.clone(); | ||
| async move { | ||
| match tokio::fs::read(url.to_file_path().unwrap()).await { |
There was a problem hiding this comment.
This should first check if there is a file in the document cache and then return that.
The remote viewer receives .slint sources from the LSP but image paths reference files on the host machine. Set a resource_url_mapper on the compiler that fetches image bytes via the existing connection and returns data: URIs which the interpreter already handles. Also consolidate send_files_to_preview into language.rs (fixing a to_file_path().unwrap() in the old main.rs version) and harden request_file against non-file paths like builtin:/.
Issue: #9880
TODO:
SetContentsas a String and have a different call for setting the resource contents.