Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix(desktop): let Pipedream Connect load in its iframe on macOS (#8226)
teo53b6dd6f4e95
diff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.mdindex 6ee525c1bb..7f744246b2 100644--- a/apps/web/AGENTS.md+++ b/apps/web/AGENTS.md@@ -123,6 +123,9 @@ on focus/reconnect; route existing subscriptions to billing management. Keepknown management access through refetch failures, but hide unconfirmed trials.Reset rejected checkout offers before refetching eligibility.+## macOS desktop gotcha: third-party iframes+WKWebView asks the desktop navigation plugin about iframe loads as well as page loads, and the plugin cannot tell them apart. A third-party iframe is classified as external: its load is cancelled and the page opens in the browser, leaving an empty frame in the app. List a third-party page the app frames in `EMBEDDED_DOCUMENTS` in `tauri/src-tauri/src/lib.rs`.+## iOS gotcha: Web Workers must be lazyOn iOS WKWebView, eagerly constructing an ES module Web Worker (`new Worker(url, { type: 'module' })`) whose script is served via the `tauri://` custom URL scheme **deadlocks the WebContent process**. The worker thread parks in WebKit's sync module loader waiting for an IPC response that never wakes it; JS execution silently stops after that point.diff --git a/apps/web/src/lib/core/pipedream/connect-ui.ts b/apps/web/src/lib/core/pipedream/connect-ui.tsindex 1aa21a0bc9..6c7728c833 100644--- a/apps/web/src/lib/core/pipedream/connect-ui.ts+++ b/apps/web/src/lib/core/pipedream/connect-ui.ts@@ -7,6 +7,8 @@* connect page, which reports lifecycle events back via `postMessage`.*/+// The desktop shell must allow this page to load in a frame: keep in sync with+// `EMBEDDED_DOCUMENTS` in `apps/web/tauri/src-tauri/src/lib.rs`.const CONNECT_UI_URL = 'https://pipedream.com/_static/connect.html';export type PipedreamConnectEvent =diff --git a/apps/web/tauri/navigation_plugin/src/lib.rs b/apps/web/tauri/navigation_plugin/src/lib.rsindex c1a6d44a45..4f878467cb 100644--- a/apps/web/tauri/navigation_plugin/src/lib.rs+++ b/apps/web/tauri/navigation_plugin/src/lib.rs@@ -23,6 +23,10 @@ enum NavigationOutput<'a> {/// the dev server, ...) — the webview is allowed to load it directly./// This is what permits the SPA's own page loads.Internal,+ /// A third-party document the SPA embeds in an iframe. WebKit asks the+ /// navigation handler about subframe loads too, so it must be allowed to+ /// load in place; as a new window it is still external.+ Embedded,/// A link to content inside the Macro app whose literal [Url] points at/// the remote website (e.g. `https://macro.com/app/...`). The webview/// must not load it — that would replace the running SPA with the live@@ -51,6 +55,7 @@ pub enum Platform {pub struct MacroNavigationPlugin {internal_domains: Arc<[Url]>,app_link_hosts: &'static [&'static str],+ embedded_documents: Arc<[Url]>,allowed_file_prefix: Option<PathBuf>,}@@ -76,6 +81,7 @@ impl MacroNavigationPlugin {.map(|s| s.parse()).collect::<Result<Arc<_>, _>>()?,app_link_hosts: &[],+ embedded_documents: Arc::new([]),allowed_file_prefix: None,})}@@ -87,6 +93,30 @@ impl MacroNavigationPlugin {self}+ /// Third-party pages the SPA loads in an iframe, matched by origin and+ /// path (any query). On macOS the navigation handler cannot tell an+ /// iframe load from a top-level one, and cancelling the iframe leaves an+ /// empty frame over the app.+ pub fn with_embedded_documents(+ mut self,+ documents: &'static [&'static str],+ ) -> Result<Self, url::ParseError> {+ self.embedded_documents = documents+ .iter()+ .map(|s| s.parse())+ .collect::<Result<Arc<_>, _>>()?;+ Ok(self)+ }++ fn is_embedded_document(&self, url: &Url) -> bool {+ self.embedded_documents.iter().any(|document| {+ document.scheme() == url.scheme()+ && document.host_str() == url.host_str()+ && document.port_or_known_default() == url.port_or_known_default()+ && document.path() == url.path()+ })+ }+pub fn with_allowed_file_prefix(mut self, prefix: PathBuf) -> Self {self.allowed_file_prefix = Some(prefix);self@@ -99,6 +129,9 @@ impl MacroNavigationPlugin {if let Some(scheme) = self.as_app_link(url) {return NavigationOutput::AppLink(scheme);}+ if self.is_embedded_document(url) {+ return NavigationOutput::Embedded;+ }match self.as_internal_url(url) {Ok(()) => NavigationOutput::Internal,Err(_)@@ -168,6 +201,9 @@ impl MacroNavigationPlugin {NavigationOutput::Internal => MacroScheme::from_url(url).map(NavigationOutput::AppLink).unwrap_or(NavigationOutput::Blocked),+ NavigationOutput::Embedded => {+ NavigationOutput::External(ExternalUrl(Cow::Borrowed(url)))+ }destination => destination,}}@@ -217,7 +253,7 @@ impl MacroNavigationPlugin {.log_and_consume();false}- NavigationOutput::Internal => true,+ NavigationOutput::Internal | NavigationOutput::Embedded => true,NavigationOutput::Blocked => false,}}diff --git a/apps/web/tauri/navigation_plugin/src/tests.rs b/apps/web/tauri/navigation_plugin/src/tests.rsindex 5a8e95c4d8..b0d033b940 100644--- a/apps/web/tauri/navigation_plugin/src/tests.rs+++ b/apps/web/tauri/navigation_plugin/src/tests.rs@@ -306,6 +306,72 @@ fn blocked_popup_neither_opens_nor_emits_navigation() {assert_eq!(received.load(Ordering::Relaxed), 0);}+const PIPEDREAM_CONNECT: &str = "https://pipedream.com/_static/connect.html";++fn embedding_plugin() -> MacroNavigationPlugin {+ test_plugin()+ .with_embedded_documents(&[PIPEDREAM_CONNECT])+ .unwrap()+}++/// WebKit routes iframe loads through the navigation handler. Cancelling the+/// Pipedream Connect frame left an empty full-screen iframe over the app and+/// opened the page in the browser, so Connect froze the desktop app.+#[test]+fn embedded_document_loads_in_place_with_any_query() {+ let plugin = embedding_plugin();+ for input in [+ PIPEDREAM_CONNECT,+ "https://pipedream.com/_static/connect.html?token=ctok_1&app=github",+ ] {+ assert!(+ matches!(+ plugin.get_destination(&Url::parse(input).unwrap()),+ NavigationOutput::Embedded+ ),+ "{input}"+ );+ }+}++#[test]+fn embedded_document_match_is_exact() {+ let plugin = embedding_plugin();+ for input in [+ "https://pipedream.com/",+ "https://pipedream.com/_static/other.html",+ "http://pipedream.com/_static/connect.html",+ "https://pipedream.com:8443/_static/connect.html",+ "https://evil.pipedream.com/_static/connect.html",+ "https://pipedream.com.example.com/_static/connect.html",+ ] {+ assert!(+ matches!(+ plugin.get_destination(&Url::parse(input).unwrap()),+ NavigationOutput::External(_)+ ),+ "{input}"+ );+ }+}++#[test]+fn embedded_document_opened_as_a_window_is_external() {+ let plugin = embedding_plugin();+ assert!(matches!(+ plugin.new_window_destination(&Url::parse(PIPEDREAM_CONNECT).unwrap()),+ NavigationOutput::External(_)+ ));+}++#[test]+fn documents_are_not_embedded_unless_configured() {+ assert!(matches!(+ test_plugin().get_destination(&Url::parse(PIPEDREAM_CONNECT).unwrap()),+ NavigationOutput::External(_)+ ));+}+#[test]fn from_url_extracts_correct_path_from_universal_link() {let url = Url::parse("https://macro.com/app/component/doc123").unwrap();diff --git a/apps/web/tauri/src-tauri/src/lib.rs b/apps/web/tauri/src-tauri/src/lib.rsindex d4fd1cef9d..e5188c9beb 100644--- a/apps/web/tauri/src-tauri/src/lib.rs+++ b/apps/web/tauri/src-tauri/src/lib.rs@@ -112,6 +112,10 @@ static ALLOWED_DOMAINS: &[&str] = &["http://localhost:3009",];+/// Third-party pages the SPA renders in an iframe. Keep in sync with+/// `CONNECT_UI_URL` in `apps/web/src/lib/core/pipedream/connect-ui.ts`.+static EMBEDDED_DOCUMENTS: &[&str] = &["https://pipedream.com/_static/connect.html"];+/// hosts whose `/app` urls are Macro app links. Main-frame navigations to/// these are routed through the SPA router instead of loading the remote/// site in the webview. Keep in parity with the deep-link hosts in@@ -174,7 +178,9 @@ pub fn run() {};let navigation = MacroNavigationPlugin::new(ALLOWED_DOMAINS).expect("Domains must be valid urls")- .with_app_link_hosts(APP_LINK_HOSTS);+ .with_app_link_hosts(APP_LINK_HOSTS)+ .with_embedded_documents(EMBEDDED_DOCUMENTS)+ .expect("Embedded documents must be valid urls");let mut builder = tauri::Builder::default();#[cfg(desktop)]diff --git a/apps/web/tauri/src-tauri/tauri.android.conf.json b/apps/web/tauri/src-tauri/tauri.android.conf.jsonindex a474155b6f..7b4fcefc93 100644--- a/apps/web/tauri/src-tauri/tauri.android.conf.json+++ b/apps/web/tauri/src-tauri/tauri.android.conf.json@@ -5,7 +5,7 @@"version": "2.5.0","bundle": {"android": {- "versionCode": 4+ "versionCode": 5}},"plugins": {