Skip to content

Commit 80aa239

Browse files
committed
fix(desktop): forward OAuth deep links to running instance
1 parent fb5d0a0 commit 80aa239

File tree

4 files changed

+37
-0
lines changed

4 files changed

+37
-0
lines changed

apps/desktop/src-tauri/Cargo.lock

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/desktop/src-tauri/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ tauri-build = { version = "2", features = [] }
1414
tauri = { version = "2", features = [] }
1515
tauri-plugin-shell = "2"
1616
tauri-plugin-deep-link = "2"
17+
tauri-plugin-single-instance = "2"
1718
tauri-plugin-fs = "2"
1819
tauri-plugin-store = "2"
1920
tauri-plugin-os = "2"

apps/desktop/src-tauri/src/deeplink.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ pub fn setup_deep_link_handler(app: &tauri::App) {
7272
println!("[DeepLink] Handler setup complete, URLs found: {}", urls_found);
7373
}
7474

75+
pub fn handle_deep_link_arg<R: tauri::Runtime>(handle: &tauri::AppHandle<R>, arg: &str) {
76+
if let Ok(url) = Url::parse(arg) {
77+
if url.scheme() == "openlinear" {
78+
handle_deep_link_url(handle, &url);
79+
}
80+
}
81+
}
82+
7583
fn handle_deep_link_url<R: tauri::Runtime>(handle: &tauri::AppHandle<R>, url: &Url) {
7684
println!("[DeepLink] Received: {}", url);
7785

apps/desktop/src-tauri/src/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,21 @@ mod opencode;
33
mod secure_storage;
44
mod sidecar;
55

6+
use tauri::Manager;
7+
68
#[cfg_attr(mobile, tauri::mobile_entry_point)]
79
pub fn run() {
810
tauri::Builder::default()
11+
.plugin(tauri_plugin_single_instance::init(|app, argv, _cwd| {
12+
for arg in argv {
13+
deeplink::handle_deep_link_arg(app, &arg);
14+
}
15+
16+
if let Some(window) = app.get_webview_window("main") {
17+
let _ = window.show();
18+
let _ = window.set_focus();
19+
}
20+
}))
921
.plugin(tauri_plugin_shell::init())
1022
.plugin(tauri_plugin_deep_link::init())
1123
.plugin(tauri_plugin_fs::init())

0 commit comments

Comments
 (0)