Skip to content

Commit bf902d9

Browse files
authored
ensure we hide options picker if session has nothing to contribute (microsoft#272977)
1 parent 848d681 commit bf902d9

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

src/vs/workbench/contrib/chat/browser/chatInputPart.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,10 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
11391139
return hideAll();
11401140
}
11411141

1142+
if (!this.chatSessionsService.hasAnySessionOptions(ctx.chatSessionType, ctx.chatSessionId)) {
1143+
return hideAll();
1144+
}
1145+
11421146
this.chatSessionHasOptions.set(true);
11431147

11441148
const currentWidgetGroupIds = new Set(this.chatSessionPickerWidgets.keys());

src/vs/workbench/contrib/chat/browser/chatSessions.contribution.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,13 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
795795
this._sessions.delete(sessionKey);
796796
}
797797

798+
public hasAnySessionOptions(chatSessionType: string, id: string): boolean {
799+
const sessionKey = `${chatSessionType}_${id}`;
800+
const session = this._sessions.get(sessionKey);
801+
return !!session && !!session.options && Object.keys(session.options).length > 0;
802+
}
803+
804+
798805
public getSessionOption(chatSessionType: string, id: string, optionId: string): string | undefined {
799806
const sessionKey = `${chatSessionType}_${id}`;
800807
const session = this._sessions.get(sessionKey);

src/vs/workbench/contrib/chat/common/chatSessionsService.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ export interface IChatSessionsService {
183183
// Notify providers about session items changes
184184
notifySessionItemsChanged(chatSessionType: string): void;
185185

186+
hasAnySessionOptions(chatSessionType: string, sessionId: string): boolean;
186187
getSessionOption(chatSessionType: string, sessionId: string, optionId: string): string | undefined;
187188
setSessionOption(chatSessionType: string, sessionId: string, optionId: string, value: string): boolean;
188189

src/vs/workbench/contrib/chat/test/common/mockChatSessionsService.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,12 @@ export class MockChatSessionsService implements IChatSessionsService {
202202
return true;
203203
}
204204

205+
hasAnySessionOptions(chatSessionType: string, sessionId: string): boolean {
206+
const sessionKey = `${chatSessionType}:${sessionId}`;
207+
const options = this.sessionOptions.get(sessionKey);
208+
return options !== undefined && options.size > 0;
209+
}
210+
205211
getCapabilitiesForSessionType(chatSessionType: string): IChatAgentAttachmentCapabilities | undefined {
206212
return this.contributions.find(c => c.type === chatSessionType)?.capabilities;
207213
}

0 commit comments

Comments
 (0)