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
@@ -1,26 +1,39 @@
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 } from 'react'
3
+ import { observer } from 'mobx-react-lite'
4
+ import { useEffect, useRef, type ReactNode } from 'react'
5
+ import { MOD_KEY } from 'src/cli/serve/web/components/modKey.ts'
6
+ 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 { isPromptLanes } from 'src/vars/lanes.ts'
5
9
  import {
6
10
  ChoiceControl,
7
11
  NumberControl,
8
- PromptControl,
9
12
  TextControl,
10
13
  ToggleControl,
11
14
  } from 'src/cli/serve/web/components/controls/BasicControls.tsx'
15
+ import { PromptControl } from 'src/cli/serve/web/components/controls/PromptControl.tsx'
12
16
  import { Icon } from 'src/cli/serve/web/components/Icon.tsx'
17
+ import { VarIcon } from 'src/cli/serve/web/components/VarIcon.tsx'
18
+ import { generateButtonLook } from 'src/cli/serve/web/state/generateButton.ts'
19
+ import { groupPlaces, type GroupPlace } from 'src/cli/serve/web/state/varGroups.ts'
13
20
  import { ImageControl } from 'src/cli/serve/web/components/controls/ImageControl.tsx'
14
21
  import { LorasControl } from 'src/cli/serve/web/components/controls/LorasControl.tsx'
15
22
  import { SeedControl } from 'src/cli/serve/web/components/controls/SeedControl.tsx'
16
23
  import { SizeControl } from 'src/cli/serve/web/components/controls/SizeControl.tsx'
17
- import type { FormSt, VarSt } from 'src/cli/serve/web/state/FormSt.ts'
18
- import { LAYOUTS, type WebSt } from 'src/cli/serve/web/state/WebSt.ts'
24
+ import type { VarSt } from 'src/cli/serve/web/state/FormSt.ts'
25
+ import type { WebSt } from 'src/cli/serve/web/state/WebSt.ts'
19
26
 
