comfy-ts 2.10.0 → 2.12.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 (110) hide show
  1. package/README.md +1 -0
  2. package/dist/{LogsSt-DFxzQfDc.js → LogsSt-U1H0mP1m.js} +35 -5
  3. package/dist/LogsSt-U1H0mP1m.js.map +1 -0
  4. package/dist/cli.js +4 -4
  5. package/dist/index.cjs +565 -62
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.cts +210 -31
  8. package/dist/index.d.ts +210 -31
  9. package/dist/index.js +561 -63
  10. package/dist/index.js.map +1 -1
  11. package/dist/{run-serve-_nrvJYyt.js → run-serve-BeAznay5.js} +549 -43
  12. package/dist/run-serve-BeAznay5.js.map +1 -0
  13. package/dist/{run-tui-Atvf9vb3.js → run-tui-BTGjvnKk.js} +75 -18
  14. package/dist/run-tui-BTGjvnKk.js.map +1 -0
  15. package/dist/{DefinedWorkflow-BatWaZO1.js → schemaDrift-Cg39vs53.js} +644 -60
  16. package/dist/schemaDrift-Cg39vs53.js.map +1 -0
  17. package/dist/serve-web.js +523 -133
  18. package/dist/{state-6RFDIQwJ.js → state-C7REnHan.js} +18 -3
  19. package/dist/{state-6RFDIQwJ.js.map → state-C7REnHan.js.map} +1 -1
  20. package/dist/web.d.ts +210 -31
  21. package/dist/web.js +561 -63
  22. package/dist/web.js.map +1 -1
  23. package/examples/comfy-cloud/capybara-i2v.cflow.ts +2 -0
  24. package/examples/comfy-cloud/wan22-5b-t2v.cflow.ts +2 -0
  25. package/examples/comfy-cloud/wan22-i2v.cflow.ts +2 -0
  26. package/examples/comfy-cloud/wan22-t2v.cflow.ts +2 -0
  27. package/examples/rvion/06-qwen-image-edit.cflow.ts +3 -2
  28. package/examples/rvion/07-local-llm-text-gen.cflow.ts +2 -2
  29. package/examples/rvion/10-anima-t2i.cflow.ts +229 -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 +17 -7
  35. package/src/cli/draftMeta.ts +39 -0
  36. package/src/cli/serve/ServeApp.ts +242 -12
  37. package/src/cli/serve/applyVarPayload.ts +50 -22
  38. package/src/cli/serve/describeVar.ts +49 -6
  39. package/src/cli/serve/favicon.ts +3 -0
  40. package/src/cli/serve/llmConfigShape.ts +51 -0
  41. package/src/cli/serve/llmConfigs.ts +52 -0
  42. package/src/cli/serve/tagList.ts +92 -0
  43. package/src/cli/serve/tagSource.ts +69 -0
  44. package/src/cli/serve/web/api.ts +60 -0
  45. package/src/cli/serve/web/components/App.tsx +336 -44
  46. package/src/cli/serve/web/components/Gallery.tsx +105 -28
  47. package/src/cli/serve/web/components/HistoryPicker.tsx +149 -0
  48. package/src/cli/serve/web/components/Icon.tsx +18 -2
  49. package/src/cli/serve/web/components/MenuButton.tsx +53 -0
  50. package/src/cli/serve/web/components/Omnibox.tsx +85 -0
  51. package/src/cli/serve/web/components/PromptEnhancer.tsx +476 -180
  52. package/src/cli/serve/web/components/TooltipLayer.tsx +45 -0
  53. package/src/cli/serve/web/components/VarIcon.tsx +24 -0
  54. package/src/cli/serve/web/components/VarsForm.tsx +341 -177
  55. package/src/cli/serve/web/components/controls/BasicControls.tsx +57 -32
  56. package/src/cli/serve/web/components/controls/LorasControl.tsx +708 -285
  57. package/src/cli/serve/web/components/controls/PresetPicker.tsx +1 -1
  58. package/src/cli/serve/web/components/controls/PromptControl.tsx +279 -0
  59. package/src/cli/serve/web/components/controls/PromptEditor.tsx +113 -0
  60. package/src/cli/serve/web/components/controls/SeedControl.tsx +17 -10
  61. package/src/cli/serve/web/components/controls/SizeControl.tsx +111 -18
  62. package/src/cli/serve/web/components/modKey.ts +2 -0
  63. package/src/cli/serve/web/llm.ts +23 -12
  64. package/src/cli/serve/web/promptEditor/promptExtensions.ts +281 -0
  65. package/src/cli/serve/web/state/EnhancerSt.ts +415 -100
  66. package/src/cli/serve/web/state/FormSt.ts +193 -29
  67. package/src/cli/serve/web/state/OmniboxSt.ts +57 -0
  68. package/src/cli/serve/web/state/WebSt.ts +281 -57
  69. package/src/cli/serve/web/state/choiceButtons.ts +61 -0
  70. package/src/cli/serve/web/state/generateButton.ts +16 -0
  71. package/src/cli/serve/web/state/history.ts +54 -0
  72. package/src/cli/serve/web/state/host.ts +5 -2
  73. package/src/cli/serve/web/state/keptLines.ts +53 -0
  74. package/src/cli/serve/web/state/latentMode.ts +20 -0
  75. package/src/cli/serve/web/state/loraSort.ts +57 -0
  76. package/src/cli/serve/web/state/moduleTree.ts +2 -2
  77. package/src/cli/serve/web/state/omnibox.ts +69 -0
  78. package/src/cli/serve/web/state/payload.ts +38 -58
  79. package/src/cli/serve/web/state/shortcuts.ts +54 -0
  80. package/src/cli/serve/web/state/sizeStars.ts +31 -0
  81. package/src/cli/serve/web/state/stableSlots.ts +21 -0
  82. package/src/cli/serve/web/state/varGroups.ts +24 -0
  83. package/src/cli/serve/web/styles.ts +472 -118
  84. package/src/cli/serve/webBundle.ts +54 -10
  85. package/src/cli/tui/components/Header.tsx +2 -0
  86. package/src/cli/tui/components/PickerOverlays.tsx +9 -2
  87. package/src/cli/tui/imagePicker/ImagePickerSt.ts +1 -1
  88. package/src/cli/tui/state/DraftsSt.ts +18 -2
  89. package/src/cli/tui/state/EditorSt.ts +1 -1
  90. package/src/cli/tui/state/HostSt.ts +34 -0
  91. package/src/cli/tui/state/LorasSt.ts +1 -1
  92. package/src/cli/tui/state/PickerSt.ts +25 -7
  93. package/src/cli/tui/state/SettingsSt.ts +1 -1
  94. package/src/cli/tui/state/TuiSt.ts +10 -0
  95. package/src/coreExports.ts +20 -0
  96. package/src/host/ComfyHost.ts +15 -0
  97. package/src/host/loraInfoCache.ts +70 -0
  98. package/src/host/loraManagerApi.ts +27 -0
  99. package/src/host/schemaDrift.ts +87 -0
  100. package/src/state.ts +5 -0
  101. package/src/vars/ComfyVars.ts +337 -67
  102. package/src/vars/DefinedWorkflow.ts +40 -19
  103. package/src/vars/lanes.ts +238 -0
  104. package/src/vars/loraEntry.ts +101 -0
  105. package/src/vars/promptSyntax.ts +382 -0
  106. package/dist/DefinedWorkflow-BatWaZO1.js.map +0 -1
  107. package/dist/LogsSt-DFxzQfDc.js.map +0 -1
  108. package/dist/run-serve-_nrvJYyt.js.map +0 -1
  109. package/dist/run-tui-Atvf9vb3.js.map +0 -1
  110. package/src/cli/serve/web/components/Sidebar.tsx +0 -66
