agentHost: add session-specific metadata#305348
Merged
connor4312 merged 8 commits intomainfrom Mar 27, 2026
Merged
Conversation
Adds a SQLite DB for session-specific metadata. Stores edits in there. It can _almost_ restore edits, but I still need to make undoStops be similarly persisted. That is a project for later this evening.
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @jriekenMatched files:
|
Contributor
There was a problem hiding this comment.
Pull request overview
Adds per-session persistent storage to the agent host by introducing a SQLite-backed session database. This enables restoring session-specific metadata (notably file-edit snapshots) across server lifetimes and wiring those snapshots into tool result rendering via session-db: content URIs.
Changes:
- Introduces
SessionDatabase(SQLite + migrations) and exposes it via a ref-countedISessionDataService.openDatabase()API. - Persists edit-tool file snapshots into the DB and restores file-edit metadata into mapped tool results using
session-db:URIs. - Adjusts session removal semantics (
removeSessionvsdeleteSession) and adds/updates tests for the new persistence and mapping behavior.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.ts | Minor catch-clause tweak while reading snapshots. |
| src/vs/platform/agentHost/test/node/sessionStateManager.test.ts | Updates tests for new removeSession vs deleteSession behavior. |
| src/vs/platform/agentHost/test/node/sessionDatabase.test.ts | New comprehensive test suite for migrations, turns, and file-edit persistence. |
| src/vs/platform/agentHost/test/node/sessionDataService.test.ts | Adds tests for DB ref-counting via openDatabase(). |
| src/vs/platform/agentHost/test/node/mapSessionEvents.test.ts | New tests for mapping session events and restoring file edits from DB. |
| src/vs/platform/agentHost/test/node/fileEditTracker.test.ts | Updates tests to use DB-backed snapshots and session-db: URIs. |
| src/vs/platform/agentHost/test/node/agentSideEffects.test.ts | Updates ISessionDataService mock to include openDatabase(). |
| src/vs/platform/agentHost/test/node/agentService.test.ts | Updates ISessionDataService mock to include openDatabase(). |
| src/vs/platform/agentHost/node/sessionStateManager.ts | Splits removal into non-notifying removeSession and notifying deleteSession. |
| src/vs/platform/agentHost/node/sessionDatabase.ts | New SQLite-backed DB implementation with migrations + file-edit APIs. |
| src/vs/platform/agentHost/node/sessionDataService.ts | Adds ref-counted DB collection and openDatabase() implementation. |
| src/vs/platform/agentHost/node/copilot/mapSessionEvents.ts | New standalone mapper that can restore file edits from the DB. |
| src/vs/platform/agentHost/node/copilot/fileEditTracker.ts | Persists before/after snapshots to DB and emits session-db: URIs. |
| src/vs/platform/agentHost/node/copilot/copilotAgent.ts | Integrates DB + event mapper and persists edits per tool completion. |
| src/vs/platform/agentHost/node/agentSideEffects.ts | Fetches session-db: content by reading file-edit blobs from the DB. |
| src/vs/platform/agentHost/node/agentService.ts | Uses deleteSession and restores sessions on subscribe when needed. |
| src/vs/platform/agentHost/common/sessionDataService.ts | Extends the public agent-host API with ISessionDatabase + openDatabase(). |
| src/vs/platform/agentHost/common/agentHostUri.ts | Avoids bypassing wrapping for local non-file schemes (e.g. session-db:). |
| src/vs/platform/agentHost/common/agentHostFileSystemProvider.ts | Treats session-db: as a file-like resource for stat. |
DonJayamanne
previously approved these changes
Mar 26, 2026
DonJayamanne
previously approved these changes
Mar 27, 2026
Member
|
@connor4312 looks like real unit test failures on Windows |
bpasero
previously approved these changes
Mar 27, 2026
roblourens
previously approved these changes
Mar 27, 2026
roblourens
approved these changes
Mar 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a SQLite DB for session-specific metadata. Stores edits in there. It can almost restore edits, but I still need to make undoStops be similarly persisted. That is a project for later this evening.