Skip to content

agentHost: adopt flattened session states and drafts#323211

Merged
connor4312 merged 7 commits into
mainfrom
connor4312/ahp-flattened-session-today
Jun 26, 2026
Merged

agentHost: adopt flattened session states and drafts#323211
connor4312 merged 7 commits into
mainfrom
connor4312/ahp-flattened-session-today

Conversation

@connor4312

@connor4312 connor4312 commented Jun 26, 2026

Copy link
Copy Markdown
Member
  • Mechanical adoption of the session state split in sessions: flatten SessionState; move model/agent to Message, drafts agent-host-protocol#264. This is the first commit and is largely some churn and reduction of duplication (+1,100 -1,330)
  • Additional adoption of AH-brokered draft states. We propagate the ChatModel input state to the AH and then also pull it when restoring a new session. This PR does not yet try to mutate input for already-loaded models when a remote draft changes. That needs some care to be done correctly and I will tackly that separately
  • I copied the CopilotChatSessionProvider here which similarly loads a session to get a pointer to the input models and operates on that, but this feels like something that should probably not happen in the IChat world -- though IChat does not currently record input state and trying to hook that up was a much bigger PR I felt less certain about.

connor4312 and others added 3 commits June 25, 2026 14:59
- Flatten SessionState (metadata inline; no state.summary); SessionSummary
  is the root catalog with ISO-8601 createdAt/modifiedAt.
- Move model/agent off SessionState/ChatState onto Message; drop
  session/modelChanged, session/agentChanged, session/activeClientToolsChanged
  actions; default model now derives from the last turn / draft selection.
- Host state manager: ISessionEntry storage, derived getSessionSummary,
  unified _meta, and a SessionSummaryNotifier for summary-notification
  bookkeeping.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Store chat drafts in the per-session database and restore draft text, attachments, model, and agent selection into the chat input. Rebuild restored Copilot turns with best-effort model and attachment metadata while avoiding unresolved subagent names as agent URIs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ned-session-today

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 26, 2026 21:04
@connor4312 connor4312 changed the title Agent host: persist chat drafts agentHost: adopt flattened session states and drafts Jun 26, 2026
Some restored-session test mocks create chat models without an input model. Skip draft syncing for those models instead of throwing during the autorun install.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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.

Pull request overview

This PR updates the Agent Host Protocol (AHP) integration to persist per-chat drafts in the agent-host per-session database and restore them into VS Code chat input state. It also migrates session state to a flattened metadata shape (removing session-level model/agent fields in favor of message-level selection), and updates host/client wiring plus tests accordingly.

Changes:

  • Persist and restore chat drafts via new chat/draftChanged action, ChatState.draft, and a new chat_drafts DB table.
  • Move model/agent selection from session summary/state into individual Message objects; remove legacy session-level model/agent actions and metadata fields.
  • Update multiple providers, protocol types/reducers, and extensive test coverage to reflect the new protocol/state model.
