jan/web-app/src/providers/ServiceHubProvider.tsx
Dinh Long Nguyen a30eb7f968
feat: Jan Web (reusing Jan Desktop UI) (#6298)
* add platform guards

* add service management

* fix types

* move to zustand for servicehub

* update App Updater

* update tauri missing move

* update app updater

* refactor: move PlatformFeatures to separate const file

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* change tauri fetch name

* update implementation

* update extension fetch

* make web version run properly

* disabled unused web settings

* fix all tests

* fix lint

* fix tests

* add mock for extension

* fix build

* update make and mise

* fix tsconfig for web-extensions

* fix loader type

* cleanup

* fix test

* update error handling + mcp should be working

* Update mcp init

* use separate is_web_app build property

* Remove fixed model catalog url

* fix additional tests

* fix download issue (event emitter not implemented correctly)

* Update Title html

* fix app logs

* update root tsx render timing

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-09-05 01:47:46 +07:00

26 lines
774 B
TypeScript

import { useEffect, useState } from 'react'
import { initializeServiceHub } from '@/services'
import { initializeServiceHubStore } from '@/hooks/useServiceHub'
interface ServiceHubProviderProps {
children: React.ReactNode
}
export function ServiceHubProvider({ children }: ServiceHubProviderProps) {
const [isReady, setIsReady] = useState(false)
useEffect(() => {
initializeServiceHub()
.then((hub) => {
console.log('Services initialized, initializing Zustand store')
initializeServiceHubStore(hub)
setIsReady(true)
})
.catch((error) => {
console.error('Service initialization failed:', error)
setIsReady(true) // Still render to show error state
})
}, [])
return <>{isReady && children}</>
}