Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ export class AgentTitleBarStatusWidget extends BaseActionViewItem {
/** First focusable element for keyboard navigation */
private _firstFocusableElement: HTMLElement | undefined;

/** Tracks if this window applied a badge filter (unread/inProgress), so we only auto-clear our own filters */
// TODO: This is imperfect. Targetted fix for vscode#290863. We should revisit storing filter state per-window to avoid this
private _badgeFilterAppliedByThisWindow: 'unread' | 'inProgress' | null = null;

/** Reusable menu for CommandCenterCenter items (e.g., debug toolbar) */
private readonly _commandCenterMenu;

Expand Down Expand Up @@ -693,7 +697,7 @@ export class AgentTitleBarStatusWidget extends BaseActionViewItem {
const hasUnreadSessions = unreadSessions.length > 0;
const hasAttentionNeeded = attentionNeededSessions.length > 0;

// Auto-clear filter if the filtered category becomes empty
// Auto-clear filter if the filtered category becomes empty if this window applied it
this._clearFilterIfCategoryEmpty(hasUnreadSessions, hasActiveSessions);

const badge = $('div.agent-status-badge');
Expand Down Expand Up @@ -872,12 +876,14 @@ export class AgentTitleBarStatusWidget extends BaseActionViewItem {
/**
* Clear the filter if the currently filtered category becomes empty.
* For example, if filtered to "unread" but no unread sessions exist, restore user's previous filter.
* Only auto-clears if THIS window applied the badge filter to avoid cross-window interference.
*/
private _clearFilterIfCategoryEmpty(hasUnreadSessions: boolean, hasActiveSessions: boolean): void {
const { isFilteredToUnread, isFilteredToInProgress } = this._getCurrentFilterState();

// Restore user's filter if filtered category is now empty
if ((isFilteredToUnread && !hasUnreadSessions) || (isFilteredToInProgress && !hasActiveSessions)) {
// Only auto-clear if this window applied the badge filter
// This prevents Window B from clearing filters that Window A set
if (this._badgeFilterAppliedByThisWindow === 'unread' && !hasUnreadSessions) {
this._restoreUserFilter();
} else if (this._badgeFilterAppliedByThisWindow === 'inProgress' && !hasActiveSessions) {
this._restoreUserFilter();
}
}
Expand Down Expand Up @@ -972,6 +978,8 @@ export class AgentTitleBarStatusWidget extends BaseActionViewItem {
}
// Clear the saved filter after restoring
this.storageService.remove(PREVIOUS_FILTER_STORAGE_KEY, StorageScope.PROFILE);
// Clear the per-window badge filter tracking
this._badgeFilterAppliedByThisWindow = null;
}

/**
Expand Down Expand Up @@ -1000,6 +1008,8 @@ export class AgentTitleBarStatusWidget extends BaseActionViewItem {
archived: true,
read: true
});
// Track that this window applied the badge filter
this._badgeFilterAppliedByThisWindow = 'unread';
}
} else {
if (isFilteredToInProgress) {
Expand All @@ -1015,6 +1025,8 @@ export class AgentTitleBarStatusWidget extends BaseActionViewItem {
archived: true,
read: false
});
// Track that this window applied the badge filter
this._badgeFilterAppliedByThisWindow = 'inProgress';
}
}

Expand Down
Loading