comfy-ts 2.11.0 → 2.13.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.
Files changed (122) hide show
  1. package/README.md +1 -0
  2. package/dist/{LogsSt-qtFzOKpu.js → LogsSt-CUeo843w.js} +51 -7
  3. package/dist/LogsSt-CUeo843w.js.map +1 -0
  4. package/dist/cli.js +4 -4
  5. package/dist/index.cjs +595 -73
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.cts +286 -46
  8. package/dist/index.d.ts +286 -46
  9. package/dist/index.js +591 -74
  10. package/dist/index.js.map +1 -1
  11. package/dist/{run-serve-BK7BA2dn.js → run-serve-DlRBv_Nk.js} +738 -58
  12. package/dist/run-serve-DlRBv_Nk.js.map +1 -0
  13. package/dist/{run-tui-CQyvMf0N.js → run-tui-B5uxm2_l.js} +43 -18
  14. package/dist/run-tui-B5uxm2_l.js.map +1 -0
  15. package/dist/{schemaDrift-DjjEtwfx.js → schemaDrift-E95iTF7E.js} +473 -60
  16. package/dist/schemaDrift-E95iTF7E.js.map +1 -0
  17. package/dist/serve-web.js +710 -174
  18. package/dist/{state--wrz0BQc.js → state-CUp2J1Zy.js} +126 -14
  19. package/dist/state-CUp2J1Zy.js.map +1 -0
  20. package/dist/web.d.ts +286 -46
  21. package/dist/web.js +591 -74
  22. package/dist/web.js.map +1 -1
  23. package/examples/comfy-cloud/sdk.d.ts +163 -163
  24. package/examples/rvion/06-qwen-image-edit.cflow.ts +3 -2
  25. package/examples/rvion/10-anima-t2i.cflow.ts +252 -0
  26. package/examples/rvion/11-yue2-t2a.cflow.ts +105 -0
  27. package/examples/rvion/12-stable-audio-3-t2a.cflow.ts +78 -0
  28. package/examples/rvion/13-ace-step-15-xl-t2a.cflow.ts +153 -0
  29. package/examples/rvion/stableAudio3Prompts.ts +19 -0
  30. package/extra/README.md +4 -0
  31. package/extra/comfyui-fresh-model-lists/README.md +25 -0
  32. package/extra/comfyui-fresh-model-lists/__init__.py +36 -0
  33. package/extra/comfyui-fresh-model-lists/test_fresh_model_lists.py +97 -0
  34. package/package.json +15 -7
  35. package/src/cli/draftMeta.ts +39 -0
  36. package/src/cli/serve/ServeApp.ts +305 -30
  37. package/src/cli/serve/applyVarPayload.ts +50 -22
  38. package/src/cli/serve/byteRange.ts +48 -0
  39. package/src/cli/serve/describeVar.ts +42 -6
  40. package/src/cli/serve/llmConfigShape.ts +51 -0
  41. package/src/cli/serve/llmConfigs.ts +52 -0
  42. package/src/cli/serve/run-serve.ts +12 -3
  43. package/src/cli/serve/tagList.ts +92 -0
  44. package/src/cli/serve/tagSource.ts +69 -0
  45. package/src/cli/serve/web/api.ts +72 -0
  46. package/src/cli/serve/web/components/App.tsx +485 -44
  47. package/src/cli/serve/web/components/DraftTabs.tsx +167 -0
  48. package/src/cli/serve/web/components/Gallery.tsx +133 -31
  49. package/src/cli/serve/web/components/HistoryPicker.tsx +149 -0
  50. package/src/cli/serve/web/components/Icon.tsx +58 -2
  51. package/src/cli/serve/web/components/MenuButton.tsx +53 -0
  52. package/src/cli/serve/web/components/Omnibox.tsx +135 -0
  53. package/src/cli/serve/web/components/PromptEnhancer.tsx +476 -180
  54. package/src/cli/serve/web/components/SideMenu.tsx +414 -0
  55. package/src/cli/serve/web/components/TooltipLayer.tsx +46 -0
  56. package/src/cli/serve/web/components/VarIcon.tsx +24 -0
  57. package/src/cli/serve/web/components/VarsForm.tsx +223 -351
  58. package/src/cli/serve/web/components/controls/BasicControls.tsx +57 -32
  59. package/src/cli/serve/web/components/controls/LorasControl.tsx +646 -317
  60. package/src/cli/serve/web/components/controls/PresetPicker.tsx +1 -1
  61. package/src/cli/serve/web/components/controls/PromptControl.tsx +279 -0
  62. package/src/cli/serve/web/components/controls/PromptEditor.tsx +113 -0
  63. package/src/cli/serve/web/components/controls/SeedControl.tsx +17 -10
  64. package/src/cli/serve/web/components/controls/SizeControl.tsx +111 -18
  65. package/src/cli/serve/web/components/modKey.ts +2 -0
  66. package/src/cli/serve/web/llm.ts +23 -12
  67. package/src/cli/serve/web/promptEditor/promptExtensions.ts +284 -0
  68. package/src/cli/serve/web/state/EnhancerSt.ts +431 -101
  69. package/src/cli/serve/web/state/FormSt.ts +214 -30
  70. package/src/cli/serve/web/state/OmniboxSt.ts +59 -0
  71. package/src/cli/serve/web/state/WebSt.ts +364 -80
  72. package/src/cli/serve/web/state/choiceButtons.ts +61 -0
  73. package/src/cli/serve/web/state/draftNames.ts +16 -0
  74. package/src/cli/serve/web/state/draftTabs.ts +75 -0
  75. package/src/cli/serve/web/state/generateButton.ts +16 -0
  76. package/src/cli/serve/web/state/history.ts +54 -0
  77. package/src/cli/serve/web/state/host.ts +5 -2
  78. package/src/cli/serve/web/state/keptLines.ts +53 -0
  79. package/src/cli/serve/web/state/latentMode.ts +20 -0
  80. package/src/cli/serve/web/state/loraSort.ts +18 -0
  81. package/src/cli/serve/web/state/moduleTree.ts +2 -2
  82. package/src/cli/serve/web/state/omnibox.ts +133 -0
  83. package/src/cli/serve/web/state/payload.ts +38 -58
  84. package/src/cli/serve/web/state/shortcuts.ts +103 -0
  85. package/src/cli/serve/web/state/sizeStars.ts +31 -0
  86. package/src/cli/serve/web/state/stableSlots.ts +21 -0
  87. package/src/cli/serve/web/state/varGroups.ts +24 -0
  88. package/src/cli/serve/web/styles.ts +653 -154
  89. package/src/cli/serve/webBundle.ts +54 -10
  90. package/src/cli/serve/workflowTags.ts +42 -0
  91. package/src/cli/serve/workspaceLabels.ts +23 -0
  92. package/src/cli/tui/components/PickerOverlays.tsx +9 -2
  93. package/src/cli/tui/imagePicker/ImagePickerSt.ts +1 -1
  94. package/src/cli/tui/state/DraftsSt.ts +28 -8
  95. package/src/cli/tui/state/EditorSt.ts +1 -1
  96. package/src/cli/tui/state/LorasSt.ts +1 -1
  97. package/src/cli/tui/state/PickerSt.ts +25 -7
  98. package/src/cli/tui/state/SettingsSt.ts +1 -1
  99. package/src/cli/tui/state/TuiSt.ts +10 -0
  100. package/src/coreExports.ts +21 -0
  101. package/src/host/ComfyHost.ts +17 -2
  102. package/src/host/ResilientWebsocket.ts +54 -4
  103. package/src/host/loraInfoCache.ts +6 -0
  104. package/src/runner/ComfyExecution.ts +60 -0
  105. package/src/runner/ComfyWorkflow.ts +4 -0
  106. package/src/runner/ComfyWsApi.ts +2 -0
  107. package/src/runner/MediaImage.ts +2 -2
  108. package/src/sdk-generator/ComfyUIObjectInfoTypes.ts +5 -5
  109. package/src/sdk-generator/comfyui-sdk-codegen.ts +1 -1
  110. package/src/state.ts +5 -0
  111. package/src/utils/copyName.ts +12 -0
  112. package/src/vars/ComfyVars.ts +337 -67
  113. package/src/vars/DefinedWorkflow.ts +47 -20
  114. package/src/vars/lanes.ts +238 -0
  115. package/src/vars/loraEntry.ts +101 -0
  116. package/src/vars/promptSyntax.ts +382 -0
  117. package/dist/LogsSt-qtFzOKpu.js.map +0 -1
  118. package/dist/run-serve-BK7BA2dn.js.map +0 -1
  119. package/dist/run-tui-CQyvMf0N.js.map +0 -1
  120. package/dist/schemaDrift-DjjEtwfx.js.map +0 -1
  121. package/dist/state--wrz0BQc.js.map +0 -1
  122. package/src/cli/serve/web/components/Sidebar.tsx +0 -66
