figma-mcp-console 0.5.4 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,6 +6,7 @@
6
6
  "ui": "ui.html",
7
7
  "editorType": ["figma"],
8
8
  "documentAccess": "dynamic-page",
9
+ "enablePrivatePluginApi": true,
9
10
  "networkAccess": {
10
11
  "allowedDomains": ["none"],
11
12
  "devAllowedDomains": ["ws://localhost:2000"],
@@ -15,7 +15,7 @@
15
15
  "Segoe UI",
16
16
  sans-serif;
17
17
  margin: 0;
18
- padding: 14px;
18
+ padding: 10px;
19
19
  color: #2c2c34;
20
20
  background: linear-gradient(160deg, #f6f7fb 0%, #eef0f7 100%);
21
21
  display: flex;
@@ -25,8 +25,8 @@
25
25
  .card {
26
26
  background: #fff;
27
27
  border: 1px solid #e6e8f0;
28
- border-radius: 10px;
29
- padding: 9px 11px;
28
+ border-radius: 9px;
29
+ padding: 7px 9px;
30
30
  box-shadow: 0 1px 2px rgba(30, 34, 60, 0.04);
31
31
  }
32
32
 
@@ -57,13 +57,6 @@
57
57
  box-shadow: 0 0 0 3px rgba(34, 160, 107, 0.15);
58
58
  }
59
59
 
60
- #hint {
61
- color: #6b6f7d;
62
- margin-top: 8px;
63
- font-size: 11px;
64
- line-height: 1.45;
65
- }
66
-
67
60
  #result {
68
61
  display: none;
69
62
  margin-top: 10px;
@@ -84,8 +77,10 @@
84
77
 
85
78
  .res-title {
86
79
  font-weight: 600;
87
- font-size: 11px;
88
- color: #1f2330;
80
+ font-size: 10px;
81
+ color: #8288a0;
82
+ text-transform: uppercase;
83
+ letter-spacing: 0.04em;
89
84
  }
90
85
 
91
86
  .res-list {
@@ -135,6 +130,38 @@
135
130
  cursor: pointer;
136
131
  }
137
132
 
133
+ /* ---- checkpoint: what changed in the selected frame since the user saved it ---- */
134
+ #cp:empty {
135
+ display: none;
136
+ }
137
+ #cp {
138
+ margin-top: 10px;
139
+ font-size: 11px;
140
+ }
141
+ #cp .res-head {
142
+ margin-bottom: 4px;
143
+ font-size: 10px;
144
+ }
145
+ .cp-bar {
146
+ display: flex;
147
+ align-items: center;
148
+ gap: 5px;
149
+ }
150
+ .cp-list {
151
+ max-height: 220px;
152
+ overflow: auto;
153
+ margin-top: 5px;
154
+ }
155
+ .cp-row {
156
+ padding: 3px 5px;
157
+ border-radius: 5px;
158
+ cursor: pointer;
159
+ overflow-wrap: anywhere;
160
+ }
161
+ .cp-row:hover {
162
+ background: #f0f2f8;
163
+ }
164
+
138
165
  .copy-btn:hover {
139
166
  background: #f0f2f8;
140
167
  }
@@ -150,113 +177,105 @@
150
177
  font-size: 10px;
151
178
  }
152
179
 
