Skip to content

sessions: set session title to first message text immediately#310345

Merged
roblourens merged 6 commits intomainfrom
agents/immediate-session-title-update
Apr 16, 2026
Merged

sessions: set session title to first message text immediately#310345
roblourens merged 6 commits intomainfrom
agents/immediate-session-title-update

Conversation

@roblourens
Copy link
Copy Markdown
Member

@roblourens roblourens commented Apr 15, 2026

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

  1. agentSideEffects.ts — On the first turn (SessionTurnStarted with turns.length === 0), immediately dispatch SessionTitleChanged with 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.

  2. agentService.tslistSessions() 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. Uses DEFAULT_SESSION_TITLE constant to avoid hardcoding the placeholder string.

  3. common/agentService.ts — Extracted DEFAULT_SESSION_TITLE constant for the initial placeholder title, used consistently in session creation and side effects checks.

(Written by Copilot)

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)
Copilot AI review requested due to automatic review settings April 15, 2026 23:49
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 15, 2026

Screenshot Changes

Base: d75a4078 Current: 6314404e

Changed (2)

agentSessionsViewer/CloudProvider/Dark
Before After
before after
agentSessionsViewer/CloudProvider/Light
Before After
before after

blocks-ci screenshots changed

Replace the contents of test/componentFixtures/blocks-ci-screenshots.md with:

Updated blocks-ci-screenshots.md
<!-- auto-generated by CI — do not edit manually -->

#### editor/codeEditor/CodeEditor/Dark
![screenshot](https://hediet-screenshots.azurewebsites.net/images/cb32a3e854b5734fe5aaca2318f2e0a42ee821b05ea97883ea42c5ba95edb3c3)

#### editor/codeEditor/CodeEditor/Light
![screenshot](https://hediet-screenshots.azurewebsites.net/images/42624fbba5e0db7f32c224b5eb9c5dd3b08245697ae2e7d2a88be0d7c287129b)

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 SessionTitleChanged on the first SessionTurnStarted to set the title from the first user message.
  • Update AgentService.listSessions() to overlay the live state manager title into returned session metadata.
  • Consume notify/sessionSummaryChanged notifications 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 SessionTitleChanged server action is emitted on the first SessionTurnStarted for a new session, and that it does not trigger when the title was already customized (e.g. via SessionTitleChanged).
				// 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

Comment thread src/vs/platform/agentHost/node/agentService.ts Outdated
Comment thread src/vs/platform/agentHost/node/agentSideEffects.ts Outdated
Comment thread src/vs/sessions/contrib/localAgentHost/browser/localAgentHostSessionsProvider.ts Outdated
- 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>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/titleChanged on the first session/turnStarted to 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

Comment thread src/vs/platform/agentHost/node/agentSideEffects.ts
Comment thread src/vs/platform/agentHost/test/node/agentSideEffects.test.ts Outdated
- 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>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/titleChanged on the first session/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 provider listSessions() 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

Comment thread src/vs/platform/agentHost/node/agentService.ts
Comment thread src/vs/platform/agentHost/node/agentService.ts
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>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/titleChanged on the first session/turnStarted when 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_TITLE constant 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

Comment thread src/vs/platform/agentHost/node/agentSideEffects.ts
…ion-title-update

# Conflicts:
#	src/vs/platform/agentHost/node/agentSideEffects.ts
@roblourens roblourens marked this pull request as ready for review April 16, 2026 01:17
@roblourens roblourens enabled auto-merge (squash) April 16, 2026 01:17
@roblourens roblourens marked this pull request as draft April 16, 2026 01:19
auto-merge was automatically disabled April 16, 2026 01:19

Pull request was converted to draft

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>
@roblourens roblourens marked this pull request as ready for review April 16, 2026 01:24
@roblourens roblourens enabled auto-merge (squash) April 16, 2026 01:24
@roblourens roblourens disabled auto-merge April 16, 2026 01:26
@roblourens roblourens enabled auto-merge (squash) April 16, 2026 01:35
@roblourens roblourens merged commit 9a19d73 into main Apr 16, 2026
25 of 26 checks passed
@roblourens roblourens deleted the agents/immediate-session-title-update branch April 16, 2026 01:45
@vs-code-engineering vs-code-engineering bot added this to the 1.117.0 milestone Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants