11'use client'
22
3+ import { DesktopAuthRelay } from '@/components/auth/desktop-auth-relay'
34import { KeyboardShortcutsProvider } from '@/components/shortcuts/keyboard-shortcuts-provider'
45import { OpenPanelIdentify } from '@/components/user/openpanel-identify'
56import { UserBootstrap } from '@/components/user/user-bootstrap'
67import { ConvexAuthProvider } from '@convex-dev/auth/react'
78import { ConvexReactClient } from 'convex/react'
89import { ThemeProvider as NextThemesProvider } from 'next-themes'
910import { NuqsAdapter } from 'nuqs/adapters/next/app'
10- import type { ReactNode } from 'react'
11+ import { type ReactNode , useCallback } from 'react'
1112import { Toaster } from 'sonner'
1213
1314// Convex client: use real URL when set; otherwise placeholder so ConvexProvider is always present
@@ -29,6 +30,14 @@ interface ProvidersProps {
2930 * - Keyboard shortcuts (power users)
3031 */
3132export function Providers ( { children } : ProvidersProps ) {
33+ // Skip automatic code handling when the OAuth callback is for the desktop app.
34+ // The DesktopAuthRelay component will relay the code via deep-link instead.
35+ const shouldHandleCode = useCallback ( ( ) => {
36+ if ( typeof window === 'undefined' ) return true
37+ const params = new URLSearchParams ( window . location . search )
38+ return params . get ( 'source' ) !== 'desktop'
39+ } , [ ] )
40+
3241 const content = (
3342 < NuqsAdapter >
3443 < NextThemesProvider
@@ -55,7 +64,8 @@ export function Providers({ children }: ProvidersProps) {
5564 )
5665
5766 return (
58- < ConvexAuthProvider client = { convex } >
67+ < ConvexAuthProvider client = { convex } shouldHandleCode = { shouldHandleCode } >
68+ < DesktopAuthRelay />
5969 < UserBootstrap />
6070 < OpenPanelIdentify />
6171 { content }
0 commit comments