Mirror global system-Python cache into workspaceState to survive cold globalState on remotes#1611
Draft
Copilot wants to merge 2 commits into
Draft
Mirror global system-Python cache into workspaceState to survive cold globalState on remotes#1611Copilot wants to merge 2 commits into
Copilot wants to merge 2 commits into
Conversation
Copilot
AI
changed the title
[WIP] Fix cross-session cache misses on fresh remote
Mirror global system-Python cache into workspaceState to survive cold globalState on remotes
Jun 25, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves startup/performance for global system Python discovery on remote scenarios by mirroring the cross-session system-Python cache into workspaceState, using globalState as a fallback. This helps avoid foreground PET refreshes when context.globalState is effectively “cold” per-remote.
Changes:
- Update system-Python global cache read/write logic to be workspaceState-primary with globalState fallback, and clear both layers during cache clears.
- Add a new unit test suite covering the two-tier lookup behavior, dual writes, and full invalidation.
- Regenerate
package-lock.jsonmetadata (removing several"peer": trueentries).
Show a summary per file
| File | Description |
|---|---|
| src/managers/builtin/cache.ts | Mirrors SYSTEM_GLOBAL_KEY into workspaceState, adds fallback read, and clears both layers. |
| src/test/managers/builtin/cache.systemEnvGlobal.unit.test.ts | Adds unit tests validating workspaceState-primary + globalState fallback behavior and clearing semantics. |
| package-lock.json | Lockfile metadata normalization (no functional code impact). |
Copilot's findings
- Files reviewed: 2/3 changed files
- Comments generated: 1
Comment on lines
+86
to
+93
| const [workspaceState, globalState] = await Promise.all([ | ||
| getWorkspacePersistentState(), | ||
| getGlobalPersistentState(), | ||
| ]); | ||
| await Promise.all([ | ||
| workspaceState.set(SYSTEM_GLOBAL_KEY, envPath), | ||
| globalState.set(SYSTEM_GLOBAL_KEY, envPath), | ||
| ]); |
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.
context.globalStateis scoped per-remote, so the cross-session cache for the discovered global system Python (PR #1455) starts cold on every fresh SSH host, WSL distro, dev container, or codespace — and on local profile resets. Every cold start falls through to a full PET refresh on the foreground env-selection path, which is the dominant remaining Linux hang.Changes
src/managers/builtin/cache.ts— promoteworkspaceStateto a primary layer forSYSTEM_GLOBAL_KEY, keepglobalStateas fallback:getSystemEnvForGlobal()— readworkspaceState[SYSTEM_GLOBAL_KEY]first, fall back toglobalState[SYSTEM_GLOBAL_KEY].setSystemEnvForGlobal()— write (andundefined-invalidate) to both layers in parallel.clearSystemEnvCache()— also clear the mirroredSYSTEM_GLOBAL_KEYfromworkspaceState.No call-site changes. The fastPath contract is preserved (single
string | undefined), soglobal_env.cachetelemetry (hit/miss/stale) and the workspace-scoped path (SYSTEM_WORKSPACE_KEY) are unaffected.Tests
New
src/test/managers/builtin/cache.systemEnvGlobal.unit.test.ts(10 cases): workspaceState-primary lookup, globalState fallback (incl. empty-string), dual-write of values andundefined, set→get round-trip, and full invalidation through both layers viaclearSystemEnvCache.Acceptance criteria mapping
hit/miss/staleunchanged ✅.