mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-17 23:35:54 +01:00
committed by
GitHub
parent
77e838d5b0
commit
229d6c5920
@@ -12,7 +12,6 @@ import { IActionWidgetService } from '../../../../platform/actionWidget/browser/
|
||||
import { ActionListItemKind, IActionListDelegate, IActionListItem } from '../../../../platform/actionWidget/browser/actionList.js';
|
||||
import { ISessionsManagementService } from '../../sessions/browser/sessionsManagementService.js';
|
||||
import { autorun } from '../../../../base/common/observable.js';
|
||||
import { ISessionsProvidersService } from '../../sessions/browser/sessionsProvidersService.js';
|
||||
import { ISessionType } from '../../sessions/browser/sessionsProvider.js';
|
||||
|
||||
export class SessionTypePicker extends Disposable {
|
||||
@@ -26,7 +25,6 @@ export class SessionTypePicker extends Disposable {
|
||||
|
||||
constructor(
|
||||
@IActionWidgetService private readonly actionWidgetService: IActionWidgetService,
|
||||
@ISessionsProvidersService private readonly sessionsProvidersService: ISessionsProvidersService,
|
||||
@ISessionsManagementService private readonly sessionsManagementService: ISessionsManagementService,
|
||||
) {
|
||||
super();
|
||||
@@ -34,7 +32,7 @@ export class SessionTypePicker extends Disposable {
|
||||
this._register(autorun(reader => {
|
||||
const session = this.sessionsManagementService.activeSession.read(reader);
|
||||
if (session) {
|
||||
this._sessionTypes = this.sessionsProvidersService.getSessionTypesForProvider(session.providerId);
|
||||
this._sessionTypes = this.sessionsManagementService.getSessionTypes(session);
|
||||
this._sessionType = session.sessionType;
|
||||
} else {
|
||||
this._sessionTypes = [];
|
||||
|
||||
@@ -895,7 +895,11 @@ export class CopilotChatSessionsProvider extends Disposable implements ISessions
|
||||
|
||||
// -- Sessions --
|
||||
|
||||
getSessionTypes(session: ISessionData): ISessionType[] {
|
||||
getSessionTypes(chatId: string): ISessionType[] {
|
||||
const session = this._currentNewSession?.id === chatId ? this._currentNewSession : this._findChatSession(chatId);
|
||||
if (!session) {
|
||||
return [];
|
||||
}
|
||||
if (session instanceof CopilotCLISession) {
|
||||
return [CopilotCLISessionType];
|
||||
}
|
||||
@@ -1130,7 +1134,6 @@ export class CopilotChatSessionsProvider extends Disposable implements ISessions
|
||||
// Remove the temp from the cache (the adapter now owns the committed key)
|
||||
this._sessionCache.delete(key);
|
||||
this._currentNewSession = undefined;
|
||||
this._onDidChangeSessions.fire({ added: [], removed: [session], changed: [] });
|
||||
session.dispose();
|
||||
|
||||
// Notify listeners that the temp session was replaced by the committed one
|
||||
|
||||
@@ -248,7 +248,7 @@ export class RemoteAgentHostSessionsProvider extends Disposable implements ISess
|
||||
|
||||
// -- Sessions --
|
||||
|
||||
getSessionTypes(_chat: ISessionData): ISessionType[] {
|
||||
getSessionTypes(_chatId: string): ISessionType[] {
|
||||
return [...this.sessionTypes];
|
||||
}
|
||||
|
||||
|
||||
@@ -447,7 +447,7 @@ suite('RemoteAgentHostSessionsProvider', () => {
|
||||
requiresWorkspaceTrust: false,
|
||||
};
|
||||
const session = provider.createNewSession(workspace);
|
||||
const types = provider.getSessionTypes(session);
|
||||
const types = provider.getSessionTypes(session.id);
|
||||
|
||||
assert.strictEqual(types.length, 1);
|
||||
});
|
||||
|
||||
@@ -77,6 +77,11 @@ export interface ISessionsManagementService {
|
||||
*/
|
||||
getSession(resource: URI): ISession | undefined;
|
||||
|
||||
/**
|
||||
* Get all session types from all registered providers.
|
||||
*/
|
||||
getSessionTypes(session: ISession): ISessionType[];
|
||||
|
||||
/**
|
||||
* Get all session types from all registered providers.
|
||||
*/
|
||||
@@ -376,6 +381,11 @@ export class SessionsManagementService extends Disposable implements ISessionsMa
|
||||
private onDidReplaceSession(from: ISessionData, to: ISessionData): void {
|
||||
if (this._activeSession.get()?.sessionId === this._chatToSession(from).sessionId) {
|
||||
this.setActiveSession(this._chatToSession(to));
|
||||
this.onDidChangeSessionsFromSessionsProviders({
|
||||
added: [],
|
||||
removed: [from],
|
||||
changed: [to],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -427,10 +437,6 @@ export class SessionsManagementService extends Disposable implements ISessionsMa
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (updated) {
|
||||
this.setActiveSession(this._chatToSession(updated));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -519,6 +525,14 @@ export class SessionsManagementService extends Disposable implements ISessionsMa
|
||||
return sessionData ? this._chatToSession(sessionData) : undefined;
|
||||
}
|
||||
|
||||
getSessionTypes(session: ISession): ISessionType[] {
|
||||
const provider = this.sessionsProvidersService.getProviders().find(p => p.id === session.providerId);
|
||||
if (!provider) {
|
||||
return [];
|
||||
}
|
||||
return provider.getSessionTypes(session.activeChat.get().chatId);
|
||||
}
|
||||
|
||||
getAllSessionTypes(): ISessionType[] {
|
||||
return [...this._sessionTypes];
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ export interface ISessionsProvider {
|
||||
/** Update the session type for a session. */
|
||||
setSessionType(chatId: string, type: ISessionType): ISessionData;
|
||||
/** Returns session types available for the given session. */
|
||||
getSessionTypes(session: ISessionData): ISessionType[];
|
||||
getSessionTypes(chatId: string): ISessionType[];
|
||||
/** Rename a session. */
|
||||
renameSession(chatId: string, title: string): Promise<void>;
|
||||
/** Set the model for a session. */
|
||||
|
||||
@@ -35,7 +35,7 @@ export interface ISessionsProvidersService {
|
||||
/** Get available session types for a provider. */
|
||||
getSessionTypesForProvider(providerId: string): ISessionType[];
|
||||
/** Get available session types for a session from its provider. */
|
||||
getSessionTypes(session: ISessionData): ISessionType[];
|
||||
getSessionTypes(sessionId: string): ISessionType[];
|
||||
|
||||
// -- Aggregated Sessions --
|
||||
|
||||
@@ -140,12 +140,12 @@ export class SessionsProvidersService extends Disposable implements ISessionsPro
|
||||
return [...entry.provider.sessionTypes];
|
||||
}
|
||||
|
||||
getSessionTypes(session: ISessionData): ISessionType[] {
|
||||
const entry = this._providers.get(session.providerId);
|
||||
if (!entry) {
|
||||
getSessionTypes(chatId: string): ISessionType[] {
|
||||
const { provider } = this._resolveProvider(chatId);
|
||||
if (!provider) {
|
||||
return [];
|
||||
}
|
||||
return entry.provider.getSessionTypes(session);
|
||||
return provider.getSessionTypes(chatId);
|
||||
}
|
||||
|
||||
// -- Aggregated Sessions --
|
||||
|
||||
Reference in New Issue
Block a user