comfy-ts 2.12.0 → 2.14.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 (81) hide show
  1. package/dist/{LogsSt-U1H0mP1m.js → LogsSt-CUeo843w.js} +18 -4
  2. package/dist/LogsSt-CUeo843w.js.map +1 -0
  3. package/dist/cli.js +4 -4
  4. package/dist/index.cjs +123 -12
  5. package/dist/index.cjs.map +1 -1
  6. package/dist/index.d.cts +96 -16
  7. package/dist/index.d.ts +96 -16
  8. package/dist/index.js +123 -12
  9. package/dist/index.js.map +1 -1
  10. package/dist/{run-serve-BeAznay5.js → run-serve-DUqcn0h3.js} +477 -63
  11. package/dist/run-serve-DUqcn0h3.js.map +1 -0
  12. package/dist/{run-tui-BTGjvnKk.js → run-tui-D-LaSqgB.js} +4 -4
  13. package/dist/{run-tui-BTGjvnKk.js.map → run-tui-D-LaSqgB.js.map} +1 -1
  14. package/dist/{schemaDrift-Cg39vs53.js → schemaDrift-E95iTF7E.js} +4 -1
  15. package/dist/{schemaDrift-Cg39vs53.js.map → schemaDrift-E95iTF7E.js.map} +1 -1
  16. package/dist/serve-web.js +378 -141
  17. package/dist/{state-C7REnHan.js → state-BytbdZ8s.js} +122 -14
  18. package/dist/state-BytbdZ8s.js.map +1 -0
  19. package/dist/web.d.ts +96 -16
  20. package/dist/web.js +123 -12
  21. package/dist/web.js.map +1 -1
  22. package/examples/comfy-cloud/sdk.d.ts +163 -163
  23. package/examples/rvion/10-anima-t2i.cflow.ts +48 -25
  24. package/examples/rvion/11-yue2-t2a.cflow.ts +105 -0
  25. package/examples/rvion/12-stable-audio-3-t2a.cflow.ts +78 -0
  26. package/examples/rvion/13-ace-step-15-xl-t2a.cflow.ts +153 -0
  27. package/examples/rvion/stableAudio3Prompts.ts +19 -0
  28. package/package.json +2 -2
  29. package/src/cli/serve/ServeApp.ts +224 -77
  30. package/src/cli/serve/byteRange.ts +48 -0
  31. package/src/cli/serve/resultHistory.ts +125 -0
  32. package/src/cli/serve/run-serve.ts +12 -3
  33. package/src/cli/serve/runError.ts +23 -0
  34. package/src/cli/serve/serveSettings.ts +17 -1
  35. package/src/cli/serve/web/api.ts +53 -2
  36. package/src/cli/serve/web/components/App.tsx +311 -160
  37. package/src/cli/serve/web/components/DraftTabs.tsx +167 -0
  38. package/src/cli/serve/web/components/Gallery.tsx +75 -25
  39. package/src/cli/serve/web/components/Icon.tsx +44 -0
  40. package/src/cli/serve/web/components/MemoryBudget.tsx +98 -0
  41. package/src/cli/serve/web/components/Omnibox.tsx +70 -20
  42. package/src/cli/serve/web/components/RunError.tsx +19 -0
  43. package/src/cli/serve/web/components/ShortcutsModal.tsx +54 -0
  44. package/src/cli/serve/web/components/SideMenu.tsx +428 -0
  45. package/src/cli/serve/web/components/TooltipLayer.tsx +3 -2
  46. package/src/cli/serve/web/components/VarsForm.tsx +141 -404
  47. package/src/cli/serve/web/components/controls/BasicControls.tsx +8 -1
  48. package/src/cli/serve/web/components/controls/LorasControl.tsx +30 -25
  49. package/src/cli/serve/web/promptEditor/promptExtensions.ts +9 -4
  50. package/src/cli/serve/web/state/EnhancerSt.ts +17 -2
  51. package/src/cli/serve/web/state/FormSt.ts +22 -2
  52. package/src/cli/serve/web/state/OmniboxSt.ts +3 -1
  53. package/src/cli/serve/web/state/RunSt.ts +61 -3
  54. package/src/cli/serve/web/state/WebSt.ts +198 -35
  55. package/src/cli/serve/web/state/draftNames.ts +16 -0
  56. package/src/cli/serve/web/state/draftTabs.ts +75 -0
  57. package/src/cli/serve/web/state/formRows.ts +9 -0
  58. package/src/cli/serve/web/state/generateButton.ts +1 -1
  59. package/src/cli/serve/web/state/keptResults.ts +26 -0
  60. package/src/cli/serve/web/state/lightbox.ts +17 -0
  61. package/src/cli/serve/web/state/omnibox.ts +82 -18
  62. package/src/cli/serve/web/state/shortcutCatalog.ts +100 -0
  63. package/src/cli/serve/web/state/shortcuts.ts +66 -7
  64. package/src/cli/serve/web/styles.ts +327 -93
  65. package/src/cli/serve/workflowTags.ts +42 -0
  66. package/src/cli/serve/workspaceLabels.ts +23 -0
  67. package/src/cli/tui/state/DraftsSt.ts +10 -6
  68. package/src/coreExports.ts +1 -0
  69. package/src/host/ComfyHost.ts +17 -2
  70. package/src/host/ResilientWebsocket.ts +54 -4
  71. package/src/runner/ComfyExecution.ts +60 -0
  72. package/src/runner/ComfyWorkflow.ts +4 -0
  73. package/src/runner/ComfyWsApi.ts +2 -0
  74. package/src/runner/MediaImage.ts +2 -2
  75. package/src/sdk-generator/ComfyUIObjectInfoTypes.ts +5 -5
  76. package/src/sdk-generator/comfyui-sdk-codegen.ts +1 -1
  77. package/src/utils/copyName.ts +12 -0
  78. package/src/vars/DefinedWorkflow.ts +7 -1
  79. package/dist/LogsSt-U1H0mP1m.js.map +0 -1
  80. package/dist/run-serve-BeAznay5.js.map +0 -1
  81. package/dist/state-C7REnHan.js.map +0 -1