153
- .filter-row {
154
- display: flex;
155
- gap: 4px;
156
- margin-bottom: 8px;
157
- }
158
-
159
- .filter-btn {
160
- flex: none;
161
- border: 1px solid #d6d9e6;
162
- background: #fff;
163
- color: #6b6f7d;
164
- border-radius: 6px;
165
- padding: 3px 9px;
166
- font-size: 10px;
180
+ .out-close {
181
+ border: none;
182
+ background: none;
183
+ color: #8288a0;
167
184
  cursor: pointer;
185
+ font-size: 13px;
186
+ padding: 0 2px;
168
187
  }
169
188
 
170
- .filter-btn:hover {
171
- background: #f0f2f8;
189
+ .muted {
190
+ color: #8288a0;
172
191
  }
173
192
 
174
- .filter-btn.on {
175
- background: #2c2c34;
176
- border-color: #2c2c34;
177
- color: #fff;
193
+ .k-del {
194
+ color: #d1434b;
195
+ font-weight: 600;
178
196
  }
179
197
 
180
- .res-empty {
181
- font-size: 11px;
182
- color: #a0a4b0;
183
- padding: 6px 2px;
198
+ .k-chg {
199
+ color: #b7791f;
200
+ font-weight: 600;
184
201
  }
185
202
 
186
- .key-prompt {
187
- margin-bottom: 8px;
188
- padding: 7px 8px;
189
- border: 1px solid #ffe0a6;
190
- background: #fff9ec;
191
- border-radius: 7px;
203
+ .used {
204
+ color: #22a06b;
205
+ font-weight: 600;
192
206
  }
193
207
 
194
- .key-note {
208
+ #credit {
209
+ margin-top: auto;
210
+ padding-top: 7px;
211
+ text-align: center;
212
+ color: #a0a4b0;
195
213
  font-size: 10px;
196
- color: #8a6d3b;
197
- line-height: 1.4;
198
- margin-bottom: 5px;
199
214
  }
200
215
 
201
- .key-input-row {
216
+ #version {
217
+ color: #8288a0;
218
+ }
219
+
220
+ /* ---- read-only switch and activity log ---- */
221
+ #act-head {
202
222
  display: flex;
223
+ align-items: center;
224
+ gap: 6px;
225
+ margin-top: 10px;
226
+ border-top: 1px solid #eceef5;
227
+ padding-top: 8px;
228
+ font-size: 10.5px;
229
+ }
230
+ #act-head label {
231
+ display: flex;
232
+ align-items: center;
203
233
  gap: 4px;
234
+ cursor: pointer;
204
235
  }
205
-
206
- .key-input {
236
+ #act-counts {
207
237
  flex: 1;
208
- min-width: 0;
209
- border: 1px solid #d6d9e6;
210
- border-radius: 6px;
211
- padding: 3px 6px;
212
- font-size: 10px;
213
- }
214
-
215
- .key-save {
216
- flex: none;
217
- border: 1px solid #d6d9e6;
218
- background: #fff;
219
- border-radius: 6px;
220
- padding: 3px 10px;
221
- font-size: 10px;
238
+ text-align: right;
222
239
  cursor: pointer;
240
+ white-space: nowrap;
223
241
  }
224
-
225
- .key-save:hover {
226
- background: #f0f2f8;
242
+ #activity {
243
+ margin-top: 4px;
244
+ font-size: 10.5px;
227
245
  }
228
-
229
- #credit {
230
- margin-top: auto;
231
- padding-top: 10px;
232
- text-align: center;
233
- color: #a0a4b0;
234
- font-size: 10px;
246
+ #activity:not(.open) {
247
+ display: none;
235
248
  }
236
-
237
- #credit a {
238
- color: #8288a0;
239
- text-decoration: none;
249
+ .act-row {
250
+ padding: 2px 4px;
251
+ border-radius: 4px;
252
+ white-space: nowrap;
253
+ overflow: hidden;
254
+ text-overflow: ellipsis;
240
255
  }
241
-
242
- #credit a:hover {
243
- text-decoration: underline;
256
+ .act-row[data-id] {
257
+ cursor: pointer;
258
+ }
259
+ .act-row[data-id]:hover {
260
+ background: #f0f2f8;
244
261
  }
245
262
  </style>
246
263
 
247
264
  <div class="card">
248
- <div id="status-row">
265
+ <div id="status-row" title="Keep open while AI works · run it in every file">
249
266
  <span id="dot"></span><span id="status">Connecting…</span>
250
267
  </div>
251
- <div id="hint">
252
- Keep this window open while AI works. Open the plugin in each file you want
253
- it to edit.
254
- </div>
255
268
  <div id="result"></div>
269
+ <div id="cp"></div>
270
+ <div id="act-head">
271
+ <label title="Refuse every AI command that would change this file"><input type="checkbox" id="readonly" checked> Read-only</label>
272
+ <span id="act-counts" class="muted" title="Show or hide what the AI did in this file"></span>
273
+ <button id="act-clear" class="out-close" title="Clear the log">×</button>
274
+ </div>
275
+ <div id="activity"></div>
256
276
  </div>
257
277
  <div id="credit">
258
- <a href="https://github.com/hoangann2000/figma-mcp-console" target="_blank">@hoangann2000</a>
259
- <a href="https://github.com/fuvavi" target="_blank">@fuvavi</a>
278
+ <span id="version"></span>
260
279
  </div>
261
280
 
262
281
  <script>
@@ -270,7 +289,7 @@
270
289
  // the status line also trigger an immediate attempt.
271
290
  const PORT = 2000,
272
291
  RETRY = 1000,
273
- PROTOCOL = 1; // must match bridge.ProtocolVersion in the Go server
292
+ PROTOCOL = 3; // must match bridge.ProtocolVersion in the Go server
274
293
  let ws = null; // open connection, null while disconnected
275
294
  let attempt = null; // socket currently trying to connect
276
295
  let reg = null; // {key, name} of this file, sent by the main thread
@@ -288,7 +307,9 @@
288
307
 
289
308
  function sendRegister() {
290
309
  if (ws && ws.readyState === WebSocket.OPEN && reg) {
291
- ws.send(JSON.stringify({ register: reg }));
310
+ // protocol tells the server this window's build, so an error from an
311
+ // outdated plugin can say "re-import" instead of "unknown command".
312
+ ws.send(JSON.stringify({ register: Object.assign({}, reg, { protocol: PROTOCOL }) }));
292
313
  }
293
314
  }
294
315
 
@@ -307,24 +328,42 @@
307
328
  ws = sock;
308
329
  sendRegister();
309
330
  setStatus(true, label());
331
+ cp = { id: null };
332
+ syncCheckpoint();
310
333
  };
311
334
  sock.onmessage = (e) => {
312
335
  const msg = JSON.parse(e.data);
313
336
  if (msg.hello) {
314
- protoWarning =
315
- msg.hello.protocol && msg.hello.protocol !== PROTOCOL
316
- ? "⚠ Plugin outdated — re-import from the latest release"
317
- : null;
337
+ // Name the side that is behind: a stale server is just as common as
338
+ // a stale plugin, and blaming the plugin sends people re-importing
339
+ // a plugin that was already up to date.
340
+ // Show which server build we are talking to; "dev" means a local
341
+ // go build rather than a release.
342
+ if (msg.hello.version) {
343
+ document.getElementById("version").textContent = "v" + msg.hello.version;
344
+ }
345
+ protoWarning = null;
346
+ if (msg.hello.protocol && msg.hello.protocol !== PROTOCOL) {
347
+ protoWarning =
348
+ msg.hello.protocol < PROTOCOL
349
+ ? "⚠ Server outdated — restart your AI client"
350
+ : "⚠ Plugin outdated — re-import from the latest release";
351
+ }
318
352
  setStatus(true, label());
319
353
  return;
320
354
  }
321
- // Relay server request to the plugin main thread.
322
- parent.postMessage({ pluginMessage: msg }, "*");
355
+ if (msg.checkpointResult) return onCheckpointResult(msg.checkpointResult);
356
+ // Relay only commands: the socket must not reach the window's own
357
+ // messages (setReadOnly, uiAction) or a local process could unlock the file.
358
+ if (msg.id && msg.command) {
359
+ parent.postMessage({ pluginMessage: { id: msg.id, command: msg.command, params: msg.params } }, "*");
360
+ }
323
361
  };
324
362
  sock.onclose = () => {
325
363
  if (attempt === sock) attempt = null;
326
364
  if (ws === sock) ws = null;
327
365
  if (!ws) {
366
+ drawCheckpoint();
328
367
  setStatus(false, "Searching for MCP server…");
329
368
  schedule();
330
369
  }
@@ -345,28 +384,8 @@
345
384
  }, RETRY);
