fix(chat): move toolbar to Header and add New Session button

- Move ChatToolbar (session selector, refresh, thinking toggle) from
  the Chat page body into the Header component, so controls appear
  at the same level as the "Chat" title
- Add New Session button (+) to create a fresh conversation
- Add newSession action to chat store
- Header conditionally renders ChatToolbar only on /chat route
- Chat page fills full content area without duplicate toolbar
This commit is contained in:
Haze
2026-02-06 04:57:25 +08:00
Unverified
parent 3468d1bdf4
commit 94a6cecf2f
4 changed files with 43 additions and 15 deletions

View File

@@ -60,6 +60,7 @@ interface ChatState {
// Actions
loadSessions: () => Promise<void>;
switchSession: (key: string) => void;
newSession: () => void;
loadHistory: () => Promise<void>;
sendMessage: (text: string) => Promise<void>;
handleChatEvent: (event: Record<string, unknown>) => void;
@@ -129,6 +130,23 @@ export const useChatStore = create<ChatState>((set, get) => ({
get().loadHistory();
},
// ── New session ──
newSession: () => {
// Generate a new unique session key and switch to it
const newKey = `session-${Date.now()}`;
set({
currentSessionKey: newKey,
messages: [],
streamingText: '',
streamingMessage: null,
activeRunId: null,
error: null,
});
// Reload sessions list to include the new one after first message
get().loadSessions();
},
// ── Load chat history ──
loadHistory: async () => {