fix: proper tab isolation with updateTabById

- Added updateTabById function to store for updating specific tabs by ID
- Capture tab ID at request start (requestTabId)
- All streaming updates now go to the captured tab ID, not activeTabId
- Switching tabs during streaming no longer pollutes other tabs
- Local UI state only updates if still on the same tab
- Complete isolation: each tab's history/preview/agent is independent
This commit is contained in:
Gemini AI
2025-12-29 03:14:07 +04:00
Unverified
parent 0e1bdb0c06
commit 9996622b12
2 changed files with 33 additions and 20 deletions

View File

@@ -56,6 +56,7 @@ interface AppState {
addAIAssistTab: (agent?: string) => void;
removeAIAssistTab: (id: string) => void;
updateActiveTab: (updates: Partial<AIAssistTab>) => void;
updateTabById: (tabId: string, updates: Partial<AIAssistTab>) => void;
setLanguage: (lang: "en" | "ru" | "he") => void;
setSelectedProvider: (provider: ModelProvider) => void;
@@ -149,6 +150,11 @@ const useStore = create<AppState>((set) => ({
t.id === state.activeTabId ? { ...t, ...updates } : t
)
})),
updateTabById: (tabId, updates) => set((state) => ({
aiAssistTabs: state.aiAssistTabs.map(t =>
t.id === tabId ? { ...t, ...updates } : t
)
})),
setLanguage: (lang) => set({ language: lang }),
setSelectedProvider: (provider) => set({ selectedProvider: provider }),