ensure modes are tracked correctly for tips (#296571)

fixes #296557
This commit is contained in:
Megan Rogge
2026-02-24 11:06:12 -06:00
committed by GitHub
parent 67c59a1440
commit 4d65a97d25
2 changed files with 27 additions and 0 deletions

View File

@@ -793,6 +793,11 @@ export class ChatTipService extends Disposable implements IChatTipService {
getWelcomeTip(contextKeyService: IContextKeyService): IChatTip | undefined {
this._createSlashCommandsUsageTracker.syncContextKey(contextKeyService);
// Always record the current mode so that mode-based exclusions are
// persisted even on stable-rerender paths (e.g. user switches to Plan
// mode while viewing the Plan tip).
this._tracker.recordCurrentMode(contextKeyService);
this._tracker.refreshPromptFileExclusions();
// Check if tips are enabled
if (!this._configurationService.getValue<boolean>('chat.tips.enabled')) {

View File

@@ -723,6 +723,28 @@ suite('ChatTipService', () => {
assert.ok(tip2, 'Should get a welcome tip after resetSession');
});
test('Plan tip is excluded after switching to Plan mode during stable rerender', () => {
const service = createService();
// Start in Agent mode — Plan tip should be eligible
contextKeyService.createKey(ChatContextKeys.chatModeKind.key, ChatModeKind.Agent);
const modeNameKey = contextKeyService.createKey<string>(ChatContextKeys.chatModeName.key, 'Agent');
assert.ok(findTipById(service, 'tip.planMode'), 'Plan tip should be shown when in Agent mode');
// Simulate user switching to Plan mode (context keys update, widget rerenders)
modeNameKey.set('Plan');
// Stable rerender — getWelcomeTip is called again without resetSession
const rerenderTip = service.getWelcomeTip(contextKeyService);
assert.ok(!rerenderTip || rerenderTip.id !== 'tip.planMode', 'Plan tip should not be shown after switching to Plan mode');
// New session in Agent mode — Plan tip must NOT reappear
service.resetSession();
modeNameKey.set('Agent');
assertTipNeverShown(service, 'tip.planMode');
});
test('excludes tip when tracked tool has been invoked', () => {
const mockToolsService = createMockToolsService();
const tip: ITipDefinition = {