Skip to content

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
mainfrom
copilot/fix-cross-session-cache-misses
Draft

Eleanor Boyd (eleanorjboyd) with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-cross-session-cache-misses

Conversation

Copilot AI commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

Why

When the cached global system-Python path is absent from globalState but still available in the workspace cache, interpreter selection can trigger an unnecessary foreground PET refresh.

Fix

Read the cached path from workspaceState first, falling back to globalState. Mirror updates and clear both copies. Log cache-write failures per layer without interrupting environment discovery.

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

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 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.json metadata (removing several "peer": true entries).
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 thread src/managers/builtin/cache.ts Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

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 High severity · 1 Medium severity · 1 Low severity

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 () => {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature-request Request for new features or functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants