Repository navigation
feat: support Cloud plugin installation deep links - #201
Conversation
There was a problem hiding this comment.
Hey - I've found 6 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src-tauri/src/install_link.rs" line_range="37-45" />
<code_context>
+ "market_plugin_id" if plugin_id.is_none() => plugin_id = Some(value.into_owned()),
+ "registry_url" if registry_url.is_none() => {
+ let registry = Url::parse(&value).ok()?;
+ if registry.scheme() != "https"
+ || registry.host_str().is_none()
+ || !registry.username().is_empty()
+ || registry.password().is_some()
+ || registry.fragment().is_some()
+ {
+ return None;
+ }
+ registry_url = Some(registry.to_string());
+ }
+ _ => return None,
</code_context>
<issue_to_address>
**Deep links probe private HTTPS services**
When an untrusted page or local process opens an `astrbot://` link whose `registry_url` resolves to a private or loopback HTTPS service, `parse_target` accepts any HTTPS host and `InstallTarget::fragment` forwards it into the WebUI marketplace flow, so a link sender can make the core’s registry lookup contact private or loopback services. HTTPS does not prevent access to those hosts, exposing internal services to requests triggered by the desktop app.
Reject private, loopback, and link-local destinations after DNS resolution (including redirects), or restrict registry URLs to explicitly trusted hosts.
</issue_to_address>
### Comment 2
<location path="src-tauri/src/install_link.rs" line_range="87" />
<code_context>
+
+pub(crate) fn setup(app: &tauri::App) -> Result<(), Box<dyn std::error::Error>> {
+ #[cfg(target_os = "linux")]
+ app.deep_link().register_all()?;
+ let handle = app.handle().clone();
+ app.deep_link().on_open_url(move |event| {
</code_context>
<issue_to_address>
**Deep-link errors prevent launch**
When linux scheme registration or current-link lookup returns an error, `install_link::setup` propagates the error through Tauri setup, and application construction panics at `expect`, so AstrBot fails to launch instead of running without deep-link support.
Handle errors from `register_all()` and `get_current()` without failing application setup.
Also at `src-tauri/src/install_link.rs:94`.
</issue_to_address>
### Comment 3
<location path="src-tauri/src/install_link.rs" line_range="113" />
<code_context>
+ "open plugin installation link",
+ move |app| {
+ let state = app.state::<InstallLinkState>();
+ *state.pending.lock().unwrap() = Some(fragment);
+ crate::window::actions::show_main_window(app, DEFAULT_SHELL_LOCALE, append_desktop_log);
+ if state.ready.load(Ordering::SeqCst) {
</code_context>
<issue_to_address>
**Earlier installation links are lost**
When multiple valid installation links arrive before the dashboard is ready, `receive` overwrites the single `pending` value for each link, so `open_pending` forwards only the last target to the WebUI and earlier installation requests are lost.
Store pending targets in a queue and forward each one when the dashboard is ready.
Also at `src-tauri/src/install_link.rs:90-91`.
</issue_to_address>
### Comment 4
<location path="src-tauri/src/install_link.rs" line_range="118-119" />
<code_context>
+ if state.ready.load(Ordering::SeqCst) {
+ let backend = app.state::<BackendState>().bridge_state(app);
+ if backend.spawning || backend.restarting {
+ state.ready.store(false, Ordering::SeqCst);
+ return;
+ }
+ if !backend.running && !backend.spawning && !backend.restarting {
</code_context>
<issue_to_address>
**Restart leaves links unopened**
When a valid link arrives during a backend restart that completes without reloading the WebUI document, `receive` clears `ready` and returns without scheduling a retry; `run_restart_backend_task` only reports the result, and the loaded document does not call `dashboard_ready` again, so the pending link stays unopened.
Retry forwarding the pending link when the backend restart completes, even if the WebUI document does not reload.
</issue_to_address>
### Comment 5
<location path="src-tauri/src/install_link.rs" line_range="123" />
<code_context>
+ }
+ if !backend.running && !backend.spawning && !backend.restarting {
+ state.ready.store(false, Ordering::SeqCst);
+ crate::startup_task::spawn_startup_task(app.clone(), crate::append_startup_log);
+ } else {
+ open_pending(app);
</code_context>
<issue_to_address>
**Retries stop after startup failure**
When a previously loaded backend becomes unavailable and the link-triggered startup attempt fails, `spawn_startup_task` reports a failed backend startup without restoring `ready`; subsequent links only replace `pending` and never start another attempt, so the installation flow remains stuck until the app is restarted or the dashboard is loaded another way.
Restore a retryable state after startup failure, or allow a later link activation to start another backend attempt when the app is showing the startup error.
</issue_to_address>
### Comment 6
<location path="src-tauri/src/install_link.rs" line_range="116" />
<code_context>
+ *state.pending.lock().unwrap() = Some(fragment);
+ crate::window::actions::show_main_window(app, DEFAULT_SHELL_LOCALE, append_desktop_log);
+ if state.ready.load(Ordering::SeqCst) {
+ let backend = app.state::<BackendState>().bridge_state(app);
+ if backend.spawning || backend.restarting {
+ state.ready.store(false, Ordering::SeqCst);
</code_context>
<issue_to_address>
**Deep link freezes desktop UI**
When the backend probe or DNS resolution is slow while a link arrives, `receive` calls `bridge_state` inside its main-thread dispatch; that call performs synchronous DNS resolution and TCP probes, so a slow resolver or backend probe stalls the UI while the link is handled.
Perform the backend-state probe off the main thread and dispatch only its result back to the UI thread.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 6 findings to address first, and an external astrbot: link can send the app to the plugin installation flow with a caller-supplied HTTPS registry URL; if a user installs a plugin from that source, its code may remain installed and run after this change is reverted. This code does not itself install a plugin, but it does introduce an untrusted link path into that security-sensitive flow.
Blocking findings: src-tauri/src/install_link.rs:45, src-tauri/src/install_link.rs:87, src-tauri/src/install_link.rs:113, src-tauri/src/install_link.rs:119, src-tauri/src/install_link.rs:123, and 1 more
| if registry.scheme() != "https" | ||
| || registry.host_str().is_none() | ||
| || !registry.username().is_empty() | ||
| || registry.password().is_some() | ||
| || registry.fragment().is_some() | ||
| { | ||
| return None; | ||
| } | ||
| registry_url = Some(registry.to_string()); |
There was a problem hiding this comment.
🟡 Medium · Deep links probe private HTTPS services
When an untrusted page or local process opens an astrbot:// link whose registry_url resolves to a private or loopback HTTPS service, parse_target accepts any HTTPS host and InstallTarget::fragment forwards it into the WebUI marketplace flow, so a link sender can make the core’s registry lookup contact private or loopback services. HTTPS does not prevent access to those hosts, exposing internal services to requests triggered by the desktop app.
Reject private, loopback, and link-local destinations after DNS resolution (including redirects), or restrict registry URLs to explicitly trusted hosts.
Prompt for AI agents
In `src-tauri/src/install_link.rs` at lines 37-45:
**Deep links probe private HTTPS services**
When an untrusted page or local process opens an `astrbot://` link whose `registry_url` resolves to a private or loopback HTTPS service, `parse_target` accepts any HTTPS host and `InstallTarget::fragment` forwards it into the WebUI marketplace flow, so a link sender can make the core’s registry lookup contact private or loopback services. HTTPS does not prevent access to those hosts, exposing internal services to requests triggered by the desktop app.
Reject private, loopback, and link-local destinations after DNS resolution (including redirects), or restrict registry URLs to explicitly trusted hosts.| "open plugin installation link", | ||
| move |app| { | ||
| let state = app.state::<InstallLinkState>(); | ||
| *state.pending.lock().unwrap() = Some(fragment); |
There was a problem hiding this comment.
🟡 Medium · Earlier installation links are lost
When multiple valid installation links arrive before the dashboard is ready, receive overwrites the single pending value for each link, so open_pending forwards only the last target to the WebUI and earlier installation requests are lost.
Store pending targets in a queue and forward each one when the dashboard is ready.
Also at src-tauri/src/install_link.rs:90-91.
Prompt for AI agents
In `src-tauri/src/install_link.rs` at line 113:
**Earlier installation links are lost**
When multiple valid installation links arrive before the dashboard is ready, `receive` overwrites the single `pending` value for each link, so `open_pending` forwards only the last target to the WebUI and earlier installation requests are lost.
Store pending targets in a queue and forward each one when the dashboard is ready.
Also at `src-tauri/src/install_link.rs:90-91`.
Summary / 改动概述
Allow Cloud to open a plugin installation in the AstrBot desktop application using
astrbot://extension/plugins?market_plugin_id=author%2Fnameand optionalregistry_url.astrbotscheme with Tauri Deep Link and forward activations through the existing single-instance application.Companion Cloud PR: https://github.com/AstrBotDevs/astrbot-cloud/pull/20
Verification / 验证方式
cargo check --manifest-path src-tauri/Cargo.tomlcargo test --manifest-path src-tauri/Cargo.toml --locked: 287 passed, including valid/default/custom-source links, invalid action/identity/credential/duplicate-parameter cases, restart recovery, and startup-failure retry decisions.cargo clippy --manifest-path src-tauri/Cargo.toml --locked --all-targets -- -D warningscargo fmt --manifest-path src-tauri/Cargo.toml --all -- --checkThe target core/WebUI needs marketplace installation-link support (AstrBot v4.30.0+). OS-level activation still needs verification with installed application bundles on Windows, macOS, and Linux. Desktop registers
astrbot; Launcher registersastrbot-launcher, allowing both applications to coexist.Checklist / 检查清单
Launcher companion: AstrBotDevs/astrbot-launcher#115
Summary by Sourcery
Enable the desktop application to receive Cloud plugin installation deep links and forward validated requests to the existing core installation confirmation flow.
New Features:
astrbot://deep links, including optional HTTPS registries.Enhancements:
Build:
Deployment:
astrbotURL scheme.Tests: