fix: privileged context state not preserved across tool calls#54
Open
fix: privileged context state not preserved across tool calls#54
Conversation
select_privileged_context switched the window and Marionette context but never updated currentContextId. Helper tools (set_firefox_prefs, get_firefox_prefs, list_extensions) saved the stale context and restored to it in their finally blocks, silently reverting the user's privileged context selection. - Add setCurrentContextId() to FirefoxClient public API - Call setCurrentContextId in select_privileged_context - Skip context restore in helper tools when already on the right chrome context Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
select_privileged_contextswitched the window and Marionette context but never updatedcurrentContextIdset_firefox_prefs,get_firefox_prefs,list_extensions) saved the stale context ID and restored to it in theirfinallyblocks, silently reverting the user's privileged context selectionChanges
src/tools/privileged-context.ts: callsetCurrentContextId()after successful context switchsrc/firefox/index.ts: exposesetCurrentContextId()onFirefoxClientsrc/tools/firefox-prefs.ts: skip context restore whenoriginalContextIdmatches the chrome context (2 finally blocks)src/tools/webextension.ts: same fix forlist_extensionstests/tools/privileged-context.test.ts: 2 tests that fail without the fix, pass with itTest plan