Turn any website into a lightweight desktop app with one command, on macOS, Windows and Linux.
Rust chatgptclaudeclidesktopdesktop-appelectron-alternativegeminilinuxmacosnativefierno-electronrusttauriweb-to-desktopwebsite-to-appwebviewwindowsyoutube
feat: group macOS multi-window clones into native tabs
zwmmm91478d5de171
diff --git a/docs/cli-usage.md b/docs/cli-usage.mdindex 0ac7dfb5..68162a3f 100644--- a/docs/cli-usage.md+++ b/docs/cli-usage.md@@ -539,6 +539,8 @@ This is different from `--multi-instance`:When enabled, relaunching an already running app opens a new window instead of only focusing the existing one.+On macOS, additional windows opened with Cmd+N join the app's native tab group. Web-auth and `window.open` popups remain separate.+This can improve popup-based authentication flows, but it cannot bypass provider policy. Some providers, especially Google, may still reject sign-in inside embedded webviews.```shelldiff --git a/docs/cli-usage_CN.md b/docs/cli-usage_CN.mdindex 2eaef456..8b7e714d 100644--- a/docs/cli-usage_CN.md+++ b/docs/cli-usage_CN.md@@ -537,6 +537,8 @@ pake https://chat.example.com --name ChatApp --multi-instance启用后,如果应用已在运行,再次启动会新开一个窗口,而不是仅聚焦已有窗口。+在 macOS 上,通过 Cmd+N 打开的附加窗口会自动加入应用的原生标签页组;网页认证和 `window.open` 弹窗仍保持独立。+这个选项可以改善基于弹窗的认证流程,但不能绕过认证提供方的策略限制。某些提供方,尤其是 Google,仍然可能拒绝在嵌入式 WebView 中完成登录。```shelldiff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.tomlindex 6c7ace1f..41d70a4e 100644--- a/src-tauri/Cargo.toml+++ b/src-tauri/Cargo.toml@@ -39,7 +39,7 @@ tauri-plugin-notification = "2.3.3"block2 = "0.6"dispatch = "0.2"objc2 = "0.6"-objc2-app-kit = { version = "0.3", features = ["NSApplication", "NSDockTile"] }+objc2-app-kit = { version = "0.3", features = ["NSApplication", "NSDockTile", "NSWindow"] }objc2-foundation = { version = "0.3", features = ["NSString"] }objc2-web-kit = { version = "0.3", default-features = false, features = ["std",diff --git a/src-tauri/src/app/window.rs b/src-tauri/src/app/window.rsindex 01a21b17..2a55c2bc 100644--- a/src-tauri/src/app/window.rs+++ b/src-tauri/src/app/window.rs@@ -362,6 +362,11 @@ fn build_window(visible,new_window_features,} = opts;+ #[cfg(target_os = "macos")]+ let use_native_window_tabbing = config.multi_window && new_window_features.is_none();+ #[cfg(target_os = "macos")]+ let prefer_native_window_tabbing = use_native_window_tabbing && label != "pake";+let package_name = tauri_config.product_name.clone()@@ -570,6 +575,22 @@ fn build_window(};window_builder = window_builder.title_bar_style(title_bar_style);window_builder = window_builder.theme(theme);++ // Tauri disables automatic tabbing unless an identifier is provided.+ // Existing multi-window apps already have a stable bundle identifier,+ // so use it without exposing another CLI/config option. Web-created+ // popups keep their own native window.+ if use_native_window_tabbing {+ window_builder = window_builder+ .tabbing_identifier(&tauri_config.identifier)+ .on_document_title_changed(|window, title| {+ if !title.trim().is_empty() {+ if let Err(error) = window.set_title(&title) {+ eprintln!("[Pake] Failed to update the macOS tab title: {error}");+ }+ }+ });+ }}// Windows and Linux: set data_directory before proxy_url@@ -689,6 +710,29 @@ fn build_window(let window = window_builder.build()?;+ // A shared identifier alone leaves each NSWindow in automatic mode.+ // Prefer tabs only for Cmd+N clones so they join the main window's tab+ // group. The main window stays bar-less until another tab exists, while+ // web-auth and window.open popups remain separate native windows.+ #[cfg(target_os = "macos")]+ if prefer_native_window_tabbing {+ let tabbing_window = window.clone();+ Queue::main().exec_async(move || match tabbing_window.ns_window() {+ Ok(ns_window_ptr) => unsafe {+ let Some(ns_window) =+ objc2::rc::Retained::retain(ns_window_ptr as *mut objc2_app_kit::NSWindow)+ else {+ eprintln!("[Pake] Failed to retain the macOS window for tabbing.");+ return;+ };+ ns_window.setTabbingMode(objc2_app_kit::NSWindowTabbingMode::Preferred);+ },+ Err(error) => {+ eprintln!("[Pake] Failed to access the macOS window for tabbing: {error}");+ }+ });+ }+// WKWebView does not show an HTTP Basic login dialog and ignores Chromium's// certificate-error flag. Install one host-scoped delegate for both flows// on the process-lifetime main window, then navigate to the real target.diff --git a/tests/unit/new-window-macos.test.js b/tests/unit/new-window-macos.test.jsindex 7d80299e..99cebea0 100644--- a/tests/unit/new-window-macos.test.js+++ b/tests/unit/new-window-macos.test.js@@ -41,4 +41,18 @@ describe("macOS new-window handling (regression: #1194)", () => {expect(source).not.toContain("removeAllUserScripts");expect(source).not.toContain("removeAllScriptMessageHandlers");});++ it("groups only multi-window clones into native macOS tabs", () => {+ const source = fs.readFileSync(sourcePath, "utf-8");++ expect(source).toContain(+ "let use_native_window_tabbing = config.multi_window && new_window_features.is_none();",+ );+ expect(source).toContain(+ 'let prefer_native_window_tabbing = use_native_window_tabbing && label != "pake";',+ );+ expect(source).toContain(".tabbing_identifier(&tauri_config.identifier)");+ expect(source).toContain("if prefer_native_window_tabbing");+ expect(source).not.toContain("tabbing_identifier: String");+ });});