fix: prevent stale cache when editing prompts across multiple windows #10177
+70
−2
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.
Summary
Fixes a bug where the context condensing prompt (and mode prompts) would revert to a previous value when multiple VS Code windows are open. This occurred because each window had its own stale cache of the global state, and read-modify-write operations would overwrite newer values from other windows.
Changes
refreshGlobalStateKey()method toContextProxythat reads fresh values directly from VS Code'sglobalStateand updates the local cacheupdateCondensingPrompthandler to userefreshGlobalStateKey()before modifyingcustomSupportPromptsupdatePrompthandler to userefreshGlobalStateKey()before modifyingcustomModePromptsrefreshGlobalStateKey()methodRoot Cause
Each VS Code window runs its own extension host process with a separate
ContextProxysingleton. The cache was populated at initialization but never refreshed when other windows updatedglobalState. This caused stale values to be used in read-modify-write operations.Important
Fixes stale cache issue in VS Code extension by adding
refreshGlobalStateKey()to update cache fromglobalState, ensuring consistency across multiple windows.ContextProxywhen editing prompts across multiple VS Code windows.refreshGlobalStateKey()inContextProxyto update cache fromglobalState.updateCondensingPromptandupdatePrompthandlers inwebviewMessageHandler.tsto userefreshGlobalStateKey().refreshGlobalStateKey()inContextProxy.spec.ts.This description was created by
for 33f8e58. You can customize this summary. It will automatically update as commits are pushed.