Skip to content

agentHost: don't allow moving a chat that hasn't sent a message - #344057

Merged
Sandeep Somavarapu (sandy081) merged 3 commits into
mainfrom
agents/unsent-nested-not-movable
Oct 26, 2026
Merged

Sandeep Somavarapu (sandy081) merged 3 commits into
mainfrom
agents/unsent-nested-not-movable

Conversation

@sandy081

@sandy081 Sandeep Somavarapu (sandy081) commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

Fixes #343966

A new nested session that was never sent (the New Nested Session composer) could be moved by drag and drop, Move Up/Down, Promote and the move_session tool, which swapped its composer. Per the decision on #343966, a chat that hasn't sent its first message can't be moved by any path, and becomes movable once its first turn starts (a chat mid-first-turn is movable).

Host (authoritative)

  • IChatMoveEligibility.notStarted: a chat with loaded state and no turns and no active turn isn't advertised movable; recomputed on ChatTurnStarted.
  • _checkChatStarted refuses move, reorder, move session and the move_session pre-check with the existing NotStarted refusal; Promote keeps its own check. Reworded host/tool/client messages beyond "promotion".
  • A chat whose state isn't loaded (restored) counts as started, so cold moves still read no history.

Client

  • sessionsManagementService.canMoveChat also refuses an untitled chat, so hosts without this fix (remote/older) don't offer drag, Move Up/Down or Promote for it.