346
385
  }
347
386
 
348
- // ---- live selection list (name + copyable link, filterable by type) ----
387
+ // ---- live selection list (name + copyable link) ----
349
388
  let selItems = []; // everything currently selected in Figma
350
- let shownItems = []; // selItems after the active type filter
351
- let selFilter = "all"; // all | frame | vector
352
- let hasKey = false; // whether the main thread knows this file's key
353
-
354
- // Pull the file key out of a pasted Figma URL (…/design/<key>/…), or accept
355
- // a bare key. Returns "" when nothing usable is found.
356
- function parseFileKey(s) {
357
- s = (s || "").trim();
358
- const m = s.match(/figma\.com\/(?:file|design|board|proto)\/([A-Za-z0-9]+)/i);
359
- if (m) return m[1];
360
- if (/^[A-Za-z0-9]{10,}$/.test(s)) return s;
361
- return "";
362
- }
363
-
364
- const FILTERS = [
365
- { key: "all", label: "All" },
366
- { key: "frame", label: "Frame" },
367
- { key: "vector", label: "Vector" },
368
- { key: "instance", label: "Instance" },
369
- ];
370
389
 
371
390
  function esc(s) {
372
391
  return String(s)
@@ -376,13 +395,6 @@
376
395
  .replace(/"/g, "&quot;");
377
396
  }
378
397
 
379
- function matches(it) {
380
- if (selFilter === "frame") return it.type === "FRAME";
381
- if (selFilter === "vector") return it.type === "VECTOR";
382
- if (selFilter === "instance") return it.type === "INSTANCE";
383
- return true;
384
- }
385
-
386
398
  // Frames copy as a link block; every other element copies its exported SVG.
387
399
  function copyLabelFor(it) {
388
400
  return it.type === "FRAME" ? "Copy" : "Copy SVG";
@@ -401,47 +413,102 @@
401
413
  function renderSelection(items) {
402
414
  if (items) selItems = items;
403
415
  drawSelection();
416
+ syncCheckpoint();
417
+ }
418
+
419
+ // ---- checkpoint: save the selected frame's design, later ask what changed ----
420
+ // The server keeps the snapshot and does the comparing; this only asks and shows.
421
+ let canEdit = false;
422
+ let cp = { id: null }; // { id, saved, changes, total, busy, error } for the selected node
423
+
424
+ function askCheckpoint(op) {
425
+ if (!ws || ws.readyState !== WebSocket.OPEN || !cp.id) return;
426
+ if (op !== "status") cp.busy = op;
427
+ ws.send(JSON.stringify({ checkpoint: { op, node_id: cp.id } }));
428
+ drawCheckpoint();
429
+ }
430
+
431
+ function syncCheckpoint() {
432
+ const id = canEdit && selItems.length === 1 ? selItems[0].id : null;
433
+ if (id === cp.id) return;
434
+ cp = { id };
435
+ drawCheckpoint();
436
+ askCheckpoint("status");
437
+ }
438
+
439
+ function onCheckpointResult(r) {
440
+ if (r.node_id !== cp.id) return; // the selection moved on
441
+ cp.busy = null;
442
+ cp.error = r.error || null;
443
+ if (r.saved) cp.saved = r.saved;
444
+ if (r.op === "save" && !r.error) cp.changes = null;
445
+ if (r.op === "diff" && !r.error) {
446
+ cp.changes = r.changes || [];
447
+ cp.total = r.total || 0;
448
+ }
449
+ drawCheckpoint();
450
+ }
451
+
452
+ const CP_KIND = { "+": ['used', "added"], "-": ['k-del', "removed"], "~": ['k-chg', "changed"] };
453
+
454
+ function drawCheckpoint() {
455
+ const box = document.getElementById("cp");
456
+ if (!cp.id || !ws) {
457
+ box.innerHTML = "";
458
+ return fit();
459
+ }
460
+ let html =
461
+ '<div class="res-head"><span class="res-title">Checkpoint</span>' +
462
+ '<span class="muted" title="Saved on this computer; the file is not changed">' +
463
+ (cp.saved ? "Saved " + esc(cp.saved) : "Not saved yet") + "</span></div>" +
464
+ '<div class="cp-bar"><button class="copy-btn" data-cp="save"' + (cp.busy ? " disabled" : "") + ' title="Remember this frame as it is now">' +
465
+ (cp.busy === "save" ? "Saving…" : "Save checkpoint") + "</button>" +
466
+ (cp.saved
467
+ ? '<button class="copy-btn" data-cp="diff"' + (cp.busy ? " disabled" : "") + ' title="What changed in this frame since the checkpoint">' +
468
+ (cp.busy === "diff" ? "Comparing…" : "What changed?") + "</button>"
469
+ : "") +
470
+ "</div>";
471
+ if (cp.error) html += '<div class="k-del">' + esc(cp.error) + "</div>";
472
+ else if (cp.changes) {
473
+ html += cp.changes.length
474
+ ? '<div class="cp-list">' +
475
+ cp.changes.map((c) => {
476
+ const k = CP_KIND[c.kind] || ["muted", ""];
477
+ return '<div class="cp-row" data-id="' + esc(c.id) + '" title="Show this layer"><span class="' + k[0] + '">' + k[1] +
478
+ "</span> <b>" + esc(c.name) + "</b>" + (c.detail ? ' <span class="muted">' + esc(c.detail) + "</span>" : "") + "</div>";
479
+ }).join("") +
480
+ "</div>" +
481
+ (cp.total > cp.changes.length ? '<div class="muted">First ' + cp.changes.length + " of " + cp.total + " changes.</div>" : "")
482
+ : '<div class="used">No changes since the checkpoint.</div>';
483
+ }
484
+ box.innerHTML = html;
485
+ fit();
404
486
  }
405
487
 
488
+ document.getElementById("cp").addEventListener("click", (e) => {
489
+ const btn = e.target.closest("[data-cp]");
490
+ if (btn) return askCheckpoint(btn.dataset.cp);
491
+ const row = e.target.closest(".cp-row");
492
+ // A removed layer no longer exists; the plugin ignores a select it cannot do.
493
+ if (row) parent.postMessage({ pluginMessage: { uiAction: "select", nodeId: row.dataset.id } }, "*");
494
+ });
495
+
406
496
  function drawSelection() {
407
497
  const box = document.getElementById("result");
408
498
  if (!selItems.length) {
409
499
  box.className = "";
410
500
  box.innerHTML = "";
501
+ fit();
411
502
  return;
412
503
  }
413
- shownItems = selItems.filter(matches);
414
-
415
- // Only frames need a link (and therefore the file key); a pure vector /
416
- // instance selection copies SVG, so don't nag for a URL then.
417
- const needsKey = !hasKey && selItems.some((it) => it.type === "FRAME");
418
- const keyPrompt = !needsKey
419
- ? ""
420
- : '<div class="key-prompt">' +
421
- '<div class="key-note">Links are empty: this file has no key yet. Paste the file URL once ' +
422
- "(Share → Copy link, or the browser address bar):</div>" +
423
- '<div class="key-input-row">' +
424
- '<input class="key-input" id="key-input" placeholder="https://www.figma.com/design/…" />' +
425
- '<button class="key-save" id="key-save">Save</button>' +
426
- "</div></div>";
427
-
428
- const filterBar =
429
- '<div class="filter-row">' +
430
- FILTERS.map(
431
- (f) =>
432
- '<button class="filter-btn' + (selFilter === f.key ? " on" : "") + '" data-f="' + f.key + '">' +
433
- f.label + "</button>",
434
- ).join("") +
435
- "</div>";
436
-
437
504
  const head =
438
- '<div class="res-head"><span class="res-title">Selected (' + shownItems.length + ")</span>" +
439
- (shownItems.length > 1 ? '<button class="copy-btn copy-all" data-all="1">Copy all</button>' : "") +
505
+ '<div class="res-head"><span class="res-title">Selected (' + selItems.length + ")</span>" +
506
+ (selItems.length > 1 ? '<button class="copy-btn copy-all" data-all="1">Copy all</button>' : "") +
440
507
  "</div>";
441
508
 
442
- const body = shownItems.length
443
- ? '<div class="res-list">' +
444
- shownItems
509
+ const body =
510
+ '<div class="res-list">' +
511
+ selItems
445
512
  .map(
446
513
  (it, i) =>
447
514
  '<div class="res-row">' +
@@ -451,21 +518,30 @@
451
518
  "</div>",
452
519
  )
453
520
  .join("") +
454
- "</div>"
455
- : '<div class="res-empty">No matching nodes selected.</div>';
521
+ "</div>";
456
522
 
457
- box.innerHTML = keyPrompt + filterBar + head + body;
523
+ box.innerHTML = head + body;
458
524
  box.className = "show";
525
+ fit();
526
+ }
527
+
528
+ // Ask the main thread to size the window to its content.
529
+ function fit() {
530
+ requestAnimationFrame(() => {
531
+ const card = document.querySelector(".card");
532
+ const credit = document.getElementById("credit");
533
+ const h = card.getBoundingClientRect().bottom + credit.offsetHeight + 12;
534
+ parent.postMessage({ pluginMessage: { resize: h } }, "*");
535
+ });
459
536
  }
460
537
 
461
538
  // What each button copies: a row copies its own value (link block for a
462
- // frame, SVG otherwise); "Copy all" joins every shown item with a blank
463
- // line between — filter to one type first for a homogeneous result.
539
+ // frame, SVG otherwise); "Copy all" joins every item with a blank line between.
464
540
  function copyValueFor(btn) {
465
541
  if (btn.hasAttribute("data-all")) {
466
- return shownItems.map(copyValueForItem).join("\n\n");
542
+ return selItems.map(copyValueForItem).join("\n\n");
467
543
  }
468
- const it = shownItems[+btn.getAttribute("data-i")];
544
+ const it = selItems[+btn.getAttribute("data-i")];
469
545
  return it ? copyValueForItem(it) : "";
470
546
  }
471
547
 
@@ -485,23 +561,6 @@
485
561
  }
486
562
 
487
563
  document.getElementById("result").addEventListener("click", (e) => {
488
- if (e.target.id === "key-save") {
489
- const inp = document.getElementById("key-input");
490
- const key = parseFileKey(inp ? inp.value : "");
491
- if (key) {
492
- parent.postMessage({ pluginMessage: { setFileKey: key } }, "*");
493
- } else if (inp) {
494
- inp.value = "";
495
- inp.placeholder = "Couldn't read a file key from that — paste the full URL";
496
- }
497
- return;
498
- }
499
- const fb = e.target.closest(".filter-btn");
500
- if (fb) {
501
- selFilter = fb.getAttribute("data-f");
502
- drawSelection();
503
- return;
504
- }
505
564
  const btn = e.target.closest(".copy-btn");
506
565
  if (!btn) return;
507
566
  copyText(copyValueFor(btn));
@@ -514,6 +573,54 @@
514
573
  }, 1200);
515
574
  });
