diff --git a/public/favicon/site.webmanifest b/public/favicon/site.webmanifest index ae6b41c0..1bb66769 100644 --- a/public/favicon/site.webmanifest +++ b/public/favicon/site.webmanifest @@ -6,6 +6,9 @@ "scope": "/", "id": "/", "display": "standalone", + "launch_handler": { + "client_mode": "focus-existing" + }, "orientation": "portrait-primary", "theme_color": "#1b1b18", "background_color": "#ffffff", diff --git a/resources/js/app.tsx b/resources/js/app.tsx index adb1fe31..add6ca0b 100644 --- a/resources/js/app.tsx +++ b/resources/js/app.tsx @@ -34,6 +34,38 @@ import { __, setTranslations } from './utils/i18n'; installChunkLoadRecovery(); +// The installed PWA claims the whole origin (manifest scope "/"), so on mobile an +// OAuth link (e.g. from ChatGPT connecting over MCP) gets captured into the app. +// Paired with launch_handler "focus-existing", the launcher hands us the target +// URL instead of dropping it and showing the dashboard — navigate there so the +// OAuth consent screen actually loads. Non-OAuth launches keep their place. +type LaunchParams = { targetURL?: string }; + +const launchQueue = ( + window as Window & { + launchQueue?: { + setConsumer(consumer: (params: LaunchParams) => void): void; + }; + } +).launchQueue; + +if (launchQueue) { + launchQueue.setConsumer(({ targetURL }) => { + if (!targetURL) { + return; + } + + const target = new URL(targetURL); + + if ( + target.pathname.startsWith('/oauth/') && + target.href !== window.location.href + ) { + window.location.href = targetURL; + } + }); +} + Sentry.init({ dsn: import.meta.env.SENTRY_LARAVEL_DSN, environment: import.meta.env.MODE,