TheYuchen commited on
Commit
cde3a67
·
1 Parent(s): f558a20

Tier 1: kill the pipeline shelf — the canvas owns its space again

Browse files

The always-visible five-column shelf (marker pipeline-shelf, commit
6d69c3f) cost ~300px of permanent chrome, was mostly whitespace, and
grew with block count at the canvas's expense. Removed wholesale:
NodePalette.tsx deleted, both <NodePalette /> mounts dropped from
App.tsx, MIN_CANVAS_W comment updated (its overflow rationale died
with the shelf). The pendingBlockKinds store bridge stays — it is
still the add mechanism for the tier-2 chooser popover that replaces
the shelf in the next commit.

frontend/src/App.tsx CHANGED
@@ -15,7 +15,6 @@ import { theaterAutoOpenEnabled, useApp } from "./lib/store";
15
  import { ensureDemoArchive } from "./lib/demoArchive";
16
  import { useIsDesktop, useMediaQuery } from "./lib/useMediaQuery";
17
  import { TopBar } from "./components/TopBar";
18
- import { NodePalette } from "./components/NodePalette";
19
  import { FlowCanvas } from "./components/FlowCanvas";
20
  import { ResultsPane } from "./components/ResultsPane";
21
  import { MultiverseBoard } from "./components/MultiverseBoard";
@@ -64,12 +63,12 @@ const COLLAPSED_W = 32;
64
  // Full-desktop threshold — below this (and ≥768px) is "the band".
65
  const WIDE_QUERY = "(min-width: 1200px)";
66
 
67
- // Minimum width we ever want to leave for the canvas (NodePalette + React
68
- // Flow). Below this, the NodePalette pipeline-shelf columns (min 96px each)
69
- // start overflowing horizontally because `<main>` has no overflow clip —
70
- // they visually escape the canvas column and cover whatever's in the
71
- // right pane. The dynamic clamp in the resize handler caps the side
72
- // panes so this never happens, regardless of viewport size.
73
  const MIN_CANVAS_W = 280;
74
  // Reserve the side resizer's footprint when computing the canvas budget.
75
  const RESIZER_W = 4;
@@ -425,7 +424,6 @@ export default function App() {
425
  />
426
  )}
427
  <main className="relative flex-1 min-w-0 flex flex-col min-h-0 overflow-x-hidden">
428
- <NodePalette />
429
  <ReactFlowProvider>
430
  <FlowCanvas />
431
  </ReactFlowProvider>
@@ -513,7 +511,6 @@ export default function App() {
513
  /* ===================== Mobile ====================== */
514
  <div className="flex-1 flex flex-col min-h-0">
515
  <main className="relative flex-1 min-w-0 flex flex-col min-h-0 overflow-x-hidden">
516
- <NodePalette />
517
  <ReactFlowProvider>
518
  <FlowCanvas />
519
  </ReactFlowProvider>
 
15
  import { ensureDemoArchive } from "./lib/demoArchive";
16
  import { useIsDesktop, useMediaQuery } from "./lib/useMediaQuery";
17
  import { TopBar } from "./components/TopBar";
 
18
  import { FlowCanvas } from "./components/FlowCanvas";
19
  import { ResultsPane } from "./components/ResultsPane";
20
  import { MultiverseBoard } from "./components/MultiverseBoard";
 
63
  // Full-desktop threshold — below this (and ≥768px) is "the band".
64
  const WIDE_QUERY = "(min-width: 1200px)";
65
 
66
+ // Minimum width we ever want to leave for the canvas (React Flow +
67
+ // its two-row toolbar). The dynamic clamp in the resize handler caps
68
+ // the side panes so the center column never falls below this,
69
+ // regardless of viewport size. (The old rationale — pipeline-shelf
70
+ // columns overflowing `<main>` — died with the shelf; the floor now
71
+ // simply keeps the toolbar rows and a useful slice of canvas usable.)
72
  const MIN_CANVAS_W = 280;
73
  // Reserve the side resizer's footprint when computing the canvas budget.
74
  const RESIZER_W = 4;
 
424
  />
425
  )}