@@ -1,11 +1,13 @@
1
1
  // the var rows: each kind dispatches to its matching control (the point of the
2
2
  // web ui — architecture item 12) + the sticky run bar
3
- import { observer, useLocalObservable } from 'mobx-react-lite'
4
- import { useEffect, useRef, type ReactNode } from 'react'
3
+ import { observer } from 'mobx-react-lite'
4
+ import { useEffect, useRef, type HTMLAttributes, type ReactNode } from 'react'
5
5
  import { MOD_KEY } from 'src/cli/serve/web/components/modKey.ts'
6
+ import { RunError } from 'src/cli/serve/web/components/RunError.tsx'
6
7
  import { runChipText } from 'src/cli/serve/web/state/stableSlots.ts'
7
- import { jumpTargets, SHORTCUT_KEYS, shortcutOf } from 'src/cli/serve/web/state/shortcuts.ts'
8
+ import { isNewJump, jumpTargets, SHORTCUT_KEYS, shortcutOf } from 'src/cli/serve/web/state/shortcuts.ts'
8
9
  import { isPromptLanes } from 'src/vars/lanes.ts'
10
+ import { formRowNames, OUTPUT_ROW } from 'src/cli/serve/web/state/formRows.ts'
9
11
  import {
10
12
  ChoiceControl,
11
13
  NumberControl,
@@ -21,7 +23,7 @@ import { ImageControl } from 'src/cli/serve/web/components/controls/ImageControl
21
23
  import { LorasControl } from 'src/cli/serve/web/components/controls/LorasControl.tsx'
22
24
  import { SeedControl } from 'src/cli/serve/web/components/controls/SeedControl.tsx'
23
25
  import { SizeControl } from 'src/cli/serve/web/components/controls/SizeControl.tsx'
24
- import type { FormSt, VarSt } from 'src/cli/serve/web/state/FormSt.ts'
26
+ import type { VarSt } from 'src/cli/serve/web/state/FormSt.ts'
25
27
  import type { WebSt } from 'src/cli/serve/web/state/WebSt.ts'
26
28
 
27
29
  const VarControl = observer(function VarControl(p: {
@@ -68,6 +70,36 @@ const VarControl = observer(function VarControl(p: {
68
70
  }
69
71
  })
70
72
 
73
+ /** a form row's reorder wiring: the row takes the drop, its label is the handle */
74
+ function rowDrag(p: { st: WebSt; module: string; names: readonly string[]; index: number }): {
75
+ row: Pick<HTMLAttributes<HTMLDivElement>, 'onDragOver' | 'onDrop'>
76
+ handle: Pick<HTMLAttributes<HTMLDivElement>, 'draggable' | 'onDragStart'>
77
+ } {
78
+ return {
79
+ row: {
80
+ onDragOver: (e) => {
81
+ // only a row drag: a file dropped on an image var must still reach its own handler
82
+ if (e.dataTransfer.types.includes('application/x-comfy-var')) e.preventDefault()
83
+ },
84
+ onDrop: (e) => {
85
+ const raw = e.dataTransfer.getData('application/x-comfy-var')
86
+ if (raw === '') return
87
+ e.preventDefault()
88
+ const from = Number(raw)
89
+ if (Number.isInteger(from) && from !== p.index)
90
+ p.st.moveVar({ module: p.module, names: p.names, from, to: p.index })
91
+ },
92
+ },
93
+ handle: {
94
+ draggable: true,
95
+ onDragStart: (e) => {
96
+ e.dataTransfer.effectAllowed = 'move'
97
+ e.dataTransfer.setData('application/x-comfy-var', String(p.index))
98
+ },
99
+ },
100
+ }
101
+ }
102
+
71
103
  const VarRow = observer(function VarRow(p: {
72
104
  v: VarSt
73
105
  host: string
@@ -83,8 +115,10 @@ const VarRow = observer(function VarRow(p: {
83
115
  const rowRef = useRef<HTMLDivElement>(null)
84
116
  const jump = p.st.jump
85
117
  const jumpKind = p.jumpKey == null ? null : p.v.desc.kind
118
+ const seenJump = useRef(jump?.seq ?? 0)
86
119
  useEffect(() => {
87
- if (jump == null || jumpKind !== 'prompt' || jump.kind !== 'prompt') return
120
+ if (jumpKind !== 'prompt' || !isNewJump(jump, 'prompt', seenJump.current)) return
121
+ seenJump.current = jump?.seq ?? 0
88
122
  const editor = rowRef.current?.querySelector<HTMLElement>('.cm-content')
89
123
  editor?.focus()
90
124
  editor?.scrollIntoView({ block: 'nearest' })
@@ -94,6 +128,7 @@ const VarRow = observer(function VarRow(p: {
94
128
  const ui = p.v.desc.ui
95
129
  const inactive = p.st.form?.inactiveReason(p.v) ?? null
96
130
  const wide = p.v.desc.kind === 'loras' || p.v.desc.kind === 'prompt'
131
+ const drag = rowDrag(p)
97
132
  return (
98
133
  <div
99
134
  ref={rowRef}
@@ -105,29 +140,23 @@ const VarRow = observer(function VarRow(p: {
105
140
  outline: ui?.border == null ? undefined : `1px solid ${ui.border}`,
106
141
  outlineOffset: ui?.border == null ? undefined : '-1px',
107
142
  }}
108
- onDragOver={(e) => {
109
- // only a row drag: a file dropped on an image var must still reach its own handler
110
- if (e.dataTransfer.types.includes('application/x-comfy-var')) e.preventDefault()
111
- }}
112
- onDrop={(e) => {
113
- const raw = e.dataTransfer.getData('application/x-comfy-var')
114
- if (raw === '') return
115
- e.preventDefault()
116
- const from = Number(raw)
117
- if (Number.isInteger(from) && from !== p.index)
118
- p.st.moveVar({ module: p.module, names: p.names, from, to: p.index })
119
- }}
143
+ {...drag.row}
120
144
  >
145
+ {/* in the form's left gutter: back to the workflow's default. Always there (disabled at
146
+ the default), so no row moves when a value changes */}
147
+ <button
148
+ type="button"
149
+ className="var-reset"
150
+ disabled={p.v.isAtDefault}
151
+ data-tip={p.v.isAtDefault ? 'at the workflow default' : 'reset to the workflow default'}
152
+ aria-label="reset to the workflow default"
153
+ onClick={() => p.v.resetToDefault()}
154
+ >
155
+ <Icon name="refresh" size={0.95} />
156
+ </button>
121
157
  {/* the LABEL is the handle: a separate grip was one more piece of permanent chrome
122
158
  for something the label itself can carry */}
123
- <div
124
- className={p.jumpKey == null ? 'var-label' : 'var-label has-kbd'}
125
- draggable
126
- onDragStart={(e) => {
127
- e.dataTransfer.effectAllowed = 'move'
128
- e.dataTransfer.setData('application/x-comfy-var', String(p.index))
129
- }}
130
- >
159
+ <div className={p.jumpKey == null ? 'var-label' : 'var-label has-kbd'} {...drag.handle}>
131
160
  {/* the kind is a TOOLTIP, not a second line: printed under every label it was a
132
161
  column of noise you read past, and it only ever answers a question you ask once */}
133
162
  {/* the (?) LEADS: labels are right-aligned against their control, so what trails a
@@ -199,242 +228,82 @@ function LabelResizer(p: { st: WebSt }): ReactNode {
199
228
  )
200
229
  }
201
230
 
202
- /** `new`, `new 2`, … the first name no draft of this workflow has */
203
- function freeDraftName(drafts: readonly string[]): string {
204
- if (!drafts.includes('new')) return 'new'
205
- let n = 2
206
- while (drafts.includes(`new ${n}`)) n++
207
- return `new ${n}`
208
- }
209
-
210
- /** the draft box: name, autosave state as its legend, and the actions that own this draft.
211
- * new and duplicate ask for the name INLINE, window.prompt is silently suppressed by browsers
212
- * after a few dialogs, which reads exactly like a dead button */
213
- const DraftBox = observer(function DraftBox(p: { st: WebSt; form: FormSt }) {
214
- const local = useLocalObservable(() => ({
215
- /** null = showing the picker; otherwise the pending name and what it will do */
216
- mode: null as null | 'duplicate' | 'rename' | 'new',
217
- name: '',
218
- start(mode: 'duplicate' | 'rename' | 'new', from: string) {
219
- this.mode = mode
220
- this.name = mode === 'duplicate' ? `${from} copy` : from
221
- },
222
- set(v: string) {
223
- this.name = v
224
- },
225
- stop() {
226
- this.mode = null
227
- },
228
- }))
229
- const drafts = p.st.moduleByKey(p.form.moduleKey)?.drafts ?? [p.form.draft]
230
- const confirm = (): void => {
231
- const name = local.name.trim()
232
- const mode = local.mode
233
- local.stop()
234
- if (name === '' || mode == null) return
235
- if (mode === 'duplicate') void p.st.duplicateDraft(name)
236
- else if (mode === 'new') void p.st.newDraft(name)
237
- else void p.st.renameDraft(name)
238
- }
231
+ /** everything about running on ONE row: Run with its stop square beside it (red while a run is
232
+ * in progress, grey otherwise), then the two buttons that clear something, each carrying the
233
+ * count it acts on. Every part is always there (disabled when it has nothing to act on), and
234
+ * the counts have tabular digits, so the row never shifts */
235
+ export const GenerateButton = observer(function GenerateButton(p: { st: WebSt }) {
236
+ const run = p.st.run
237
+ // the text never changes, so the button never changes size: the progress is a fill sweeping
238
+ // across it, the exact percent is on the running card
239
+ const look = generateButtonLook({ isRunning: run.isRunning, percent: run.progressPercent })
240
+ const pending = runChipText({ kind: 'queue', count: run.pendingCount }).count
241
+ const images = runChipText({ kind: 'results', count: run.results.length }).count
239
242
  return (
240
- <div className="head-box">
241
- <span className="head-label">
242
- draft
243
- <span className={p.form.saveState === 'error' ? 'save-state error' : 'save-state'}>
244
- {p.form.saveState === 'saving' ? '· saving' : null}
245
- {p.form.saveState === 'saved' ? '· saved' : null}
246
- {p.form.saveState === 'error' ? '· NOT SAVED' : null}
247
- </span>
248
- </span>
249
- {local.mode != null ? (
250
- <input
251
- type="text"
252
- autoFocus
253
- className="head-input"
254
- value={local.name}
255
- // enter is the ONLY commit now, so it has to be said
256
- placeholder={
257
- local.mode === 'rename'
258
- ? 'new name, then enter'
259
- : local.mode === 'new'
260
- ? 'name of the new draft (workflow defaults), then enter'
261
- : 'new draft name, then enter'
243
+ <span className="run-bar">
244
+ <span className="btn-group run-split">
245
+ <button
246
+ type="button"
247
+ className={look.running ? 'primary running' : 'primary'}
248
+ data-tip={
249
+ look.running
250
+ ? `running ${look.fill ?? 0}%: click again to queue another (⌘⏎ / ctrl+⏎)`
251
+ : '⌘⏎ / ctrl+⏎: click again to queue another'
262
252
  }
263
- onFocus={(e) => e.currentTarget.select()}
264
- onChange={(e) => local.set(e.target.value)}
265
- onKeyDown={(e) => {
266
- if (e.key === 'Enter') confirm()
267
- if (e.key === 'Escape') local.stop()
268
- }}
269
- // blur CANCELS, it does not commit: picking another draft blurs this input, and a
270
- // rename committed on blur raced that selection, renameDraft bails when the form
271
- // has already moved on, leaving a duplicate instead of a rename, silently. enter
272
- // commits, which is the only unambiguous signal
273
- onBlur={() => local.stop()}
274
- />
275
- ) : (
276
- /* the name IS the picker: every draft of this workflow, switching selects it. Rename
277
- sits before it and delete after it: the two actions ON this name, around it */
278
- <span className="head-line draft-line">
279
- <button
280
- type="button"
281
- className="head-icon"
282
- data-tip="rename this draft (the file is renamed)"
283
- onClick={() => local.start('rename', p.form.draft)}
284
- >
285
- <Icon name="pen" />
286
- </button>
287
- <select
288
- className="head-select draft"
289
- value={p.form.draft}
290
- data-tip="switch draft"
291
- onChange={(e) => void p.st.select({ module: p.form.moduleKey, draft: e.target.value })}
292
- >
293
- {drafts.map((d) => (
294
- <option key={d} value={d}>
295
- {d}
296
- </option>
297
- ))}
298
- </select>
299
- <button
300
- type="button"
301
- className="head-icon danger"
302
- data-tip="delete this draft's file (default resets to the workflow's own values)"
303
- onClick={() => {
304
- if (window.confirm(`delete draft '${p.form.draft}' of ${p.form.moduleKey}? the file is removed.`))
305
- void p.st.deleteDraft({ module: p.form.moduleKey, draft: p.form.draft })
306
- }}
307
- >
308
- <Icon name="trash" />
309
- </button>
310
- </span>
311
- )}
312
- <span className="head-line">
313
- {/* the two ways to MAKE a draft, side by side: from the workflow's defaults, or from
314
- what is on screen */}
315
- <span className="btn-group">
316
- <button
317
- type="button"
318
- className="accent"
319
- data-tip="new draft with the workflow's own default values"
320
- onClick={() => (local.mode != null ? confirm() : local.start('new', freeDraftName(drafts)))}
321
- >
322
- <Icon name="plus" /> new
323
- </button>
324
- <button
325
- type="button"
326
- className="accent"
327
- data-tip="save these values as a new draft"
328
- onClick={() => (local.mode != null ? confirm() : local.start('duplicate', p.form.draft))}
329
- >
330
- <Icon name="copy-plus" /> copy
331
- </button>
332
- </span>
333
- {/* FAR RIGHT of the same line, outside the group: inside it, the broom appeared and
334
- vanished with the dirty count and shoved the other buttons sideways */}
335
- {p.form.dirtyCount > 0 ? (
336
- <button
337
- type="button"
338
- className="dirty head-right"
339
- data-tip={`${p.form.dirtyCount} var${p.form.dirtyCount > 1 ? 's' : ''} changed this session — revert to the values this draft loaded with`}
340
- onClick={() => p.form.revertAll()}
341
- >
342
- <Icon name="broom" />
343
- </button>
344
- ) : null}
253
+ style={
254
+ look.fill == null
255
+ ? undefined
256
+ : {
257
+ background: `linear-gradient(90deg, var(--accent) ${look.fill}%, var(--accent-dim) ${look.fill}%)`,
258
+ }
259
+ }
260
+ onClick={() => p.st.generate()}
261
+ >
262
+ <Icon name="play" size={0.85} /> {look.label}
263
+ {/* the shortcut is SAID, not only tooltipped: nobody hovers a button they can click */}
264
+ <span className="kbd-hint">{MOD_KEY}⏎</span>
265
+ </button>
266
+ <button
267
+ type="button"
268
+ className={run.isRunning ? 'run-stop live' : 'run-stop'}
269
+ disabled={!run.isRunning}
270
+ data-tip="stop the run in progress (the queue behind it stays)"
271
+ onClick={() => void p.st.hostAction('interrupt')}
272
+ >
273
+ <Icon name="stop" />
274
+ </button>
345
275
  </span>
346
- </div>
347
- )
348
- })
349
-
350
- function RunChip(p: {
351
- kind: 'queue' | 'results'
352
- count: number
353
- tip: string
354
- clearTip: string
355
- canClear: boolean
356
- onClear(): void
357
- }): ReactNode {
358
- const t = runChipText({ kind: p.kind, count: p.count })
359
- // an icon and a count, the word in the tooltip: the results panel can be narrow
360
- return (
361
- <span className={p.count > 0 ? 'run-chip' : 'run-chip empty'} data-tip={`${t.label}: ${p.tip}`}>
362
- <Icon name={p.kind === 'queue' ? 'rows' : 'image'} size={0.95} />
363
- <span className="run-chip-count">{t.count}</span>
364
276
  <button
365
277
  type="button"
366
- className="run-chip-clear"
367
- data-tip={p.clearTip}
368
- aria-label={`clear the ${t.label}`}
369
- disabled={!p.canClear}
370
- onClick={() => p.onClear()}
278
+ className="run-end"
279
+ disabled={run.pendingCount === 0}
280
+ data-tip={`drop the ${run.pendingCount} prompt(s) not yet sent to the host`}
281
+ onClick={() => run.clearQueue()}
371
282
  >
372
- <Icon name="close" size={0.8} />
283
+ <Icon name="close" /> Clear <b className="run-num">{pending}</b> queue
373
284
  </button>
374
- </span>
375
- )
376
- }
377
-
378
- /** everything about running on one line: the button, what is queued behind it, what it has
379
- * produced. a count and one clear is the whole decision a queue offers */
380
- export const GenerateButton = observer(function GenerateButton(p: { st: WebSt }) {
381
- const run = p.st.run
382
- // the text never changes, so the button never changes size: the progress is a fill sweeping
383
- // across it, the exact percent is on the running card
384
- const look = generateButtonLook({ isRunning: run.isRunning, percent: run.progressPercent })
385
- return (
386
- <span className="run-line">
387
285
  <button
388
286
  type="button"
389
- className={look.running ? 'primary running' : 'primary'}
390
- data-tip={
391
- look.running
392
- ? `running ${look.fill ?? 0}%: click again to queue another (⌘⏎ / ctrl+⏎)`
393
- : '⌘⏎ / ctrl+⏎: click again to queue another'
394
- }
395
- style={
396
- look.fill == null
397
- ? undefined
398
- : {
399
- background: `linear-gradient(90deg, var(--accent) ${look.fill}%, var(--accent-dim) ${look.fill}%)`,
400
- }
401
- }
402
- onClick={() => p.st.generate()}
287
+ className="run-end"
288
+ disabled={run.results.length === 0}
289
+ data-tip="forget every image shown here (saved files stay on disk)"
290
+ onClick={() => run.clear()}
403
291
  >
404
- <Icon name="play" size={0.85} /> {look.label}
405
- {/* the shortcut is SAID, not only tooltipped: nobody hovers a button they can click */}
406
- <span className="kbd-hint">{MOD_KEY}⏎</span>
292
+ <Icon name="trash" /> Erase <b className="run-num">{images}</b> img
407
293
  </button>
408
- {/* both chips are ALWAYS here at one width: a chip appearing, or a count growing a
409
- digit, moved everything beside it. An empty one is dimmed, its clear disabled */}
410
- <RunChip
411
- kind="queue"
412
- count={run.queue.length}
413
- tip="prompts waiting behind this one"
414
- clearTip={`drop the ${run.pendingCount} not yet sent to the host`}
415
- canClear={run.pendingCount > 0}
416
- onClear={() => run.clearQueue()}
417
- />
418
- <RunChip
419
- kind="results"
420
- count={run.results.length}
421
- tip="runs kept in this page"
422
- clearTip="forget every run shown here"
423
- canClear={run.results.length > 0}
424
- onClear={() => run.clear()}
425
- />
426
294
  </span>
427
295
  )
428
296
  })
429
297
 
430
298
  /** where the generated images go: the same row shape as a var, because it is one more knob
431
299
  * of the run. The toggle and the folder are SERVER settings, so curl sees the same choice */
432
- const SaveRow = observer(function SaveRow(p: { st: WebSt; module: string }) {
300
+ const SaveRow = observer(function SaveRow(p: { st: WebSt; module: string; index: number; names: readonly string[] }) {
433
301
  const on = p.st.saveToDisk
302
+ const drag = rowDrag(p)
434
303
  return (
435
- <div className="var-row">
436
- <div className="var-label">
437
- <span data-tip="save — where this workflow's images go">output</span>
304
+ <div className="var-row" {...drag.row}>
305
+ <div className="var-label" {...drag.handle}>
306
+ <span data-tip={"save — where this workflow's images go\ndrag the label to reorder"}>output</span>
438
307
  </div>
439
308
  <div className="var-control">
440
309
  <div className="row-inline">
@@ -481,11 +350,14 @@ export const VarsForm = observer(function VarsForm(p: { st: WebSt }) {
481
350
  return
482
351
  }
483
352
  const s = shortcutOf(e)
484
- if (s == null) return
353
+ // the menu is page layout: App owns that key
354
+ if (s == null || s === 'toggle-menu') return
485
355
  // the jumps land in the form, which the enhancer covers: only the blur still makes sense
486
356
  if (p.st.enhancer.isOpen && s !== 'toggle-blur') return
487
357
  e.preventDefault()
488
358
  if (s === 'toggle-blur') return p.st.toggleBlur()
359
+ if (s === 'duplicate-draft') return void p.st.duplicateCurrentDraft()
360
+ if (s === 'rename-draft') return p.st.startRename()
489
361
  if (s === 'open-enhancer') {
490
362
  const f = p.st.form
491
363
  const v = f?.vars.find((x) => x.name === targetsRef.current.prompt)
@@ -501,12 +373,10 @@ export const VarsForm = observer(function VarsForm(p: { st: WebSt }) {
501
373
  }, [p.st])
502
374
  if (form == null) return null
503
375
  // YOUR order (drag), falling back to the workflow's own declaration order
504
- const orderedNames = p.st.orderedVars(
505
- form.moduleKey,
506
- form.vars.map((v) => v.name),
507
- )
376
+ const orderedNames = p.st.orderedVars(form.moduleKey, formRowNames(form.vars.map((v) => v.name)))
508
377
  const orderedVars = orderedNames.map((n) => form.vars.find((v) => v.name === n)).filter((v) => v != null)
509
- const places = groupPlaces(orderedVars.map((v) => v.desc.ui ?? {}))
378
+ // over every ROW, the output slot included, so an index here is a row index
379
+ const places = groupPlaces(orderedNames.map((n) => form.vars.find((v) => v.name === n)?.desc.ui ?? {}))
510
380
  const targets = jumpTargets(
511
381
  orderedVars.map((v) => ({ name: v.name, kind: v.desc.kind, inactive: form.inactiveReason(v) != null })),
512
382
  )
@@ -519,141 +389,6 @@ export const VarsForm = observer(function VarsForm(p: { st: WebSt }) {
519
389
  : null
520
390
  return (
521
391
  <div>
522
- {/* the TUI header, on the web: labelled boxes for what you are editing and where it runs.
523
- head-shell is the QUERY CONTAINER: the boxes size themselves against the form
524
- column, which the results placement widens and narrows, not against the window */}
525
- <div className="head-shell">
526
- <div className="head-boxes">
527
- {/* the workflow name IS the way into the omnibox, and so is ⌘K / ⌘J */}
528
- <div className="head-box">
529
- <span className="head-label">workflow</span>
530
- <div className="head-line">
531
- <button
532
- type="button"
533
- className="head-value app as-link"
534
- data-tip="search every workflow and draft (⌘K or ⌘J)"
535
- onClick={() => p.st.omnibox.open()}
536
- >
537
- {form.moduleKey}
538
- </button>
539
- </div>
540
- <div className="head-line">
541
- <span className="btn-group">
542
- <button
543
- type="button"
544
- data-tip="search every workflow and draft (⌘K or ⌘J)"
545
- onClick={() => p.st.omnibox.open()}
546
- >
547
- <Icon name="search" /> search <span className="kbd-hint">{MOD_KEY}K</span>
548
- </button>
549
- </span>
550
- {Object.keys(p.st.loadErrors).length > 0 ? (
551
- <button
552
- type="button"
553
- className="link load-errors"
554
- data-tip="some workflows failed to load: the list is at the bottom of the search"
555
- onClick={() => p.st.omnibox.open()}
556
- >
557
- <Icon name="warn" /> {Object.keys(p.st.loadErrors).length} failed
558
- </button>
559
- ) : null}
560
- </div>
561
- </div>
562
- {/* duplicate and delete act on THIS draft, so they live in the draft box */}
563
- <DraftBox st={p.st} form={form} />
564
- <div className="head-box">
565
- {/* a restart shows HERE, as the card's legend like the draft's `· saving`: a line
566
- under the cards moved the whole form and read as unrelated to the host */}
567
- <span className="head-label">
568
- host
569
- {p.st.hostWatch === 'down' ? <span className="save-state pulse">· restarting…</span> : null}
570
- {p.st.hostWatch === 'back' ? <span className="save-state">· back up</span> : null}
571
- </span>
572
- {/* the box itself, like the draft: its name, with the two actions ON the box
573
- around it. The ones on the RUNNING work sit on the line below, in words */}
574
- <div className="head-line draft-line">
575
- {/* the ONE refresh: models, nodes and the lora list. It also runs by itself when
576
- the host changes, pulsing while it works */}
577
- <button
578
- type="button"
579
- className={p.st.refreshing ? 'head-icon pulse' : 'head-icon'}
580
- data-tip={
581
- p.st.refreshing
582
- ? 'refreshing what the host has…'
583
- : 'refresh what the host has (models, nodes, loras). It also refreshes by itself when something new appears'
584
- }
585
- onClick={() => void p.st.refreshHost()}
586
- >
587
- <Icon name="refresh" />
588
- </button>
589
- {/* pick where this workflow RUNS (the TUI's host override), remembered per module */}
590
- {p.st.hosts.hosts.length > 1 ? (
591
- <select
592
- className="head-select"
593
- value={p.st.hostFor(form.moduleKey)}
594
- data-tip="run this workflow on another host"
595
- onChange={(e) => void p.st.setModuleHost({ module: form.moduleKey, host: e.target.value })}
596
- >
597
- {p.st.hosts.hosts.map((h) => (
598
- <option key={h.id} value={h.id}>
599
- {h.id === (p.st.hosts.defaults[form.moduleKey] ?? '') ? `${h.id} (its own)` : h.id}
600
- </option>
601
- ))}
602
- </select>
603
- ) : (
604
- <span className="head-value host">{p.st.hostFor(form.moduleKey) || form.host}</span>
605
- )}
606
- <button
607
- type="button"
608
- className="head-icon danger"
609
- data-tip="restart ComfyUI on that host (manager reboot) — it reconnects when back"
610
- onClick={() => {
611
- if (window.confirm(`restart ComfyUI on '${p.st.hostFor(form.moduleKey)}'?`))
612
- void p.st.hostAction('restart')
613
- }}
614
- >
615
- <Icon name="power" />
616
- </button>
617
- </div>
618
- <div className="head-line">
619
- {/* two separate buttons: stopping the run and emptying the queue are different
620
- decisions, and the destructive one wears its warning color */}
621
- <span className="btn-group">
622
- <button
623
- type="button"
624
- data-tip="interrupt the prompt running now"
625
- onClick={() => void p.st.hostAction('interrupt')}
626
- >
627
- <Icon name="pause" /> stop
628
- </button>
629
- </span>
630
- <span className="btn-group">
631
- <button
632
- type="button"
633
- className="quiet-danger"
634
- data-tip="drop everything still pending in the host queue"
635
- onClick={() => void p.st.hostAction('clear-queue')}
636
- >
637
- <Icon name="trash" /> clear queue
638
- </button>
639
- </span>
640
- {p.st.isHostOverridden(form.moduleKey) ? (
641
- <button
642
- type="button"
643
- className="link"
644
- data-tip={`runs on an override — back to ${p.st.hosts.defaults[form.moduleKey] ?? 'its own host'}`}
645
- onClick={() => void p.st.setModuleHost({ module: form.moduleKey, host: null })}
646
- >
647
- <Icon name="swap" /> reset
648
- </button>
649
- ) : null}
650
- </div>
651
- </div>
652
- </div>
653
- </div>
654
- {/* a host action that FAILS says so on its own line; one that works says nothing here,
655
- the ↻ pulse and the host card's legend show what runs */}
656
- {p.st.hostError != null ? <div className="error">🔴 {p.st.hostError}</div> : null}
657
392
  {/* the autosave state is the draft box's legend now; only a FAILURE gets a line of
658
393
  its own, because that one you must not miss */}
659
394
  {form.saveState === 'error' ? <div className="error">🔴 draft save failed: {form.saveError}</div> : null}
@@ -661,37 +396,39 @@ export const VarsForm = observer(function VarsForm(p: { st: WebSt }) {
661
396
  drag it (kept in this browser): labels never wrap, a cut one shows whole on hover */}
662
397
  <div className="vars" style={{ gridTemplateColumns: `${p.st.labelWidth}px minmax(0, 1fr)` }}>
663
398
  <LabelResizer st={p.st} />
664
- {orderedVars.map((v, ix) => (
399
+ {orderedNames.map((name, ix) => {
400
+ // the OUTPUT is a knob like the others: a row, not a lone button in the header
401
+ if (name === OUTPUT_ROW)
402
+ return <SaveRow key={OUTPUT_ROW} st={p.st} module={form.moduleKey} index={ix} names={orderedNames} />
403
+ const v = form.vars.find((x) => x.name === name)
404
+ if (v == null) return null
665
405
  // keyed by MODULE and DRAFT: a switch must reset per-row ui state (lora filter,
666
406
  // remembered strengths, paused set), not carry the other selection's over.
667
407
  // module matters because every workflow has a `default` draft and a `prompt`
668
408
  // var, so draft+name alone matches across workflows and react reuses the row
669
- <VarRow
670
- key={`${form.moduleKey}/${form.draft}/${v.name}`}
671
- v={v}
672
- host={form.host}
673
- st={p.st}
674
- module={form.moduleKey}
675
- index={ix}
676
- names={orderedNames}
677
- place={places[ix] ?? null}
678
- jumpKey={jumpKeyOf(v.name)}
679
- />
680
- ))}
681
- {/* the OUTPUT is a knob like the others: a row, not a lone button in the header */}
682
- <SaveRow st={p.st} module={form.moduleKey} />
409
+ return (
410
+ <VarRow
411
+ key={`${form.moduleKey}/${form.draft}/${v.name}`}
412
+ v={v}
413
+ host={form.host}
414
+ st={p.st}
415
+ module={form.moduleKey}
416
+ index={ix}
417
+ names={orderedNames}
418
+ place={places[ix] ?? null}
419
+ jumpKey={jumpKeyOf(v.name)}
420
+ />
421
+ )
422
+ })}
683
423
  </div>
684
- {/* side and pinned put generate INSIDE the results panel, with its error slot; the
685
- form keeps both otherwise. The error is one reserved line either way, so a failed
686
- run never adds a bar or pushes anything down */}
424
+ {/* side and pinned put generate INSIDE the results panel; the form keeps it otherwise.
425
+ The error shows under the prompt preview, in the results panel, unless that is off */}
687
426
  {p.st.generateInResults ? null : (
688
427
  <div className="runbar">
689
428
  <GenerateButton st={p.st} />
690
- <span className="run-error" data-tip={p.st.run.error ?? undefined}>
691
- {p.st.run.error == null ? '' : `🔴 ${p.st.run.error}`}
692
- </span>
693
429
  </div>
694
430
  )}
431
+ {p.st.layout === 'off' ? <RunError st={p.st} /> : null}
695
432
  </div>
696
433
  )
697
434
  })