mirror of
https://github.com/microsoft/vscode.git
synced 2026-08-16 02:56:37 +01:00
* agents window: apply session `_meta` once per update and keep it transactional Follow-up to "agents window: keep workspace-less quick chats out of bogus workspace groups". That change made `_meta` arrive on every `listSessions` refresh, which turns two pre-existing quirks in `AgentHostSessionAdapter.update` into per-session, per-turn-completion work: - `_meta` was applied twice: once inline and again through the trailing `setMeta`. With the promotion logic now living in `setMeta`, that also ran `_promoteToQuickChatIfWorkspaceless` and `_computeWorkspace` twice. Apply it once, up front, where the promotion still precedes the workspace rebuild. - `setMeta` opened its own `transaction()`. `transaction()` never joins an enclosing one - it constructs a `TransactionImpl` and `finish()`es it - so moving the single application to the top of `update` would notify observers of `_meta` / `isQuickChat` / `workspace` before `isArchived`, `isRead`, `changes` and `activity` were applied, handing them a torn snapshot. Take an optional `ITransaction` and use `subtransaction`, and thread the caller's transaction from `update` and `_handleSessionSummaryChanged`. The two standalone callers pass nothing and keep their own transaction. Also pins the absent-`_meta` case on the wire (the item is built field by field and `satisfies SessionSummary` cannot catch a dropped optional in either direction), and corrects the session-database key named in the docs: the marker is persisted as `agentHost.workspaceless` (`AH_META_WORKSPACELESS_DB_KEY`, written by `AgentService`), never `copilot.workspaceless`. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8f4788b1-3307-4b88-b3fc-23565548de06 * agents window: drop the redundant workspace rebuild and finish the transaction threading Addresses review feedback on this PR. - `update()` still recomputed the workspace unconditionally after `setMeta` had already rebuilt it from the same project / working directories and the same `_meta`, so a `_meta`-bearing refresh paid for `_computeWorkspace()` twice - exactly the duplicate per-turn work this PR set out to remove. The fallback rebuild now only runs when the snapshot carries no `_meta`. - `setChangesSummary` and `setActivity` wrote their observables with no transaction, and `observableValue.set(v, undefined)` builds and finishes one of its own, so they notified mid-way through the enclosing update. Both now take an optional `ITransaction`, and `update()` / `_handleSessionSummaryChanged` thread theirs through. Without this, threading the transaction into `setMeta` alone left `SessionSummaryChanged` still torn: `changes` is applied before `_meta`, so an observer of both ran once on the new chip with the stale workspace, then again at the outer finish. The new test covers that notification path and fails with the intermediate `{ branch: undefined, files: 2 }` snapshot when the transaction is dropped. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8f4788b1-3307-4b88-b3fc-23565548de06 --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8f4788b1-3307-4b88-b3fc-23565548de06