sessions: set session title to first message text immediately#310345
sessions: set session title to first message text immediately#310345roblourens merged 6 commits intomainfrom
Conversation
When a new agent host session starts, the title shows "New Session" for a long time until the AI-generated title arrives. Fix this by: 1. Dispatching SessionTitleChanged with the user's message text on the first turn in agentSideEffects 2. Overlaying the live title from the state manager in listSessions so refreshSessions picks up the updated title instead of the stale SDK value 3. Handling notify/sessionSummaryChanged in both local and remote session providers to propagate title changes via the notification channel Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> (Written by Copilot)
Screenshot ChangesBase: Changed (2)blocks-ci screenshots changedReplace the contents of Updated blocks-ci-screenshots.md<!-- auto-generated by CI — do not edit manually -->
#### editor/codeEditor/CodeEditor/Dark

#### editor/codeEditor/CodeEditor/Light
 |
There was a problem hiding this comment.
Pull request overview
Improves the Agents/Sessions UI experience by ensuring new sessions get a meaningful title immediately (using the user’s first message), and by ensuring session listings reflect the state manager’s live title instead of being overwritten by stale provider/SDK metadata.
Changes:
- Dispatch
SessionTitleChangedon the firstSessionTurnStartedto set the title from the first user message. - Update
AgentService.listSessions()to overlay the live state manager title into returned session metadata. - Consume
notify/sessionSummaryChangednotifications in local/remote sessions providers to react to title changes via the notification channel.
Show a summary per file
| File | Description |
|---|---|
| src/vs/sessions/contrib/remoteAgentHost/browser/remoteAgentHostSessionsProvider.ts | Handles notify/sessionSummaryChanged (title) to update cached session titles. |
| src/vs/sessions/contrib/localAgentHost/browser/localAgentHostSessionsProvider.ts | Handles notify/sessionSummaryChanged (title) to update cached session titles. |
| src/vs/platform/agentHost/node/agentSideEffects.ts | Sets session title to first user message text on the first turn. |
| src/vs/platform/agentHost/node/agentService.ts | Overlays live state manager title into listSessions() results. |
Copilot's findings
Comments suppressed due to low confidence (1)
src/vs/platform/agentHost/node/agentSideEffects.ts:568
- This new behavior (auto-setting the session title on the first turn) isn’t covered by existing AgentSideEffects tests. Please add a unit test that asserts a
SessionTitleChangedserver action is emitted on the firstSessionTurnStartedfor a new session, and that it does not trigger when the title was already customized (e.g. viaSessionTitleChanged).
// On the very first turn, immediately set the session title to the
// user's message so the UI shows a meaningful title right away
// instead of "New Session" while waiting for the AI-generated title.
const state = this._stateManager.getSessionState(action.session);
if (state && state.turns.length === 0) {
this._stateManager.dispatchServerAction({
type: ActionType.SessionTitleChanged,
session: action.session,
title: action.userMessage.text,
});
- Files reviewed: 4/4 changed files
- Comments generated: 4
- Use empty string as initial session title instead of 'New Session' sentinel. The UI already falls back to the localized 'New Session' label when the title is falsy, so no display change. - Simplify listSessions overlay: liveTitle || s.summary (natural falsy) - Simplify side effects check: just turns.length === 0, no string compare - Remove redundant sessionSummaryChanged notification handlers - Add 3 unit tests for immediate title dispatch (first turn, whitespace, second turn) - Add 1 unit test for listSessions title overlay - Add 1 integration test for end-to-end immediate title via WebSocket - Update existing agent-generated title integration test to expect immediate title first (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Improves session UX in the Agent Host by ensuring new sessions get a meaningful title immediately (using the first user message) and by preventing listSessions() results from overwriting that live title with stale provider/SDK titles.
Changes:
- Dispatch
session/titleChangedon the firstsession/turnStartedto immediately set the title from the user’s message text. - Update
AgentService.listSessions()to overlay live state manager title (when non-empty) over provider/SDK session summaries. - Adjust and add tests to validate immediate title behavior and
listSessions()title overlay.
Show a summary per file
| File | Description |
|---|---|
| src/vs/platform/agentHost/node/agentSideEffects.ts | Adds first-turn fallback title dispatch based on the user’s first message. |
| src/vs/platform/agentHost/node/agentService.ts | Overlays live state-manager title into listSessions() results; initializes new session title as empty string. |
| src/vs/platform/agentHost/test/node/protocol/sessionFeatures.integrationTest.ts | Updates existing title broadcast test to account for fallback-first behavior; adds integration test for immediate title + listSessions(). |
| src/vs/platform/agentHost/test/node/agentSideEffects.test.ts | Adds unit coverage for first-turn immediate title behavior, including whitespace and second-turn cases. |
| src/vs/platform/agentHost/test/node/agentService.test.ts | Adds unit test ensuring listSessions() prefers live state-manager title over SDK summary. |
| src/vs/platform/agentHost/test/node/protocolServerHandler.test.ts | Updates mock session creation to start with an empty title. |
Copilot's findings
- Files reviewed: 6/6 changed files
- Comments generated: 2
- Only dispatch immediate title when state.summary.title is empty, preventing overwrite of user-renamed or provider-set titles - Add test for the non-empty title guard - Fix misleading test comment (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR improves the user experience for newly created agent host sessions by setting a meaningful session title immediately (based on the first user message) instead of showing a placeholder until an agent-generated title arrives. It does this by updating server-side side effects to emit an early session/titleChanged, and by ensuring listSessions() prefers the state manager’s live title so refreshed session lists don’t regress to stale provider/SDK titles.
Changes:
- Dispatch an immediate
session/titleChangedon the firstsession/turnStarted, using the trimmed first user message as a fallback title. - Update
AgentService.listSessions()to overlay the live state-manager title (in addition to status/model) onto providerlistSessions()results. - Update/extend agent host protocol and unit/integration tests to cover the immediate-title behavior and the
listSessions()overlay.
Show a summary per file
| File | Description |
|---|---|
| src/vs/platform/agentHost/node/agentSideEffects.ts | Emits a fallback title change on the first user turn when the title is still unset. |
| src/vs/platform/agentHost/node/agentService.ts | Overlays the live state-manager title into listSessions() results; initializes new session title as empty. |
| src/vs/platform/agentHost/test/node/protocol/sessionFeatures.integrationTest.ts | Adds coverage for immediate title behavior and adjusts existing title broadcast test. |
| src/vs/platform/agentHost/test/node/agentSideEffects.test.ts | Adds unit tests for first-turn immediate title dispatch and guard conditions. |
| src/vs/platform/agentHost/test/node/agentService.test.ts | Adds test verifying listSessions() prefers state-manager title over SDK/provider title. |
| src/vs/platform/agentHost/test/node/protocolServerHandler.test.ts | Updates mock session creation to align with empty initial title behavior. |
Copilot's findings
- Files reviewed: 6/6 changed files
- Comments generated: 2
Reverts from empty string to 'New Session' placeholder with a named constant (DEFAULT_SESSION_TITLE) to avoid blank titles in consumers using nullish coalescing (`??`) instead of logical OR (`||`). The side effects check now compares against the constant, and listSessions overlay skips the default title to avoid overwriting SDK-reported titles. Updated PR description to match final implementation (removed reference to provider-side sessionSummaryChanged handlers). (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR improves early session UX in the agent host by setting a meaningful session title immediately on the first user turn (using the first message text), and ensuring subsequent listSessions() results don’t overwrite that early title with the provider’s placeholder value.
Changes:
- Dispatch
session/titleChangedon the firstsession/turnStartedwhen the session is still using the default placeholder title. - Update
AgentService.listSessions()to prefer the live state-manager title (when not the placeholder) over the provider/SDK-reported title. - Introduce and reuse a shared
DEFAULT_SESSION_TITLEconstant and add tests covering the new behavior.
Show a summary per file
| File | Description |
|---|---|
| src/vs/platform/agentHost/common/agentService.ts | Introduces DEFAULT_SESSION_TITLE constant for consistent placeholder title usage. |
| src/vs/platform/agentHost/node/agentSideEffects.ts | On first turn, dispatches an immediate SessionTitleChanged based on the user’s message text. |
| src/vs/platform/agentHost/node/agentService.ts | Overlays the live state-manager title in listSessions() to avoid stale/placeholder clobbering. |
| src/vs/platform/agentHost/test/node/protocolServerHandler.test.ts | Uses DEFAULT_SESSION_TITLE in test session creation to match production behavior. |
| src/vs/platform/agentHost/test/node/protocol/sessionFeatures.integrationTest.ts | Updates title broadcast test expectations and adds coverage for the immediate first-turn title + listSessions. |
| src/vs/platform/agentHost/test/node/agentSideEffects.test.ts | Adds unit coverage for immediate title dispatch and guard conditions. |
| src/vs/platform/agentHost/test/node/agentService.test.ts | Adds unit coverage for listSessions() title overlay behavior. |
Copilot's findings
- Files reviewed: 7/7 changed files
- Comments generated: 1
…ion-title-update # Conflicts: # src/vs/platform/agentHost/node/agentSideEffects.ts
Reverts to empty string as the initial session title for simplicity. Fixes downstream consumers that used nullish coalescing (??) to use logical OR (||) so empty strings correctly fall through to the fallback label. Also normalizes whitespace and truncates the fallback title to 200 characters. Affected consumers: - agentHostSessionListController.ts - localAgentHostSessionsProvider.ts - remoteAgentHostSessionsProvider.ts (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
When a new agent host session starts, the title shows "New Session" for a long time until the AI-generated title arrives. This fixes the issue by immediately setting the title to the user's first message text.
Changes
agentSideEffects.ts— On the first turn (SessionTurnStartedwithturns.length === 0), immediately dispatchSessionTitleChangedwith the user's message text so the state manager has a meaningful title right away. Guards against clobbering user-renamed titles or whitespace-only messages.agentService.ts—listSessions()now overlays the title from the state manager's live state (not just status/model). This prevents the stale SDK-reported title from overwriting the immediate title that was already dispatched. UsesDEFAULT_SESSION_TITLEconstant to avoid hardcoding the placeholder string.common/agentService.ts— ExtractedDEFAULT_SESSION_TITLEconstant for the initial placeholder title, used consistently in session creation and side effects checks.(Written by Copilot)