20
- const VarControl = observer(function VarControl(p: { v: VarSt; host: string; st: WebSt; module: string }) {
27
+ const VarControl = observer(function VarControl(p: {
28
+ v: VarSt
29
+ host: string
30
+ st: WebSt
31
+ module: string
32
+ jumpTarget: boolean
33
+ }) {
21
34
  switch (p.v.desc.kind) {
22
35
  case 'prompt':
23
- return <PromptControl v={p.v} st={p.st} module={p.module} />
36
+ return <PromptControl v={p.v} st={p.st} module={p.module} jumpTarget={p.jumpTarget} />
24
37
  case 'text':
25
38
  return <TextControl v={p.v} />
26
39
  case 'int':
@@ -36,9 +49,17 @@ const VarControl = observer(function VarControl(p: { v: VarSt; host: string; st:
36
49
  // the OVERRIDE host, like every other host-scoped read: with `host` fixed at form
37
50
  // construction the previews, trigger words and details sheet came from the workflow's
38
51
  // own box while the manager link opened the one actually selected
39
- return <LorasControl v={p.v} host={p.st.hostFor(p.module)} st={p.st} hostUrl={p.st.hostUrlFor(p.module)} />
52
+ return (
53
+ <LorasControl
54
+ v={p.v}
55
+ host={p.st.hostFor(p.module)}
56
+ st={p.st}
57
+ hostUrl={p.st.hostUrlFor(p.module)}
58
+ jumpTarget={p.jumpTarget}
59
+ />
60
+ )
40
61
  case 'size':
41
- return <SizeControl v={p.v} />
62
+ return <SizeControl v={p.v} st={p.st} module={p.module} />
42
63
  case 'image':
43
64
  return <ImageControl v={p.v} />
44
65
  default:
@@ -54,12 +75,36 @@ const VarRow = observer(function VarRow(p: {
54
75
  module: string
55
76
  index: number
56
77
  names: readonly string[]
78
+ /** where this row sits in a block of vars that go together, null outside any */
79
+ place: GroupPlace
80
+ /** the ⌘ key that jumps here (first prompt, first loras), null for every other var */
81
+ jumpKey: string | null
57
82
  }) {
83
+ const rowRef = useRef<HTMLDivElement>(null)
84
+ const jump = p.st.jump
85
+ const jumpKind = p.jumpKey == null ? null : p.v.desc.kind
86
+ useEffect(() => {
87
+ if (jump == null || jumpKind !== 'prompt' || jump.kind !== 'prompt') return
88
+ const editor = rowRef.current?.querySelector<HTMLElement>('.cm-content')
89
+ editor?.focus()
90
+ editor?.scrollIntoView({ block: 'nearest' })
91
+ }, [jump, jumpKind])
92
+ // the workflow's looks (VarUi): every slot optional, absent = the panel's own style. None
93
+ // of them moves anything: a background or a border never shifts the label off its column
94
+ const ui = p.v.desc.ui
95
+ const inactive = p.st.form?.inactiveReason(p.v) ?? null
96
+ const wide = p.v.desc.kind === 'loras' || p.v.desc.kind === 'prompt'
58
97
  return (
59
98
  <div
99
+ ref={rowRef}
60
100
  /* loras and prompts need the whole width on a phone; every other kind keeps its
61
101
  label beside the control, which is what makes the form readable at a glance */
62
- className={p.v.desc.kind === 'loras' || p.v.desc.kind === 'prompt' ? 'var-row wide' : 'var-row'}
102
+ className={`var-row${wide ? ' wide' : ''}${inactive == null ? '' : ' inactive'}${p.place == null ? '' : ` in-group group-${p.place.pos}`}`}
103
+ style={{
104
+ background: ui?.background ?? (p.place == null ? undefined : (p.place.color ?? undefined)),
105
+ outline: ui?.border == null ? undefined : `1px solid ${ui.border}`,
106
+ outlineOffset: ui?.border == null ? undefined : '-1px',
107
+ }}
63
108
  onDragOver={(e) => {
64
109
  // only a row drag: a file dropped on an image var must still reach its own handler
65
110
  if (e.dataTransfer.types.includes('application/x-comfy-var')) e.preventDefault()
@@ -73,10 +118,22 @@ const VarRow = observer(function VarRow(p: {
73
118
  p.st.moveVar({ module: p.module, names: p.names, from, to: p.index })
74
119
  }}
75
120
  >
121
+ {/* in the form's left gutter: back to the workflow's default. Always there (disabled at
122
+ the default), so no row moves when a value changes */}
123
+ <button
124
+ type="button"
125
+ className="var-reset"
126
+ disabled={p.v.isAtDefault}
127
+ data-tip={p.v.isAtDefault ? 'at the workflow default' : 'reset to the workflow default'}
128
+ aria-label="reset to the workflow default"
129
+ onClick={() => p.v.resetToDefault()}
130
+ >
131
+ <Icon name="refresh" size={0.95} />
132
+ </button>
76
133
  {/* the LABEL is the handle: a separate grip was one more piece of permanent chrome
77
134
  for something the label itself can carry */}
78
135
  <div
79
- className="var-label"
136
+ className={p.jumpKey == null ? 'var-label' : 'var-label has-kbd'}
80
137
  draggable
81
138
  onDragStart={(e) => {
82
139
  e.dataTransfer.effectAllowed = 'move'
@@ -85,7 +142,21 @@ const VarRow = observer(function VarRow(p: {
85
142
  >
86
143
  {/* the kind is a TOOLTIP, not a second line: printed under every label it was a
87
144
  column of noise you read past, and it only ever answers a question you ask once */}
88
- <span data-tip={`${p.v.desc.kind}\ndrag the label to reorder`}>{p.v.desc.label ?? p.v.name}</span>
145
+ {/* the (?) LEADS: labels are right-aligned against their control, so what trails a
146
+ name is what touches the control, and a help mark there read as part of it */}
147
+ {ui?.description == null ? null : (
148
+ <span className="var-help" data-tip={ui.description}>
149
+ ?
150
+ </span>
151
+ )}
152
+ {ui?.icon == null ? null : <VarIcon icon={ui.icon} color={ui.color} />}
153
+ <span
154
+ className="var-name"
155
+ data-tip={`${p.v.desc.label ?? p.v.name ?? ''}\n${inactive ?? p.v.desc.kind}\ndrag the label to reorder`}
156
+ style={ui?.labelColor == null ? undefined : { color: ui.labelColor }}
157
+ >
158
+ {p.v.desc.label ?? p.v.name}
159
+ </span>
89
160
  {p.v.dirty ? (
90
161
  <button
91
162
  type="button"
@@ -96,181 +167,113 @@ const VarRow = observer(function VarRow(p: {
96
167
  ●
97
168
  </button>
98
169
  ) : null}
170
+ {p.jumpKey == null ? null : (
171
+ <span
172
+ className="var-kbd-line"
173
+ data-tip={p.v.desc.kind === 'loras' ? 'opens the loras picker' : 'puts the cursor in this prompt'}
174
+ >
175
+ <span className="kbd-hint">
176
+ {MOD_KEY}
177
+ {p.jumpKey}
178
+ </span>
179
+ </span>
180
+ )}
99
181
  </div>
100
- <div className="var-control">
101
- <VarControl v={p.v} host={p.host} st={p.st} module={p.module} />
182
+ {/* inert, not just dimmed: a disabled field must not take a click or a keystroke */}
183
+ <div className="var-control" inert={inactive != null}>
184
+ <VarControl v={p.v} host={p.host} st={p.st} module={p.module} jumpTarget={p.jumpKey != null} />
102
185
  </div>
103
186
  </div>
104
187
  )
105
188
  })
106
189
 
107
- /** the draft box: name, autosave state as its legend, and the two actions that own this draft.
108
- * duplicate asks for the name INLINE, window.prompt is silently suppressed by browsers after
109
- * a few dialogs, which reads exactly like a dead button */
110
- const DraftBox = observer(function DraftBox(p: { st: WebSt; form: FormSt }) {
111
- const local = useLocalObservable(() => ({
112
- /** null = showing the picker; otherwise the pending name and what it will do */
113
- mode: null as null | 'duplicate' | 'rename',
114
- name: '',
115
- start(mode: 'duplicate' | 'rename', from: string) {
116
- this.mode = mode
117
- this.name = mode === 'duplicate' ? `${from} copy` : from
118
- },
119
- set(v: string) {
120
- this.name = v
121
- },
122
- stop() {
123
- this.mode = null
124
- },
125
- }))
126
- const drafts = p.st.moduleByKey(p.form.moduleKey)?.drafts ?? [p.form.draft]
127
- const confirm = (): void => {
128
- const name = local.name.trim()
129
- const mode = local.mode
130
- local.stop()
131
- if (name === '' || mode == null) return
132
- if (mode === 'duplicate') void p.st.duplicateDraft(name)
133
- else void p.st.renameDraft(name)
134
- }
190
+ /** the handle on the label column's edge: drag to widen or narrow every label at once */
191
+ function LabelResizer(p: { st: WebSt }): ReactNode {
135
192
  return (
136
- <div className="head-box">
137
- <span className="head-label">
138
- draft
139
- <span className={p.form.saveState === 'error' ? 'save-state error' : 'save-state'}>
140
- {p.form.saveState === 'saving' ? '· saving' : null}
141
- {p.form.saveState === 'saved' ? '· saved' : null}
142
- {p.form.saveState === 'error' ? '· NOT SAVED' : null}
143
- </span>
144
- </span>
145
- {local.mode != null ? (
146
- <input
147
- type="text"
148
- autoFocus
149
- className="head-input"
150
- value={local.name}
151
- // enter is the ONLY commit now, so it has to be said
152
- placeholder={local.mode === 'rename' ? 'new name, then enter' : 'new draft name, then enter'}
153
- onFocus={(e) => e.currentTarget.select()}
154
- onChange={(e) => local.set(e.target.value)}
155
- onKeyDown={(e) => {
156
- if (e.key === 'Enter') confirm()
157
- if (e.key === 'Escape') local.stop()
158
- }}
159
- // blur CANCELS, it does not commit: clicking another draft in the sidebar blurred
160
- // this input, and the rename then raced that selection, renameDraft bails when
161
- // the form has already moved on, leaving a duplicate instead of a rename, silently.
162
- // enter commits, which is the only unambiguous signal
163
- onBlur={() => local.stop()}
164
- />
165
- ) : (
166
- /* the name IS the picker: every draft of this workflow, switching selects it */
167
- <select
168
- className="head-select draft"
169
- value={p.form.draft}
170
- data-tip="switch draft"
171
- onChange={(e) => void p.st.select({ module: p.form.moduleKey, draft: e.target.value })}
172
- >
173
- {drafts.map((d) => (
174
- <option key={d} value={d}>
175
- {d}
176
- </option>
177
- ))}
178
- </select>
179
- )}
180
- <span className="head-line">
181
- <span className="btn-group head-group">
182
- <button
183
- type="button"
184
- data-tip="rename this draft (the file is renamed)"
185
- onClick={() => (local.mode != null ? confirm() : local.start('rename', p.form.draft))}
186
- >
187
- <Icon name="pen" />
188
- </button>
189
- <button
190
- type="button"
191
- data-tip="save these values as a new draft"
192
- onClick={() => (local.mode != null ? confirm() : local.start('duplicate', p.form.draft))}
193
- >
194
- <Icon name="copy-plus" />
195
- </button>
196
- <button
197
- type="button"
198
- className="danger"
199
- data-tip="delete this draft's file (default resets to the workflow's own values)"
200
- onClick={() => {
201
- if (window.confirm(`delete draft '${p.form.draft}' of ${p.form.moduleKey}? the file is removed.`))
202
- void p.st.deleteDraft({ module: p.form.moduleKey, draft: p.form.draft })
203
- }}
204
- >
205
- <Icon name="trash" />
206
- </button>
207
- </span>
208
- {/* FAR RIGHT of the same line, outside the group: inside it, the broom appeared and
209
- vanished with the dirty count and shoved the other buttons sideways */}
210
- {p.form.dirtyCount > 0 ? (
211
- <button
212
- type="button"
213
- className="dirty head-right"
214
- data-tip={`${p.form.dirtyCount} var${p.form.dirtyCount > 1 ? 's' : ''} changed this session — revert to the values this draft loaded with`}
215
- onClick={() => p.form.revertAll()}
216
- >
217
- <Icon name="broom" />
218
- </button>
219
- ) : null}
220
- </span>
221
- </div>
193
+ <div
194
+ className="label-resizer"
195
+ style={{ left: p.st.labelWidth + 2 }}
196
+ data-tip="drag to resize the label column"
197
+ onPointerDown={(e) => {
198
+ e.preventDefault()
199
+ const startX = e.clientX
200
+ const startW = p.st.labelWidth
201
+ const move = (ev: PointerEvent): void => p.st.setLabelWidth(startW + ev.clientX - startX, false)
202
+ const up = (): void => {
203
+ window.removeEventListener('pointermove', move)
204
+ window.removeEventListener('pointerup', up)
205
+ p.st.setLabelWidth(p.st.labelWidth, true)
206
+ }
207
+ window.addEventListener('pointermove', move)
208
+ window.addEventListener('pointerup', up)
209
+ }}
210
+ />
222
211
  )
223
- })
212
+ }
224
213
 
225
- /** everything about running on one line: the button, what is queued behind it, what it has
226
- * produced. a count and one clear is the whole decision a queue offers */
214
+ /** everything about running on ONE row: Run with its stop square beside it (red while a run is
215
+ * in progress, grey otherwise), then the two buttons that clear something, each carrying the
216
+ * count it acts on. Every part is always there (disabled when it has nothing to act on), and
217
+ * the counts have tabular digits, so the row never shifts */
227
218
  export const GenerateButton = observer(function GenerateButton(p: { st: WebSt }) {
228
219
  const run = p.st.run
220
+ // the text never changes, so the button never changes size: the progress is a fill sweeping
221
+ // across it, the exact percent is on the running card
222
+ const look = generateButtonLook({ isRunning: run.isRunning, percent: run.progressPercent })
223
+ const pending = runChipText({ kind: 'queue', count: run.pendingCount }).count
224
+ const images = runChipText({ kind: 'results', count: run.results.length }).count
229
225
  return (
230
- <span className="run-line">
226
+ <span className="run-bar">
227
+ <span className="btn-group run-split">
228
+ <button
229
+ type="button"
230
+ className={look.running ? 'primary running' : 'primary'}
231
+ data-tip={
232
+ look.running
233
+ ? `running ${look.fill ?? 0}%: click again to queue another (⌘⏎ / ctrl+⏎)`
234
+ : '⌘⏎ / ctrl+⏎: click again to queue another'
235
+ }
236
+ style={
237
+ look.fill == null
238
+ ? undefined
239
+ : {
240
+ background: `linear-gradient(90deg, var(--accent) ${look.fill}%, var(--accent-dim) ${look.fill}%)`,
241
+ }
242
+ }
243
+ onClick={() => p.st.generate()}
244
+ >
245
+ <Icon name="play" size={0.85} /> {look.label}
246
+ {/* the shortcut is SAID, not only tooltipped: nobody hovers a button they can click */}
247
+ <span className="kbd-hint">{MOD_KEY}⏎</span>
248
+ </button>
249
+ <button
250
+ type="button"
251
+ className={run.isRunning ? 'run-stop live' : 'run-stop'}
252
+ disabled={!run.isRunning}
253
+ data-tip="stop the run in progress (the queue behind it stays)"
254
+ onClick={() => void p.st.hostAction('interrupt')}
255
+ >
256
+ <Icon name="stop" />
257
+ </button>
258
+ </span>
231
259
  <button
232
260
  type="button"
233
- className={run.isRunning ? 'primary pulse' : 'primary'}
234
- data-tip="⌘⏎ / ctrl+⏎ — click again to queue another"
235
- onClick={() => p.st.generate()}
261
+ className="run-end"
262
+ disabled={run.pendingCount === 0}
263
+ data-tip={`drop the ${run.pendingCount} prompt(s) not yet sent to the host`}
264
+ onClick={() => run.clearQueue()}
236
265
  >
237
- <Icon name="play" size={0.85} />{' '}
238
- {run.isRunning
239
- ? run.progressPercent != null
240
- ? `generating… ${Math.round(run.progressPercent)}%`
241
- : 'generating…'
242
- : 'generate'}
243
- {/* the shortcut is SAID, not only tooltipped: nobody hovers a button they can click */}
244
- {run.isRunning ? null : <span className="kbd-hint">⌘⏎</span>}
266
+ <Icon name="close" /> Clear <b className="run-num">{pending}</b> queue
267
+ </button>
268
+ <button
269
+ type="button"
270
+ className="run-end"
271
+ disabled={run.results.length === 0}
272
+ data-tip="forget every image shown here (saved files stay on disk)"
273
+ onClick={() => run.clear()}
274
+ >
275
+ <Icon name="trash" /> Erase <b className="run-num">{images}</b> img
245
276
  </button>
246
- {run.queue.length > 0 ? (
247
- <span className="run-chip" data-tip="prompts waiting behind this one">
248
- queue: {run.queue.length}
249
- {run.pendingCount > 0 ? (
250
- <button
251
- type="button"
252
- className="link"
253
- data-tip={`drop the ${run.pendingCount} not yet sent to the host`}
254
- onClick={() => run.clearQueue()}
255
- >
256
- clear
257
- </button>
258
- ) : null}
259
- </span>
260
- ) : null}
261
- {run.results.length > 0 ? (
262
- <span className="run-chip" data-tip="runs kept in this page">
263
- {run.results.length} result{run.results.length === 1 ? '' : 's'}
264
- <button
265
- type="button"
266
- className="link"
267
- data-tip="forget every run shown here"
268
- onClick={() => run.clear()}
269
- >
270
- clear
271
- </button>
272
- </span>
273
- ) : null}
274
277
  </span>
275
278
  )
276
279
  })
@@ -317,15 +320,35 @@ const SaveRow = observer(function SaveRow(p: { st: WebSt; module: string }) {
317
320
 
318
321
  export const VarsForm = observer(function VarsForm(p: { st: WebSt }) {
319
322
  const form = p.st.form
320
- // ⌘⏎ / ctrl+⏎ submits from anywhere, textarea included
323
+ /** which var each jump lands on, as last rendered: the key handler reads it */
324
+ const targetsRef = useRef<{ prompt: string | null; loras: string | null }>({ prompt: null, loras: null })
325
+ // ⌘⏎ / ctrl+⏎ generates from anywhere, textarea and enhancer included: one key, one meaning
321
326
  useEffect(() => {
322
327
  const onKey = (e: KeyboardEvent): void => {
323
- // the enhancer modal owns ⌘⏎ while it is open (refine), so a rewrite never queues a run
324
- if (p.st.enhancer.isOpen) return
325
328
  if (e.key === 'Enter' && (e.metaKey || e.ctrlKey)) {
326
329
  e.preventDefault()
327
- p.st.generate()
330
+ // in the enhancer with a rewrite, generate TRIES it; the form keeps its own prompt
331
+ p.st.generate(p.st.enhancer.tryOverride)
332
+ return
328
333
  }
334
+ const s = shortcutOf(e)
335
+ // the menu is page layout: App owns that key
336
+ if (s == null || s === 'toggle-menu') return
337
+ // the jumps land in the form, which the enhancer covers: only the blur still makes sense
338
+ if (p.st.enhancer.isOpen && s !== 'toggle-blur') return
339
+ e.preventDefault()
340
+ if (s === 'toggle-blur') return p.st.toggleBlur()
341
+ if (s === 'duplicate-draft') return void p.st.duplicateCurrentDraft()
342
+ if (s === 'rename-draft') return p.st.startRename()
343
+ if (s === 'open-enhancer') {
344
+ const f = p.st.form
345
+ const v = f?.vars.find((x) => x.name === targetsRef.current.prompt)
346
+ // in lanes mode the enhancer opens on the first lane, the one its ✨ sits on
347
+ if (f != null && v != null)
348
+ p.st.enhancer.openFor({ v, module: f.moduleKey, lane: isPromptLanes(v.value) ? 0 : undefined })
349
+ return
350
+ }
351
+ p.st.requestJump(s === 'focus-prompt' ? 'prompt' : 'loras')
329
352
  }
330
353
  window.addEventListener('keydown', onKey)
331
354
  return () => window.removeEventListener('keydown', onKey)
@@ -337,180 +360,26 @@ export const VarsForm = observer(function VarsForm(p: { st: WebSt }) {
337
360
  form.vars.map((v) => v.name),
338
361
  )
339
362
  const orderedVars = orderedNames.map((n) => form.vars.find((v) => v.name === n)).filter((v) => v != null)
363
+ const places = groupPlaces(orderedVars.map((v) => v.desc.ui ?? {}))
364
+ const targets = jumpTargets(
365
+ orderedVars.map((v) => ({ name: v.name, kind: v.desc.kind, inactive: form.inactiveReason(v) != null })),
366
+ )
367
+ targetsRef.current = targets
368
+ const jumpKeyOf = (name: string): string | null =>
369
+ name === targets.prompt
370
+ ? SHORTCUT_KEYS['focus-prompt']
371
+ : name === targets.loras
372
+ ? SHORTCUT_KEYS['open-loras']
373
+ : null
340
374
  return (
341
375
  <div>
342
- {/* the TUI header, on the web: labelled boxes for what you are editing and where it runs.
343
- head-shell is the QUERY CONTAINER: the boxes size themselves against the form
344
- column, which the results placement widens and narrows, not against the window */}
345
- <div className="head-shell">
346
- <div className="head-boxes">
347
- {/* the workflow name IS the way into the menu: the sidebar already holds the
348
- folder → workflow → draft tree, so a second dropdown would be a rival copy of it */}
349
- <div className="head-box">
350
- <span className="head-label">workflow</span>
351
- <div className="head-line">
352
- <button
353
- type="button"
354
- className="head-value app as-link"
355
- data-tip={p.st.sidebarOpen ? 'close the workflow menu' : 'browse every workflow'}
356
- onClick={() => p.st.toggleSidebar()}
357
- >
358
- {form.moduleKey}
359
- </button>
360
- </div>
361
- <div className="head-line">
362
- <span className="btn-group">
363
- <button
364
- type="button"
365
- data-tip={p.st.sidebarOpen ? 'close the workflow menu' : 'browse every workflow'}
366
- onClick={() => p.st.toggleSidebar()}
367
- >
368
- <Icon name="folder" />
369
- </button>
370
- </span>
371
- <span className="hint">{form.vars.length} vars</span>
372
- </div>
373
- </div>
374
- {/* duplicate and delete act on THIS draft, so they live in the draft box */}
375
- <DraftBox st={p.st} form={form} />
376
- <div className="head-box">
377
- <span className="head-label">host</span>
378
- <div className="head-line">
379
- {/* pick where this workflow RUNS (the TUI's host override), remembered per module */}
380
- {p.st.hosts.hosts.length > 1 ? (
381
- <select
382
- className="head-select"
383
- value={p.st.hostFor(form.moduleKey)}
384
- data-tip="run this workflow on another host"
385
- onChange={(e) => void p.st.setModuleHost({ module: form.moduleKey, host: e.target.value })}
386
- >
387
- {p.st.hosts.hosts.map((h) => (
388
- <option key={h.id} value={h.id}>
389
- {h.id === (p.st.hosts.defaults[form.moduleKey] ?? '') ? `${h.id} (its own)` : h.id}
390
- </option>
391
- ))}
392
- </select>
393
- ) : (
394
- <span className="head-value host">{p.st.hostFor(form.moduleKey) || form.host}</span>
395
- )}
396
- </div>
397
- {/* the TUI's host actions: they act on the box this workflow runs on */}
398
- <div className="head-line">
399
- <span className="btn-group">
400
- <button
401
- type="button"
402
- data-tip="interrupt the prompt running now"
403
- onClick={() => void p.st.hostAction('interrupt')}
404
- >
405
- <Icon name="pause" />
406
- </button>
407
- <button
408
- type="button"
409
- data-tip="drop everything still pending in the host queue"
410
- onClick={() => void p.st.hostAction('clear-queue')}
411
- >
412
- <Icon name="trash" />
413
- </button>
414
- {p.st.drift != null && p.st.drift.host === p.st.hostFor(form.moduleKey) ? (
415
- <button
416
- type="button"
417
- className="attention"
418
- data-tip={`the host changed since this panel loaded its schema (${p.st.drift.summary}): refetch to use it`}
419
- onClick={() => void p.st.hostAction('refresh-schema')}
420
- >
421
- <Icon name="refresh" /> {p.st.drift.summary}
422
- </button>
423
- ) : (
424
- <button
425
- type="button"
426
- data-tip="refetch object_info from the host and rewrite sdk.d.ts (the var lists widen in place)"
427
- onClick={() => void p.st.hostAction('refresh-schema')}
428
- >
429
- <Icon name="refresh" />
430
- </button>
431
- )}
432
- <button
433
- type="button"
434
- className="danger"
435
- data-tip="restart ComfyUI on that host (manager reboot) — it reconnects when back"
436
- onClick={() => {
437
- if (window.confirm(`restart ComfyUI on '${p.st.hostFor(form.moduleKey)}'?`))
438
- void p.st.hostAction('restart')
439
- }}
440
- >
441
- <Icon name="power" />
442
- </button>
443
- </span>
444
- {p.st.isHostOverridden(form.moduleKey) ? (
445
- <button
446
- type="button"
447
- className="link"
448
- data-tip={`runs on an override — back to ${p.st.hosts.defaults[form.moduleKey] ?? 'its own host'}`}
449
- onClick={() => void p.st.setModuleHost({ module: form.moduleKey, host: null })}
450
- >
451
- <Icon name="swap" /> reset
452
- </button>
453
- ) : null}
454
- </div>
455
- </div>
456
- {/* its own box beside host: on a phone, scrolling between the knobs and the image
457
- is the whole friction, so the corner placement floats the newest one */}
458
- <div className="head-box">
459
- <span className="head-label">preview</span>
460
- {/* first line: WHERE the results sit. second: what shows up while it runs */}
461
- <div className="head-line">
462
- <span className="btn-group">
463
- {LAYOUTS.map((l) => (
464
- <button
465
- key={l.id}
466
- type="button"
467
- className={p.st.layout === l.id ? 'sel' : ''}
468
- data-tip={l.title}
469
- onClick={() => p.st.setLayout(l.id)}
470
- >
471
- <Icon name={l.icon} />
472
- </button>
473
- ))}
474
- </span>
475
- </div>
476
- <div className="head-line">
477
- <span className="btn-group">
478
- <button
479
- type="button"
480
- className={p.st.showLatent ? 'sel' : ''}
481
- data-tip={
482
- p.st.showLatent ? 'hide the latent preview during a run' : 'show the latent preview'
483
- }
484
- onClick={() => p.st.toggleLatent()}
485
- >
486
- <Icon name="image" />
487
- </button>
488
- <button
489
- type="button"
490
- className={p.st.showLogs ? 'sel' : ''}
491
- data-tip={p.st.showLogs ? 'hide the ComfyUI console' : 'show the ComfyUI console'}
492
- onClick={() => p.st.toggleLogs()}
493
- >
494
- <Icon name="terminal" />
495
- </button>
496
- </span>
497
- </div>
498
- </div>
499
- </div>
500
- </div>
501
- {/* every host action SAYS what happened: the note was computed and thrown away, which
502
- is precisely why restart looked like a dead button */}
503
- {p.st.hostError != null ? <div className="error">🔴 {p.st.hostError}</div> : null}
504
- {p.st.hostWatch === 'down' ? (
505
- <div className="host-note pulse">restarting… waiting for the host to answer again</div>
506
- ) : null}
507
- {p.st.hostNote != null && p.st.hostWatch !== 'down' ? <div className="host-note">{p.st.hostNote}</div> : null}
508
376
  {/* the autosave state is the draft box's legend now; only a FAILURE gets a line of
509
377
  its own, because that one you must not miss */}
510
378
  {form.saveState === 'error' ? <div className="error">🔴 draft save failed: {form.saveError}</div> : null}
511
- {/* ONE grid for every row (rows are subgrids of it), so the label column can size
512
- itself to the longest label instead of reserving a fixed slab of the width */}
513
- <div className="vars">
379
+ {/* ONE grid for every row (rows are subgrids of it). The label column is as wide as YOU
380
+ drag it (kept in this browser): labels never wrap, a cut one shows whole on hover */}
381
+ <div className="vars" style={{ gridTemplateColumns: `${p.st.labelWidth}px minmax(0, 1fr)` }}>
382
+ <LabelResizer st={p.st} />
514
383
  {orderedVars.map((v, ix) => (
515
384
  // keyed by MODULE and DRAFT: a switch must reset per-row ui state (lora filter,
516
385
  // remembered strengths, paused set), not carry the other selection's over.
@@ -524,19 +393,22 @@ export const VarsForm = observer(function VarsForm(p: { st: WebSt }) {
524
393
  module={form.moduleKey}
525
394
  index={ix}
526
395
  names={orderedNames}
396
+ place={places[ix] ?? null}
397
+ jumpKey={jumpKeyOf(v.name)}
527
398
  />
528
399
  ))}
529
400
  {/* the OUTPUT is a knob like the others: a row, not a lone button in the header */}
530
401
  <SaveRow st={p.st} module={form.moduleKey} />
531
402
  </div>
532
- {/* side and pinned put generate INSIDE the results panel (it sits next to what it
533
- produces, and on a phone it stays on screen); the form keeps it otherwise. With
534
- neither a button nor an error there is nothing to bar: rendering it anyway left a
535
- sticky bordered strip holding nothing */}
536
- {p.st.generateInResults && p.st.run.error == null ? null : (
403
+ {/* side and pinned put generate INSIDE the results panel, with its error slot; the
404
+ form keeps both otherwise. The error is one reserved line either way, so a failed
405
+ run never adds a bar or pushes anything down */}
406
+ {p.st.generateInResults ? null : (
537
407
  <div className="runbar">
538
- {p.st.generateInResults ? null : <GenerateButton st={p.st} />}
539
- {p.st.run.error != null ? <span className="error">🔴 {p.st.run.error}</span> : null}
408
+ <GenerateButton st={p.st} />
409
+ <span className="run-error" data-tip={p.st.run.error ?? undefined}>
410
+ {p.st.run.error == null ? '' : `🔴 ${p.st.run.error}`}
411
+ </span>
540
412
  </div>
541
413
  )}
542
414
  </div>