Fix explicit active file drift in multi-file bridge - #90
Open
StealthEyeLLC wants to merge 1 commit into
Open
Conversation
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
Fixes #72.
This makes explicit multi-file targeting sticky in the local WebSocket Desktop Bridge. Before an MCP client explicitly targets a file, the legacy behavior is preserved: the active file follows the latest connected/user-touched file. After
setActiveFile()is called (normally throughfigma_navigate), passive peerFILE_INFO,SELECTION_CHANGE, andPAGE_CHANGEevents continue updating per-file state, but no longer silently retarget subsequent tool calls.Why
In multi-file sessions, background events from another Figma file can currently override an explicit
figma_navigate()target. That makes long-running agent workflows unsafe: an operation can begin in file A and silently continue in file B after a tab focus, selection event, page event, or plugin reconnect.Changes
FigmaWebSocketServer.FILE_INFOreconnects/new file connections from stealing an explicit active target.figma_navigatealready-connected path callsetActiveFile()so it pins the target explicitly even when the requested file is already active.SELECTION_CHANGE,PAGE_CHANGE, andFILE_INFOreconnect/new-file drift.Validation
Run on OVH using the upstream repo checkout on branch
fix-explicit-active-file-lock.npm ci --include=dev✅npx -y node@22 node_modules/jest/bin/jest.js tests/websocket-bridge.test.ts --runInBand✅npx -y node@22 node_modules/typescript/bin/tsc -p tsconfig.local.json --noEmit✅npx -y node@22 node_modules/typescript/bin/tsc --project tsconfig.local.json✅npx -y node@22 node_modules/jest/bin/jest.js --runInBand✅ — 45 suites / 1339 tests passedgit diff --check✅Note: full
tsc --noEmitstill reports existing app UI type errors insrc/apps/*/ui/mcp-app.tsunrelated to this change. The touched local-server path passestsconfig.local.jsontype-check and build, and the full Jest suite passes under Node 22.