mirror of
https://github.com/jlengrand/Maestro.git
synced 2026-03-10 08:31:19 +00:00
fix: Clear unread indicator when switching to a tab
Added a central useEffect that clears the hasUnread flag whenever the active tab changes. This handles all tab switch scenarios (click, keyboard, programmatic) in one place.
This commit is contained in:
@@ -1664,11 +1664,27 @@ export default function MaestroConsole() {
|
||||
const prevActiveTabIdRef = useRef<string | undefined>(activeTab?.id);
|
||||
|
||||
// Sync local AI input with tab's persisted value when switching tabs
|
||||
// Also clear the hasUnread indicator when a tab becomes active
|
||||
useEffect(() => {
|
||||
if (activeTab && activeTab.id !== prevActiveTabIdRef.current) {
|
||||
// Tab changed - load the new tab's persisted input value
|
||||
setAiInputValueLocal(activeTab.inputValue ?? '');
|
||||
prevActiveTabIdRef.current = activeTab.id;
|
||||
|
||||
// Clear hasUnread indicator on the newly active tab
|
||||
// This is the central place that handles all tab switches regardless of how they happen
|
||||
// (click, keyboard shortcut, programmatic, etc.)
|
||||
if (activeTab.hasUnread && activeSession) {
|
||||
setSessions(prev => prev.map(s => {
|
||||
if (s.id !== activeSession.id) return s;
|
||||
return {
|
||||
...s,
|
||||
aiTabs: s.aiTabs.map(t =>
|
||||
t.id === activeTab.id ? { ...t, hasUnread: false } : t
|
||||
)
|
||||
};
|
||||
}));
|
||||
}
|
||||
}
|
||||
// Note: We intentionally only depend on activeTab?.id, NOT activeTab?.inputValue
|
||||
// The inputValue changes when we blur (syncAiInputToSession), but we don't want
|
||||
|
||||
@@ -322,24 +322,12 @@ export function setActiveTab(session: Session, tabId: string): SetActiveTabResul
|
||||
};
|
||||
}
|
||||
|
||||
// Update the session with the new active tab
|
||||
// Also clear the hasUnread flag on the tab being activated
|
||||
const updatedTabs = session.aiTabs.map(tab =>
|
||||
tab.id === tabId ? { ...tab, hasUnread: false } : tab
|
||||
);
|
||||
|
||||
const updatedSession: Session = {
|
||||
...session,
|
||||
activeTabId: tabId,
|
||||
aiTabs: updatedTabs
|
||||
};
|
||||
|
||||
// Return the updated target tab (with hasUnread cleared)
|
||||
const updatedTargetTab = updatedTabs.find(tab => tab.id === tabId)!;
|
||||
|
||||
return {
|
||||
tab: updatedTargetTab,
|
||||
session: updatedSession
|
||||
tab: targetTab,
|
||||
session: {
|
||||
...session,
|
||||
activeTabId: tabId
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user