Change:
The context key used in terminal and notebook chat which is wrong because it signals that there is a chat participant for the editor location and it doesn't know anything about other locations.
It's now removed from the notebook side.

Discussion:
registerTerminalContribution(TerminalChatController.ID, TerminalChatController, false); <ins> registerWorkbenchContribution2(TerminalChatEnabler.Id, TerminalChatEnabler, WorkbenchPhase.AfterRestored); </ins> // #endregion // #region Contributions

import 'vs/workbench/contrib/terminalContrib/chat/browser/terminalChatActions'; import { AccessibleViewRegistry } from 'vs/platform/accessibility/browser/accessibleViewRegistry'; import { TerminalChatAccessibilityHelp } from 'vs/workbench/contrib/terminalContrib/chat/browser/terminalChatAccessibilityHelp'; <ins> import { registerWorkbenchContribution2, WorkbenchPhase } from 'vs/workbench/common/contributions'; import { TerminalChatEnabler } from 'vs/workbench/contrib/terminalContrib/chat/browser/terminalChatEnabler'; </ins> // #endregion

/** The chat response contains multiple code blocks */ export const responseContainsMultipleCodeBlocks = new RawContextKey<boolean>(TerminalChatContextKeyStrings.ChatResponseContainsMultipleCodeBlocks, false, localize('chatResponseContainsMultipleCodeBlocksContextKey', "Whether the chat response contains multiple code blocks.")); <ins> /** A chat agent exists for the terminal location */ export const hasChatAgent = new RawContextKey<boolean>(TerminalChatContextKeyStrings.ChatAgentRegistered, false, localize('chatAgentRegisteredContextKey', "Whether a chat agent is registered for the terminal location.")); </ins> }

import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { AbstractInlineChatAction } from 'vs/workbench/contrib/inlineChat/browser/inlineChatActions'; <del> import { CTX_INLINE_CHAT_EMPTY, CTX_INLINE_CHAT_FOCUSED, CTX_INLINE_CHAT_HAS_AGENT } from 'vs/workbench/contrib/inlineChat/common/inlineChat'; </del> <ins> import { CTX_INLINE_CHAT_EMPTY, CTX_INLINE_CHAT_FOCUSED } from 'vs/workbench/contrib/inlineChat/common/inlineChat'; </ins> import { isDetachedTerminalInstance } from 'vs/workbench/contrib/terminal/browser/terminal'; import { registerActiveXtermAction } from 'vs/workbench/contrib/terminal/browser/terminalActions'; import { TerminalContextKeys } from 'vs/workbench/contrib/terminal/common/terminalContextKey';

precondition: ContextKeyExpr.and( ContextKeyExpr.or(TerminalContextKeys.processSupported, TerminalContextKeys.terminalHasBeenCreated), // TODO: This needs to change to check for a terminal location capable agent <del> CTX_INLINE_CHAT_HAS_AGENT </del> <ins> TerminalChatContextKeys.hasChatAgent </ins> ), run: (_xterm, _accessor, activeInstance, opts?: unknown) => { if (isDetachedTerminalInstance(activeInstance)) {

<ins> /*--------------------------------------------------------------------------------------------- *  Copyright (c) Microsoft Corporation. All rights reserved. *  Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ import { DisposableStore } from 'vs/base/common/lifecycle'; import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IChatAgentService, ChatAgentLocation } from 'vs/workbench/contrib/chat/common/chatAgents'; import { TerminalChatContextKeys } from 'vs/workbench/contrib/terminal/browser/terminalContribExports'; export class TerminalChatEnabler { static Id = 'terminalChat.enabler'; private readonly _ctxHasProvider: IContextKey<boolean>; private readonly _store = new DisposableStore(); constructor( @IContextKeyService contextKeyService: IContextKeyService, @IChatAgentService chatAgentService: IChatAgentService ) { this._ctxHasProvider = TerminalChatContextKeys.hasChatAgent.bindTo(contextKeyService); this._store.add(chatAgentService.onDidChangeAgents(() => { const hasTerminalAgent = Boolean(chatAgentService.getDefaultAgent(ChatAgentLocation.Terminal)); this._ctxHasProvider.set(hasTerminalAgent); })); } dispose() { this._ctxHasProvider.reset(); this._store.dispose(); } } </ins>