Intended behavior change in existing tests (moving a never-run chat now needs a turn first; this is the #343966 decision):

  • agentService.test.ts: chat/session creations in the move tests now use started helpers (createStartedChat/createStartedSession); MovingAgent restores one message; expectations adjusted in "a chat promotes only once its first turn started", the "deleting a chat that never moved" peer helper, "work deferred until a chat's turn ends", "checks a move as the host would refuse it", and the D4 confirmation test.
  • agentHostChatMovability.test.ts: addStartedChat helper for existing tests.
  • agentHostChatMoveErrors.test.ts, sessionsListContextMenu.test.ts: new message text.

New tests: every move path refuses an unsent chat and allows it after the first turn (agentService); movable once the first turn started, including while running (movability); untitled chat not movable on the client (sessionsManagementService). Each fails without its fix (mutation-checked).

Validation (whole folders): platform/agentHost/test/node 13466 passing; sessions/contrib/sessions/test/browser 1005; sessions/contrib/providers/agentHost/test/browser 1065; sessions/services/sessions/test/browser 657; eslint and typecheck-client clean. Live (isolated Code - OSS Agents window): an unsent New Nested Session row has no Promote to Session, Move Up/Down or other move entries, and dragging it onto another row moves nothing; after sending one message the row offers Promote to Session. Not covered live: the move_session refusal and nesting an unsent-only session (the agent cannot see the unsent draft; covered by unit tests). Base-build repro of the composer swap was not done.

A nested chat whose first message was never sent (the New Nested Session composer) is no longer advertised as movable, and every host move path (move, reorder, move session, promote, move_session tool) refuses it with NotStarted. The client also blocks untitled chats.

Fixes #343966

Co-authored-by: Copilot <[email protected]>
@sandy081 Sandeep Somavarapu (sandy081) added this to the 1.145.0 milestone Oct 24, 2026
Copilot AI balanced review requested due to automatic review settings October 24, 2026 15:29
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

Ladislau Szomoru (@lszomoru)

Matched files:

  • src/vs/sessions/services/sessions/browser/sessionsManagementService.ts
  • src/vs/sessions/services/sessions/test/browser/sessionsManagementService.test.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Move eligibility can remain stale after remote activity, history changes, or lazy hydration, leaving client actions inconsistent with host validation.

3 open issues
What changed in this PR

Prevents unsent chats from being moved in the Agent Host and Agents Window, addressing the composer-switching behavior in #343966. Chats become movable once their first turn starts.

Changes:

  • Adds host-side eligibility and validation checks for unsent chats.
  • Blocks client move actions for untitled chats and generalizes refusal messages.
  • Adds regression coverage and updates existing move tests to use started chats.
File Description
src/​vs/​sessions/​services/​sessions/​test/​browser/​sessionsManagementService.test.ts Tests the client guard for untitled chats.
src/​vs/​sessions/​services/​sessions/​browser/​sessionsManagementService.ts Rejects move eligibility for untitled chats.
src/​vs/​sessions/​contrib/​sessions/​test/​browser/​sessionsListContextMenu.test.ts Updates expected move-refusal messages.
src/​vs/​sessions/​contrib/​providers/​agentHost/​test/​browser/​agentHostChatMoveErrors.test.ts Updates refusal-message coverage.
src/​vs/​sessions/​contrib/​providers/​agentHost/​browser/​agentHostChatMoveErrors.ts Generalizes the localized unsent-chat refusal.
src/​vs/​platform/​agentHost/​test/​node/​agentService.test.ts Tests unsent-chat refusals and adjusts move fixtures.
src/​vs/​platform/​agentHost/​test/​node/​agentHostChatMovability.test.ts Tests eligibility before and during the first turn.
src/​vs/​platform/​agentHost/​node/​shared/​sessionMoveTools.ts Generalizes the tool’s refusal message.
src/​vs/​platform/​agentHost/​node/​agentService.ts Validates that a chat has started before moving.
src/​vs/​platform/​agentHost/​node/​agentHostChatMovability.ts Computes unsent-chat eligibility and refreshes it on turn start.
src/​vs/​platform/​agentHost/​common/​agentHostChatMove.ts Adds notStarted to shared move eligibility.

Review effort: Balanced

…te first messages

Recompute movability on truncation, loaded turns and lazy hydration of restored chats, and stop presenting a peer chat as Untitled once the host reports a turn sent by another client.

Co-authored-by: Copilot <[email protected]>
A peer chat that never ran a turn is no longer movable, and the conformance tier cannot run a turn. Expect the unsent peer as not movable in the refusal scenario and drop the archive scenario, which the movability unit test covers.

Co-authored-by: Copilot <[email protected]>
auto-merge was automatically disabled October 26, 2026 14:43

Pull request was closed

@sandy081
Sandeep Somavarapu (sandy081) merged commit 13832cc into main Oct 26, 2026
99 checks passed
@sandy081
Sandeep Somavarapu (sandy081) deleted the agents/unsent-nested-not-movable branch October 26, 2026 15:32
Christof Marti (chrmarti) added a commit that referenced this pull request Oct 26, 2026
<!-- Thank you for submitting a Pull Request. Please:
* Read our Pull Request guidelines:

https://github.com/microsoft/vscode/wiki/How-to-Contribute#pull-requests
* Associate an issue with the Pull Request.
* Ensure that the code is up-to-date with the `main` branch.
* Include a description of the proposed changes and how to test them.
-->

## Summary

- Rename **Manage...** in the Environment picker to **Manage Remote
Environments...**.
- Align the setting description and chat/Remotes accessibility help with
the new label.
- Preserve the command, visibility gates, selected environment, and
per-host Manage submenus.

Rebased onto `origin/release/1.144` at `62620115296` to avoid the
unrelated chat-move test regression introduced on main by #344057
(`13832cc4487`). The diff remains the same six-file label-only change.
Follow-up to the release backports #344266 and #344313; related to
#344263.

## Validation

- `npm run build-fast -- --client-only` - passed after rebasing onto
release/1.144.
- Focused picker and accessibility tests on release/1.144 - **79
passing**:

```powershell
.\scripts\test.bat --run src\vs\sessions\contrib\chat\test\browser\sessionEnvironmentPicker.test.ts --run src\vs\sessions\contrib\chat\test\browser\sessionsChatAccessibilityHelp.test.ts --reporter dot
```

- Release-diff ESLint and hygiene - **6 files passed**; whitespace check
passed:

```powershell
$files = @(git diff --name-only origin/release/1.144...HEAD -- '*.ts')
npm run eslint -- $files
node build\hygiene.ts $files
git diff --check origin/release/1.144...HEAD
```

This is a string-only change; full type-check and smoke/integration
suites were not run.

## Manual check

Open the Environment picker, select **Manage Remote Environments...**,
and verify Remotes management opens without changing the selected
environment.
Ladislau Szomoru (lszomoru) added a commit that referenced this pull request Oct 26, 2026
Picks up #344327, which fixes the agentService read-state tests that #344057 broke on main.
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.

Moving uncomitted new subsession to other root changes the composer

3 participants