Skip to content

Tracking PR for the remote viewer #11634

Draft
ogoffart wants to merge 8 commits into
masterfrom
feature/remote-viewer
Draft

Tracking PR for the remote viewer #11634
ogoffart wants to merge 8 commits into
masterfrom
feature/remote-viewer

Conversation

@ogoffart
Copy link
Copy Markdown
Member

@ogoffart ogoffart commented May 6, 2026

Issue: #9880

TODO:

  • remote assests
  • Merge the remote viewer and the viewer.
  • Keep SetContents as a String and have a different call for setting the resource contents.

anlumo and others added 3 commits May 6, 2026 10:36
…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
ogoffart added 2 commits May 7, 2026 13:01
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";
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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")]
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm not sure this is correct to use tokio like that.

ogoffart added 2 commits May 11, 2026 17:45
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 LeonMatthes self-requested a review May 12, 2026 12:43
Copy link
Copy Markdown
Member

@LeonMatthes LeonMatthes left a comment

Choose a reason for hiding this comment

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

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",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
"title": "Connect to Remote Preview",
"title": "(Experimental) Connect to Remote Preview",

},
{
"command": "slint.disconnectRemotePreview",
"title": "Disconnect Remote Preview",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
"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)]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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())]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we really want to pull in a whole new dependency because of this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please make this a sub-module under preview/connector/.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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).

Comment thread tools/lsp/language.rs
}

#[cfg(feature = "preview-remote")]
pub fn connect_remote_preview_command(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please move the connect remote preview commands into the connector/remote module.

Comment thread tools/lsp/main.rs Outdated
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 {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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:/.
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.

3 participants