516
575
 
576
+ // ---- activity log: what the AI did in this file, newest first ----
577
+ let acts = [];
578
+ let counts = { read: 0, write: 0, error: 0 };
579
+
580
+ function logActivity(a) {
581
+ counts[a.error ? "error" : a.write ? "write" : "read"]++;
582
+ acts.unshift(Object.assign({ time: new Date().toTimeString().slice(0, 8) }, a));
583
+ acts = acts.slice(0, 5);
584
+ renderActivity();
585
+ }
586
+
587
+ function renderActivity() {
588
+ const open = document.getElementById("activity").classList.contains("open");
589
+ const parts = [];
590
+ if (counts.read) parts.push(counts.read + " read");
591
+ if (counts.write) parts.push(counts.write + " write");
592
+ if (counts.error) parts.push('<span class="k-del">' + counts.error + " error</span>");
593
+ document.getElementById("act-counts").innerHTML =
594
+ "AI: " + (parts.join(" · ") || "no activity") + (open ? " ▾" : " ▸");
595
+ document.getElementById("activity").innerHTML = acts
596
+ .map((a) =>
597
+ '<div class="act-row"' + (a.node && !a.error ? ' data-id="' + esc(a.node) + '"' : "") + ' title="' + esc(a.error || a.command) + '">' +
598
+ '<span class="muted">' + a.time + "</span> " +
599
+ (a.error ? '<span class="k-del">✗</span> ' : '<span class="used">✓</span> ') + esc(a.command) +
600
+ (a.write && !a.error ? ' <span class="k-chg">edit</span>' : "") +
601
+ (a.error ? ' <span class="muted">' + esc(a.error) + "</span>" : "") +
602
+ "</div>")
603
+ .join("");
604
+ fit();
605
+ }
606
+
607
+ document.getElementById("readonly").onchange = (e) =>
608
+ parent.postMessage({ pluginMessage: { setReadOnly: e.target.checked } }, "*");
609
+ document.getElementById("act-clear").onclick = () => {
610
+ acts = [];
611
+ counts = { read: 0, write: 0, error: 0 };
612
+ renderActivity();
613
+ };
614
+ document.getElementById("act-counts").onclick = () => {
615
+ document.getElementById("activity").classList.toggle("open");
616
+ renderActivity();
617
+ };
618
+ renderActivity();
619
+ document.getElementById("activity").addEventListener("click", (e) => {
620
+ const row = e.target.closest(".act-row[data-id]");
621
+ if (row) parent.postMessage({ pluginMessage: { uiAction: "select", nodeId: row.dataset.id } }, "*");
622
+ });
623
+
517
624
  // Relay plugin main-thread frames: the register frame is cached here and
