mirror of
https://github.com/NanmiCoder/cc-haha
synced 2026-07-19 13:33:35 +08:00
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:
parent
e3accc4068
commit
8f0bbf0817
@ -5,6 +5,9 @@ import { ToastContainer } from '../shared/Toast'
|
|||||||
import { useSettingsStore } from '../../stores/settingsStore'
|
import { useSettingsStore } from '../../stores/settingsStore'
|
||||||
import { useKeyboardShortcuts } from '../../hooks/useKeyboardShortcuts'
|
import { useKeyboardShortcuts } from '../../hooks/useKeyboardShortcuts'
|
||||||
import { initializeDesktopServerUrl } from '../../lib/desktopRuntime'
|
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)
|
const isTauri = typeof window !== 'undefined' && ('__TAURI_INTERNALS__' in window || '__TAURI__' in window)
|
||||||
|
|
||||||
@ -21,6 +24,12 @@ export function AppShell() {
|
|||||||
try {
|
try {
|
||||||
await initializeDesktopServerUrl()
|
await initializeDesktopServerUrl()
|
||||||
await fetchSettings()
|
await fetchSettings()
|
||||||
|
// Restore tabs from localStorage
|
||||||
|
await useTabStore.getState().restoreTabs()
|
||||||
|
const activeId = useTabStore.getState().activeTabId
|
||||||
|
if (activeId) {
|
||||||
|
useChatStore.getState().connectToSession(activeId)
|
||||||
|
}
|
||||||
if (!cancelled) {
|
if (!cancelled) {
|
||||||
setReady(true)
|
setReady(true)
|
||||||
}
|
}
|
||||||
@ -92,6 +101,7 @@ export function AppShell() {
|
|||||||
)}
|
)}
|
||||||
<Sidebar />
|
<Sidebar />
|
||||||
<main id="content-area" className={`flex-1 flex flex-col overflow-hidden relative ${isTauri ? 'pt-[38px]' : ''}`}>
|
<main id="content-area" className={`flex-1 flex flex-col overflow-hidden relative ${isTauri ? 'pt-[38px]' : ''}`}>
|
||||||
|
<TabBar />
|
||||||
<ContentRouter />
|
<ContentRouter />
|
||||||
</main>
|
</main>
|
||||||
<ToastContainer />
|
<ToastContainer />
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { useUIStore } from '../../stores/uiStore'
|
import { useUIStore } from '../../stores/uiStore'
|
||||||
import { useSessionStore } from '../../stores/sessionStore'
|
import { useTabStore } from '../../stores/tabStore'
|
||||||
import { useTeamStore } from '../../stores/teamStore'
|
import { useTeamStore } from '../../stores/teamStore'
|
||||||
import { EmptySession } from '../../pages/EmptySession'
|
import { EmptySession } from '../../pages/EmptySession'
|
||||||
import { ActiveSession } from '../../pages/ActiveSession'
|
import { ActiveSession } from '../../pages/ActiveSession'
|
||||||
@ -9,7 +9,7 @@ import { AgentTranscript } from '../../pages/AgentTranscript'
|
|||||||
|
|
||||||
export function ContentRouter() {
|
export function ContentRouter() {
|
||||||
const activeView = useUIStore((s) => s.activeView)
|
const activeView = useUIStore((s) => s.activeView)
|
||||||
const activeSessionId = useSessionStore((s) => s.activeSessionId)
|
const activeTabId = useTabStore((s) => s.activeTabId)
|
||||||
const viewingAgentId = useTeamStore((s) => s.viewingAgentId)
|
const viewingAgentId = useTeamStore((s) => s.viewingAgentId)
|
||||||
|
|
||||||
if (activeView === 'settings') {
|
if (activeView === 'settings') {
|
||||||
@ -33,7 +33,7 @@ export function ContentRouter() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Code view
|
// Code view
|
||||||
if (!activeSessionId) {
|
if (!activeTabId) {
|
||||||
return <EmptySession />
|
return <EmptySession />
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user