@@ -1,12 +1,17 @@
1
- // layout root: sidebar drawer + form column + results column (right on wide
2
- // screens, below on narrow ones). NO title bar: the workflow head box opens the
3
- // sidebar, so a permanent bar would only spend vertical space naming the app
1
+ // layout root: form column + results column, placed by the preview panel's own buttons.
2
+ // NO title bar and no menu: ⌘K / ⌘J or the workflow head box opens the omnibox
4
3
  import { observer } from 'mobx-react-lite'
5
- import { useEffect } from 'react'
4
+ import { useEffect, useState, type ReactNode } from 'react'
5
+ import { Group, Panel, Separator, useDefaultLayout } from 'react-resizable-panels'
6
6
  import { Gallery } from 'src/cli/serve/web/components/Gallery.tsx'
7
- import { Sidebar } from 'src/cli/serve/web/components/Sidebar.tsx'
7
+ import { Icon, type IconName } from 'src/cli/serve/web/components/Icon.tsx'
8
+ import { LATENT_MODES, type LatentMode } from 'src/cli/serve/web/state/latentMode.ts'
9
+ import { Omnibox, useOmniboxShortcut } from 'src/cli/serve/web/components/Omnibox.tsx'
10
+ import { TooltipLayer } from 'src/cli/serve/web/components/TooltipLayer.tsx'
11
+ import { MOD_KEY } from 'src/cli/serve/web/components/modKey.ts'
12
+ import { collapsedPreview } from 'src/cli/serve/web/state/stableSlots.ts'
8
13
  import { GenerateButton, VarsForm } from 'src/cli/serve/web/components/VarsForm.tsx'
