fix(connect): don't quit a Figma that is already debuggable - #40
Open
clementcopper wants to merge 1 commit into
Open
fix(connect): don't quit a Figma that is already debuggable#40clementcopper wants to merge 1 commit into
clementcopper wants to merge 1 commit into
Conversation
`connect` quit and relaunched Figma unconditionally, costing the user
their window arrangement and any unsaved state — including the common
case where the CDP port already answers and nothing needs to happen.
connect now probes the port first and branches on the result:
reuse CDP answers -> leave Figma alone, wire up the daemon
needs-quit Figma up, no debug port -> ask the user to quit (they may have
unsaved work; we must not kill it)
start-fresh no Figma -> patch if needed and launch, as before
The decision itself is a pure function in src/lib/connect-plan.js so it
can be unit-tested without a Figma or an open port. The process probe uses
isFigmaRunning() from platform.js, so it works on all three platforms.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
clementcopper
added a commit
to clementcopper/figma-claude
that referenced
this pull request
Sep 3, 2026
Seven branches became one on 2026-09-03. The skill's first line still said the default was v2, and it is the file you read right before merging from upstream. What the cleanup was based on: `feat/swift-host` was v2 plus 26 commits with v2 fully contained, the only tree difference being `swift-host/`, and `app/` sitting in both. The Electron app is a directory, not a branch — `make-app.sh` reads `app/build/icon.icns` — so a second branch beside the trunk would have been a copy of the same CLI falling behind. v2 had stood still since 22.08. `v2` and `archive/draft-v1` are now the tags `v2-final` and `draft-v1`. The four PR branches stay on origin because deleting them there closes PRs silships#40, silships#41, silships#43 and silships#44; that is written down so nobody tidies them away later. Also noted: CI triggers on `branches: [main]`, which this fork has never had, so it has never run on a push here. Left alone. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QuvZuDad3hi3CVwNDbTvr2
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
connectquits and relaunches Figma unconditionally:That runs even when the CDP port is already answering and nothing needs to happen to Figma at all — which is the common case once you're set up. The cost is the user's window arrangement, their zoom/scroll position, and whatever hasn't synced yet. Running
connecta second time "just to be sure" is a normal thing to do, and it shouldn't be destructive.It also affects the recovery path people are told to take: when a command times out, restarting the daemon is usually enough, but
connectlooks like the safer, more thorough option — and it's the one that costs you your session.The change
connectprobes the CDP port first and branches on what it finds:The
start-freshbranch is the existing code, unchanged. Only the guard in front of it is new.The decision itself is a pure function in
src/lib/connect-plan.js, following the pattern ofbrowserDebugArgs/tests/browser-mode.test.js, so it's unit-tested without a Figma or an open port:The process probe uses the existing
isFigmaRunning()fromsrc/platform.js, so it works on macOS, Windows and Linux. The port comes fromgetCdpPort(), so--port/FIGMA_PORTare honored.Verification
npm test→ 525 passing, including 4 new cases intests/connect-plan.test.jsconnect; output✓ Figma already running (left untouched), daemon reconnectedapp.asar:connectprinted the quit prompt and left the process aloneNotes
Happy to adjust the wording of the
needs-quitmessage, or to make it offer a--forceflag that restores the old quit-and-relaunch behavior, if you'd rather keep an escape hatch.