mirror of
https://github.com/microsoft/vscode.git
synced 2026-08-15 10:15:04 +01:00
ensure terminal agent is registered
This commit is contained in:
@@ -43,6 +43,7 @@ export const enum TerminalContextKeyStrings {
|
||||
ChatVisible = 'terminalChatVisible',
|
||||
ChatActiveRequest = 'terminalChatActiveRequest',
|
||||
ChatInputHasText = 'terminalChatInputHasText',
|
||||
ChatAgentRegistered = 'terminalChatAgentRegistered',
|
||||
}
|
||||
|
||||
export namespace TerminalContextKeys {
|
||||
@@ -175,4 +176,7 @@ export namespace TerminalContextKeys {
|
||||
|
||||
/** Whether the chat input has text */
|
||||
export const chatInputHasText = new RawContextKey<boolean>(TerminalContextKeyStrings.ChatInputHasText, false, localize('chatInputHasTextContextKey', "Whether the chat input has text."));
|
||||
|
||||
/** Whether the terminal chat agent has been registered */
|
||||
export const chatAgentRegistered = new RawContextKey<boolean>(TerminalContextKeyStrings.ChatAgentRegistered, false, localize('chatAgentRegisteredContextKey', "Whether the terminal chat agent has been registered."));
|
||||
}
|
||||
|
||||
@@ -72,7 +72,8 @@ registerActiveXtermAction({
|
||||
precondition: ContextKeyExpr.and(
|
||||
ContextKeyExpr.has(`config.${TerminalSettingId.ExperimentalInlineChat}`),
|
||||
ContextKeyExpr.or(TerminalContextKeys.processSupported, TerminalContextKeys.terminalHasBeenCreated),
|
||||
TerminalContextKeys.chatRequestActive.negate()
|
||||
TerminalContextKeys.chatRequestActive.negate(),
|
||||
TerminalContextKeys.chatAgentRegistered
|
||||
),
|
||||
icon: Codicon.send,
|
||||
keybinding: {
|
||||
@@ -103,6 +104,7 @@ registerActiveXtermAction({
|
||||
precondition: ContextKeyExpr.and(
|
||||
ContextKeyExpr.has(`config.${TerminalSettingId.ExperimentalInlineChat}`),
|
||||
TerminalContextKeys.chatRequestActive,
|
||||
TerminalContextKeys.chatAgentRegistered
|
||||
),
|
||||
icon: Codicon.debugStop,
|
||||
menu: {
|
||||
|
||||
@@ -41,6 +41,7 @@ export class TerminalChatController extends Disposable implements ITerminalContr
|
||||
get chatWidget(): TerminalChatWidget | undefined { return this._chatWidget?.value; }
|
||||
|
||||
private readonly _ctxHasActiveRequest!: IContextKey<boolean>;
|
||||
private readonly _ctxHasTerminalAgent!: IContextKey<boolean>;
|
||||
|
||||
private _cancellationTokenSource!: CancellationTokenSource;
|
||||
|
||||
@@ -60,6 +61,16 @@ export class TerminalChatController extends Disposable implements ITerminalContr
|
||||
return;
|
||||
}
|
||||
this._ctxHasActiveRequest = TerminalContextKeys.chatRequestActive.bindTo(this._contextKeyService);
|
||||
this._ctxHasTerminalAgent = TerminalContextKeys.chatAgentRegistered.bindTo(this._contextKeyService);
|
||||
if (!this._chatAgentService.hasAgent('terminal')) {
|
||||
this._register(this._chatAgentService.onDidChangeAgents(() => {
|
||||
if (this._chatAgentService.getAgent('terminal')) {
|
||||
this._ctxHasTerminalAgent.set(true);
|
||||
}
|
||||
}));
|
||||
} else {
|
||||
this._ctxHasTerminalAgent.set(true);
|
||||
}
|
||||
this._cancellationTokenSource = new CancellationTokenSource();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user