Repository navigation
feat(safe-mode): drive two open files at once, one daemon per session - #61
Closed
vfragkoulopoulou wants to merge 1 commit into
Closed
vfragkoulopoulou wants to merge 1 commit into
vfragkoulopoulou wants to merge 1 commit into
Conversation
… once DAEMON_PORT (3456-3460) now picks the daemon port in the CLI, with a per-port PID file and token. The daemon turns away a FigCli window from another file while it serves a live one, so the window moves to the next free port; a claim (Take over button) still replaces it. Plugins without an instance id keep the old last-one-wins behaviour. status shows the connected file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
|
Thank you for this! I am holding it back for now. It changes Safe Mode for people with only one open file too: a second FigCli window no longer takes over and shows a Take over button instead. I want to test that with two files first. |
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.
The problem
In Safe Mode every CLI session talks to the same daemon on port 3456, and that daemon holds one FigCli connection. With two files open and FigCli started in both, whichever window connected last takes over. The other session's commands then go silently to the wrong file.
FIGMA_FILEdoesn't help because it only applies to CDP.A common case is two agent sessions open side by side, one per file (e.g. reading components from a library file while building in another). Today you have to close FigCli in one file before working in the other.
What this does
DAEMON_PORT(3456–3460) picks the daemon port in the CLI. Each port has its own PID file and token. With noDAEMON_PORT, paths and behaviour are unchanged.busy). The window then tries the next port. A reconnect from the same window (same instance id) is accepted, and a connection that has gone stale (no ping for 10s) can be replaced.claim: true), which replaces the current connection deliberately.figma-cli statusshows which file the session is connected to (pluginFilein/health, kept separate fromfileso theFIGMA_FILEpin check never restarts a plugin daemon).Usage
Then start FigCli in each file.
Testing
npm test: 549 passing.evalrouted to the right file.eval figma.root.nameandcanvas inforun at the same moment on 3456 and 3457 each returned their own file.🤖 Generated with Claude Code