Mirror global system-Python cache into workspaceState to survive cold globalState on remotes - #1611
Draft
Eleanor Boyd (eleanorjboyd) with Copilot wants to merge 4 commits into
Draft
Eleanor Boyd (eleanorjboyd) with Copilot wants to merge 4 commits into
Eleanor Boyd (eleanorjboyd) with Copilot wants to merge 4 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
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot started reviewing on behalf of
Eleanor Boyd (eleanorjboyd)
September 25, 2026 17:29
View session
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Address stale workspace-cache precedence and ensure both cache layers are cleared independently.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (3)
Resolved since last review (1)
Comment on lines
+69
to
+75
| const workspaceState = await getWorkspacePersistentState(); | ||
| const workspaceValue = await workspaceState.get<string>(SYSTEM_GLOBAL_KEY); | ||
| if (workspaceValue) { | ||
| return workspaceValue; | ||
| } | ||
| const globalState = await getGlobalPersistentState(); | ||
| return await globalState.get<string>(SYSTEM_GLOBAL_KEY); |
| // getSystemEnvForGlobal/setSystemEnvForGlobal) so that the cross-session | ||
| // cache survives on fresh remotes where globalState is cold. Clear both | ||
| // the workspace-scoped map and the mirrored global key here. | ||
| await workspaceState.clear([SYSTEM_WORKSPACE_KEY, SYSTEM_GLOBAL_KEY]); |
| assert.strictEqual(result, '/global/python'); | ||
| }); | ||
|
|
||
| test('does not interact with persistent state when called (sanity: lazy/awaited only)', async () => { |
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.



Why
When the cached global system-Python path is absent from
globalStatebut still available in the workspace cache, interpreter selection can trigger an unnecessary foreground PET refresh.Fix
Read the cached path from
workspaceStatefirst, falling back toglobalState. Mirror updates and clear both copies. Log cache-write failures per layer without interrupting environment discovery.