@@ -0,0 +1,167 @@
1
+ // the open drafts as tabs over the work area: a click opens one (a click on the open one shows
2
+ // its actions), × or a middle click closes it, ⌘1 to ⌘8 pick one, ⌘9 the last, ⌘PageUp and
3
+ // ⌘PageDown step (ctrl elsewhere), from any focus
4
+ import {
5
+ autoUpdate,
6
+ flip,
7
+ FloatingPortal,
8
+ offset,
9
+ shift,
10
+ useDismiss,
11
+ useFloating,
12
+ useInteractions,
13
+ } from '@floating-ui/react'
14
+ import { observer } from 'mobx-react-lite'
15
+ import { useEffect, useState } from 'react'
16
+ import { Icon } from 'src/cli/serve/web/components/Icon.tsx'
17
+ import { MOD_KEY } from 'src/cli/serve/web/components/modKey.ts'
18
+ import { tabForKey, tabStepForKey, type DraftTab } from 'src/cli/serve/web/state/draftTabs.ts'
19
+ import { shortcutLabel } from 'src/cli/serve/web/state/shortcuts.ts'
20
+ import type { WebSt } from 'src/cli/serve/web/state/WebSt.ts'
21
+
22
+ export function useTabShortcuts(st: WebSt): void {
23
+ useEffect(() => {
24
+ const onKey = (e: KeyboardEvent): void => {
25
+ const t = tabForKey(st.tabs, e) ?? tabStepForKey(st.tabs, st.activeTab, e)
26
+ if (t == null) return
27
+ e.preventDefault()
28
+ void st.select(t)
29
+ }
30
+ window.addEventListener('keydown', onKey)
31
+ return () => window.removeEventListener('keydown', onKey)
32
+ }, [st])
33
+ }
34
+
35
+ export const DraftTabs = observer(function DraftTabs(p: { st: WebSt }) {
36
+ const active = p.st.activeTab
37
+ const tabs = p.st.tabs
38
+ /** the open tab's element while its actions show, null when they do not */
39
+ const [menuAt, setMenuAt] = useState<HTMLElement | null>(null)
40
+ if (tabs.length === 0) return null
41
+ return (
42
+ <div className="draft-tabs" role="tablist">
43
+ {tabs.map((t, ix) => {
44
+ const on = active != null && active.module === t.module && active.draft === t.draft
45
+ const key = ix < 8 ? `${MOD_KEY}${ix + 1}` : ix === tabs.length - 1 ? `${MOD_KEY}9` : null
46
+ return (
47
+ <div
48
+ key={`${t.module}/${t.draft}`}
49
+ role="tab"
50
+ aria-selected={on}
51
+ className={on ? 'draft-tab on' : 'draft-tab'}
52
+ data-tip={`${t.module} / ${t.draft}${key == null ? '' : `\n${key}`}${on ? '\nclick: rename, duplicate, delete' : ''}`}
53
+ onClick={(e) => {
54
+ // another tab is a jump; the open one has nowhere to jump, so it shows its actions
55
+ if (on) setMenuAt(e.currentTarget)
56
+ else void p.st.select(t)
57
+ }}
58
+ onAuxClick={(e) => {
59
+ if (e.button !== 1) return
60
+ e.preventDefault()
61
+ p.st.closeTab(t)
62
+ }}
63
+ >
64
+ <span className="draft-tab-name">
65
+ {t.draft}
66
+ {/* two open drafts share the name (default, default): the workflow tells them apart */}
67
+ {tabs.some((o) => o.draft === t.draft && o.module !== t.module) ? (
68
+ <span className="draft-tab-wf"> · {t.module}</span>
69
+ ) : null}
70
+ </span>
71
+ {tabs.length > 1 ? (
72
+ <button
73
+ type="button"
74
+ className="draft-tab-close"
75
+ aria-label={`close ${t.draft}`}
76
+ onClick={(e) => {
77
+ e.stopPropagation()
78
+ p.st.closeTab(t)
79
+ }}
80
+ >
81
+ <Icon name="close" size={0.8} />
82
+ </button>
83
+ ) : null}
84
+ </div>
85
+ )
86
+ })}
87
+ {menuAt != null && active != null ? (
88
+ <TabMenu st={p.st} tab={active} anchor={menuAt} onClose={() => setMenuAt(null)} />
89
+ ) : null}
90
+ </div>
91
+ )
92
+ })
93
+
94
+ /** under the open tab: its name to edit (focused, enter renames), then the other draft actions.
95
+ * In a portal: the tab bar scrolls sideways and would clip it */
96
+ const TabMenu = observer(function TabMenu(p: { st: WebSt; tab: DraftTab; anchor: HTMLElement; onClose: () => void }) {
97
+ const [name, setName] = useState(p.tab.draft)
98
+ const { refs, floatingStyles, context } = useFloating({
99
+ open: true,
100
+ onOpenChange: (open) => {
101
+ if (!open) p.onClose()
102
+ },
103
+ placement: 'bottom-start',
104
+ middleware: [offset(4), flip(), shift({ padding: 8 })],
105
+ whileElementsMounted: autoUpdate,
106
+ elements: { reference: p.anchor },
107
+ })
108
+ const { getFloatingProps } = useInteractions([useDismiss(context)])
109
+ const run = (action: () => unknown): void => {
110
+ p.onClose()
111
+ void action()
112
+ }
113
+ const rename = (): void => {
114
+ const next = name.trim()
115
+ run(() => (next !== '' && next !== p.tab.draft ? p.st.renameDraft(next) : undefined))
116
+ }
117
+ return (
118
+ <FloatingPortal>
119
+ <div ref={refs.setFloating} style={floatingStyles} className="tab-menu" {...getFloatingProps()}>
120
+ <input
121
+ type="text"
122
+ className="head-input"
123
+ autoFocus
124
+ value={name}
125
+ aria-label="draft name"
126
+ placeholder="new name, then enter"
127
+ onFocus={(e) => e.currentTarget.select()}
128
+ onChange={(e) => setName(e.target.value)}
129
+ onKeyDown={(e) => {
130
+ if (e.key === 'Enter') rename()
131
+ if (e.key === 'Escape') p.onClose()
132
+ }}
133
+ />
134
+ <button
135
+ type="button"
136
+ className="menu-row menu-action"
137
+ onClick={() => run(() => p.st.duplicateCurrentDraft())}
138
+ >
139
+ <Icon name="copy-plus" />
140
+ <span>duplicate</span>
141
+ <span className="kbd-hint">{shortcutLabel('duplicate-draft')}</span>
142
+ </button>
143
+ <button
144
+ type="button"
145
+ className="menu-row menu-action"
146
+ onClick={() => run(() => p.st.newDraftFromDefaults())}
147
+ >
148
+ <Icon name="plus" />
149
+ <span>new default</span>
150
+ </button>
151
+ <button
152
+ type="button"
153
+ className="menu-row menu-action danger"
154
+ onClick={() =>
155
+ run(() => {
156
+ if (window.confirm(`delete draft '${p.tab.draft}' of ${p.tab.module}? the file is removed.`))
157
+ return p.st.deleteDraft(p.tab)
158
+ })
159
+ }
160
+ >
161
+ <Icon name="trash" />
162
+ <span>delete</span>
163
+ </button>
164
+ </div>
165
+ </FloatingPortal>
166
+ )
167
+ })
@@ -6,9 +6,23 @@ import { Icon } from 'src/cli/serve/web/components/Icon.tsx'
6
6
  import { observer, useLocalObservable } from 'mobx-react-lite'
