Suppress chat tips in terminal/editor inline chat (#295170)

This commit is contained in:
Copilot
2026-02-13 14:42:23 +00:00
committed by GitHub
parent d0a3dbb109
commit 60bf10573c
2 changed files with 39 additions and 2 deletions

View File

@@ -9,7 +9,7 @@ import { ContextKeyExpr, ContextKeyExpression, IContextKeyService } from '../../
import { createDecorator, IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js';
import { IProductService } from '../../../../platform/product/common/productService.js';
import { ChatContextKeys } from '../common/actions/chatContextKeys.js';
import { ChatModeKind } from '../common/constants.js';
import { ChatAgentLocation, ChatModeKind } from '../common/constants.js';
import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js';
import { Disposable, MutableDisposable } from '../../../../base/common/lifecycle.js';
import { ICommandService } from '../../../../platform/commands/common/commands.js';
@@ -655,6 +655,11 @@ export class ChatTipService extends Disposable implements IChatTipService {
return undefined;
}
// Only show tips in the main chat panel, not in terminal/editor inline chat
if (!this._isChatLocation(contextKeyService)) {
return undefined;
}
// Check if this is the request that was assigned a tip (for stable rerenders)
if (this._tipRequestId === requestId && this._shownTip) {
return this._createTip(this._shownTip);
@@ -693,6 +698,11 @@ export class ChatTipService extends Disposable implements IChatTipService {
return undefined;
}
// Only show tips in the main chat panel, not in terminal/editor inline chat
if (!this._isChatLocation(contextKeyService)) {
return undefined;
}
// Return the already-shown tip for stable rerenders
if (this._tipRequestId === 'welcome' && this._shownTip) {
return this._createTip(this._shownTip);
@@ -769,6 +779,11 @@ export class ChatTipService extends Disposable implements IChatTipService {
return true;
}
private _isChatLocation(contextKeyService: IContextKeyService): boolean {
const location = contextKeyService.getContextKeyValue<ChatAgentLocation>(ChatContextKeys.location.key);
return !location || location === ChatAgentLocation.Chat;
}
private _isCopilotEnabled(): boolean {
const defaultChatAgent = this._productService.defaultChatAgent;
return !!defaultChatAgent?.chatExtensionId;

View File

@@ -19,7 +19,7 @@ import { ChatTipService, ITipDefinition, TipEligibilityTracker } from '../../bro
import { AgentFileType, IPromptPath, IPromptsService, IResolvedAgentFile, PromptsStorage } from '../../common/promptSyntax/service/promptsService.js';
import { URI } from '../../../../../base/common/uri.js';
import { ChatContextKeys } from '../../common/actions/chatContextKeys.js';
import { ChatModeKind } from '../../common/constants.js';
import { ChatAgentLocation, ChatModeKind } from '../../common/constants.js';
import { PromptsType } from '../../common/promptSyntax/promptTypes.js';
import { ILanguageModelToolsService, IToolData, ToolDataSource } from '../../common/tools/languageModelToolsService.js';
import { MockLanguageModelToolsService } from '../common/tools/mockLanguageModelToolsService.js';
@@ -142,6 +142,28 @@ suite('ChatTipService', () => {
assert.strictEqual(tip, undefined, 'Should not return a tip when tips setting is disabled');
});
test('returns undefined when location is terminal', () => {
const service = createService();
const now = Date.now();
const terminalContextKeyService = new MockContextKeyServiceWithRulesMatching();
terminalContextKeyService.createKey(ChatContextKeys.location.key, ChatAgentLocation.Terminal);
const tip = service.getNextTip('request-1', now + 1000, terminalContextKeyService);
assert.strictEqual(tip, undefined, 'Should not return a tip in terminal inline chat');
});
test('returns undefined when location is editor inline', () => {
const service = createService();
const now = Date.now();
const editorContextKeyService = new MockContextKeyServiceWithRulesMatching();
editorContextKeyService.createKey(ChatContextKeys.location.key, ChatAgentLocation.EditorInline);
const tip = service.getNextTip('request-1', now + 1000, editorContextKeyService);
assert.strictEqual(tip, undefined, 'Should not return a tip in editor inline chat');
});
test('old requests do not consume the session tip allowance', () => {
const service = createService();
const now = Date.now();