@@ -87,6 +87,10 @@ export class AgentTitleBarStatusWidget extends BaseActionViewItem {
8787 /** First focusable element for keyboard navigation */
8888 private _firstFocusableElement : HTMLElement | undefined ;
8989
90+ /** Tracks if this window applied a badge filter (unread/inProgress), so we only auto-clear our own filters */
91+ // TODO: This is imperfect. Targetted fix for vscode#290863. We should revisit storing filter state per-window to avoid this
92+ private _badgeFilterAppliedByThisWindow : 'unread' | 'inProgress' | null = null ;
93+
9094 /** Reusable menu for CommandCenterCenter items (e.g., debug toolbar) */
9195 private readonly _commandCenterMenu ;
9296
@@ -693,7 +697,7 @@ export class AgentTitleBarStatusWidget extends BaseActionViewItem {
693697 const hasUnreadSessions = unreadSessions . length > 0 ;
694698 const hasAttentionNeeded = attentionNeededSessions . length > 0 ;
695699
696- // Auto-clear filter if the filtered category becomes empty
700+ // Auto-clear filter if the filtered category becomes empty if this window applied it
697701 this . _clearFilterIfCategoryEmpty ( hasUnreadSessions , hasActiveSessions ) ;
698702
699703 const badge = $ ( 'div.agent-status-badge' ) ;
@@ -872,12 +876,14 @@ export class AgentTitleBarStatusWidget extends BaseActionViewItem {
872876 /**
873877 * Clear the filter if the currently filtered category becomes empty.
874878 * For example, if filtered to "unread" but no unread sessions exist, restore user's previous filter.
879+ * Only auto-clears if THIS window applied the badge filter to avoid cross-window interference.
875880 */
876881 private _clearFilterIfCategoryEmpty ( hasUnreadSessions : boolean , hasActiveSessions : boolean ) : void {
877- const { isFilteredToUnread, isFilteredToInProgress } = this . _getCurrentFilterState ( ) ;
878-
879- // Restore user's filter if filtered category is now empty
880- if ( ( isFilteredToUnread && ! hasUnreadSessions ) || ( isFilteredToInProgress && ! hasActiveSessions ) ) {
882+ // Only auto-clear if this window applied the badge filter
883+ // This prevents Window B from clearing filters that Window A set
884+ if ( this . _badgeFilterAppliedByThisWindow === 'unread' && ! hasUnreadSessions ) {
885+ this . _restoreUserFilter ( ) ;
886+ } else if ( this . _badgeFilterAppliedByThisWindow === 'inProgress' && ! hasActiveSessions ) {
881887 this . _restoreUserFilter ( ) ;
882888 }
883889 }
@@ -972,6 +978,8 @@ export class AgentTitleBarStatusWidget extends BaseActionViewItem {
972978 }
973979 // Clear the saved filter after restoring
974980 this . storageService . remove ( PREVIOUS_FILTER_STORAGE_KEY , StorageScope . PROFILE ) ;
981+ // Clear the per-window badge filter tracking
982+ this . _badgeFilterAppliedByThisWindow = null ;
975983 }
976984
977985 /**
@@ -1000,6 +1008,8 @@ export class AgentTitleBarStatusWidget extends BaseActionViewItem {
10001008 archived : true ,
10011009 read : true
10021010 } ) ;
1011+ // Track that this window applied the badge filter
1012+ this . _badgeFilterAppliedByThisWindow = 'unread' ;
10031013 }
10041014 } else {
10051015 if ( isFilteredToInProgress ) {
@@ -1015,6 +1025,8 @@ export class AgentTitleBarStatusWidget extends BaseActionViewItem {
10151025 archived : true ,
10161026 read : false
10171027 } ) ;
1028+ // Track that this window applied the badge filter
1029+ this . _badgeFilterAppliedByThisWindow = 'inProgress' ;
10181030 }
10191031 }
10201032
0 commit comments