feat: integrate TabBar into AppShell layout and route by activeTabId

- Add TabBar, useTabStore, useChatStore imports to AppShell
- Restore tabs from localStorage during bootstrap and connect active session
- Render <TabBar /> before <ContentRouter /> in the main content area
- Replace useSessionStore/activeSessionId with useTabStore/activeTabId in ContentRouter

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
程序员阿江(Relakkes) 2026-04-09 00:33:21 +08:00
parent e3accc4068
commit 8f0bbf0817
2 changed files with 13 additions and 3 deletions

View File

@ -5,6 +5,9 @@ import { ToastContainer } from '../shared/Toast'
import { useSettingsStore } from '../../stores/settingsStore'
import { useKeyboardShortcuts } from '../../hooks/useKeyboardShortcuts'
import { initializeDesktopServerUrl } from '../../lib/desktopRuntime'
import { TabBar } from './TabBar'
import { useTabStore } from '../../stores/tabStore'
import { useChatStore } from '../../stores/chatStore'
const isTauri = typeof window !== 'undefined' && ('__TAURI_INTERNALS__' in window || '__TAURI__' in window)
@ -21,6 +24,12 @@ export function AppShell() {
try {
await initializeDesktopServerUrl()
await fetchSettings()
// Restore tabs from localStorage
await useTabStore.getState().restoreTabs()
const activeId = useTabStore.getState().activeTabId
if (activeId) {
useChatStore.getState().connectToSession(activeId)
}
if (!cancelled) {
setReady(true)
}
@ -92,6 +101,7 @@ export function AppShell() {
)}
<Sidebar />
<main id="content-area" className={`flex-1 flex flex-col overflow-hidden relative ${isTauri ? 'pt-[38px]' : ''}`}>
<TabBar />
<ContentRouter />
</main>
<ToastContainer />

View File

@ -1,5 +1,5 @@
import { useUIStore } from '../../stores/uiStore'
import { useSessionStore } from '../../stores/sessionStore'
import { useTabStore } from '../../stores/tabStore'
import { useTeamStore } from '../../stores/teamStore'
import { EmptySession } from '../../pages/EmptySession'
import { ActiveSession } from '../../pages/ActiveSession'
@ -9,7 +9,7 @@ import { AgentTranscript } from '../../pages/AgentTranscript'
export function ContentRouter() {
const activeView = useUIStore((s) => s.activeView)
const activeSessionId = useSessionStore((s) => s.activeSessionId)
const activeTabId = useTabStore((s) => s.activeTabId)
const viewingAgentId = useTeamStore((s) => s.viewingAgentId)
if (activeView === 'settings') {
@ -33,7 +33,7 @@ export function ContentRouter() {
}
// Code view
if (!activeSessionId) {
if (!activeTabId) {
return <EmptySession />
}