7
7
  import { useEffect, useRef } from 'react'
8
8
  import { runPreviewSrc } from 'src/cli/serve/web/api.ts'
9
+ import { asSizeForm } from 'src/cli/serve/web/state/payload.ts'
9
10
  import { lightboxView, type LightboxTarget } from 'src/cli/serve/web/state/lightbox.ts'
10
11
  import { copyImageToClipboard } from 'src/cli/serve/web/clipboard.ts'
11
12
  import type { WebSt } from 'src/cli/serve/web/state/WebSt.ts'
13
+ import { MOD_KEY } from 'src/cli/serve/web/components/modKey.ts'
14
+ import { SHORTCUT_KEYS } from 'src/cli/serve/web/state/shortcuts.ts'
15
+
16
+ /** the unblur shortcut, said ON a blurred image: the place you look when you want it gone */
17
+ const BlurHint = observer(function BlurHint(p: { st: WebSt }) {
18
+ if (!p.st.blurResults) return null
19
+ return (
20
+ <span className="blur-hint kbd-hint">
21
+ {MOD_KEY}
22
+ {SHORTCUT_KEYS['toggle-blur']}
23
+ </span>
24
+ )
25
+ })
12
26
 
13
27
  const canCopy = typeof navigator !== 'undefined' && navigator.clipboard != null
