@@ -15,21 +15,16 @@ import { Label } from "@/components/ui/label";
1515import { Popover } from "@/components/ui/popover" ;
1616import { api , type Session } from "@/lib/api" ;
1717import { cn } from "@/lib/utils" ;
18+ import { listen as tauriListen } from "@tauri-apps/api/event" ;
1819
19- // Conditional imports for Tauri APIs
20- let tauriListen : any ;
2120type UnlistenFn = ( ) => void ;
2221
23- try {
24- if ( typeof window !== 'undefined' && window . __TAURI__ ) {
25- tauriListen = require ( "@tauri-apps/api/event" ) . listen ;
22+ // Web-compatible replacements
23+ const listen = ( eventName : string , callback : ( event : any ) => void ) => {
24+ if ( typeof window !== 'undefined' && '__TAURI__' in window ) {
25+ return tauriListen ( eventName , callback ) ;
2626 }
27- } catch ( e ) {
28- console . log ( '[ClaudeCodeSession] Tauri APIs not available, using web mode' ) ;
29- }
3027
31- // Web-compatible replacements
32- const listen = tauriListen || ( ( eventName : string , callback : ( event : any ) => void ) => {
3328 console . log ( '[ClaudeCodeSession] Setting up DOM event listener for:' , eventName ) ;
3429
3530 // In web mode, listen for DOM events
@@ -46,7 +41,7 @@ const listen = tauriListen || ((eventName: string, callback: (event: any) => voi
4641 console . log ( '[ClaudeCodeSession] Removing DOM event listener for:' , eventName ) ;
4742 window . removeEventListener ( eventName , domEventHandler ) ;
4843 } ) ;
49- } ) ;
44+ } ;
5045import { StreamMessage } from "./StreamMessage" ;
5146import { FloatingPromptInput , type FloatingPromptInputRef } from "./FloatingPromptInput" ;
5247import { ErrorBoundary } from "./ErrorBoundary" ;
0 commit comments