11import { useState , useEffect , useCallback , lazy , Suspense } from "react" ;
22import { Navbar } from "./components/Navbar" ;
33import { IdentityPanel } from "./components/IdentityPanel" ;
4+ import { TokenManagerDialog } from "./components/TokenManagerDialog" ;
45import { ThemeProvider } from "./lib/theme" ;
5- import { getUuid , setUuid , apiBind } from "./api/client" ;
6+ import { getUuid , setUuid , apiBind , setActiveApiToken } from "./api/client" ;
67import { ACPDirectView } from "./components/ACPDirectView" ;
8+ import { useTokens } from "./hooks/useTokens" ;
79
810const Dashboard = lazy ( ( ) => import ( "./pages/Dashboard" ) . then ( ( m ) => ( { default : m . Dashboard } ) ) ) ;
911const SessionDetail = lazy ( ( ) => import ( "./pages/SessionDetail" ) . then ( ( m ) => ( { default : m . SessionDetail } ) ) ) ;
1012
1113export default function App ( ) {
1214 const [ currentSessionId , setCurrentSessionId ] = useState < string | null > ( null ) ;
1315 const [ identityOpen , setIdentityOpen ] = useState ( false ) ;
16+ const [ tokenDialogOpen , setTokenDialogOpen ] = useState ( false ) ;
1417 const [ acpDirect , setAcpDirect ] = useState < { url : string ; token : string } | null > ( null ) ;
18+ const { tokens, activeTokenId, activeLabel, activeTokenValue, setActiveTokenId, addToken, removeToken, updateToken } = useTokens ( ) ;
19+
20+ // Sync active token to API client
21+ useEffect ( ( ) => {
22+ setActiveApiToken ( activeTokenValue ) ;
23+ } , [ activeTokenValue ] ) ;
24+
25+ const handleSetActiveToken = useCallback ( ( id : string ) => {
26+ setActiveTokenId ( id ) ;
27+ } , [ setActiveTokenId ] ) ;
1528
1629 // Simple hash-based router
1730 const parseRoute = useCallback ( ( ) => {
@@ -97,6 +110,8 @@ export default function App() {
97110 < div className = "flex h-screen flex-col bg-surface-0 text-text-primary" >
98111 < Navbar
99112 onIdentityClick = { ( ) => setIdentityOpen ( true ) }
113+ onTokenClick = { ( ) => setTokenDialogOpen ( true ) }
114+ activeTokenLabel = { currentSessionId ? undefined : activeLabel }
100115 sessionTitle = { currentSessionId || ( acpDirect ? "ACP" : undefined ) }
101116 onBack = { ( currentSessionId || acpDirect ) ? navigateToDashboard : undefined }
102117 />
@@ -114,6 +129,17 @@ export default function App() {
114129 </ Suspense >
115130
116131 < IdentityPanel open = { identityOpen } onClose = { ( ) => setIdentityOpen ( false ) } />
132+
133+ < TokenManagerDialog
134+ open = { tokenDialogOpen }
135+ onClose = { ( ) => setTokenDialogOpen ( false ) }
136+ tokens = { tokens }
137+ activeTokenId = { activeTokenId }
138+ onSetActive = { handleSetActiveToken }
139+ onAdd = { addToken }
140+ onRemove = { removeToken }
141+ onUpdate = { updateToken }
142+ />
117143 </ div >
118144 </ ThemeProvider >
119145 ) ;
0 commit comments