9
- import type { WebSt } from 'src/cli/serve/web/state/WebSt.ts'
14
+ import { LAYOUTS, type WebSt } from 'src/cli/serve/web/state/WebSt.ts'
10
15
 
11
16
  /** ⌘A / ctrl+A selects the field you are in. The browser does this on its own until something
12
17
  * on the page consumes the event, and this panel has several window-level key handlers plus a
@@ -34,8 +39,251 @@ function useSelectAllInFields(): void {
34
39
  }, [])
35
40
  }
36
41
 
42
+ /** the preview panel's own controls, on top of it: where it sits, what shows while it runs */
43
+ /** the workflow's live previews (defineWorkflow({ previews })): text computed from the values
44
+ * on screen, refreshed as you edit. Compact by default, the name inline and every line cut to
45
+ * one; a click opens the full text, remembered. A `- ` line is the negative, as in a prompt */
46
+ const LivePreviews = observer(function LivePreviews(p: { st: WebSt }) {
47
+ const form = p.st.form
48
+ const names = form == null ? [] : (p.st.moduleByKey(form.moduleKey)?.previews ?? [])
49
+ if (form == null || names.length === 0) return null
50
+ return (
51
+ <div className="live-previews">
52
+ {names.map((name) => {
53
+ const key = `${form.moduleKey}/${name}`
54
+ const expanded = p.st.expandedPreviews.includes(key)
55
+ const text = form.previews[name] ?? '…'
56
+ const lines = text.split('\n').filter((l) => l.trim() !== '')
57
+ // collapsed = exactly two lines whatever the prompt holds, so typing never moves the
58
+ // gallery; the full text is one click away
59
+ const short = collapsedPreview(text)
60
+ return (
61
+ <button
62
+ key={name}
63
+ type="button"
64
+ className={expanded ? 'live-preview expanded' : 'live-preview'}
65
+ data-tip={expanded ? 'click to show one line each' : 'click for the full text'}
66
+ onClick={() => p.st.togglePreviewExpanded(key)}
67
+ >
68
+ <span className="live-preview-name">
69
+ {name}
70
+ {form.previewError == null ? null : (
71
+ <span className="live-preview-error" data-tip={`preview failed: ${form.previewError}`}>
72
+ 🔴
73
+ </span>
74
+ )}
75
+ </span>
76
+ <span className="live-preview-lines">
77
+ {!expanded ? (
78
+ <>
79
+ <span className="live-preview-line">{short.positive}</span>
80
+ <span className="live-preview-line negative">
81
+ {short.negative === '' ? '' : `− ${short.negative}`}
82
+ </span>
83
+ </>
84
+ ) : null}
85
+ {expanded &&
86
+ lines.map((line, ix) =>
87
+ line.startsWith('- ') ? (
88
+ // index keys: a preview's lines have no identity of their own
89
+ <span key={ix} className="live-preview-line negative">
90
+ − {line.slice(2)}
91
+ </span>
92
+ ) : (
93
+ <span key={ix} className="live-preview-line">
94
+ {line}
95
+ </span>
96
+ ),
97
+ )}
98
+ </span>
99
+ </button>
100
+ )
101
+ })}
102
+ </div>
103
+ )
104
+ })
105
+
106
+ const LATENT_ICON: Record<LatentMode, IconName> = { full: 'image', corner: 'panel-corner', off: 'panel-off' }
107
+
108
+ const ResultsHead = observer(function ResultsHead(p: { st: WebSt }) {
109
+ return (
110
+ <div className="results-head">
111
+ {/* a caption over each group: three unlabelled icon strips read as one */}
112
+ <div className="head-group-labeled">
113
+ <span className="group-caption">preview</span>
114
+ <span className="btn-group">
115
+ {LAYOUTS.map((l) => (
116
+ <button
117
+ key={l.id}
118
+ type="button"
119
+ className={p.st.layout === l.id ? 'sel' : ''}
120
+ data-tip={l.title}
121
+ onClick={() => p.st.setLayout(l.id)}
122
+ >
123
+ <Icon name={l.icon} />
124
+ </button>
125
+ ))}
126
+ </span>
127
+ </div>
128
+ <div className="head-group-labeled">
129
+ <span className="group-caption">while running</span>
130
+ <span className="row-inline head-row">
131
+ <span className="btn-group">
132
+ {LATENT_MODES.map((m) => (
133
+ <button
134
+ key={m.mode}
135
+ type="button"
136
+ className={p.st.latentMode === m.mode ? 'sel' : ''}
137
+ data-tip={m.tip}
138
+ onClick={() => p.st.setLatentMode(m.mode)}
139
+ >
140
+ <Icon name={LATENT_ICON[m.mode]} />
141
+ </button>
142
+ ))}
143
+ </span>
144
+ <span className="btn-group">
145
+ <button
146
+ type="button"
147
+ className={p.st.showLogs ? 'sel' : ''}
148
+ data-tip={p.st.showLogs ? 'hide the ComfyUI console' : 'show the ComfyUI console'}
149
+ onClick={() => p.st.toggleLogs()}
150
+ >
151
+ <Icon name="terminal" />
152
+ </button>
153
+ </span>
154
+ </span>
155
+ </div>
156
+ <div className="head-group-labeled">
157
+ <span className="group-caption">results</span>
158
+ <span className="row-inline results-view">
159
+ <span className="btn-group">
160
+ <button
161
+ type="button"
162
+ className={p.st.resultsView === 'fit' ? 'sel' : ''}
163
+ data-tip="fit: one image per row, as wide as this panel"
164
+ onClick={() => p.st.setResultsView('fit')}
165
+ >
166
+ <Icon name="rows" />
167
+ </button>
168
+ <button
169
+ type="button"
170
+ className={p.st.resultsView === 'grid' ? 'sel' : ''}
171
+ data-tip="grid: images at the size you set, as many per row as fit"
172
+ onClick={() => p.st.setResultsView('grid')}
173
+ >
174
+ <Icon name="grid" />
175
+ </button>
176
+ </span>
177
+ {/* always here, greyed out in fit: appearing with grid moved the groups beside it */}
178
+ <input
179
+ type="range"
180
+ className="setting-range"
181
+ min={120}
182
+ max={640}
183
+ step={20}
184
+ disabled={p.st.resultsView !== 'grid'}
185
+ value={p.st.resultsSize}
186
+ data-tip={
187
+ p.st.resultsView === 'grid' ? `image size ${p.st.resultsSize}px` : 'image size, for the grid view'
188
+ }
189
+ onChange={(e) => p.st.setResultsSize(Number(e.target.value))}
190
+ />
191
+ </span>
192
+ </div>
193
+ <div className="head-group-labeled">
194
+ <span className="group-caption">
195
+ blur <span className="kbd-hint">{MOD_KEY}B</span>
196
+ </span>
197
+ <span className="btn-group">
198
+ <button
199
+ type="button"
200
+ className={p.st.blurResults ? 'sel' : ''}
201
+ data-tip={
202
+ p.st.blurResults
203
+ ? `blurred until you hover: click (or ${MOD_KEY}B) for always clear`
204
+ : `always clear: click (or ${MOD_KEY}B) to blur until you hover`
205
+ }
206
+ onClick={() => p.st.toggleBlur()}
207
+ >
208
+ <Icon name={p.st.blurResults ? 'eye-off' : 'eye'} />
209
+ </button>
210
+ </span>
211
+ </div>
212
+ </div>
213
+ )
214
+ })
215
+
216
+ /** below this width two side by side panels leave the form unusable, so a side placement
217
+ * stacks: the chosen mode adapting, the button stays lit */
218
+ const SPLIT_MIN_WIDTH = 760
219
+
220
+ function useNarrow(): boolean {
221
+ const query = `(max-width: ${SPLIT_MIN_WIDTH}px)`
222
+ const [narrow, setNarrow] = useState(() => window.matchMedia(query).matches)
223
+ useEffect(() => {
224
+ const mq = window.matchMedia(query)
225
+ const on = (): void => setNarrow(mq.matches)
226
+ mq.addEventListener('change', on)
227
+ return () => mq.removeEventListener('change', on)
228
+ }, [query])
229
+ return narrow
230
+ }
231
+
232
+ /** the sizes you drag are kept in this browser; a blocked storage just forgets them */
233
+ const splitStorage = {
234
+ getItem: (key: string): string | null => {
235
+ try {
236
+ return localStorage.getItem(key)
237
+ } catch {
238
+ return null
239
+ }
240
+ },
241
+ setItem: (key: string, value: string): void => {
242
+ try {
243
+ localStorage.setItem(key, value)
244
+ } catch {
245
+ // storage full or blocked: the split just is not remembered
246
+ }
247
+ },
248
+ }
249
+
250
+ const SplitWork = observer(function SplitWork(p: { st: WebSt; left: boolean; form: ReactNode; results: ReactNode }) {
251
+ // one remembered layout per side: dragging the left split does not move the right one
252
+ const id = p.left ? 'comfy-ts-split-left' : 'comfy-ts-split-right'
253
+ const saved = useDefaultLayout({ id, storage: splitStorage })
254
+ const formPanel = (
255
+ <Panel id="form" minSize="30%" className="split-panel split-form">
256
+ {p.form}
257
+ </Panel>
258
+ )
259
+ const resultsPanel = (
260
+ <Panel id="results" defaultSize="34%" minSize="16%" className="split-panel split-results">
261
+ {p.results}
262
+ </Panel>
263
+ )
264
+ return (
265
+ <Group
266
+ key={id}
267
+ id={id}
268
+ orientation="horizontal"
269
+ // NOT the layout-side / layout-left classes: those style the stacked page, and one of
270
+ // their rules (align-items: flex-start) kept the panels from stretching to the window,
271
+ // so they grew with the form and the window cut it off, with nothing to scroll
272
+ className={`work split split-${p.left ? 'left' : 'right'}`}
273
+ defaultLayout={saved.defaultLayout}
274
+ onLayoutChanged={saved.onLayoutChanged}
275
+ >
276
+ {p.left ? resultsPanel : formPanel}
277
+ <Separator className="split-handle" />
278
+ {p.left ? formPanel : resultsPanel}
279
+ </Group>
280
+ )
281
+ })
282
+
37
283
  export const App = observer(function App(p: { st: WebSt }) {
284
+ const narrow = useNarrow()
38
285
  useSelectAllInFields()
286
+ useOmniboxShortcut(p.st)
39
287
  if (p.st.phase === 'loading') return <div className="center">loading…</div>
40
288
  if (p.st.phase === 'error')
41
289
  return (
@@ -43,50 +291,94 @@ export const App = observer(function App(p: { st: WebSt }) {
43
291
  <div className="error">🔴 {p.st.bootError}</div>
44
292
  </div>
45
293
  )
294
+ const layout = p.st.layout
295
+ const formCol = (
296
+ <div className="form-col">
297
+ <VarsForm st={p.st} />
298
+ {/* the ComfyUI console, only while asked for (it polls) */}
299
+ {p.st.showLogs ? (
300
+ <div className="logs">
301
+ <div className="logs-head">
302
+ {/* the host the lines actually come from (pullLogs uses hostFor),
303
+ not the module's declared default */}
304
+ <span>console · {p.st.hostFor(p.st.form?.moduleKey ?? '') || 'host'}</span>
305
+ <button type="button" className="link" onClick={() => p.st.toggleLogs()}>
306
+ hide
307
+ </button>
308
+ </div>
309
+ {p.st.logsError != null ? <div className="error">🔴 {p.st.logsError}</div> : null}
310
+ <pre>{p.st.logLines.join('\n')}</pre>
311
+ </div>
312
+ ) : null}
313
+ </div>
314
+ )
315
+ const resultsCol = (
316
+ <div className="results-col">
317
+ <ResultsHead st={p.st} />
318
+ {p.st.generateInResults ? (
319
+ <div className="results-run">
320
+ <GenerateButton st={p.st} />
321
+ {/* one line, always reserved: an error arriving never pushes the gallery down */}
322
+ <span className="run-error" data-tip={p.st.run.error ?? undefined}>
323
+ {p.st.run.error == null ? '' : `🔴 ${p.st.run.error}`}
324
+ </span>
325
+ </div>
326
+ ) : null}
327
+ <LivePreviews st={p.st} />
328
+ <Gallery st={p.st} compact={layout === 'pinned'} />
329
+ </div>
330
+ )
331
+ const notices = (
332
+ <>
333
+ {p.st.formError != null ? <div className="center error">🔴 {p.st.formError}</div> : null}
334
+ {p.st.formLoading && p.st.form == null ? <div className="center">loading draft…</div> : null}
335
+ {p.st.modules.length === 0 ? <div className="center">no workflow modules loaded</div> : null}
336
+ </>
337
+ )
338
+ // left / right on a screen wide enough: two FULL-HEIGHT panels, each scrolling on its own,
339
+ // split by a handle you drag. Everything else is one scrolling page
340
+ const split = (layout === 'side' || layout === 'left') && !narrow
46
341
  return (
47
342
  <div className="app">
48
343
  <div className="cols">
49
- {p.st.sidebarOpen ? <div className="backdrop" onClick={() => p.st.toggleSidebar()} /> : null}
50
- {p.st.sidebarOpen ? <Sidebar st={p.st} /> : null}
51
- <div className="main">
52
- {p.st.formError != null ? <div className="center error">🔴 {p.st.formError}</div> : null}
53
- {p.st.formLoading && p.st.form == null ? <div className="center">loading draft…</div> : null}
54
- {p.st.modules.length === 0 ? <div className="center">no workflow modules loaded</div> : null}
55
- {/* the layout buttons drive ONE class, and it is the whole truth: the selected
56
- button always names where the panel is */}
57
- <div className={`work layout-${p.st.layout}`}>
58
- <div className="form-col">
59
- <VarsForm st={p.st} />
60
- {/* the ComfyUI console, only while asked for (it polls) */}
61
- {p.st.showLogs ? (
62
- <div className="logs">
63
- <div className="logs-head">
64
- {/* the host the lines actually come from (pullLogs uses hostFor),
65
- not the module's declared default */}
66
- <span>console · {p.st.hostFor(p.st.form?.moduleKey ?? '') || 'host'}</span>
67
- <button type="button" className="link" onClick={() => p.st.toggleLogs()}>
68
- hide
69
- </button>
70
- </div>
71
- {p.st.logsError != null ? <div className="error">🔴 {p.st.logsError}</div> : null}
72
- <pre>{p.st.logLines.join('\n')}</pre>
73
- </div>
74
- ) : null}
344
+ {split ? (
345
+ <SplitWork
346
+ st={p.st}
347
+ left={layout === 'left'}
348
+ form={
349
+ <>
350
+ {notices}
351
+ {formCol}
352
+ </>
353
+ }
354
+ results={resultsCol}
355
+ />
356
+ ) : (
357
+ <div className="main">
358
+ {notices}
359
+ {/* the layout buttons drive ONE class, and it is the whole truth: the selected
360
+ button always names where the panel is */}
361
+ <div className={`work layout-${layout}`}>
362
+ {formCol}
363
+ {layout === 'off' ? (
364
+ // the panel took its buttons with it: this is the way back
365
+ <button
366
+ type="button"
367
+ className="show-preview"
368
+ data-tip="show the preview panel again"
369
+ onClick={() => p.st.showPreview()}
370
+ >
371
+ <Icon name="panel-side" /> preview
372
+ </button>
373
+ ) : (
374
+ resultsCol
375
+ )}
75
376
  </div>
76
- {p.st.layout === 'off' ? null : (
77
- <div className="results-col">
78
- {p.st.generateInResults ? (
79
- <div className="results-run">
80
- <GenerateButton st={p.st} />
81
- {p.st.run.error != null ? <span className="error">🔴 {p.st.run.error}</span> : null}
82
- </div>
83
- ) : null}
84
- <Gallery st={p.st} compact={p.st.layout === 'pinned'} />
85
- </div>
86
- )}
87
377
  </div>
88
- </div>
378
+ )}
89
379
  </div>
380
+ <Omnibox st={p.st} />
381
+ <TooltipLayer />
90
382
  </div>
91
383
  )
92
384
  })
@@ -6,6 +6,7 @@ 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'
@@ -297,11 +298,53 @@ const LiveText = observer(function LiveText(p: { text: string }) {
297
298
  )
298
299
  })
299
300
 
301
+ /** the corner mode: the run as a small card floating over the gallery's top right corner, on a
302
+ * zero-height sticky anchor, so it takes no room. The last image stays where it is while the
303
+ * next one runs, and the finished one lands at the top in one go */
304
+ const CornerRun = observer(function CornerRun(p: { st: WebSt; local: GalleryLocal; module: string }) {
305
+ const percent = p.st.run.progressPercent
306
+ const node = p.st.run.progressNode
307
+ const count = p.st.run.progressCount
308
+ return (
309
+ <div className="corner-run-anchor">
310
+ <div className="corner-run">
311
+ {p.st.run.hasPreview ? (
312
+ <button
313
+ type="button"
314
+ className="img-button"
315
+ data-tip="the latent so far: click to see it big"
316
+ onClick={() =>
317
+ p.local.openLightbox({
318
+ kind: 'latent',
319
+ module: p.module,
320
+ after: p.st.run.results.filter((r) => r.module === p.module).length,
321
+ })
322
+ }
323
+ >
324
+ <img src={runPreviewSrc({ module: p.module, tick: p.st.run.previewTick })} alt="latent preview" />
325
+ </button>
326
+ ) : null}
327
+ <div className="corner-run-meta">
328
+ <span className="run-meta-text">
329
+ {node == null ? p.module : node}
330
+ {count != null ? ` ${count.value}/${count.max}` : ''}
331
+ </span>
332
+ <span>{percent != null ? `${Math.round(percent)}%` : ''}</span>
333
+ </div>
334
+ <div className="progress-track">
335
+ <div className="progress-fill" style={{ width: `${percent ?? 0}%` }} />
336
+ </div>
337
+ </div>
338
+ </div>
339
+ )
340
+ })
341
+
300
342
  /** live card while a run is in flight: progress bar + the latest latent frame */
301
343
  const RunningCard = observer(function RunningCard(p: { st: WebSt; local: GalleryLocal }) {
302
344
  // the RUNNING module, never the selection: switching modules mid-run must not retarget the card
303
345
  const moduleKey = p.st.run.runningModule
304
346
  if (!p.st.run.isRunning || moduleKey == null) return null
347
+ if (p.st.latentMode === 'corner') return <CornerRun st={p.st} local={p.local} module={moduleKey} />
305
348
  const percent = p.st.run.progressPercent
306
349
  const previewUrl = runPreviewSrc({ module: moduleKey, tick: p.st.run.previewTick })
307
350
  // the node's OWN counter: generated tokens on a text node, sampler steps on a KSampler.
@@ -309,41 +352,63 @@ const RunningCard = observer(function RunningCard(p: { st: WebSt; local: Gallery
309
352
  const node = p.st.run.progressNode
310
353
  const count = p.st.run.progressCount
311
354
  const liveText = p.st.run.progressText
355
+ // the frame is RESERVED from the first moment at the image's own ratio (the size var of the
356
+ // running workflow) and the box a finished image takes (.run-card img: 320px max each way),
357
+ // the bar drawn over its foot, the node counter on the one header line: nothing grows while
358
+ // the run goes and the result lands in the same space
359
+ const form = p.st.form
360
+ const sizeVar = form?.moduleKey === moduleKey ? form.vars.find((v) => v.desc.kind === 'size') : undefined
361
+ const size = sizeVar == null ? null : asSizeForm(sizeVar.value)
362
+ const imageGraph = size != null || p.st.run.hasPreview
363
+ const ratio = size == null ? 1 : size.width / size.height
312
364
  return (
313
365
  <div className="run-card running">
314
366
  <div className="meta">
315
- <span>generating {moduleKey}…</span>
367
+ <span className="run-meta-text">
368
+ generating {moduleKey}…
369
+ {node != null ? ` · ${node}${count != null ? ` ${count.value}/${count.max}` : ''}` : ''}
370
+ </span>
316
371
  <span>{percent != null ? `${Math.round(percent)}%` : ''}</span>
317
372
  </div>
318
- {node != null ? (
319
- <div className="run-node">
320
- {node}
321
- {count != null ? ` ${count.value}/${count.max}` : ''}
322
- </div>
323
- ) : null}
324
373
  {/* a node streaming its text as it produces it: the answer builds up here before the
325
374
  run ends. Same fold as a finished result, so watching and reading look alike */}
326
375
  {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>
376
+ {imageGraph ? (
377
+ <div
378
+ className="run-frame"
379
+ style={{
380
+ aspectRatio: String(ratio),
381
+ // the box the finished image will take in the current view, so it lands in place
382
+ width:
383
+ p.st.resultsView === 'fit'
384
+ ? '100%'
385
+ : `min(100%, ${p.st.resultsSize}px, calc(${p.st.resultsSize}px * ${ratio}))`,
386
+ }}
387
+ >
388
+ {p.st.run.hasPreview && p.st.latentMode === 'full' ? (
389
+ <button
390
+ type="button"
391
+ className="img-button"
392
+ onClick={() =>
393
+ p.local.openLightbox({
394
+ kind: 'latent',
395
+ module: moduleKey,
396
+ after: p.st.run.results.filter((r) => r.module === moduleKey).length,
397
+ })
398
+ }
399
+ >
400
+ <img src={previewUrl} alt="latent preview" />
401
+ </button>
402
+ ) : null}
403
+ <div className="progress-track over">
404
+ <div className="progress-fill" style={{ width: `${percent ?? 0}%` }} />
405
+ </div>
345
406
  </div>
346
- ) : null}
407
+ ) : (
408
+ <div className="progress-track">
409
+ <div className="progress-fill" style={{ width: `${percent ?? 0}%` }} />
410
+ </div>
411
+ )}
347
412
  </div>
348
413
  )
349
414
  })
@@ -356,7 +421,11 @@ export const Gallery = observer(function Gallery(p: { st: WebSt; compact?: boole
356
421
  if (p.st.run.results.length === 0 && !p.st.run.isRunning) return null
357
422
  const results = p.compact === true ? p.st.run.results.slice(0, 1) : p.st.run.results
358
423
  return (
359
- <div className="gallery">
424
+ // fit: one per row at the panel's width; grid: the slider's size, wrapping. The corner
425
+ // placement keeps its own compact look
426
+ <div
427
+ className={`gallery${p.st.blurResults ? ' blur' : ''}${p.compact === true ? '' : ` view-${p.st.resultsView}`}`}
428
+ >
360
429
  <RunningCard st={p.st} local={local} />
361
430
  {/* the count and clear-all moved onto the run line beside the generate button: two
362
431
  headers for one idea is a header too many */}
@@ -394,7 +463,15 @@ export const Gallery = observer(function Gallery(p: { st: WebSt; compact?: boole
394
463
  })
395
464
  }}
396
465
  >
397
- <img src={img.url} alt={img.filename} />
466
+ <img
467
+ src={img.url}
468
+ alt={img.filename}
469
+ style={
470
+ p.st.resultsView === 'grid' && p.compact !== true
471
+ ? { maxWidth: `min(100%, ${p.st.resultsSize}px)`, maxHeight: p.st.resultsSize }
472
+ : undefined
473
+ }
474
+ />
398
475
  </button>
399
476
  {/* the EMBEDDING page's buttons (host protocol): what it does with the
400
477
  image is its business — send it somewhere, keep it as something */}