14
28
 
@@ -297,11 +311,54 @@ const LiveText = observer(function LiveText(p: { text: string }) {
297
311
  )
298
312
  })
299
313
 
314
+ /** the corner mode: the run as a small card floating over the gallery's top right corner, on a
315
+ * zero-height sticky anchor, so it takes no room. The last image stays where it is while the
316
+ * next one runs, and the finished one lands at the top in one go */
317
+ const CornerRun = observer(function CornerRun(p: { st: WebSt; local: GalleryLocal; module: string }) {
318
+ const percent = p.st.run.progressPercent
319
+ const node = p.st.run.progressNode
320
+ const count = p.st.run.progressCount
321
+ return (
322
+ <div className="corner-run-anchor">
323
+ <div className="corner-run">
324
+ {p.st.run.hasPreview ? (
325
+ <button
326
+ type="button"
327
+ className="img-button"
328
+ data-tip="the latent so far: click to see it big"
329
+ onClick={() =>
330
+ p.local.openLightbox({
331
+ kind: 'latent',
332
+ module: p.module,
333
+ after: p.st.run.results.filter((r) => r.module === p.module).length,
334
+ })
335
+ }
336
+ >
337
+ <img src={runPreviewSrc({ module: p.module, tick: p.st.run.previewTick })} alt="latent preview" />
338
+ <BlurHint st={p.st} />
339
+ </button>
340
+ ) : null}
341
+ <div className="corner-run-meta">
342
+ <span className="run-meta-text">
343
+ {node == null ? p.module : node}
344
+ {count != null ? ` ${count.value}/${count.max}` : ''}
345
+ </span>
346
+ <span>{percent != null ? `${Math.round(percent)}%` : ''}</span>
347
+ </div>
348
+ <div className="progress-track">
349
+ <div className="progress-fill" style={{ width: `${percent ?? 0}%` }} />
350
+ </div>
351
+ </div>
352
+ </div>
353
+ )
354
+ })
355
+
300
356
  /** live card while a run is in flight: progress bar + the latest latent frame */
