agentHost: polish: skip side-chat rename round-trip

Keep the deterministic side-question title while avoiding an unnecessary model-tool-model cycle before the answer.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: f48399f6-8524-4cb1-b187-d7f3eb899620
This commit is contained in:
ulugbekna
2026-08-19 15:03:39 +02:00
co-authored by Copilot App
parent f9b007c9fc
commit cf6c02441f
2 changed files with 26 additions and 0 deletions
@@ -11,6 +11,7 @@ import { ILogService } from '../../log/common/log.js';
import { ISessionDataService } from '../common/sessionDataService.js';
import { SessionServerToolName } from '../common/serverToolNames.js';
import { ActionType } from '../common/state/sessionActions.js';
import { ChatOriginKind } from '../common/state/protocol/state.js';
import { buildDefaultChatUri, isAhpChatChannel, isDefaultChatUri, type Turn, type URI as ProtocolURI } from '../common/state/sessionState.js';
import { buildConversationContext, renderResponseMarkdown, truncateMiddle } from '../common/agentHostConversationContext.js';
import { AgentHostStateManager } from './agentHostStateManager.js';
@@ -448,6 +449,9 @@ export class AgentHostSessionTitleController extends Disposable {
return undefined;
}
const independentChat = this._independentChatChannel(channel, chatChannel);
if (independentChat && this._stateManager.getChatOrigin(independentChat)?.kind === ChatOriginKind.SideChat) {
return undefined;
}
const key = independentChat ?? channel;
if (this._renamedTitles.has(key)) {
return undefined;
@@ -13,6 +13,7 @@ import { NullLogService } from '../../../log/common/log.js';
import { AgentHostStateManager } from '../../node/agentHostStateManager.js';
import { AgentHostSessionTitleController } from '../../node/agentHostSessionTitleController.js';
import { ActionType } from '../../common/state/sessionActions.js';
import { ChatOriginKind } from '../../common/state/protocol/state.js';
import { buildChatUri, buildDefaultChatUri, MessageKind, ResponsePartKind, SessionStatus, ToolCallConfirmationReason, ToolCallStatus, TurnState, type ResponsePart, type SessionSummary, type ToolCallCompletedState, type Turn } from '../../common/state/sessionState.js';
import { type AutoMergeMethod, type CreatedPullRequest, type GitHubIssueOrPullRequest, type IAgentHostOctoKitService } from '../../node/shared/agentHostOctoKitService.js';
import { type ICopilotApiService, type ICopilotApiServiceRequestOptions, type ICopilotUtilityChatCompletionRequest } from '../../node/shared/copilotApiService.js';
@@ -269,6 +270,27 @@ suite('AgentHostSessionTitleController', () => {
});
});
test('active-agent mode keeps the fallback title without a rename reminder for side chats', async () => {
const { controller, stateManager, session } = setup(undefined, 'Session title', undefined, undefined, undefined, undefined, undefined, true);
const chat = buildChatUri(session.toString(), 'side-chat');
stateManager.addChat(session.toString(), chat, {
origin: {
kind: ChatOriginKind.SideChat,
chat: buildDefaultChatUri(session),
turnId: 'turn-1',
},
});
controller.seedTitleFromFirstMessage(session.toString(), 'salut', chat);
assert.deepStrictEqual({
title: stateManager.getChatState(chat)?.title,
instruction: await controller.prepareInstructionForAgent(session.toString(), chat),
}, {
title: 'salut',
instruction: undefined,
});
});
test('clearSession releases session and peer-chat rename state', async () => {
const { controller, stateManager, session, db } = setup(undefined, '', undefined, undefined, undefined, undefined, undefined, true);
const defaultChat = buildDefaultChatUri(session);