Show a summary per file
File Description
src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostClientTools.test.ts Updates test session summary timestamps to ISO strings.
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionListStore.ts Serializes session timestamps to ISO strings in list store.
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionListController.ts Parses ISO timestamps back to epoch millis for UI.
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionHandler.ts Adds draft hydration + debounced input-state→draft sync; moves selection to message.
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostModeSynchronizer.ts Stops dispatching session agent changes; relies on stored picker selection.
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostGenericConfigChips.ts Reads working directory from flattened session state.
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostCustomizationService.ts Removes dependency on session agent change actions; uses flattened working dir.
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostChatInputPicker.ts Reads working directory from flattened session state.
src/vs/sessions/contrib/providers/remoteAgentHost/test/browser/remoteAgentHostSessionsProvider.test.ts Updates remote provider tests for message-level model and ISO timestamps.
src/vs/sessions/contrib/providers/remoteAgentHost/test/browser/remoteAgentHostCustomizationHarness.test.ts Removes session-agent-changed filtering from harness test.
src/vs/sessions/contrib/providers/remoteAgentHost/browser/remoteAgentHostSessionsProvider.ts Drops persisting session-level model in remote metadata serialization.
src/vs/sessions/contrib/providers/agentHost/browser/baseAgentHostSessionsProvider.ts Adjusts running/new session model/agent handling; adds draft dispatch hooks and chat-state updates.
src/vs/sessions/contrib/providers/agentHost/AGENT_HOST_SESSIONS_PROVIDER.md Documents draft persistence + message-level selection behavior.
src/vs/platform/agentHost/test/node/sessionPermissions.test.ts Updates timestamps to ISO strings in tests.
src/vs/platform/agentHost/test/node/sessionDatabase.test.ts Adds coverage for chat draft DB round-tripping + migration v6.
src/vs/platform/agentHost/test/node/reducers.test.ts Updates reducer tests for flattened session metadata.
src/vs/platform/agentHost/test/node/protocolServerHandler.test.ts Updates protocol server handler tests for ISO timestamps and removed model/agent.
src/vs/platform/agentHost/test/node/protocol/turnExecution.integrationTest.ts Updates integration test to read chat modifiedAt (ISO) instead of session summary.
src/vs/platform/agentHost/test/node/protocol/sessionLifecycle.integrationTest.ts Updates integration test to read status from flattened session state.
src/vs/platform/agentHost/test/node/protocol/sessionFeatures.integrationTest.ts Migrates model flow test to message-level model on chat/turnStarted.
src/vs/platform/agentHost/test/node/protocol/realSdkTestHelpers.ts Updates assertions for flattened session state fields.
src/vs/platform/agentHost/test/node/mapSessionEvents.test.ts Adds coverage for best-effort model/agent/attachments restore onto messages.
src/vs/platform/agentHost/test/node/claudeSessionMetadataStore.test.ts Removes model expectations from metadata store tests.
src/vs/platform/agentHost/test/node/claudeAgent.test.ts Updates Claude agent tests to validate model via SDK startup options rather than metadata.
src/vs/platform/agentHost/test/node/agentSideEffects.test.ts Updates tests to validate selection applied via chat/turnStarted message.
src/vs/platform/agentHost/test/node/agentService.test.ts Adds tests for persisting/restoring chat drafts; updates flattened state usage.
src/vs/platform/agentHost/test/node/agentHostTurnTelemetry.test.ts Updates telemetry tests to pass model via message rather than session-level model.
src/vs/platform/agentHost/test/node/agentHostStateManager.test.ts Updates state manager tests for flattened session summary accessors.
src/vs/platform/agentHost/test/node/agentHostSessionTitleController.test.ts Updates title controller tests for flattened title access.
src/vs/platform/agentHost/test/node/agentHostPullRequestOperationHandler.test.ts Updates tests for unified _meta bag and ISO timestamps.
src/vs/platform/agentHost/test/node/agentHostGitStateService.test.ts Updates tests for unified _meta bag access.
src/vs/platform/agentHost/test/node/agentHostFileCompletionProvider.test.ts Updates tests for flattened working directory access.
src/vs/platform/agentHost/test/node/agentHostDiscardChangesOperationHandler.test.ts Updates tests for flattened working directory access.
src/vs/platform/agentHost/test/node/agentHostCommitOperationHandler.test.ts Updates tests for flattened working directory access.
src/vs/platform/agentHost/test/node/agentHostChangesetService.test.ts Updates tests for flattened summary accessors.
src/vs/platform/agentHost/test/node/agentHostChangesetOperationService.test.ts Updates tests for ISO timestamps.
src/vs/platform/agentHost/test/node/agentHostChangesetCoordinator.test.ts Updates tests for flattened summary accessors.
src/vs/platform/agentHost/test/node/agentFeedbackServerTools.test.ts Updates tests for ISO timestamps.
src/vs/platform/agentHost/test/node/agentConfigurationService.test.ts Updates tests for ISO timestamps.
src/vs/platform/agentHost/test/common/sessionTestHelpers.ts Extends in-memory test DB with chat draft storage.
src/vs/platform/agentHost/test/common/agentSubscription.test.ts Updates subscription tests for flattened session state + ISO timestamps.
src/vs/platform/agentHost/node/sessionDatabase.ts Adds migration v6 and implements set/get chat drafts in sqlite.
src/vs/platform/agentHost/node/protocolServerHandler.ts Removes createSession/createChat model passthrough; switches listSessions timestamps to ISO.
src/vs/platform/agentHost/node/copilot/mapSessionEvents.ts Adds options object and propagates model/agent/attachments into message construction.
src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts Passes working directory + fallback model when mapping SDK events.
src/vs/platform/agentHost/node/copilot/copilotAgent.ts Removes session-level model/agent metadata surfacing.
src/vs/platform/agentHost/node/claude/claudeSessionMetadataStore.ts Removes model/agent overlay from Claude metadata store projection.
src/vs/platform/agentHost/node/agentSideEffects.ts Persists chat drafts on ChatDraftChanged; applies selection from message on ChatTurnStarted.
src/vs/platform/agentHost/node/agentService.ts Restores drafts from DB into session/chat state; updates summary timestamps and meta overlay logic.
src/vs/platform/agentHost/node/agentHostSyncOperationHandler.ts Reads working directory from flattened session state.
src/vs/platform/agentHost/node/agentHostSessionTitleController.ts Updates title logic to use flattened title field.
src/vs/platform/agentHost/node/agentHostPullRequestOperationHandler.ts Reads working directory and GitHub state from flattened state + unified _meta.
src/vs/platform/agentHost/node/agentHostGitStateService.ts Unifies git/GitHub meta; adds DB-backed GitHub state load helper.
src/vs/platform/agentHost/node/agentHostFileCompletionProvider.ts Reads working directory from flattened session state.
src/vs/platform/agentHost/node/agentHostDiscardChangesOperationHandler.ts Reads working directory from flattened session state.
src/vs/platform/agentHost/node/agentHostCommitOperationHandler.ts Reads working directory from flattened session state.
src/vs/platform/agentHost/node/agentHostChangesetService.ts Reads working directory / summary changes via flattened accessors.
src/vs/platform/agentHost/node/agentHostChangesetOperationService.ts Reads GitHub state from unified _meta.
src/vs/platform/agentHost/node/agentHostChangesetCoordinator.ts Reads working directory from flattened session state.
src/vs/platform/agentHost/node/agentConfigurationService.ts Reads working directory from flattened session state.
src/vs/platform/agentHost/common/state/sessionState.ts Flattens session state creation; adds draft field to default-chat merge.
src/vs/platform/agentHost/common/state/sessionActions.ts Removes exported session-level model/agent action type aliases.
src/vs/platform/agentHost/common/state/protocol/version/registry.ts Removes legacy session model/agent actions; adds ChatDraftChanged versioning.
src/vs/platform/agentHost/common/state/protocol/common/actions.ts Removes session model/agent/action types; adds ChatDraftChanged action type.
src/vs/platform/agentHost/common/state/protocol/channels-session/state.ts Introduces SessionMetadata; flattens SessionState; changes timestamps to ISO strings.
src/vs/platform/agentHost/common/state/protocol/channels-session/reducer.ts Updates reducer to mutate flattened fields; removes model/agent reducers.
src/vs/platform/agentHost/common/state/protocol/channels-session/commands.ts Removes createSession model/agent params; clarifies active client docs.
src/vs/platform/agentHost/common/state/protocol/channels-session/actions.ts Removes session model/agent actions; clarifies active-client semantics.
src/vs/platform/agentHost/common/state/protocol/channels-root/notifications.ts Updates docs/examples for ISO timestamps.
src/vs/platform/agentHost/common/state/protocol/channels-chat/state.ts Adds ChatState.draft; moves model/agent selection onto Message; removes chat-level overrides.
src/vs/platform/agentHost/common/state/protocol/channels-chat/reducer.ts Adds reducer handling for ChatDraftChanged.
src/vs/platform/agentHost/common/state/protocol/channels-chat/commands.ts Removes createChat model/agent params.
src/vs/platform/agentHost/common/state/protocol/channels-chat/actions.ts Adds ChatDraftChanged action and documentation.
src/vs/platform/agentHost/common/state/protocol/action-origin.generated.ts Regenerates dispatchability/origin unions incl. ChatDraftChanged.
src/vs/platform/agentHost/common/state/protocol/.ahp-version Bumps protocol schema/version pointer.
src/vs/platform/agentHost/common/sessionDataService.ts Extends ISessionDatabase with set/get chat drafts.
src/vs/platform/agentHost/common/agentService.ts Removes session-level model/agent from IAgentSessionMetadata; clarifies _meta bag.
src/vs/platform/agentHost/browser/remoteAgentHostProtocolClient.ts Stops sending model in createSession/createChat; parses ISO timestamps on listSessions.
.github/skills/sessions/SKILL.md Adds guidance about draft persistence via debounced input-state sync (no model-only draft dispatch).

Review details

  • Files reviewed: 82/82 changed files
  • Comments generated: 5
  • Review effort level: Low

Comment thread src/vs/platform/agentHost/node/sessionDatabase.ts
Comment thread src/vs/platform/agentHost/node/agentSideEffects.ts
connor4312 and others added 3 commits June 26, 2026 14:20
Avoid model-only draft dispatches from the provider, wait indefinitely for draft sync models while the session is alive, fail closed on corrupt draft rows, and serialize selection changes before sending turns.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The protocol test now fetches the merged session/default-chat state before asserting restored turn message model data, matching the split chat state layout.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@connor4312 connor4312 marked this pull request as ready for review June 26, 2026 22:08
@connor4312 connor4312 enabled auto-merge June 26, 2026 22:08
@connor4312 connor4312 merged commit dac0f5b into main Jun 26, 2026
29 checks passed
@connor4312 connor4312 deleted the connor4312/ahp-flattened-session-today branch June 26, 2026 23:40
@vs-code-engineering vs-code-engineering Bot added this to the 1.127.0 milestone Jun 26, 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.

4 participants