fix(native): dedupe cold-start deep-link double navigation (D4)
Build Lotus Chat Desktop / prepare (push) Successful in 4s
Build Lotus Chat Desktop / build-windows (push) Failing after 26m23s
Build Lotus Chat Desktop / build-linux (push) Successful in 23m35s
Build Lotus Chat Desktop / update-manifest (push) Has been skipped

on_open_url and the argv fallback can both forward the same launch matrix: URL
on cold start, navigating the room twice. forward_deeplink now drops a repeat of
the same URL within ~1s (plain std Mutex/Instant — no windows-crate surface).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-02 22:57:09 -04:00
parent 749804cde6
commit 28d960b04f
+18
View File
@@ -27,6 +27,24 @@ fn show_main(app: &tauri::AppHandle) {
/// CustomEvent the client listens for (see useDeepLinkNavigate.ts). Uses /// CustomEvent the client listens for (see useDeepLinkNavigate.ts). Uses
/// `eval` so we don't need the @tauri-apps/api event package on the web side. /// `eval` so we don't need the @tauri-apps/api event package on the web side.
fn forward_deeplink(app: &tauri::AppHandle, url: &str) { fn forward_deeplink(app: &tauri::AppHandle, url: &str) {
// Dedupe: on a cold start the deep-link plugin's `on_open_url` AND the argv
// fallback (`matrix_url_from_args(std::env::args())`) can both forward the
// same launch URL, navigating the room twice (re-show/re-focus + a duplicate
// `lotus-deeplink`). Drop a repeat of the same URL within a short window.
{
use std::sync::Mutex;
use std::time::{Duration, Instant};
static LAST: Mutex<Option<(String, Instant)>> = Mutex::new(None);
if let Ok(mut last) = LAST.lock() {
let now = Instant::now();
if let Some((prev_url, prev_at)) = last.as_ref() {
if prev_url == url && now.duration_since(*prev_at) < Duration::from_millis(1000) {
return;
}
}
*last = Some((url.to_string(), now));
}
}
show_main(app); show_main(app);
if let Some(window) = app.get_webview_window("main") { if let Some(window) = app.get_webview_window("main") {
if let Ok(json) = serde_json::to_string(url) { if let Ok(json) = serde_json::to_string(url) {