518
625
  // re-sent on every reconnect, the selection frame drives the list above, and
519
626
  // everything else goes to the server.
@@ -527,10 +634,23 @@
527
634
  return;
528
635
  }
529
636
  if (Array.isArray(msg.selection)) {
530
- hasKey = !!msg.hasKey;
531
637
  renderSelection(msg.selection);
532
638
  return;
533
639
  }
640
+ if (msg.activity) {
641
+ logActivity(msg.activity);
642
+ return;
643
+ }
644
+ if (msg.canEdit !== undefined) {
645
+ canEdit = msg.canEdit;
646
+ cp = { id: null };
647
+ syncCheckpoint();
648
+ return;
649
+ }
650
+ if (msg.readOnly !== undefined) {
651
+ document.getElementById("readonly").checked = msg.readOnly;
652
+ return;
653
+ }
534
654
  if (ws && ws.readyState === WebSocket.OPEN) {
535
655
  ws.send(JSON.stringify(msg));
536
656
  }
@@ -542,4 +662,5 @@
542
662
  });
543
663
 
544
664
  connect();
665
+ fit();
545
666
  </script>
Binary file
Binary file
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "figma-mcp-console",
3
- "version": "0.5.4",
3
+ "version": "0.6.0",
4
4
  "scripts": {
5
- "prepublishOnly": "cp ../README.md ./README.md"
5
+ "prepublishOnly": "test -d bin/plugin && cd .. && go vet ./... && go test ./... && node --check plugin/code.js && cp README.md npm/README.md"
6
6
  },
7
7
  "description": "Figma MCP server for AI coding assistants — real-time read/write via a Figma Desktop plugin. No API token, no rate limits.",
8
8
  "bin": {