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:
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user