426
  <main className="relative flex-1 min-w-0 flex flex-col min-h-0 overflow-x-hidden">
 
427
  <ReactFlowProvider>
428
  <FlowCanvas />
429
  </ReactFlowProvider>
 
511
  /* ===================== Mobile ====================== */
512
  <div className="flex-1 flex flex-col min-h-0">
513
  <main className="relative flex-1 min-w-0 flex flex-col min-h-0 overflow-x-hidden">
 
514
  <ReactFlowProvider>
515
  <FlowCanvas />
516
  </ReactFlowProvider>
frontend/src/components/NodePalette.tsx DELETED
@@ -1,535 +0,0 @@
1
- import { Fragment, useEffect, useMemo, useRef, useState } from "react";
2
- import { ChevronDown, FileText, Search, X } from "lucide-react";
3
- import { api } from "../lib/api";
4
- import {
5
- NODE_CATALOG,
6
- synthesizePluginSpec,
7
- type NodeKind,
8
- type NodeSpec,
9
- type PluginNodeSpec,
10
- } from "../lib/nodeCatalog";
11
- import { useApp } from "../lib/store";
12
- import { ANON } from "../lib/anon";
13
- import { bumpPluginsRev, getUserId } from "../lib/userId";
14
- import { BlockPicker } from "./BlockPicker";
15
-
16
- /**
17
- * Pipeline shelf (marker: pipeline-shelf) — the block palette above the
18
- * canvas, laid out AS the pipeline grammar itself: five stage columns,
19
- * Source → Backend → Algorithm → Metric → Sink, separated by faint
20
- * arrow glyphs. Each column carries a compact header (stage name + a
21
- * one-line tagline) and stacks its blocks VERTICALLY beneath as
22
- * compact rows, so the shelf teaches the sentence structure a valid
23
- * pipeline follows while it serves as the drag source. Growth is
24
- * always vertical: a column with ≥5 blocks (plugins join their
25
- * declared family's column) scrolls internally behind a subtle fade
26
- * instead of sprawling horizontally.
27
- *
28
- * Interaction modes preserved from the previous strip:
29
- * - **Drag** a row onto the canvas (HTML5 dataTransfer payload
30
- * "application/reactflow", unchanged — FlowCanvas's onDrop and
31
- * edge-splice targeting work as before).
32
- * - **Tap / click / Enter / Space** queue the kind through the
33
- * pendingBlockKinds store bridge (same path BlockPicker uses).
34
- * - **Touch drag** via the PointerEvent bridge (touchDrag /
35
- * pendingTouchDrop in the store; FlowCanvas renders the floating
36
- * preview and commits the drop).
37
- * - **"Add blocks"** (BlockPicker modal) and the live search stay in
38
- * the header row; search filters rows across all five columns.
39
- *
40
- * Responsive: a ResizeObserver on the shelf (container query, same
41
- * pattern as MultiverseBoard's grid — the palette lives in a resizable
42
- * center column, so viewport breakpoints would lie) wraps the shelf to
43
- * two rows below ~880px container width: Source/Backend/Algorithm on
44
- * top, Metric/Sink below.
45
- */
46
-
47
- const STAGE_META: {
48
- key: NodeSpec["family"];
49
- label: string;
50
- tagline: string;
51
- }[] = [
52
- { key: "source", label: "Source", tagline: "where the circuit comes from" },
53
- { key: "backend", label: "Backend", tagline: "the noisy machine" },
54
- { key: "algorithm", label: "Algorithm", tagline: "transforms the circuit" },
55
- { key: "metric", label: "Metric", tagline: "measures the result" },
56
- { key: "sink", label: "Sink", tagline: "collects the evidence" },
57
- ];
58
-
59
- /** Container width below which the shelf wraps to two rows. */
60
- const SHELF_WRAP_PX = 880;
61
-
62
- export function NodePalette() {
63
- const [search, setSearch] = useState("");
64
- // Kinds currently on the canvas — published by FlowCanvas (store
65
- // bridge, audit S2). It is a MULTISET (one entry per node), so the
66
- // shelf can show a per-row count dot for kinds already placed;
67
- // BlockPicker keeps consuming it as a Set for its badges.
68
- const canvasKindsArr = useApp((s) => s.canvasKinds);
69
- const canvasKinds = useMemo(
70
- () => new Set<NodeKind>(canvasKindsArr),
71
- [canvasKindsArr],
72
- );
73
- const canvasCounts = useMemo(() => {
74
- const m = new Map<string, number>();
75
- for (const k of canvasKindsArr) m.set(k, (m.get(k) ?? 0) + 1);
76
- return m;
77
- }, [canvasKindsArr]);
78
- const [expanded, setExpanded] = useState(true);
79
-
80
- // Container-query wrap (ResizeObserver like MultiverseBoard, NOT a
81
- // viewport breakpoint: the center column is user-resizable).
82
- const shelfRef = useRef<HTMLDivElement>(null);
83
- const [narrow, setNarrow] = useState(false);
84
- useEffect(() => {
85
- const el = shelfRef.current;
86
- if (!el) return;
87
- const update = () => setNarrow(el.clientWidth < SHELF_WRAP_PX);
88
- update();
89
- const ro = new ResizeObserver(update);
90
- ro.observe(el);
91
- return () => ro.disconnect();
92
- }, [expanded]);
93
-
94
- // Plugin manifests this browser has uploaded — merged with NODE_CATALOG
95
- // so plugins show up under their declared family alongside built-ins
96
- // (resolveNodeSpec family; manifests without a known family synthesize
97
- // as "algorithm" and land in that column, plugin badge intact).
98
- const plugins = useApp((s) => s.plugins);
99
- const setPlugins = useApp((s) => s.setPlugins);
100
- const pluginSpecs: PluginNodeSpec[] = useMemo(
101
- () => plugins.map(synthesizePluginSpec),
102
- [plugins],
103
- );
104
- const combined: (NodeSpec | PluginNodeSpec)[] = useMemo(
105
- () => [...NODE_CATALOG, ...pluginSpecs],
106
- [pluginSpecs],
107
- );
108
-
109
- const handleDeletePlugin = async (kind: string) => {
110
- try {
111
- await api.deletePlugin(getUserId(), kind);
112
- const fresh = await api.listPlugins(getUserId());
113
- setPlugins(fresh);
114
- bumpPluginsRev();
115
- } catch (err) {
116
- // Destructive actions failing silently look like the click
117
- // didn't register. Surface the error so the user knows to retry
118
- // — via the global toast channel (danger = sticky), not the
119
- // blocking alert() the toast idiom replaced. window.confirm
120
- // stays as the guard BEFORE the delete: destructive actions
121
- // still deserve a blocking yes/no.
122
- const msg = err instanceof Error ? err.message : String(err);
123
- useApp.getState().setGlobalNotice({
124
- text: `Could not delete plugin "${kind}": ${msg}`,
125
- tone: "danger",
126
- });
127
- }
128
- };
129
-
130
- const filtered = useMemo(() => {
131
- if (!search.trim()) return combined;
132
- const q = search.toLowerCase();
133
- return combined.filter(
134
- (n) =>
135
- n.label.toLowerCase().includes(q) ||
136
- n.tagline.toLowerCase().includes(q) ||
137
- n.family.toLowerCase().includes(q) ||
138
- n.kind.toLowerCase().includes(q),
139
- );
140
- }, [search, combined]);
141
-
142
- const totalCount = combined.length;
143
-
144
- if (!expanded) {
145
- return (
146
- <div className="shrink-0 border-b border-edge bg-surface/40">
147
- <button
148
- type="button"
149
- onClick={() => setExpanded(true)}
150
- className="w-full px-3 py-1.5 flex items-center justify-between text-[10px] text-mute hover:text-ink transition-colors"
151
- >
152
- <span className="uppercase tracking-wider">
153
- {totalCount} blocks available
154
- </span>
155
- <ChevronDown className="w-3 h-3" />
156
- </button>
157
- </div>
158
- );
159
- }
160
-
161
- // Stage rows: one row of five in wide containers; Source/Backend/
162
- // Algorithm over Metric/Sink when narrow.
163
- const stageRows = narrow
164
- ? [STAGE_META.slice(0, 3), STAGE_META.slice(3)]
165
- : [STAGE_META];
166
-
167
- return (
168
- <div className="shrink-0 border-b border-edge bg-surface/40">
169
- {/* Header row */}
170
- <div className="px-3 pt-2 pb-1 flex items-center gap-2">
171
- {/* Multi-select dropdown picker */}
172
- <BlockPicker canvasKinds={canvasKinds} />
173
- {/* Plugin upload UI removed in Wave P (de-product). The plugin
174
- protocol itself is a paper claim and stays fully exercised
175
- via the backend API; uploaded plugins still appear here and
176
- still execute. */}
177
- {/* Search — filters rows across all five stage columns, live */}
178
- <div className="relative flex-1 max-w-[200px]">
179
- <Search className="absolute left-2 top-1/2 -translate-y-1/2 w-3 h-3 text-mute pointer-events-none" />
180
- <input
181
- type="text"
182
- aria-label="Search blocks"
183
- value={search}
184
- onChange={(e) => setSearch(e.target.value)}
185
- placeholder="Search..."
186
- className="w-full text-[11px] bg-surfaceAlt border border-edge rounded-md pl-6 pr-6 py-1 text-ink placeholder:text-mute/60 focus:outline-none focus:border-accent/60"
187
- />
188
- {search && (
189
- <button
190
- type="button"
191
- onClick={() => setSearch("")}
192
- className="absolute right-1.5 top-1/2 -translate-y-1/2 text-mute hover:text-ink"
193
- >
194
- <X className="w-3 h-3" />
195
- </button>
196
- )}
197
- </div>
198
- <div className="flex-1" />
199
- <span className="hidden lg:inline text-[10px] text-mute/60">
200
- drag to canvas or use Add blocks
201
- </span>
202
- <button
203
- type="button"
204
- onClick={() => setExpanded(false)}
205
- className="text-mute hover:text-ink p-0.5"
206
- title="Collapse block palette"
207
- >
208
- <ChevronDown className="w-3.5 h-3.5 rotate-180" />
209
- </button>
210
- </div>
211
-
212
- {/* The shelf: stage columns in pipeline order, arrows between */}
213
- <div
214
- ref={shelfRef}
215
- data-marker="pipeline-shelf"
216
- className="px-3 pb-2 flex flex-col gap-1.5"
217
- >
218
- {stageRows.map((row, ri) => (
219
- <div key={ri} className="flex items-stretch gap-1">
220
- {row.map((st, i) => (
221
- <Fragment key={st.key}>
222
- {i > 0 && (
223
- <div
224
- className="shrink-0 self-start pt-1 text-[11px] leading-none text-mute/40 select-none"
225
- aria-hidden="true"
226
- >
227
- →
228
- </div>
229
- )}
230
- <StageColumn
231
- meta={st}
232
- narrow={narrow}
233
- items={filtered.filter((n) => n.family === st.key)}
234
- searching={search.trim().length > 0}
235
- canvasCounts={canvasCounts}
236
- onDeletePlugin={handleDeletePlugin}
237
- />
238
- </Fragment>
239
- ))}
240
- </div>
241
- ))}
242
- {search.trim() && filtered.length === 0 && (
243
- <div className="py-1 w-full text-center text-[11px] text-mute">
244
- No blocks match "{search.trim()}".
245
- </div>
246
- )}
247
- </div>
248
- </div>
249
- );
250
- }
251
-
252
- /** One stage of the grammar: compact header + vertically stacked block
253
- * rows. ≥5 rows → the body scrolls internally behind a fade (growth
254
- * is vertical, never horizontal sprawl). */
255
- function StageColumn({
256
- meta,
257
- narrow,
258
- items,
259
- searching,
260
- canvasCounts,
261
- onDeletePlugin,
262
- }: {
263
- meta: (typeof STAGE_META)[number];
264
- narrow: boolean;
265
- items: (NodeSpec | PluginNodeSpec)[];
266
- searching: boolean;
267
- canvasCounts: Map<string, number>;
268
- onDeletePlugin: (kind: string) => void;
269
- }) {
270
- // Columns share width equally (flex-1 basis-0). Min width 120px in
271
- // the wide layout; the narrow two-row layout relaxes to 96px so a
272
- // 360px phone column still fits three stages plus arrows.
273
- const scrollable = items.length >= 5;
274
- return (
275
- <div
276
- className={`flex-1 basis-0 flex flex-col ${
277
- narrow ? "min-w-[96px]" : "min-w-[120px]"
278
- }`}
279
- >
280
- <div className="px-0.5 pb-1" title={`${meta.label}: ${meta.tagline}`}>
281
- <div className="text-[10px] uppercase tracking-wider font-medium text-mute leading-tight">
282
- {meta.label}
283
- </div>
284
- <div className="text-[9px] text-mute/60 leading-tight truncate">
285
- {meta.tagline}
286
- </div>
287
- </div>
288
- <div
289
- className={`flex flex-col gap-1 ${
290
- scrollable ? "overflow-y-auto max-h-[124px] pr-0.5" : ""
291
- }`}
292
- // Subtle bottom fade signals there are more rows below the
293
- // 3-row window. mask-image is theme-independent (no hardcoded
294
- // background color under a translucent shelf).
295
- style={
296
- scrollable
297
- ? {
298
- maskImage:
299
- "linear-gradient(to bottom, black calc(100% - 14px), transparent)",
300
- WebkitMaskImage:
301
- "linear-gradient(to bottom, black calc(100% - 14px), transparent)",
302
- }
303
- : undefined
304
- }
305
- >
306
- {items.map((n) => (
307
- <ShelfRow
308
- key={n.kind}
309
- spec={n}
310
- canvasCount={canvasCounts.get(n.kind) ?? 0}
311
- onDelete={
312
- "isPlugin" in n && n.isPlugin
313
- ? () => onDeletePlugin(n.kind)
314
- : undefined
315
- }
316
- />
317
- ))}
318
- {items.length === 0 && searching && (
319
- <div className="px-1 py-1.5 text-[9px] italic text-mute/50">
320
- no match
321
- </div>
322
- )}
323
- </div>
324
- </div>
325
- );
326
- }
327
-
328
- function ShelfRow({
329
- spec,
330
- canvasCount,
331
- onDelete,
332
- }: {
333
- spec: NodeSpec | PluginNodeSpec;
334
- /** Copies of this kind already on the canvas (0 = none) — rendered
335
- * as a subtle count dot so "already placed" reads at a glance. */
336
- canvasCount: number;
337
- /** When set, shows a small × that calls back on click — used for
338
- * user-uploaded plugins. */
339
- onDelete?: () => void;
340
- }) {
341
- const addBlocksToCanvas = useApp((s) => s.addBlocksToCanvas);
342
- const setTouchDrag = useApp((s) => s.setTouchDrag);
343
- const setPendingTouchDrop = useApp((s) => s.setPendingTouchDrop);
344
- const isPlugin = "isPlugin" in spec && spec.isPlugin;
345
- const Icon = spec.icon;
346
-
347
- function onDragStart(e: React.DragEvent) {
348
- e.dataTransfer.setData("application/reactflow", spec.kind);
349
- e.dataTransfer.effectAllowed = "move";
350
- }
351
-
352
- // Tap (mobile) / click (mouse) / Enter+Space (keyboard) all funnel
353
- // into the same "queue this kind for the canvas" path that the
354
- // BlockPicker dropdown uses. Drag-and-drop continues to work for
355
- // mouse users on top of this — they get both interactions.
356
- function addToCanvas() {
357
- addBlocksToCanvas([spec.kind]);
358
- }
359
-
360
- // ---- Touch drag (mobile) ------------------------------------------
361
- //
362
- // HTML5 drag-and-drop doesn't fire on touch; instead we implement a
363
- // PointerEvent-based drag that mirrors the HTML5 behaviour for the
364
- // canvas. Flow:
365
- // 1. pointerdown (touch only) — remember the start coord. No drag
366
- // state yet; small movements still register as taps via the
367
- // button's onClick.
368
- // 2. pointermove past TAP_THRESHOLD_PX — enter drag mode: take
369
- // pointer capture, set touchDrag in the store, suppress scroll.
370
- // 3. pointermove while dragging — update touchDrag.x/y; FlowCanvas
371
- // watches this and renders the floating preview + edge target.
372
- // 4. pointerup while dragging — set pendingTouchDrop with the
373
- // final coords; FlowCanvas commits the drop.
374
- // 5. pointercancel / pointerup with no drag — clear state, let
375
- // onClick fire normally.
376
- function onPointerDown(e: React.PointerEvent) {
377
- if (e.pointerType !== "touch") return;
378
- const startX = e.clientX;
379
- const startY = e.clientY;
380
- const pointerId = e.pointerId;
381
- const TAP_THRESHOLD_PX = 8;
382
- let dragging = false;
383
-
384
- const onMove = (ev: PointerEvent) => {
385
- if (ev.pointerId !== pointerId) return;
386
- const dx = ev.clientX - startX;
387
- const dy = ev.clientY - startY;
388
- if (!dragging) {
389
- if (Math.hypot(dx, dy) > TAP_THRESHOLD_PX) {
390
- dragging = true;
391
- try {
392
- (e.target as Element).setPointerCapture?.(pointerId);
393
- } catch {
394
- /* element may have already lost pointer */
395
- }
396
- } else {
397
- return;
398
- }
399
- }
400
- setTouchDrag({ kind: spec.kind, x: ev.clientX, y: ev.clientY });
401
- // preventDefault suppresses the column's internal scroll once
402
- // we've committed to dragging.
403
- ev.preventDefault();
404
- };
405
-
406
- const cleanup = () => {
407
- window.removeEventListener("pointermove", onMove);
408
- window.removeEventListener("pointerup", onUp);
409
- window.removeEventListener("pointercancel", onCancel);
410
- };
411
-
412
- const onUp = (ev: PointerEvent) => {
413
- if (ev.pointerId !== pointerId) return;
414
- cleanup();
415
- if (dragging) {
416
- // Hand off the final position to FlowCanvas via the store.
417
- setPendingTouchDrop({
418
- kind: spec.kind,
419
- x: ev.clientX,
420
- y: ev.clientY,
421
- });
422
- setTouchDrag(null);
423
- }
424
- // Non-drag pointerup: tap; the button's onClick will fire.
425
- };
426
-
427
- const onCancel = (ev: PointerEvent) => {
428
- if (ev.pointerId !== pointerId) return;
429
- cleanup();
430
- setTouchDrag(null);
431
- };
432
-
433
- window.addEventListener("pointermove", onMove, { passive: false });
434
- window.addEventListener("pointerup", onUp);
435
- window.addEventListener("pointercancel", onCancel);
436
- }
437
-
438
- return (
439
- <button
440
- type="button"
441
- draggable
442
- onDragStart={onDragStart}
443
- onPointerDown={onPointerDown}
444
- onClick={addToCanvas}
445
- // The button gives us Enter/Space → click for free; we override
446
- // Space below so it doesn't also scroll the column.
447
- onKeyDown={(e) => {
448
- if (e.key === " ") {
449
- e.preventDefault();
450
- addToCanvas();
451
- }
452
- }}
453
- className={`qf-no-callout group relative shrink-0 cursor-grab active:cursor-grabbing flex items-center gap-1.5 w-full h-9 rounded-md border transition-colors text-left px-1.5 focus:outline-none focus-visible:ring-2 focus-visible:ring-accent ${
454
- isPlugin
455
- ? "border-edge bg-surface/60 hover:bg-surfaceAlt"
456
- : "border-edge/60 hover:border-edge hover:bg-surfaceAlt"
457
- }`}
458
- // The tile's visible tagline moved here: tooltip = tagline +
459
- // long-form description.
460
- title={`${spec.tagline} — ${spec.description}`}
461
- aria-label={`Add ${spec.label} block to canvas. ${spec.tagline}`}
462
- >
463
- {isPlugin ? (
464
- <span
465
- className="shrink-0 w-5 h-5 rounded-md flex items-center justify-center text-[9px] font-bold text-white"
466
- style={{ backgroundColor: (spec as PluginNodeSpec).pluginColor }}
467
- aria-hidden
468
- >
469
- {(spec as PluginNodeSpec).initials}
470
- </span>
471
- ) : (
472
- <span
473
- className={`shrink-0 w-5 h-5 rounded-md border ${spec.accentRing} bg-surface flex items-center justify-center ${spec.accent}`}
474
- aria-hidden
475
- >
476
- <Icon className="w-3 h-3" strokeWidth={2} />
477
- </span>
478
- )}
479
- <span className="flex-1 min-w-0 text-[10px] text-ink truncate leading-tight">
480
- {spec.label}
481
- </span>
482
- {/* "On canvas" count dot — subtle, non-interactive. */}
483
- {canvasCount > 0 && (
484
- <span
485
- className="shrink-0 min-w-[14px] h-3.5 px-0.5 rounded-full bg-accent/15 border border-accent/40 text-accent text-[8px] leading-none font-medium flex items-center justify-center tabular-nums"
486
- title={`${canvasCount} on canvas`}
487
- aria-label={`${canvasCount} already on canvas`}
488
- >
489
- {canvasCount}
490
- </span>
491
- )}
492
- {/* Right-edge adornments: paper link (built-ins, non-anon) or
493
- plugin delete. Interactive children; stopPropagation keeps
494
- the parent button from also firing. */}
495
- {spec.paper && !isPlugin && !ANON && (
496
- <a
497
- href={spec.paper.url}
498
- target="_blank"
499
- rel="noopener noreferrer"
500
- draggable={false}
501
- onDragStart={(e) => e.stopPropagation()}
502
- onClick={(e) => e.stopPropagation()}
503
- className="shrink-0 w-4 h-4 rounded-full bg-accent/20 border border-accent/70 text-accent hover:bg-accent/40 hover:border-accent hover:text-ink flex items-center justify-center transition-colors"
504
- title={`Paper: ${spec.paper.title} (${spec.paper.venue})`}
505
- aria-label={`Open paper: ${spec.paper.title}`}
506
- >
507
- <FileText className="w-2 h-2" strokeWidth={2} />
508
- </a>
509
- )}
510
- {isPlugin && onDelete && (
511
- // Always visible (hover-only left mobile + keyboard users with
512
- // no way to find it); slight rest opacity keeps it quiet.
513
- <button
514
- type="button"
515
- draggable={false}
516
- onDragStart={(e) => e.stopPropagation()}
517
- onClick={(e) => {
518
- e.stopPropagation();
519
- if (window.confirm(`Delete plugin "${spec.label}"?`)) onDelete();
520
- }}
521
- onKeyDown={(e) => {
522
- // Don't bubble Enter/Space to the parent button when
523
- // focused on the delete X.
524
- if (e.key === "Enter" || e.key === " ") e.stopPropagation();
525
- }}
526
- className="shrink-0 w-4 h-4 rounded-full border border-edge bg-surface text-mute hover:text-danger hover:border-danger/60 flex items-center justify-center opacity-70 hover:opacity-100 focus:opacity-100 transition-opacity"
527
- title={`Delete plugin ${spec.label}`}
528
- aria-label={`Delete plugin ${spec.label}`}
529
- >
530
- <X className="w-2.5 h-2.5" strokeWidth={2.5} />
531
- </button>
532
- )}
533
- </button>
534
- );
535
- }