301
357
  const RunningCard = observer(function RunningCard(p: { st: WebSt; local: GalleryLocal }) {
302
358
  // the RUNNING module, never the selection: switching modules mid-run must not retarget the card
303
359
  const moduleKey = p.st.run.runningModule
304
360
  if (!p.st.run.isRunning || moduleKey == null) return null
361
+ if (p.st.latentMode === 'corner') return <CornerRun st={p.st} local={p.local} module={moduleKey} />
305
362
  const percent = p.st.run.progressPercent
306
363
  const previewUrl = runPreviewSrc({ module: moduleKey, tick: p.st.run.previewTick })
307
364
  // the node's OWN counter: generated tokens on a text node, sampler steps on a KSampler.
@@ -309,41 +366,61 @@ const RunningCard = observer(function RunningCard(p: { st: WebSt; local: Gallery
309
366
  const node = p.st.run.progressNode
310
367
  const count = p.st.run.progressCount
311
368
  const liveText = p.st.run.progressText
369
+ // the frame is RESERVED from the first moment at the image's own ratio (the size var of the
370
+ // running workflow) and the box a finished image takes (.run-card img: 320px max each way),
371
+ // the bar drawn over its foot, the node counter on the one header line: nothing grows while
372
+ // the run goes and the result lands in the same space
373
+ const form = p.st.form
374
+ const sizeVar = form?.moduleKey === moduleKey ? form.vars.find((v) => v.desc.kind === 'size') : undefined
375
+ const size = sizeVar == null ? null : asSizeForm(sizeVar.value)
376
+ const imageGraph = size != null || p.st.run.hasPreview
377
+ const ratio = size == null ? 1 : size.width / size.height
312
378
  return (
313
- <div className="run-card running">
379
+ <div className={imageGraph ? 'run-card running cell' : 'run-card running'}>
314
380
  <div className="meta">
315
- <span>generating {moduleKey}…</span>
381
+ <span className="run-meta-text">
382
+ generating {moduleKey}…
383
+ {node != null ? ` · ${node}${count != null ? ` ${count.value}/${count.max}` : ''}` : ''}
384
+ </span>
316
385
  <span>{percent != null ? `${Math.round(percent)}%` : ''}</span>
317
386
  </div>
318
- {node != null ? (
319
- <div className="run-node">
320
- {node}
321
- {count != null ? ` ${count.value}/${count.max}` : ''}
322
- </div>
323
- ) : null}
324
387
  {/* a node streaming its text as it produces it: the answer builds up here before the
325
388
  run ends. Same fold as a finished result, so watching and reading look alike */}
326
389
  {liveText != null && liveText !== '' ? <LiveText text={liveText} /> : null}
327
- <div className="progress-track">
328
- <div className="progress-fill" style={{ width: `${percent ?? 0}%` }} />
329
- </div>
330
- {p.st.run.hasPreview && p.st.showLatent ? (
331
- <div className="imgs">
332
- <button
333
- type="button"
334
- className="img-button"
335
- onClick={() =>
336
- p.local.openLightbox({
337
- kind: 'latent',
338
- module: moduleKey,
339
- after: p.st.run.results.filter((r) => r.module === moduleKey).length,
340
- })
341
- }
342
- >
343
- <img src={previewUrl} alt="latent preview" />
344
- </button>
390
+ {imageGraph ? (
391
+ <div
392
+ className="run-frame"
393
+ style={{
394
+ aspectRatio: String(ratio),
395
+ // one column's width, the box the finished image takes, so it lands in place
396
+ width: '100%',
397
+ }}
398
+ >
399
+ {p.st.run.hasPreview && p.st.latentMode === 'full' ? (
400
+ <button
401
+ type="button"
402
+ className="img-button"
403
+ onClick={() =>
404
+ p.local.openLightbox({
405
+ kind: 'latent',
406
+ module: moduleKey,
407
+ after: p.st.run.results.filter((r) => r.module === moduleKey).length,
408
+ })
409
+ }
410
+ >
411
+ <img src={previewUrl} alt="latent preview" />
412
+ <BlurHint st={p.st} />
413
+ </button>
414
+ ) : null}
415
+ <div className="progress-track over">
416
+ <div className="progress-fill" style={{ width: `${percent ?? 0}%` }} />
417
+ </div>
345
418
  </div>
346
- ) : null}
419
+ ) : (
420
+ <div className="progress-track">
421
+ <div className="progress-fill" style={{ width: `${percent ?? 0}%` }} />
422
+ </div>
423
+ )}
347
424
  </div>
348
425
  )
349
426
  })
@@ -356,14 +433,24 @@ export const Gallery = observer(function Gallery(p: { st: WebSt; compact?: boole
356
433
  if (p.st.run.results.length === 0 && !p.st.run.isRunning) return null
357
434
  const results = p.compact === true ? p.st.run.results.slice(0, 1) : p.st.run.results
358
435
  return (
359
- <div className="gallery">
436
+ // fit: one per row at the panel's width; grid: the slider's size, wrapping. The corner
437
+ // placement keeps its own compact look
438
+ <div
439
+ className={`gallery${p.st.blurResults ? ' blur' : ''}${p.compact === true ? '' : ' by-cols'}`}
440
+ style={
441
+ p.compact === true ? undefined : { gridTemplateColumns: `repeat(${p.st.resultsColumns}, minmax(0, 1fr))` }
442
+ }
443
+ >
360
444
  <RunningCard st={p.st} local={local} />
361
445
  {/* the count and clear-all moved onto the run line beside the generate button: two
362
446
  headers for one idea is a header too many */}
363
447
  {results.map((r) => (
364
- <div key={r.promptId} className="run-card">
448
+ <div
449
+ key={r.promptId}
450
+ className={r.images.some((img) => img.url != null) ? 'run-card has-image' : 'run-card'}
451
+ >
365
452
  <div className="meta">
366
- <span>
453
+ <span className="meta-text">
367
454
  {r.at} · {r.module}/{r.draft} · {(r.durationMs / 1000).toFixed(1)}s
368
455
  {Object.entries(r.seeds).map(([k, seed]) => ` · ${k}: ${seed}`)}
369
456
  </span>
@@ -395,6 +482,7 @@ export const Gallery = observer(function Gallery(p: { st: WebSt; compact?: boole
395
482
  }}
396
483
  >
397
484
  <img src={img.url} alt={img.filename} />
485
+ <BlurHint st={p.st} />
398
486
  </button>
399
487
  {/* the EMBEDDING page's buttons (host protocol): what it does with the
400
488
  image is its business — send it somewhere, keep it as something */}
@@ -436,7 +524,21 @@ export const Gallery = observer(function Gallery(p: { st: WebSt; compact?: boole
436
524
  </div>
437
525
  ),
438
526
  )}
439
- {r.images.length === 0 && (r.texts ?? []).length === 0 ? (
527
+ {(r.audios ?? []).map((a, ix) =>
528
+ a.url != null ? (
529
+ <div key={`${r.promptId}-audio-${ix}`} className="audio-cell">
530
+ <audio controls preload="metadata" src={a.url} />
531
+ <a className="hint" href={a.url} download={a.filename}>
532
+ {a.filename}
533
+ </a>
534
+ </div>
535
+ ) : (
536
+ <div key={`${r.promptId}-audio-${ix}`} className="noimg">
537
+ {a.filename} (not kept — no preview)
538
+ </div>
539
+ ),
540
+ )}
541
+ {r.images.length === 0 && (r.texts ?? []).length === 0 && (r.audios ?? []).length === 0 ? (
440
542
  <div className="noimg">no outputs</div>
441
543
  ) : null}
442
544
  </div>
@@ -0,0 +1,149 @@
1
+ // the history picker: every value submitted this page, searchable. Two columns: the matches on
2
+ // the left (first line, how long ago, where from), the FULL text of the highlighted one on the
3
+ // right, so arrowing down previews exactly what a pick writes. Enter or a click picks
4
+ import { useEffect, useRef, useState, type ReactNode } from 'react'
5
+ import { Icon } from 'src/cli/serve/web/components/Icon.tsx'
6
+ import { searchHistory, timeAgo, type HistoryEntry } from 'src/cli/serve/web/state/history.ts'
7
+
8
+ /** the button that opens it: always there, disabled while nothing was submitted yet. Plain (not
9
+ * an observer) to stay generic: the observer parent reads the list and passes it down */
10
+ export function HistoryButton<V>(p: {
11
+ entries: readonly HistoryEntry<V>[]
12
+ what: string
13
+ onPick(entry: HistoryEntry<V>): void
14
+ compact?: boolean
15
+ }): ReactNode {
16
+ const [open, setOpen] = useState(false)
17
+ const n = p.entries.length
18
+ return (
19
+ <>
20
+ <button
21
+ type="button"
22
+ className={p.compact === true ? 'link' : 'mini'}
23
+ disabled={n === 0}
24
+ data-tip={
25
+ n === 0
26
+ ? `every ${p.what} you submit shows here, until you close the page`
27
+ : `${n} past ${p.what}s: search, preview, restore`
28
+ }
29
+ onClick={() => setOpen(true)}
30
+ >
31
+ <Icon name="history" />
32
+ {p.compact === true ? null : ' history'}
33
+ </button>
34
+ {open ? (
35
+ <HistoryPicker
36
+ entries={p.entries}
37
+ what={p.what}
38
+ onPick={(e) => {
39
+ setOpen(false)
40
+ p.onPick(e)
41
+ }}
42
+ onClose={() => setOpen(false)}
43
+ />
44
+ ) : null}
45
+ </>
46
+ )
47
+ }
48
+
49
+ function HistoryPicker<V>(p: {
50
+ entries: readonly HistoryEntry<V>[]
51
+ what: string
52
+ onPick(entry: HistoryEntry<V>): void
53
+ onClose(): void
54
+ }): ReactNode {
55
+ const [query, setQuery] = useState('')
56
+ const [cursor, setCursor] = useState(0)
57
+ const [now, setNow] = useState(() => Date.now())
58
+ const listRef = useRef<HTMLDivElement>(null)
59
+ const matches = searchHistory(p.entries, query)
60
+ const sel = matches[Math.min(cursor, Math.max(0, matches.length - 1))] ?? null
61
+ // "3 min ago" keeps being true while the picker stays open
62
+ useEffect(() => {
63
+ const t = setInterval(() => setNow(Date.now()), 10_000)
64
+ return () => clearInterval(t)
65
+ }, [])
66
+ // esc closes THIS, never the modal under it (the enhancer listens on window too): a capture
67
+ // listener runs first and stops the event there
68
+ useEffect(() => {
69
+ const onKey = (e: KeyboardEvent): void => {
70
+ if (e.key !== 'Escape') return
71
+ e.stopImmediatePropagation()
72
+ p.onClose()
73
+ }
74
+ window.addEventListener('keydown', onKey, true)
75
+ return () => window.removeEventListener('keydown', onKey, true)
76
+ }, [p])
77
+ useEffect(() => {
78
+ listRef.current?.querySelector('.hist-row.sel')?.scrollIntoView({ block: 'nearest' })
79
+ }, [cursor, query])
80
+ const move = (delta: number): void => setCursor((c) => Math.max(0, Math.min(matches.length - 1, c + delta)))
81
+ return (
82
+ <div className="modal-overlay top hist-overlay" onClick={() => p.onClose()}>
83
+ <div className="modal hist-modal" onClick={(e) => e.stopPropagation()}>
84
+ <div className="modal-head">
85
+ <Icon name="history" />
86
+ <input
87
+ type="text"
88
+ autoFocus
89
+ placeholder={`search ${p.entries.length} past ${p.what}s, every word must match`}
90
+ value={query}
91
+ onChange={(e) => {
92
+ setQuery(e.target.value)
93
+ setCursor(0)
94
+ }}
95
+ onKeyDown={(e) => {
96
+ if (e.key === 'ArrowDown') {
97
+ e.preventDefault()
98
+ move(1)
99
+ } else if (e.key === 'ArrowUp') {
100
+ e.preventDefault()
101
+ move(-1)
102
+ } else if (e.key === 'Enter') {
103
+ e.preventDefault()
104
+ if (sel != null) p.onPick(sel)
105
+ }
106
+ }}
107
+ />
108
+ <button type="button" className="modal-close" data-tip="close (esc)" onClick={() => p.onClose()}>
109
+ <Icon name="close" />
110
+ </button>
111
+ </div>
112
+ <div className="hist-cols">
113
+ <div className="hist-list" ref={listRef}>
114
+ {matches.length === 0 ? <div className="hist-empty">nothing matches '{query}'</div> : null}
115
+ {matches.map((e, ix) => (
116
+ <button
117
+ key={e.text}
118
+ type="button"
119
+ className={e === sel ? 'hist-row sel' : 'hist-row'}
120
+ onMouseEnter={() => setCursor(ix)}
121
+ onClick={() => p.onPick(e)}
122
+ >
123
+ <span className="hist-first">{e.text.split('\n')[0]}</span>
124
+ <span className="hist-meta">
125
+ {timeAgo(e.at, now)}
126
+ {e.count > 1 ? ` · ${e.count}×` : ''}
127
+ {e.source === '' ? '' : ` · ${e.source}`}
128
+ </span>
129
+ </button>
130
+ ))}
131
+ </div>
132
+ <div className="hist-preview">
133
+ {sel == null ? null : (
134
+ <>
135
+ <pre className="hist-text">{sel.text}</pre>
136
+ <div className="hist-foot">
137
+ <span className="hint">↑↓ to preview, enter or click to restore</span>
138
+ <button type="button" className="primary" onClick={() => p.onPick(sel)}>
139
+ restore this {p.what}
140
+ </button>
141
+ </div>
142
+ </>
143
+ )}
144
+ </div>
145
+ </div>
146
+ </div>
147
+ </div>
148
+ )
149
+ }
@@ -6,6 +6,7 @@ import type { ReactNode } from 'react'
6
6
 
7
7
  export type IconName =
8
8
  | 'close'
9
+ | 'check'
9
10
  | 'trash'
10
11
  | 'copy'
11
12
  | 'external'
@@ -15,6 +16,7 @@ export type IconName =
15
16
  | 'sparkle'
16
17
  | 'play'
17
18
  | 'pause'
19
+ | 'stop'
18
20
  | 'save'
19
21
  | 'ghost'
20
22
  | 'panel-off'
@@ -36,12 +38,28 @@ export type IconName =
36
38
  | 'unlink'
37
39
  | 'refresh'
38
40
  | 'terminal'
39
- | 'folder'
41
+ | 'search'
42
+ | 'history'
43
+ | 'rows'
44
+ | 'grid'
45
+ | 'eye'
46
+ | 'eye-off'
47
+ | 'more'
48
+ | 'text'
40
49
  | 'dot'
50
+ | 'audio'
51
+ | 'video'
52
+ | 'workflow'
53
+ | 'draft'
54
+ | 'folder'
55
+ | 'folder-tree'
56
+ | 'server'
57
+ | 'menu'
41
58
 
42
59
  /** 24x24 viewBox paths, stroked (fill: none) unless the shape reads better solid */
43
60
  const PATHS: Record<IconName, ReactNode> = {
44
61
  close: <path d="M6 6l12 12M18 6L6 18" />,
62
+ check: <path d="M5 12.5l4.5 4.5L19 7.5" />,
45
63
  trash: <path d="M4 7h16M10 7V5h4v2M6 7l1 12h10l1-12M10 11v5M14 11v5" />,
46
64
  copy: <path d="M9 9h10v10H9zM5 15V5h10" />,
47
65
  external: <path d="M14 5h5v5M19 5l-8 8M18 14v5H5V6h5" />,
@@ -71,6 +89,7 @@ const PATHS: Record<IconName, ReactNode> = {
71
89
  ),
72
90
  play: <path d="M7 4l13 8-13 8z" fill="currentColor" stroke="none" />,
73
91
  pause: <path d="M8 5v14M16 5v14" />,
92
+ stop: <rect x="6" y="6" width="12" height="12" rx="1.5" fill="currentColor" stroke="none" />,
74
93
  save: <path d="M5 4h11l3 3v13H5zM8 4v6h7V4M8 20v-6h8v6" />,
75
94
  ghost: <path d="M5 20V10a7 7 0 0114 0v10l-2.3-2-2.4 2-2.3-2-2.4 2zM9.5 10h.01M14.5 10h.01" />,
76
95
  'panel-off': (
@@ -133,8 +152,45 @@ const PATHS: Record<IconName, ReactNode> = {
133
152
  ),
134
153
  refresh: <path d="M20 11a8 8 0 10-2 6M20 6v5h-5" />,
135
154
  terminal: <path d="M4 5h16v14H4zM7 9l3 3-3 3M13 15h4" />,
136
- folder: <path d="M3 7h6l2 2h10v10H3z" />,
155
+ text: <path d="M4 7h16M4 12h10M4 17h13" />,
156
+ more: <path d="M5 12h.01M12 12h.01M19 12h.01" strokeWidth={3.2} />,
157
+ eye: <path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12zM12 9a3 3 0 110 6 3 3 0 010-6z" />,
158
+ 'eye-off': (
159
+ <path d="M3 3l18 18M10.6 5.1A10 10 0 0112 5c6.5 0 10 7 10 7a17 17 0 01-3.2 4.2M6.6 6.6C3.9 8.4 2 12 2 12s3.5 7 10 7a9.7 9.7 0 005.4-1.6M9.9 9.9a3 3 0 004.2 4.2" />
160
+ ),
161
+ rows: <path d="M4 5h16v6H4zM4 13h16v6H4z" />,
162
+ grid: <path d="M4 4h7v7H4zM13 4h7v7h-7zM4 13h7v7H4zM13 13h7v7h-7z" />,
163
+ search: <path d="M10.5 4a6.5 6.5 0 110 13 6.5 6.5 0 010-13zM15.5 15.5L20 20" />,
164
+ history: <path d="M4 12a8 8 0 102.3-5.6M4 4v4h4M12 8v4l3 2" />,
137
165
  dot: <circle cx="12" cy="12" r="5" fill="currentColor" stroke="none" />,
166
+ audio: <path d="M3 12h2M7 8v8M11 4v16M15 7v10M19 10v4M21 12h0" />,
167
+ video: (
168
+ <>
169
+ <rect x="3" y="6" width="13" height="12" rx="2" />
170
+ <path d="M16 10l5-3v10l-5-3z" />
171
+ </>
172
+ ),
173
+ workflow: (
174
+ <>
175
+ <rect x="3" y="4" width="6" height="5" rx="1.2" />
176
+ <rect x="15" y="4" width="6" height="5" rx="1.2" />
177
+ <rect x="9" y="15" width="6" height="5" rx="1.2" />
178
+ <path d="M6 9v2.5a1.5 1.5 0 001.5 1.5h9a1.5 1.5 0 001.5-1.5V9M12 13v2" />
179
+ </>
180
+ ),
181
+ draft: <path d="M6 3h8l4 4v14H6zM14 3v4h4M9 12h6M9 16h4" />,
182
+ folder: (
183
+ <path d="M3 6.5A1.5 1.5 0 014.5 5H9l2 2h8.5A1.5 1.5 0 0121 8.5v9a1.5 1.5 0 01-1.5 1.5h-15A1.5 1.5 0 013 17.5z" />
184
+ ),
185
+ 'folder-tree': <path d="M4 4v14a2 2 0 002 2h2M4 10h4M10 7h3l1 1.5h6V12H10zM10 16h3l1 1.5h6V21H10z" />,
186
+ server: (
187
+ <>
188
+ <rect x="3" y="4" width="18" height="7" rx="1.5" />
189
+ <rect x="3" y="13" width="18" height="7" rx="1.5" />
190
+ <path d="M7 7.5h.01M7 16.5h.01M11 7.5h6M11 16.5h6" />
191
+ </>
192
+ ),
193
+ menu: <path d="M4 7h16M4 12h16M4 17h16" />,
138
194
  }
139
195
 
140
196
  /** `size` is a multiplier of the surrounding font size, so icons scale with their button */