11import { useState , useCallback , useEffect , useRef , useMemo } from 'react'
22import { Routes , Route , Navigate , useNavigate , useLocation , useSearchParams , matchPath } from 'react-router-dom'
3- import { FluentProvider , webLightTheme , webDarkTheme } from '@fluentui/react-components'
43import { useMsal } from '@azure/msal-react'
54import { Joyride } from 'react-joyride'
5+ import { useTheme } from './hooks/useTheme'
66import MainLayout from './components/Layout/MainLayout'
77import ChatWindow from './components/Chat/ChatWindow'
88import AttackNotFound from './components/Chat/AttackNotFound'
@@ -94,7 +94,6 @@ function App() {
9494 const routeConversationId = conversationMatch ?. params . conversationId ?? null
9595 const currentView : ViewName = routeAttackId !== null ? 'chat' : viewFromPath ( location . pathname )
9696
97- const [ isDarkMode , setIsDarkMode ] = useState ( true )
9897 const [ activeTarget , setActiveTarget ] = useState < TargetInstance | null > ( null )
9998 const [ globalLabels , setGlobalLabels ] = useState < Record < string , string > > ( { ...DEFAULT_GLOBAL_LABELS } )
10099
@@ -310,10 +309,6 @@ function App() {
310309 navigate ( attackPath ( openAttackResultId ) )
311310 } , [ navigate ] )
312311
313- const toggleTheme = ( ) => {
314- setIsDarkMode ( ! isDarkMode )
315- }
316-
317312 const chatElement = isAttackNotFound || isAttackError ? (
318313 < AttackNotFound
319314 attackId = { routeAttackId ?? '' }
@@ -341,7 +336,8 @@ function App() {
341336 )
342337
343338 // Onboarding tour — pass handleNavigate so the tour can switch views between steps
344- const { startTour, hasCompletedTour, tourProps } = useTour ( handleNavigate , isDarkMode , currentView )
339+ const { resolved } = useTheme ( )
340+ const { startTour, hasCompletedTour, tourProps } = useTour ( handleNavigate , resolved === 'dark' , currentView )
345341
346342 // Auto-start the tour on first visit
347343 useEffect ( ( ) => {
@@ -354,14 +350,11 @@ function App() {
354350 return (
355351 < ErrorBoundary >
356352 < ConnectionHealthProvider >
357- < FluentProvider theme = { isDarkMode ? webDarkTheme : webLightTheme } >
358353 < Joyride { ...tourProps } />
359354 < ConnectionBannerContainer />
360355 < MainLayout
361356 currentView = { currentView }
362357 onNavigate = { handleNavigate }
363- onToggleTheme = { toggleTheme }
364- isDarkMode = { isDarkMode }
365358 onOpenFeedback = { ( ) => setFeedbackOpen ( true ) }
366359 onStartTour = { startTour }
367360 >
@@ -423,7 +416,6 @@ function App() {
423416 } }
424417 />
425418 ) }
426- </ FluentProvider >
427419 </ ConnectionHealthProvider >
428420 </ ErrorBoundary >
429421 )
0 commit comments