Skip to content

chat: clarify organization-managed model defaults - #342122

Merged
Ross Wollman (rwoll) merged 10 commits into
mainfrom
agents/enterprise-settings-user-clarity
Oct 16, 2026
Merged

Ross Wollman (rwoll) merged 10 commits into
mainfrom
agents/enterprise-settings-user-clarity

Conversation

@rwoll

@rwoll Ross Wollman (rwoll) commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

An organization-managed model default can override chat.defaultModel, making new conversations appear to ignore the user's preference without explaining why.

Clarifies the override in the model picker, Settings, and Settings JSON, reusing the existing Org default and Managed by organization UI treatments used for managed settings. Users can still change models per conversation. Their saved preference is preserved and applies again when the policy is removed; this behavior is unchanged. Picker explanations follow Agent Host-managed defaults before local policy and reuse the rendered catalog.

Screenshots

Model picker

Screenshot 2026-10-16 at 10 17 52 AM

Settings

Screenshot 2026-10-16 at 10 18 23 AM

Testing

Test-only CI correction: the peer-context recreation test now uses a fresh peer URI after disposal, respecting catalog tombstones while preserving its old-context isolation assertion and existing fixtures. Strict replay passed twice for Claude, Copilot, Codex, and the replacement-peer conformance case; full compile, hygiene, and changed-file lint passed.

Set a managed model default that differs from the saved preference. Check the picker and Settings explanations, switch models within a conversation, then remove the policy and confirm the saved preference applies again.

Initial validation: 295 focused UI tests, 99 Node tests, type/layer checks, and CI compilation checks passed. Follow-up validation: 206 picker/selection tests, npm run compile, npm run hygiene, and changed-file lint passed.

The additional build-script suite had 978 passes, 1 skip, and 4 local fixture/environment failures: two temporary Git commits, a startup fixture, and macOS path canonicalization. No build-script files are changed by this PR.

🤖 Authored with GitHub Copilot on behalf of Ross Wollman (@rwoll).

Explain why an organization default overrides a saved model preference using the existing managed-setting UI. Preserve per-conversation choices and saved preferences.

🤖 Authored with GitHub Copilot on behalf of @rwoll.

Co-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 16, 2026 17:29
Reviewed-head: 6fc2924
Pull-request: #342122
Approved-by: rwoll via PR Sign-Off
Requested-by: Copilot

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

Picker explanations can contradict the effective Agent Host managed default.

1 open finding
What changed in this PR

Clarifies organization-managed chat defaults across the model picker and Settings while preserving saved preferences and per-conversation model choices.

Changes:

  • Adds policy explanations to picker hovers and accessibility descriptions.
  • Supports setting-specific policy descriptions in Settings UI and JSON.
  • Adds tests for explanations, policy updates, and preference preservation.
File Description
src/​vs/​workbench/​contrib/​preferences/​test/​browser/​settingsTreeModels.test.ts Tests managed descriptions and preference restoration.
src/​vs/​workbench/​contrib/​preferences/​test/​browser/​settingsEditorSettingIndicators.test.ts Tests custom and fallback indicator text.
src/​vs/​workbench/​contrib/​preferences/​test/​browser/​preferencesRenderers.test.ts Tests policy hints in Settings JSON.
src/​vs/​workbench/​contrib/​preferences/​browser/​settingsTreeModels.ts Computes setting-specific policy descriptions.
src/​vs/​workbench/​contrib/​preferences/​browser/​settingsEditorSettingIndicators.ts Uses descriptions in hovers and accessible labels.
src/​vs/​workbench/​contrib/​preferences/​browser/​preferencesRenderers.ts Customizes JSON policy hints.
src/​vs/​workbench/​contrib/​chat/​test/​common/​modelSelection.test.ts Tests policy explanation wording.
src/​vs/​workbench/​contrib/​chat/​test/​browser/​widget/​input/​modelPicker/​modelPickerActionItem.test.ts Tests picker explanations and policy changes.
src/​vs/​workbench/​contrib/​chat/​common/​modelSelection.ts Adds localized default-policy explanations.
src/​vs/​workbench/​contrib/​chat/​browser/​widget/​input/​modelPicker/​modelPickerWidget.ts Exposes and refreshes accessible policy descriptions.
src/​vs/​workbench/​contrib/​chat/​browser/​widget/​input/​modelPicker/​modelPickerTabbedWidget.ts Reuses shared default resolution.
src/​vs/​workbench/​contrib/​chat/​browser/​widget/​input/​modelPicker/​modelPickerBadges.ts Extracts organization-default lookup.
src/​vs/​workbench/​contrib/​chat/​browser/​widget/​input/​modelPicker/​modelPickerActionItem.ts Adds policy explanations to hovers.
src/​vs/​workbench/​contrib/​chat/​browser/​chat.shared.contribution.ts Clarifies default-model setting documentation.
src/​vs/​platform/​configuration/​common/​configurationRegistry.ts Adds a policy-description callback.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Ross Wollman (rwoll) and others added 2 commits October 16, 2026 10:47
Reuse the rendered model catalog for managed-default presentation and hover text. Prefer the Agent Host advertised default over local policy, matching model selection. Cover lookup counts and host precedence with regression tests.

🤖 Authored with GitHub Copilot on behalf of @rwoll.

Co-authored-by: Copilot <[email protected]>
Reviewed-head: b63b07c
Pull-request: #342122
Approved-by: rwoll via PR Sign-Off
Requested-by: Copilot
@rwoll
Ross Wollman (rwoll) marked this pull request as ready for review October 16, 2026 17:55
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

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

Raymond Zhao (@rzhao271)

Matched files:

  • src/vs/workbench/contrib/preferences/browser/preferencesRenderers.ts
  • src/vs/workbench/contrib/preferences/browser/settingsEditorSettingIndicators.ts
  • src/vs/workbench/contrib/preferences/browser/settingsTreeModels.ts
  • src/vs/workbench/contrib/preferences/test/browser/preferencesRenderers.test.ts
  • src/vs/workbench/contrib/preferences/test/browser/settingsEditorSettingIndicators.test.ts
  • src/vs/workbench/contrib/preferences/test/browser/settingsTreeModels.test.ts

roblourens
roblourens previously approved these changes Oct 16, 2026
Disposed peer identities are tombstoned once the chat catalog is normalized. Recreate the logical peer with a fresh URI while retaining the provider-context isolation assertion and existing replay fixtures.

🤖 Authored with GitHub Copilot on behalf of @rwoll.

Co-authored-by: Copilot <[email protected]>
@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Screenshot Changes

Base: a7e1fc08 Current: 9c308418

Changed (1)

sessions/sessionActivityBar/sessionActivityBar/SubmenuOpen/Light
Before After
before after

Ross Wollman (rwoll) and others added 2 commits October 16, 2026 13:45
Reviewed-head: 7e49495
Pull-request: #342122
Approved-by: rwoll via PR Sign-Off
Requested-by: Copilot
Integrate main at a7e1fc0. Remove the redundant gitService fixture property introduced upstream so the merged branch compiles.

🤖 Authored with GitHub Copilot on behalf of @rwoll.

Co-authored-by: Copilot <[email protected]>
@rwoll

Copy link
Copy Markdown
Member Author

Merged main at a7e1fc0 in d38fa89. Removed the redundant second gitService entry in the upstream test fixture, which caused TS1117 in the synthetic merge.

Post-merge validation passed: npm run compile, npm run hygiene, 393 focused unit/UI tests, and two strict replay runs covering Claude, Copilot, Codex, and replacement-peer conformance (4 tests per run). No fixtures or assertions were weakened.

🤖 Authored with GitHub Copilot on behalf of Ross Wollman (@rwoll).

Ross Wollman (rwoll) and others added 2 commits October 16, 2026 14:07
Reviewed-head: d38fa89
Pull-request: #342122
Approved-by: rwoll via PR Sign-Off
Requested-by: Copilot
Fix the full-repository ESLint failure from merged main by combining imports from agentHostBranchChangesetScope. No runtime behavior changes.

🤖 Authored with GitHub Copilot on behalf of @rwoll.

Co-authored-by: Copilot <[email protected]>
@rwoll

Copy link
Copy Markdown
Member Author

Fixed the remaining full-repository ESLint failure in e42b372 by consolidating the duplicated agentHostBranchChangesetScope imports inherited from main.

Before pushing the final content, all three passed locally:

  • npm run compile
  • npm run hygiene (13,565 files)
  • npm run eslint across the full repository (13,585 files), not just changed files

🤖 Authored with GitHub Copilot on behalf of Ross Wollman (@rwoll).

Reviewed-head: e42b372
Pull-request: #342122
Approved-by: rwoll via PR Sign-Off
Requested-by: Copilot
@rwoll
Ross Wollman (rwoll) merged commit bb42e51 into main Oct 16, 2026
49 checks passed
@rwoll
Ross Wollman (rwoll) deleted the agents/enterprise-settings-user-clarity branch October 16, 2026 22:09
@vs-code-engineering vs-code-engineering Bot added this to the 1.143.0 milestone Oct 16, 2026
RomanNikitenko added a commit to RomanNikitenko/che-code that referenced this pull request Nov 16, 2026
* Modern UI: balance Connected tab geometry (#342074)

* Modern UI: balance Connected tab geometry

Share the active Connected tab's top stroke with the editor frame and derive terminal action spacing from the painted cap. Keep fit-sized tabs stable across density, wrapping, and persistent action states.

Fixes #341702

Co-authored-by: Copilot <[email protected]>

* Modern UI: preserve Connected tab accents

Keep custom and modified top accents inside the visible tab viewport, and align persistent upper-row action reservations with cached fit widths.

Fixes #341702

Co-authored-by: Copilot <[email protected]>

* Modern UI: preserve HC Connected outlines

Restrict inset top-accent paint to explicit customizations and modified tabs while leaving high-contrast structural selection borders on the cap.

Fixes #341702

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>

* Fix API contract compatibility and stale PR state (#342056)

Align API contracts with valid response shapes

Fixes #342003

Co-authored-by: Copilot <[email protected]>

* Fix Quick Open link query transitions and specialized pickers

Invalidate cached file-query state when showing links and only capture an editor source group for picker runs that support links. Add regression coverage for returning to file ranges and initializing file-only, delegated, custom-accept, and quick-navigation pickers.

Co-authored-by: Copilot <[email protected]>

* agentHost: fence the peer chat burst publish statement count on its trace (#342054)

Follow-up to #341995, which fixed the older-build check test by waiting for
the drain statement's own trace as well as its completion. The 'burst of
ten creates or ten deletes' test in the same suite still assumed traces of
finished statements arrive before the drain completes. @vscode/sqlite3
delivers trace events through a separate async callback, so its statement
count could miss late traces in the same way.

Use the same trace-fenced drain as the older-build test.

Co-authored-by: Copilot <[email protected]>

* agentHost: stop retrying chat catalog conversions that wait for an impossible re-projection (#342077)

Block 4a (#341904) made every legacy chat catalog convert, including older
provider-scheme sessions whose provider cannot vouch for them (registered
but with an unreadable catalog, or no longer knowing the session). Their
aggregate never becomes verified, so every conversion attempt ended
`notReady` and fed a loop:

- `_migrateChatCatalog` opened the session database (`runMigrationExclusive`)
  and ran legacy reconciliation before the readiness check, then marked the
  payload dirty, which superseded in-flight re-projections and woke parked
  sessions so the reconciliation re-opened them on the next pass.
- The conversion batch re-attempted every legacy session each cursor cycle,
  and `_convertReprojected` treated parked or unverified sessions as ready
  because `_listDirtySessions` omits parked rows, so the retry limit of five
  never bounded them. Each attempt also scheduled a follow-up pass.

Production (one Insiders profile, ~717 sessions, ~110 affected): ~920
migration operations in two ~5 minute windows, passes every 20-30 s.

Conversion now decides readiness from central state first: an unverified or
dirty aggregate returns `notReady` without opening session.db, writing or
waking anything (its re-projection is already owed). A waiting session is
skipped by the conversion batches and owes no follow-up pass; it converts
right after a pass re-projects it (`succeeded` or an already-current
`skipped`) or once its receipt is verified and clean. The check under the
session lock stays authoritative.

With 110 unvouchable sessions over twelve 30 s passes: 150 migration
operations, 350 session database opens and 100 dirty marks per pass before;
50/50/10 operations in the first three passes (re-projections parking each
session once, no conversion opens or writes) and nothing after.

Co-authored-by: Copilot <[email protected]>

* ci: skip PR checks that the changes cannot affect (#342091)

The Linux 1ES pool is the PR CI bottleneck. Add a shared Detect Changes job that lists the pull request's changed files, and use it to skip checks the changes cannot affect:

- The CLI and Copilot Shim Rust checks run only when their crates, the files their builds read, or their workflows change. They also move to GitHub-hosted ubuntu-24.04 runners. They skip inside the reusable workflow so the required Linux / CLI check still reports.
- The Copilot extension checks run only when extensions/copilot, the API typings, the root ESLint setup, or the root dependencies change. They test against a downloaded Insiders build, and the Electron jobs still run the Copilot tests against the PR's own build.
- Jobs that never read Git LFS content no longer download the 271 MB Copilot simulation cache.

Every check still runs when the changed files cannot be listed.

Co-authored-by: Copilot <[email protected]>

* chat: clarify organization-managed model defaults

Explain why an organization default overrides a saved model preference using the existing managed-setting UI. Preserve per-conversation choices and saved preferences.

🤖 Authored with GitHub Copilot on behalf of @rwoll.

Co-authored-by: Copilot <[email protected]>

* Approve reviewed PR state

Reviewed-head: 6fc292485420a0c5582a1d31e851fc1256ddc775
Pull-request: https://github.com/microsoft/vscode/pull/342122
Approved-by: rwoll via PR Sign-Off
Requested-by: Copilot

* fix(agents): recover remote chats across provider replacement (#342062)

* test(agents): cover remote session replacement and reopen failures

Add regressions for shared content loads across provider replacement and explicit reopening of an active session. These fail on the current implementation for #341828.

* test(agents): cover mounted retries and drafts during replacement

Exercise explicit reopen routing through retained and pinned chat groups. Cover draft edits and deletion across repeated provider replacement, and prevent retired content from publishing session options.

* fix(agents): preserve remote chat loads across provider replacement

Keep a shared content request alive when its provider is replaced, while preserving terminal caller and session cancellation. Route explicit reopens to the selected chat Retry action and retain the current draft through repeated loads.

Fixes #341828.

* test(agents): cover cached load and navigation retry races

Reproduce provider retirement after content is cached but before the shared request returns. Verify obsolete navigation stops waiting on a retained chat retry while provider preparation keeps its existing lifetime.

* test(chat): retain cached content for a joining caller

Cover a caller acquiring newly cached content before the original caller cancels. The shared request must retain that content while another caller still needs it.

* test(chat): cover acquisition during cancelled request cleanup

Exercise cancel-before-reacquire, a cancelled newcomer, and stalled untitled input metadata so shared-request cleanup cannot expose stale cache entries or block future callers.

* fix(agents): respect cancellation through chat recovery

Validate provider attempts before returning cached content. Keep cancelled resolutions registered until cleanup settles so another caller cannot acquire content being disposed, and make untitled input-state waits cancellable.

Release obsolete navigation waits without cancelling the retained chat retry or changing provider preparation.

* agentHost: settle the session artifact removal fixture before reading session.db (#342096)

The fixture's seeded summary change was flushed 100 ms later, in the middle
of whichever test was running. On a slow agent its background catalog write
replays the removal's sync, and session.db briefly keeps the caller's
serialization of the artifacts until the session state store mirrors its
own. Tests that read session.db right away (the idempotent removal test in
CI, and the first removal test) then see a different key order.

Wait for the seeded summary change and its background write in the fixture,
and read store-owned keys from session.db only once the store has mirrored
them. The dedicated summary-flush test still forces that interleaving.

Follow-up to #341001

Co-authored-by: Copilot <[email protected]>

* chat: reuse model catalogs and honor host-managed defaults

Reuse the rendered model catalog for managed-default presentation and hover text. Prefer the Agent Host advertised default over local policy, matching model selection. Cover lookup counts and host precedence with regression tests.

🤖 Authored with GitHub Copilot on behalf of @rwoll.

Co-authored-by: Copilot <[email protected]>

* Approve reviewed PR state

Reviewed-head: b63b07ca3e515981629ebfcea75d73ad3e68f5e7
Pull-request: https://github.com/microsoft/vscode/pull/342122
Approved-by: rwoll via PR Sign-Off
Requested-by: Copilot

* sessions: read session list hover change counts from the catalog (#342097)

* sessions: read session list hover change counts from the catalog

Building the hover for a chat row read the chat's changes and changesets.
For an agent host chat that is not open this subscribed the chat on the
host and released it at once, before the snapshot arrived, so the hover
showed no counts while every mouseover cost a full subscribe. Moving the
pointer across 8 peer chat rows caused 122 subscribes.

The hover now reads the catalog changesSummary whenever the provider
supplies one; providers without it keep reading their in-memory changes.

Co-authored-by: Copilot <[email protected]>

* sessions: keep the previous hover counts for providers without catalog summaries

When neither the session nor its main chat has a catalog summary, read the
main chat's own changes as before instead of its default changeset. For an
archived Copilot Chat session the default changeset is All Changes, whose
changes resolve a diff when read, so the hover would have started that
work on every mouseover.

Co-authored-by: Copilot <[email protected]>

* sessions: match the open main chat's row counts in the session hover

The row of a multi-folder session shows its open main chat's Branch
Changes and observes them, so the hover can read them without loading
anything. Show those in the main chat section while that chat is open,
and its catalog counts otherwise.

Co-authored-by: Copilot <[email protected]>

* Sessions list: let the hover read Branch Changes only when the row observes them

Compact rows, comparison attempts and compact quick chats return before reading counts, so the open main chat's Branch Changes are unobserved there and reading them from the hover loaded the chat again. The details row now records whether it observes them and the hover uses that.

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>

* agentHost: update bundled Codex SDK to 0.162.0 (#341965)

* agentHost: update bundled Codex SDK to 0.162.0

* agentHost: adapt tests to Codex SDK 0.162.0

Add the required rootTurnId to typed Turn fixtures. Recognize the base prompt in developer-role Responses messages so strict replay keeps asserting instruction presence with Codex 0.162.0.

* agentHost: refresh Codex model selection recordings

Re-record the three fixtures that previously omitted the system-prompt marker. Codex 0.162.0 supplies the prompt through developer-role input messages. Verify the regenerated captures with strict replay.

* agentHost: stabilize legacy metadata concurrency test

Wait for the metadata reads to start before asserting their concurrency. The fixed timer-tick budget could expire during SDK startup on CI and report zero active reads. Preserve the four-read concurrency assertions.

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Giuseppe Cianci <[email protected]>

* Agents - Fix session diff statistics for inactive folder sessions (#342099)

Agent Host changes for lszomoru/agents/fix-session-diff-statistics-regression

* agentHost: map opaque host URIs without error (#342107)

* agentHost: map opaque host URIs without error

A remote agent host can send a valid opaque URI, for example the
`mcp-top-level:<provider>:<session>:<name>` URI of a top-level MCP server.
The client mapper put the path of this URI below an authority. The path did
not start with "/", thus `URI.from` threw an error. The error occurred in the
session snapshot, and the client did not open the session.

- Add "/" to the start of the wrapped path when the original path does not
  start with "/". Keep the original path in the existing `_ah` metadata, thus
  `fromAgentHostUri` restores the original URI exactly.
- Add a round-trip test for an opaque URI.
- Add a `CustomizationIndex` test with a remote mapper and an opaque URI.

(Commit message generated by Copilot)

Co-authored-by: Copilot <[email protected]>

* sessions: use a label failure in the reconnect isolation test

The test used an opaque artifact URI to make a session fail. The agent host
URI mapper now maps opaque URIs, thus that artifact does not fail.

- Make the session label fail for the old session, as the neighboring
  isolation test does. The test continues to make sure that a malformed
  session does not prevent new sessions after reconnect.

(Commit message generated by Copilot)

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>

* ci: fix skipped Rust check names and Copilot change paths (#342134)

* ci: report skipped Rust checks under their required names

When GitHub skips a job, it does not evaluate expressions in the job's name. The Rust jobs skipped inside the shared reusable workflow, whose job name is ${{ inputs.job_name }}, so they reported as 'Linux / inputs.job_name'. The required Linux / CLI check then never reported, which blocks every pull request that does not change the CLI.

Run both Rust checks as jobs with fixed names in pr.yml, and move their shared steps from the reusable workflow into a composite action.

Also run the Copilot checks when build/npm/dirs.ts or build/azure-pipelines/win32/exec.ps1 change. The node_modules cache setup in those jobs uses both files (review feedback on #342091).

Co-authored-by: Copilot <[email protected]>

* ci: use a fixed name for the shared Rust job instead of a composite action

Revert the composite action and fix the skipped check name with a one-line change: the reusable workflow's job is named CLI instead of ${{ inputs.job_name }}. The required Linux / CLI check is unchanged; the Copilot Shim check (not required) reports as Linux Copilot Shim / CLI.

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>

* build: update distro for Copilot BYOK voice speech proposal (#342079)

Pin microsoft/vscode-distro#1468 so product builds allow Copilot Chat to register its BYOK voice provider.

Co-authored-by: Copilot <[email protected]>

* copilot: remove unused tool category lookup helper (#342032)

Co-authored-by: dmitrivMS <[email protected]>
Co-authored-by: Copilot <[email protected]>

* Agent Host: disable the Copilot runtime's semantic_code_search tool (#342126)

Exclude the runtime's built-in `semantic_code_search` tool from Copilot SDK
sessions in favor of the Agent Host's own `semantic_search` client tool.
The runtime tool is remote-only (no local chunking/embedding or external
ingest) and the CLI is still A/B testing its prompt variations and
deferred-loading strategies; revisit in a future iteration.

Co-authored-by: Copilot <[email protected]>

* Install the localized policy templates with VS Code setup (#341847)

Since the policies moved to their own [Files] entry in January, setup has
installed only the top-level .admx file. The .adml files in the language
subfolders (en-us, de-de, ...) were skipped because the entry didn't recurse,
so the installed templates can't be loaded in the Group Policy editor. The ZIP
archive was not affected.

Co-authored-by: Copilot <[email protected]>

* Keep contributed tool sets whose members register late (#339870)

* Keep contributed tool sets whose members register late

A contributed tool set whose members could not be resolved at contribution
time was dropped permanently, while partially resolved sets picked up late
members. Copilot's read, web, vscode, and execute sets could therefore lose
read_file and other tools when their members were not yet resolvable at
startup.

Co-authored-by: Copilot <[email protected]>

* Handle late and recursive tool set members

Retry pending tool set members when tool sets change, since tool set
registration does not fire onDidChangeTools, and reject tool sets that would
create an indirect nesting cycle.

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>

* agentHost: align the on-device model catalog with the Copilot CLI (#342098)

* Agent Host changes for agents/review-upstream-epics-for-prs

* agentHost: tighten checksumless downloads and incomplete catalog searches

A file without a published checksum now requires the response's strong ETag to equal the resolved one, and a placed copy that can't be reused is removed before downloading again so a retry doesn't need room for two copies. A public search that still has pages after the page limit fails the refresh instead of selecting versions from partial results.

Co-authored-by: Copilot <[email protected]>

* chat: acknowledge the on-device ready offer once the user takes it

Selecting the on-device model in the picker, selecting Auto once Auto may use it, or making a second install active now acknowledges its ready offer, and the notice stays hidden in an input already on that model.

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>

* agentHost: inject Copilot home URIs (#342149)

* agentHost: inject Copilot home URIs (Written by Copilot)

Resolve the Copilot home once through an injectable service in the agent host and workbench. Keep URI composition in consumers and convert to filesystem paths only at native and SDK boundaries.

Give unit fixtures isolated Copilot homes so inherited COPILOT_HOME does not override mocked user homes. Preserve production environment overrides and add poisoned-environment and URI-scheme regression coverage.

Co-authored-by: Copilot <[email protected]>

* test: normalize Copilot home expectation (Written by Copilot)

Compare the extension's inherited home against the URI filesystem path so Windows drive-letter normalization matches the injected home service.

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>

* chat: add remote connection method dropdown (#341942)

* chat: add remote connection method dropdown (Written by Copilot)

Replace the backend setting with an application-local stored preference and migrate existing local user choices. Add descriptive method selection outside Stable and keep remote controls keyboard accessible.

Co-authored-by: Copilot <[email protected]>

* chat: keep remote method setting and preview UI (Written by Copilot)

Write method selections directly to the preview setting, preserve data-handling disclosures, and remove the transient sharing confirmation label.

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>

* agentHost: fix remote editor file previews and links (#342158)

Use the editor remote connection authority for Agent Host resource links and content snapshots, and map pending edit resources through the connection's URI mapper.

Fixes #342112

Co-authored-by: Copilot <[email protected]>

* Fix GDPR declarations for auto tiers in BYOK providers (#342154)

Agent Host changes for lramos15/agents/telemetry-gdpr-comments-check

* agentHost: isolate Mission Control credential sponsorship (#341455)

* agentHost: isolate MC credential sponsors (Written by Copilot)

Keep Mission Control credentials out of legacy authentication and pin protected execution to client-owned grants. Preserve untouched local, SSH and tunnel behavior; cover cold restore, queues, native GitHub work, scoped SDK runtimes and configuration races.

Co-authored-by: Copilot <[email protected]>
(cherry picked from commit 99da3e5b6dd3e2d497d31178e94bbfc9cd754589)

* agentHost: surface scoped clone failures (Written by Copilot)

Report failed clone outcomes instead of masking Git errors behind a readiness timeout, and include the actual SSH failure in assertion output.

Co-authored-by: Copilot <[email protected]>

* agentHost: use portable Git null configs (Written by Copilot)

Git for Windows cannot read Node's Win32 null-device path as a config file. Use the Git-recognized empty config path while preserving scoped clone authentication and transport restrictions.

Co-authored-by: Copilot <[email protected]>

* agentHost: harden scoped execution (Written by Copilot)

Make chat credential contexts authoritative, separate history observation from execution sponsorship, preserve local control and Git refresh without implicit authentication, and correct scoped SDK tool, configuration and storage lifecycles. Add actual-provider exact-token and coding-parity coverage while preserving untouched legacy behavior.

Co-authored-by: Copilot <[email protected]>

* agentHost: use native test paths (Written by Copilot)

Keep the disconnected-sponsor discard assertion platform-neutral by comparing the restored native filesystem path.

Co-authored-by: Copilot <[email protected]>

* agentHost: scope retries to grants (Written by Copilot)

Capture and validate operation credentials before deduplication, and include the captured grant generation in the retry key without retaining token values in keys. Preserve mutation serialization and same-generation retries; cover rotation and disconnected sponsors.

Co-authored-by: Copilot <[email protected]>

* agentHost: normalize prompt line endings (Written by Copilot)

Canonicalize CRLF before removing reviewed SQL instruction sections so Windows prompt parity compares content rather than leftover blank lines. Cover both line-ending styles and ensure unreviewed differences still fail.

Co-authored-by: Copilot <[email protected]>

* agentHost: normalize escaped prompt paths (Written by Copilot)

Normalize JSON-escaped copies of the known fixture home and workspace while preserving unrelated paths and prompt differences. Add token-safe mismatch metadata so cross-platform parity failures remain actionable without printing prompt or credential contents.

Co-authored-by: Copilot <[email protected]>

* agentHost: normalize fixture drive casing (Written by Copilot)

Match the lowercased Windows drive letter supplied through URI.fsPath while preserving unrelated paths and the strict prompt digest assertion.

Co-authored-by: Copilot <[email protected]>

* agentHost: clarify S03 contract and MCP limits (Written by Copilot)

Describe stable implementation boundaries and standing release checks rather than in-progress CI status. Identify the two accepted MCP attribution deferrals against the pinned upstream authentication documentation.

Co-authored-by: Copilot <[email protected]>

* agentHost: await archived workspace changes (Written by Copilot)

Replace the worktree archive regression's fixed 10ms sleep with working-directory change events registered before dispatch. This waits for the detach/attach contract without changing production behavior, timeouts or expected state.

Co-authored-by: Copilot <[email protected]>

* agentHost: match upstream steering (Written by Copilot)

Authorize steering by the existing same-owner identity boundary without requiring the running turn's token. Retain the running credential for client, trusted-local and agent-to-agent steering; new turns and queued work still use their own credentials. Document the accepted limitation rather than claiming complete per-device permission isolation.

Co-authored-by: Copilot <[email protected]>

* agentHost: simplify MC runtime auth (Written by Copilot)

Use normal Copilot runtime features and VS Code settings with explicit caller GitHub credentials. Remove scoped profile/tool/skill restrictions, treat GitHub scopes as OAuth hints, preserve BYOK, seed caller credentials for agent shells, and clone with the requesting connection API token and normal network configuration. Keep legacy authentication paths and MCP challenge scope checks unchanged.

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>

* Agents - Fix branch changeset description to reflect actual comparison ref (#342128)

* Agent Host changes for lszomoru/agents/fix-branch-changeset-description

* Refactor things so that the base branch is recorded for a folder session as well

* agentHost: use a fresh identity when testing peer recreation

Disposed peer identities are tombstoned once the chat catalog is normalized. Recreate the logical peer with a fresh URI while retaining the provider-context isolation assertion and existing replay fixtures.

🤖 Authored with GitHub Copilot on behalf of @rwoll.

Co-authored-by: Copilot <[email protected]>

* Approve reviewed PR state

Reviewed-head: 7e49495ac6b3c3ed0bb18f7cd58da03ae7121e05
Pull-request: https://github.com/microsoft/vscode/pull/342122
Approved-by: rwoll via PR Sign-Off
Requested-by: Copilot

* Approve reviewed PR state

Reviewed-head: d38fa8979395ae059b2991fb286ee97e08ef8936
Pull-request: https://github.com/microsoft/vscode/pull/342122
Approved-by: rwoll via PR Sign-Off
Requested-by: Copilot

* agentHost: consolidate branch changeset scope imports

Fix the full-repository ESLint failure from merged main by combining imports from agentHostBranchChangesetScope. No runtime behavior changes.

🤖 Authored with GitHub Copilot on behalf of @rwoll.

Co-authored-by: Copilot <[email protected]>

* Approve reviewed PR state

Reviewed-head: e42b3726f21f9c61119316b220783aba145c9a91
Pull-request: https://github.com/microsoft/vscode/pull/342122
Approved-by: rwoll via PR Sign-Off
Requested-by: Copilot

* agentHost: honor managed Assisted approval verdicts (#341889)

<!-- 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.
-->

Fixes #341390.

Forward the SDK's derived permission prompt so an approving Assisted
verdict permits a managed request once without prompting. Preserve
managed one-time restrictions and sandbox safeguards.

`ls` now properly goes through to the judge and deny is still respected:

<img width="1552" height="1088" alt="Screenshot 2026-10-15 at 5 09
19 PM"
src="https://github.com/user-attachments/assets/16c0c446-31a0-4197-9cf4-4830fdd2641d"
/>


*🤖 Authored with GitHub Copilot on behalf of @rwoll.*

* notebook: avoid quadratic carriage-return stream normalization (#339459)

Compose each overwritten line from the uncovered suffixes of its carriage-return segments instead of repeatedly scanning the full output stream. Preserve the existing dollar-text replacement path, pending returns, backspace behavior, compression flags and output model events.

Co-authored-by: Copilot <[email protected]>

* Fix Agent Host build errors from overlapping merges (#342187)

Co-authored-by: Copilot <[email protected]>

* chat: Avoid MCP gallery continuation failures (#342177)

* chat: cap MCP gallery native page size

Avoid requesting the registry's broken 100-item continuation boundary while preserving 100-item combined browse pages. Fixes #342176.

Co-authored-by: Copilot <[email protected]>

* agentHost: remove duplicate git service fixture property

Fix the Compile & Hygiene TypeScript failure introduced on main.

Co-authored-by: Copilot <[email protected]>

* agentHost: consolidate changeset scope imports

Fix the Compile & Hygiene duplicate-import failure introduced on main.

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>

* chat: Fix failures when organization settings load slowly (#342167)

* chat: Fix premature organization settings timeouts

Keep slow Copilot managed-settings queries pending, show delayed progress, and offer retry without weakening policy enforcement. Preserve cancellation and runtime recovery across chat creation and model changes.

Fixes #342123.

🤖 Authored with GitHub Copilot on behalf of @rwoll.

Co-authored-by: Copilot <[email protected]>

* chat: Initialize managed settings after injected services

Construct the resolver and its progress event in the CopilotAgent constructor so native class-field initialization never reads the log service before it is assigned. This fixes the Compile & Hygiene define-class-fields check.

🤖 Authored with GitHub Copilot on behalf of @rwoll.

Co-authored-by: Copilot <[email protected]>

* build: Remove duplicate entries from branch changeset update

Unblock validation after merging main: consolidate the branch changeset helper imports and remove a duplicate gitService fixture property introduced by #342128. No runtime behavior changes.

🤖 Authored with GitHub Copilot on behalf of @rwoll.

Co-authored-by: Copilot <[email protected]>

* chat: Preserve policy retries and cancellation across setup

Cancel queued agent selection alongside model selection, release generation listeners when policy queries time out, and preserve retryable policy errors across JSON-RPC and IPC before the first turn starts. Add paired-selection, listener cleanup, and first-send Retry regressions.

🤖 Authored with GitHub Copilot on behalf of @rwoll.

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>

* agentHost: park sessions whose provider cannot vouch for them until its catalog becomes readable (#342127)

* agentHost: park sessions whose provider cannot vouch for them until its catalog becomes readable

Reconciliation parked `sourceUnresolvable` sessions but retried
`providerUnavailable` ones on every pass. A registered provider whose
catalog is unreadable (older codex sessions in production) therefore had
each session's database opened on every 30 s pass, indefinitely: about
10 re-attempts per session per hour before Block 4a and about 80 after it.

- `providerUnavailable` now parks the session like `sourceUnresolvable`,
  both when the provider is unregistered (checked before any storage is
  claimed) and when a registered provider cannot vouch for it. Parked
  sessions remember their provider.
- When a provider's catalog becomes readable, `wakeParkedProviderSessions`
  releases only that provider's parked sessions and a pass is scheduled if
  any were released. That pass re-projects them and converts their legacy
  chat catalogs. Provider registration, session mutations and the hourly
  verification still wake parked sessions as before.
- A wake generation keeps a pass from parking a session whose source it
  resolved before a wake, matching the existing dirty-marker guard.
- Parking and every wake, including the per-provider one, are announced
  through `onDidChangeParkedSessions`, so chat movability (#342047), which
  treats a parked legacy catalog as unverifiable, stays current.
- AGENTS.md describes the two parking reasons and their wake signals.

Measured with 110 such sessions and passes every 30 s: 6,000 session
database opens in an hour before, 110 after (each session's re-projection
parks it once), then only the hourly verification's sample. End to end
with 70 sessions: 150 opens every pass before; 150 and 60 in the first two
passes after, then 0. All 70 convert once the catalog becomes readable.

Co-authored-by: Copilot <[email protected]>

* agentHost: release a parked session when it restores through its own lookup

A legacy session parked as `providerUnavailable` can restore through its
provider's per-session lookup (`activation: 'restore'`) while the
provider's whole catalog stays unreadable. Codex, for example, answers a
restore but returns nothing to passive lookups until it is activated. That
restore neither made the catalog readable nor woke the session, so the
session stayed excluded from reconciliation. `_normalizeCatalogForMove`
then refused its chats as `legacyCatalog` until another wake, possibly
the hourly verification.

A successful restore is evidence that the session's source resolves, so it
now releases that session's parking and schedules a pass. Once loaded, the
session re-projects from its live state and converts.

Addresses review feedback on #342127.

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>

* Stream detached background shell output in Agent Host chats (#341700)

* Stream detached background shell output in Agent Host chats

A detached Copilot shell writes its output only to a log, so neither its
tool call nor its Background Shells entry had a terminal. Read that log
with the SDK's session.rpc.tasks.readOutput from each returned cursor,
append every page to the tool call's output-only terminal, and mark the
terminal exited with the exit code the final read reports. An exit that
the task list or a stop result reports first waits until the reads have
drained the log, so the last lines and the exit code aren't lost.

A detached shell doesn't keep its turn open the way an attached one does,
so keep a completed tool call's live output attached after its turn ends
while the terminal still runs. Its inline terminal then keeps streaming
until the command exits or the chat closes.

* Keep detached shell output after exit and settle reused shell IDs

When the task list or a stop result reports a detached shell's exit
before its log has been read to the end, remember the shell until the
read finishes. A new command that reuses its shell ID can then settle
the old terminal, so a read still in flight can't append the new
command's output to it.

Keep the output of a completed tool call whose command outlived its turn
attached until the chat closes, instead of releasing it when the command
exits. A tool card rendered after the exit, such as a Fusion phase chat
or a card recreated by the chat list, then still shows the output and
exit code instead of "Terminal is no longer available".

* sessions: close side pane on last tab close when multiple chats are shown (#342117)

* sessions: close side pane on last tab close when multiple chats are shown

Closing the last editor tab while several chats of the same session are shown in the per-chat layout left an empty side pane open. The last-editor-close guards only need to defer to another visible session, since chats of the same session share its main editor part.

Co-authored-by: Copilot <[email protected]>

* sessions: ignore mounted sessions that are not shown on last tab close

In the per-chat layout a maximized chat can leave other sessions mounted but not shown; only block the last-editor close when another session's chat is actually shown.

Co-authored-by: Copilot <[email protected]>

* agentHost: remove duplicate gitService property in git state test

Fixes TS1117 after #341455 and #342128 both added the same shorthand property to the test fixture.

Co-authored-by: Copilot <[email protected]>

* agentHost: merge duplicate agentHostBranchChangesetScope import

Fixes the duplicate-import lint error after #341455 and #342128 both imported from the same module.

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>

* workbench: center Modern UI status bar items (#342182)

* workbench: center Modern UI status bar items

Center status bar content within the painted background while preserving compact density and classic layout behavior. Add regression coverage against the status bar bounds.

Co-authored-by: Copilot <[email protected]>

* test: update status bar component screenshot

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>

* Add local-network access guidance for Windows sandboxing (#342171)

Add local-network guidance for Windows sandboxing

Fixes #342169

Co-authored-by: Copilot <[email protected]>

* agentHost: roll back a failed artifact persistence (#342137)

* agentHost: roll back a failed artifact persistence

A list-visible write first stores its owned values in the session state
store (and session.db's mirror), then synchronizes the session catalog.
When that synchronization failed, the owned values stayed: a failed
artifact removal left central state and session.db without the artifact
while the published state and the catalog still listed it, so a restart
would have hidden it.

Ordered writes whose caller publishes only after persisting can now roll
back. The owned values are swapped in one exclusive section of the store,
which records what they replaced; if the synchronization throws, each key
that still holds this write's value (or the value its synchronization
adopted) gets the previous value back, mirrored to session.db before the
error propagates. A newer write is left alone. Artifact persistence opts
in; writes of already-published state still roll forward through catalog
reconciliation.

A crash before the rollback recovers forward: the owned write marks the
catalog payload dirty in the same agent-host.db transaction, session.db's
mirror is repaired from central state, and the startup reconciliation pass
re-projects the catalog.

Co-authored-by: Copilot <[email protected]>

* agentHost: keep failed artifact rollbacks consistent after post-commit failures

Two review findings on the rollback of a failed artifact persistence:

- The values to restore were recorded only once the owned write's
  exclusive section resolved. That section commits central state and
  session.db, then records the mirror acknowledgement, which can still
  reject. The previous values were then lost and a later catalog failure
  skipped the rollback, leaving the failed removal durable. Record them in
  caller-owned state inside the exclusive section, before the write; the
  compare-and-restore rollback stays a no-op if the write never committed.

- A receipt acknowledgement that failed after the catalog upsert committed
  was thrown, so the owned values were rolled back while the catalog and
  session.db's pending receipt kept the removal. After a restart,
  reconciliation replayed that receipt and marked the payload clean, so the
  listing omitted an artifact that restore, central state and session.db
  still had. The catalog sync now reports such a failure as pending
  ('acknowledgementFailed'), as it already does for a superseded
  acknowledgement: the mutation is committed, the caller publishes it, and
  reconciliation acknowledges the receipt. Rollback is thus limited to
  synchronizations that did not commit the catalog.

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>

* chat: add an opt-in session working set (#341120)

* chat: add an opt-in session working set

Co-authored-by: Copilot <[email protected]>

* chat: limit the working set to Copilot Agent Host sessions

Preserve the Local harness working-set controls and editor navigation.

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>

* agentHost: enable multi-root by default (#342188)

* agentHost: enable multi-root by default (Written by Copilot)

Remove the Copilot, Claude, and Codex multi-root settings and provider gates so all three providers always advertise multiple working directories. Update directory handling, tests, and documentation for unconditional support.

Co-authored-by: Copilot <[email protected]>

* agentHost: refresh multi-root prompt baselines (Written by Copilot)

Regenerate all 19 Copilot model prompt baselines in tokenless replay for the always-enabled multi-root create_session schema. The complete prompt suite passes strict replay with 24 tests.

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>

* Clarify that Copilot Memory settings respect GitHub memory settings (#342151)

* Copilot Memory: default on and respect GitHub memory settings

Default chat.copilot.memory.enabled to true so the user's Copilot Memory
settings and org/enterprise policies on GitHub decide whether memory is
used (the runtime checks them via the Memory API), matching the Copilot
CLI. The VS Code setting remains a client-side opt-out. Clarify that the
local in-repo memory mode does not check GitHub memory settings or policies.

Co-authored-by: Copilot <[email protected]>

* Keep Copilot Memory opt-in; shorten setting descriptions

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>

* copilot: provide the copilot command in WSL, Git Bash, and Cygwin (#342115)

* copilot: provide the copilot command in WSL, Git Bash, and Cygwin

Windows builds now ship a POSIX `copilot` launcher next to `copilot.exe` in
bin/copilot-shim, like `bin/code` next to `code.cmd`. WSL shells see the
Windows PATH, but the folder only contained `copilot.exe`, so `copilot` was
not found there while `code` worked.

In WSL the launcher runs the Linux shim of the VS Code Server installed in
the distribution: the server for its own commit in the Remote - WSL or code
CLI layout, else the newest installed one. It removes VS Code launcher
folders from PATH first so the shim's search never finds a launcher, and
explains how to set up the server when none is installed. In Git Bash and
Cygwin it runs `copilot.exe`. Windows shells keep running `copilot.exe`.

Setup publishes the launcher with the shim and removes it with the shim when
the CopilotCliCommand policy disables the command.

Fixes #342108

Co-authored-by: Copilot <[email protected]>

* copilot: find code CLI servers and read only the launcher header

Address review feedback on the WSL launcher:

- Also look for the server in the standalone code CLI's data folder
  (`VSCODE_CLI_DATA_DIR`, or else `~/<dataFolderName>/cli`), as used by
  `code tunnel`, and include `~/.vscode*/cli/servers` when falling back to the
  newest installed shim.
- Read only the first 512 bytes of each `copilot` on PATH when looking for the
  launcher marker, so a GitHub Copilot CLI executable isn't read in full on
  every run.

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>

* agentHost: use static SDK tokens for Mission Control credentials (#342201)

agentHost: use static MC credentials (Written by Copilot)

Pass captured Mission Control credentials as explicit SDK tokens so valid one-hour grants do not enter the provider's minimum-lifetime path. Preserve scoped expiry/revocation admission checks and legacy credential-provider behavior.

Co-authored-by: Copilot <[email protected]>

* copilot: remove unused request HMAC helper (#342028)

Co-authored-by: dmitrivMS <[email protected]>
Co-authored-by: Copilot <[email protected]>

* fix: handle reentrant row recycling in listView (fixes #314134) (#314546)

* fix: guard against null item.row after renderElement in listView (fixes #314134)

renderElement can trigger reentrant splice/dispose operations via event
handlers, which may release item.row before insertItemInDOM completes.
Add a null check after renderElement returns to prevent the TypeError.

Co-authored-by: Copilot <[email protected]>

* fix: add regression test for null item.row after reentrant renderElement

Adds a test that verifies insertItemInDOM does not throw when
renderElement triggers a reentrant splice that nulls item.row.

Co-authored-by: Copilot <[email protected]>

* fix: remove unused parameter in listView test renderer

Co-authored-by: Copilot <[email protected]>

* fix: stop stale list insertions after reentrant rendering

Stop the remaining splice insertion pass when rendering recycles its row, preventing ghost rows after a viewport collapse. Replace the recursive-splice test with regressions for recovery, row reuse, drag state, disposal, and stale insertion ranges.

Fixes #314134

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: vs-code-engineering[bot] <122617954+vs-code-engineering[bot]@users.noreply.github.com>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Aaron Munger <[email protected]>

* agentHost: let chats in worktrees move by sharing their worktrees (Move Chats Block 5) (#342144)

* agentHost: record who shares a worktree and remove shared worktrees by reference

Move Chats, Block 5 (part 1): the storage and clean-up a shared worktree needs.

- agent-host.db migration 20 adds `worktree_co_owners` (one row per session
  sharing a worktree, written only in the move, promotion and session-move
  transactions, deleted with the session's tombstone; a session move gives its
  rows to the target) and rebuilds `pending_worktree_removals` to accept the
  `coOwned` kind. The move transactions also carry the session values a
  transferred worktree record changes.
- The in-use check counts other live, non-archived co-owners. Each co-owner's
  archive or deletion records its own removal; a pass prunes co-owners that are
  deleted or no longer work there (one row stays) and commits rather than
  force-removes a folder that was ever shared. Unarchive recreates a missing
  shared folder from the recorded branch.
- Worktree isolation can hand a session's worktree to another session as a
  detached worktree (its record locked until the move commits), re-own a
  record to the session whose central list names it (startup repair), and
  recreate a missing shared folder on resume.

Callers pass no shared worktrees yet.

Co-authored-by: Copilot <[email protected]>

* agentHost: withhold a shared worktree's branch from older builds

Move Chats, Block 5 (part 2). 1.140-1.142 resolve no session worktree without
`copilot.worktree.branchName`, so none of their delete, archive or repair paths
removes a worktree whose branch they don't see.

- The central-only flag `agentHost.olderBuildWorktreeWithheld` makes the
  older-build copy of a session omit its worktree branch; the mirror records the
  absence as its merge base, so the next import never reads it as an older
  build's deletion, and an older build writing the branch back is imported
  unchanged and withheld again. Readers of central state keep the branch.
- `AgentHostWorktreeCoOwnership` decides what a move does with its source's
  worktrees (transfer a chat's own worktree, share the others, refuse a chat's
  own worktree a staying chat also uses), withholds before a move commits, hands
  transferred records over in the order 1.142 relies on (target lists it, the
  record names the target, the source drops it), and stops withholding when the
  session's older-build copy is published with fewer than two live co-owners.
- The peer chat store runs a participant before each older-build publish.

Co-authored-by: Copilot <[email protected]>

* agentHost: let chats in worktrees move, sharing or transferring their worktrees

Move Chats, Block 5 (part 3): lift the worktree restriction for chats.

- A chat (or promoted chat) that works in a worktree of its session moves: the
  worktree becomes shared by the source and the target in the move's
  transaction, and its recorder withholds its branch from older builds first
  (undone if the move is refused). A chat's own additional worktree that no
  staying chat uses moves with it; one a staying chat also uses still refuses
  the move (`worktreeFolder`, D2).
- A session that moves under another session hands over its own worktree
  (unless already shared, then its share continues as the target's) and its
  additional worktrees.
- `ChatSummary.movable` and the move validation keep `worktreeFolder` only for
  D2, from in-memory state. A deleted co-owner's peers get their older-build
  copy published, so withholding can stop.
- AGENTS.md 3b (worktree clean-up) and 3c describe shared worktrees.

Co-authored-by: Copilot <[email protected]>

* agentHost: pin that chats in shared additional worktrees move without withholding

Move Chats, Block 5 (decision): a chat working in a session-level additional
worktree, or in another chat's own worktree, moves and co-owns it; no refusal
and no withholding. Older builds may still remove such a worktree with its
original owner, which is accepted and now documented in AGENTS.md 3b.

Co-authored-by: Copilot <[email protected]>

* agentHost: record one worktree removal per folder per session

Move Chats, Block 5 (G3): a session that shares its own worktree recorded both
its own (`session`) removal and a `coOwned` one for the same folder, under
different locks. Archive and deletion now skip a co-owner removal for a folder
the session's own removal already covers; its other shares keep theirs.

Co-authored-by: Copilot <[email protected]>

* agentHost: keep a moved worktree chat a worktree chat in its new home

Move Chats, Block 5 (option B, B-i).

- `agentHost.worktreeFolders`: a central-only (never mirrored), projected session
  value recording the worktrees a move shared with, or transferred to, the
  target ({workingDirectory, repositoryRoot, branch} from the recorded rows),
  written in the move's, promotion's or session move's transaction. A move back
  to the session that records the worktree as its own writes none.
- A session whose primary folder is (inside) one of them reports its
  repository as `project`: catalog resolver, list overlay, restore and the
  promoted session's live summary. Stale entries are ignored; its own recorded
  worktree wins. Clients then show a promoted worktree chat's session as a
  worktree session grouped under its repository, with Changes in worktree mode.
  No protocol change.
- G1: a promoted chat's base branch is keyed for its new session's default chat
  (`chatMoveFolderTransfers(..., targetIsDefault)`), and the new session's config
  reports `isolation: 'worktree'` with that base branch as `branch` (`folder`
  when its primary folder is no recorded worktree).
- AGENTS.md 3b: presentation, and the accepted older-build gap of workspace
  conversion of a session whose worktree is shared (G2, declined).

Co-authored-by: Copilot <[email protected]>

* agentHost: never release a withheld worktree branch while a share is in flight

Review H1 (Block 5). A move withholds its source's (or target's) worktree branch
before it commits, but the co-owner rows only exist once it commits. A publish of
the session in between (the olderBuildEdits retry flushes it, or a debounced one),
or a concurrent refused move's undo, saw no rows and released the branch for good.

`withhold` now returns a withholding that ends with the move (`done` on commit,
`undo` on refusal) and counts it as in flight. Release skips a session with a share
in flight, deciding again inside the store's section; a refused move's undo releases
only by the same rule instead of clearing the flag.

Co-authored-by: Copilot <[email protected]>

* agentHost: count a co-owner as using a worktree only while it works there

Review M1 (Block 5). The in-use check counted any live, non-archived co-owner row,
including the "ever shared" marker row that pruning keeps. Once a moved chat was
deleted (or moved back) and its original session deleted, the marker kept the
worktree in use for as long as the other session lived, so it leaked. The co-owner
branch now also requires that the session still has a folder (or a chat, archived
included) at or inside the worktree; the marker then only forces commit mode.

Co-authored-by: Copilot <[email protected]>

* agentHost: share, don't transfer, worktrees into sessions older builds don't read

Review M2 (Block 5). A promoted session, or any session whose default chat stores
elsewhere, gets no older-build copy of its session values (Q8a). Transferring a
chat's own worktree record there named an owner whose older-build copy never
lists it, so 1.142's reconciliation removed the folder and deleted the record.

Into such a target a move now shares instead (decision): the source keeps listing
the handle and stays the record's owner, and both sessions get co-owner rows. A
session that moves under such a target leaves its records where they are (older
builds no longer list the ended session) and the target shares them.

Co-authored-by: Copilot <[email protected]>

* agentHost: apply a move's worktree list changes to the lists as they are at commit

Review M3 (Block 5). A move built the source's and target's
`agentHost.additionalWorktrees` (and the target's `agentHost.worktreeFolders`) JSON
before taking the store's locks, and the transaction wrote it verbatim. A worktree
another chat created in between was dropped from its owner's list, leaving its
record naming an owner that doesn't list it.

Moves and promotions now pass list changes (handles leaving the source, records
joining the target, folders the target records), which the store applies to each
list's current value inside the move's section.

Co-authored-by: Copilot <[email protected]>

* agentHost: migrate the worktree tables of profiles a pre-release build left behind

Review M4 (Block 5). Migration 20 rebuilt `pending_worktree_removals` from an
existing table, so a profile shared with a pre-release build that skipped it (the
case the open-time repair already covers) failed to open. It now creates the table
first when missing. The open-time repair also rebuilds a removal table at 20 or
later that still has the old `kind` check, which would have failed every co-owner
removal, including inside a deletion's tombstone transaction.

Co-authored-by: Copilot <[email protected]>

* agentHost: re-own a session move's worktree past the ended source's stale list

Review L1 (Block 5). Reconciliation took the cheap path when the recorded owner's
list named the handle. A session move that crashed before the record was re-owned
leaves the ended source's own database still listing it (it is never rewritten),
so the record kept naming the ended source until that was garbage collected. The
central lists of live sessions are now read first; the owner's own list only
counts when no live session lists the handle centrally.

Co-authored-by: Copilot <[email protected]>

* agentHost: record a worktree whose metadata isn't persisted yet when a chat moves

Review L2 (Block 5). A move planned only over persisted worktree metadata, so a
worktree this process created whose metadata write failed (or hasn't happened
yet) got no co-owner rows, no withholding and no forced-commit marker: a session
move then left it unrecorded, and a chat move shared it unprotected. Reading a
session's worktrees now includes those this process knows about, as the
removal path already does.

Movability is unchanged: it refuses only a chat's own additional worktree that a
staying chat also uses, which comes from the session's in-memory list, not from
the handle's metadata.

Co-authored-by: Copilot <[email protected]>

* agentHost: don't recreate a stale share's folder when its session is unarchived

Review L3 (Block 5). Unarchiving a session recreated the folder of every co-owner
row it had, including one it no longer works in (not yet pruned, or kept as the
folder's forced-commit marker). Its own removal of that share was just dropped,
so a recreated folder could leak. Restore now prunes the folder's rows under the
folder lock and recreates it only while the session's row is live.

Co-authored-by: Copilot <[email protected]>

* agentHost: lock an ever-shared worktree's folder for its owner's removal

Review L5 (Block 5). A session's (or handle's) worktree removal locked only its
owner, while co-owner removals and the recreate of a shared folder (unarchive,
resume repair) lock its path. A co-owner's recreate could run between the owner's
last in-use check and the Git removal, and see a folder that was about to go.
A folder that was ever shared (co-owner rows exist) is now also locked by its
path for its owner's removal, nested inside the owner's lock, the order the
resume repair uses too.

Co-authored-by: Copilot <[email protected]>

* agentHost: plan a move's worktrees by the folders of the whole moved subtree

Review L6 (Block 5). A move planned its worktrees by the moved chat's folders only.
A descendant moving with it that works in another worktree (the session's own,
or its own additional one) got no share: its record stayed with the source, with
no co-owner rows or withholding, while it runs in the target. The plan now takes
the folders each moved descendant set for itself too. One without folders of its
own follows its session's, the target's once it moves, so it adds none.

Co-authored-by: Copilot <[email protected]>

* agentHost: make the older-build copy participant a constructor dependency

Review L7 (Block 5). The participant that releases a withheld worktree branch
before a session's older-build copy is published was a late-bound, optional hook
on the peer chat store: unwired, a release silently never happened. It is now a
required constructor dependency (`IOlderBuildCopyParticipant`); the composition
builds the worktree co-ownership first and hands it to both the peer chat store
and the agent service. A real-path test covers the release on publish, which no
test did before.

Also moves `moveChat`'s JSDoc back onto it (Block 5 inserted members between
them) and corrects it: the move's worktree lists do reach older-build mirrors.

Co-authored-by: Copilot <[email protected]>

* agentHost: document the shared-worktree review fixes and why rows snapshot the branch

Review L4 (Block 5), plus AGENTS.md for H1, M1-M4 and L1-L7. A co-owner row's
branch is the one recorded when the move shared the worktree. That snapshot is
kept rather than replaced by the original owner's current record: the host never
renames a branch it created, and the owner's record holds the same creation-time
name, so it would add nothing and isn't there once the owner is deleted. A
branch removed outside the host keeps the folder intact (the removal is skipped
and retried with capped backoff), exactly as for an unshared worktree.

Co-authored-by: Copilot <[email protected]>

* agentHost: prove a session move lists a handed-over worktree for older builds before its record names the target

Live check F1 (Block 5). After a session move into "Sky color" and "Simple
arithmetic", the handle's record named the target while the target's
session.db never listed `agentHost.additionalWorktrees`, which 1.142 would
treat as an unlisted handle (removed after its grace period, leaked on the
target's deletion). Both targets were sessions an earlier step had promoted:
a promoted session's default chat keeps its own storage, so older builds read
no session values from it (Q8a) and the republish has nowhere to go. The live
build predated 760d83230f7 (M2), which shares instead of transferring or
handing over into such a target.

This adds the real-path proof the move path lacked (per-session databases):
into a target older builds read (legacy and opaque chat URIs), the target's
session.db lists the handle when the record is made to name it; into a
promoted target nothing is handed over and the target co-owns the worktree;
a crash before the record names the target leaves the target listing it, for
startup reconciliation to re-own (L1). Skipping the target's republish,
dropping the no-copy rule for session moves, or claiming every target has a
copy each fails it.

Co-authored-by: Copilot <[email protected]>

* agentHost: make recomputing chat movability linear in a session's chats

Perf check (Block 5). With moving chats on, a pass over a session's chats was
O(n^2): each chat looked itself up in its session's chat list, re-scanned the
whole list to find its subtree, and (since Block 5) built the folders of every
staying chat, even in a session recording no additional worktree for a chat.
A 200-chat pass went from 1.82 to 2.97 ms.

Each pass now builds a session's context once: its chats by resource, their
children by parent chat, and, only when the session records an additional
worktree for a chat, the staying chats using each such worktree (the indexed
form of the D2 rule the move planner applies). A chat then costs its own
subtree. A session with no such worktree builds nothing for D2.

A test counts the lookups of a full recompute at 100 and 400 chats, with and
without a chat's own worktree: 2 per chat plus 9 per pass at both sizes, against
114 and 444 per chat before.

Co-authored-by: Copilot <[email protected]>

* agentHost: one removal per shared folder on archive also for a session's additional worktrees

Re-review LOW 2 (Block 5). Archive deduped a session's co-owned removals only
against its own primary worktree. A session that co-owns a folder that is also
one of its additional worktrees got both a co-owned removal and the handle's
detached removal for it, and its unarchive recreated its own primary (and that
folder) a second time from the co-owner row. Harmless (the folder lock
serializes them, the second finds the folder gone), but not one per folder.

Archive and unarchive now skip a co-owner row for any folder the session records
itself: its own worktree, or an additional worktree its central list names. The
list is read only when the session co-owns a folder.

Co-authored-by: Copilot <[email protected]>

* agentHost: put the worktree co-ownership class doc on its class and note migration 20

Re-review LOW 4 (Block 5). The class JSDoc of AgentHostWorktreeCoOwnership sat
above the IWorktreeWithholding interface. The co-owner migration's version
constant now notes that version 20 is taken by it, so parallel work picks the
next free version.

Co-authored-by: Copilot <[email protected]>

* agentHost: note that the planner backstops a movability check asked for another owner

Re-review LOW 3 (Block 5). Asked whether a chat may move once another …
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants