comfy-ts 2.7.0 → 2.9.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.
- package/README.md +20 -13
- package/dist/{DefinedWorkflow-BJgt5t0x.js → DefinedWorkflow-BatWaZO1.js} +199 -16
- package/dist/DefinedWorkflow-BatWaZO1.js.map +1 -0
- package/dist/{DraftsSt-dizp3VcC.js → LogsSt-DFxzQfDc.js} +152 -4
- package/dist/LogsSt-DFxzQfDc.js.map +1 -0
- package/dist/cli.js +7 -5
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +284 -35
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +125 -7
- package/dist/index.d.ts +125 -7
- package/dist/index.js +282 -37
- package/dist/index.js.map +1 -1
- package/dist/run-serve-_nrvJYyt.js +1948 -0
- package/dist/run-serve-_nrvJYyt.js.map +1 -0
- package/dist/{run-tui-JxlEbb_f.js → run-tui-BLEdTsOX.js} +106 -157
- package/dist/run-tui-BLEdTsOX.js.map +1 -0
- package/dist/serve-web.js +441 -72
- package/dist/{state-CaHeDL-0.js → state-BbgJeCe6.js} +180 -45
- package/dist/state-BbgJeCe6.js.map +1 -0
- package/dist/web.d.ts +185 -7
- package/dist/web.js +235 -36
- package/dist/web.js.map +1 -1
- package/examples/README.md +1 -0
- package/examples/comfy-cloud/sdk.d.ts +4066 -321
- package/examples/rvion/04-krea2-turbo-t2i.cflow.ts +18 -2
- package/examples/rvion/07-local-llm-text-gen.cflow.ts +220 -0
- package/examples/web/tsconfig.json +3 -0
- package/extra/README.md +32 -0
- package/extra/comfyui-textgen-stream/README.md +35 -0
- package/extra/comfyui-textgen-stream/__init__.py +166 -0
- package/extra/scripts/fetch_text_encoder.py +137 -0
- package/package.json +6 -3
- package/src/cli/comfy-ts-cli.ts +3 -1
- package/src/cli/serve/ServeApp.ts +754 -40
- package/src/cli/serve/applyVarPayload.ts +10 -3
- package/src/cli/serve/describeVar.ts +47 -7
- package/src/cli/serve/hostProtocol.ts +68 -0
- package/src/cli/serve/managerOnlyLoras.ts +27 -0
- package/src/cli/serve/run-serve.ts +35 -38
- package/src/cli/serve/serveSettings.ts +86 -0
- package/src/cli/serve/startupPrint.ts +111 -0
- package/src/cli/serve/web/api.ts +97 -1
- package/src/cli/serve/web/components/App.tsx +61 -22
- package/src/cli/serve/web/components/Gallery.tsx +306 -41
- package/src/cli/serve/web/components/Icon.tsx +160 -0
- package/src/cli/serve/web/components/PromptEnhancer.tsx +12 -9
- package/src/cli/serve/web/components/Sidebar.tsx +43 -19
- package/src/cli/serve/web/components/VarsForm.tsx +440 -91
- package/src/cli/serve/web/components/controls/BasicControls.tsx +38 -5
- package/src/cli/serve/web/components/controls/ImageControl.tsx +3 -2
- package/src/cli/serve/web/components/controls/LorasControl.tsx +498 -81
- package/src/cli/serve/web/components/controls/PresetPicker.tsx +60 -0
- package/src/cli/serve/web/components/controls/SeedControl.tsx +38 -20
- package/src/cli/serve/web/components/controls/SizeControl.tsx +3 -2
- package/src/cli/serve/web/llm.ts +1 -1
- package/src/cli/serve/web/logWeb.ts +6 -0
- package/src/cli/serve/web/state/EnhancerSt.ts +8 -15
- package/src/cli/serve/web/state/FormSt.ts +74 -18
- package/src/cli/serve/web/state/RunSt.ts +22 -1
- package/src/cli/serve/web/state/WebSt.ts +814 -22
- package/src/cli/serve/web/state/host.ts +206 -0
- package/src/cli/serve/web/state/lightbox.ts +44 -0
- package/src/cli/serve/web/state/moduleTree.ts +52 -0
- package/src/cli/serve/web/state/payload.ts +44 -2
- package/src/cli/serve/web/state/urlSelection.ts +53 -0
- package/src/cli/serve/web/styles.ts +422 -57
- package/src/cli/serve/web/tsconfig.json +4 -0
- package/src/cli/tui/components/PickerOverlays.tsx +37 -0
- package/src/cli/tui/components/StatusBar.tsx +14 -1
- package/src/cli/tui/components/TuiApp.tsx +5 -2
- package/src/cli/tui/state/HostSt.ts +3 -2
- package/src/cli/tui/state/PickerSt.ts +48 -2
- package/src/cli/tui/state/TreeSt.ts +1 -1
- package/src/cli/tui/state/TuiSt.ts +2 -1
- package/src/coreExports.ts +8 -1
- package/src/graph/ComfyNode.ts +58 -1
- package/src/host/ComfyHost.ts +13 -2
- package/src/host/ComfyManager.ts +31 -13
- package/src/host/loraInfoCache.ts +35 -1
- package/src/host/loraManagerApi.ts +94 -0
- package/src/index.ts +2 -0
- package/src/promptEnhancers.ts +102 -0
- package/src/runner/ComfyExecution.ts +61 -6
- package/src/runner/ComfyWorkflow.ts +18 -4
- package/src/runner/ComfyWsApi.ts +3 -0
- package/src/runner/describePromptRejection.ts +34 -0
- package/src/sdk-generator/ComfySchema.ts +17 -4
- package/src/sdk-generator/comfyui-sdk-codegen.ts +56 -2
- package/src/utils/ansi.ts +13 -0
- package/src/utils/matchesRegex.ts +13 -0
- package/src/utils/safeName.ts +29 -0
- package/src/utils/stringMap.ts +9 -0
- package/src/vars/ComfyVars.ts +61 -10
- package/src/vars/presets.ts +17 -0
- package/src/web.ts +12 -0
- package/dist/DefinedWorkflow-BJgt5t0x.js.map +0 -1
- package/dist/DraftsSt-dizp3VcC.js.map +0 -1
- package/dist/run-serve-D1Tsuru9.js +0 -1162
- package/dist/run-serve-D1Tsuru9.js.map +0 -1
- package/dist/run-tui-JxlEbb_f.js.map +0 -1
- package/dist/state-CaHeDL-0.js.map +0 -1
- package/src/cli/serve/promptEnhancers.ts +0 -69
- package/src/cli/serve/safeName.ts +0 -12
|
@@ -1,6 +1,6 @@
|
|
|
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 } from 'mobx-react-lite'
|
|
3
|
+
import { observer, useLocalObservable } from 'mobx-react-lite'
|
|
4
4
|
import { useEffect } from 'react'
|
|
5
5
|
import {
|
|
6
6
|
ChoiceControl,
|
|
@@ -9,12 +9,13 @@ import {
|
|
|
9
9
|
TextControl,
|
|
10
10
|
ToggleControl,
|
|
11
11
|
} from 'src/cli/serve/web/components/controls/BasicControls.tsx'
|
|
12
|
+
import { Icon } from 'src/cli/serve/web/components/Icon.tsx'
|
|
12
13
|
import { ImageControl } from 'src/cli/serve/web/components/controls/ImageControl.tsx'
|
|
13
14
|
import { LorasControl } from 'src/cli/serve/web/components/controls/LorasControl.tsx'
|
|
14
15
|
import { SeedControl } from 'src/cli/serve/web/components/controls/SeedControl.tsx'
|
|
15
16
|
import { SizeControl } from 'src/cli/serve/web/components/controls/SizeControl.tsx'
|
|
16
|
-
import type { VarSt } from 'src/cli/serve/web/state/FormSt.ts'
|
|
17
|
-
import type
|
|
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'
|
|
18
19
|
|
|
19
20
|
const VarControl = observer(function VarControl(p: { v: VarSt; host: string; st: WebSt; module: string }) {
|
|
20
21
|
switch (p.v.desc.kind) {
|
|
@@ -32,7 +33,10 @@ const VarControl = observer(function VarControl(p: { v: VarSt; host: string; st:
|
|
|
32
33
|
case 'choice':
|
|
33
34
|
return <ChoiceControl v={p.v} />
|
|
34
35
|
case 'loras':
|
|
35
|
-
|
|
36
|
+
// the OVERRIDE host, like every other host-scoped read: with `host` fixed at form
|
|
37
|
+
// construction the previews, trigger words and details sheet came from the workflow's
|
|
38
|
+
// 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)} />
|
|
36
40
|
case 'size':
|
|
37
41
|
return <SizeControl v={p.v} />
|
|
38
42
|
case 'image':
|
|
@@ -43,22 +47,55 @@ const VarControl = observer(function VarControl(p: { v: VarSt; host: string; st:
|
|
|
43
47
|
}
|
|
44
48
|
})
|
|
45
49
|
|
|
46
|
-
const VarRow = observer(function VarRow(p: {
|
|
50
|
+
const VarRow = observer(function VarRow(p: {
|
|
51
|
+
v: VarSt
|
|
52
|
+
host: string
|
|
53
|
+
st: WebSt
|
|
54
|
+
module: string
|
|
55
|
+
index: number
|
|
56
|
+
names: readonly string[]
|
|
57
|
+
}) {
|
|
47
58
|
return (
|
|
48
|
-
<div
|
|
49
|
-
|
|
50
|
-
|
|
59
|
+
<div
|
|
60
|
+
/* loras and prompts need the whole width on a phone; every other kind keeps its
|
|
61
|
+
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'}
|
|
63
|
+
onDragOver={(e) => {
|
|
64
|
+
// only a row drag: a file dropped on an image var must still reach its own handler
|
|
65
|
+
if (e.dataTransfer.types.includes('application/x-comfy-var')) e.preventDefault()
|
|
66
|
+
}}
|
|
67
|
+
onDrop={(e) => {
|
|
68
|
+
const raw = e.dataTransfer.getData('application/x-comfy-var')
|
|
69
|
+
if (raw === '') return
|
|
70
|
+
e.preventDefault()
|
|
71
|
+
const from = Number(raw)
|
|
72
|
+
if (Number.isInteger(from) && from !== p.index)
|
|
73
|
+
p.st.moveVar({ module: p.module, names: p.names, from, to: p.index })
|
|
74
|
+
}}
|
|
75
|
+
>
|
|
76
|
+
{/* the LABEL is the handle: a separate grip was one more piece of permanent chrome
|
|
77
|
+
for something the label itself can carry */}
|
|
78
|
+
<div
|
|
79
|
+
className="var-label"
|
|
80
|
+
draggable
|
|
81
|
+
onDragStart={(e) => {
|
|
82
|
+
e.dataTransfer.effectAllowed = 'move'
|
|
83
|
+
e.dataTransfer.setData('application/x-comfy-var', String(p.index))
|
|
84
|
+
}}
|
|
85
|
+
>
|
|
86
|
+
{/* the kind is a TOOLTIP, not a second line: printed under every label it was a
|
|
87
|
+
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>
|
|
51
89
|
{p.v.dirty ? (
|
|
52
90
|
<button
|
|
53
91
|
type="button"
|
|
54
92
|
className="dirty-dot"
|
|
55
|
-
|
|
93
|
+
data-tip="changed this session — click to restore the loaded value (autosaves)"
|
|
56
94
|
onClick={() => p.v.revert()}
|
|
57
95
|
>
|
|
58
96
|
●
|
|
59
97
|
</button>
|
|
60
98
|
) : null}
|
|
61
|
-
<span className="kind">{p.v.desc.kind}</span>
|
|
62
99
|
</div>
|
|
63
100
|
<div className="var-control">
|
|
64
101
|
<VarControl v={p.v} host={p.host} st={p.st} module={p.module} />
|
|
@@ -67,44 +104,220 @@ const VarRow = observer(function VarRow(p: { v: VarSt; host: string; st: WebSt;
|
|
|
67
104
|
)
|
|
68
105
|
})
|
|
69
106
|
|
|
70
|
-
/**
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
+
}
|
|
74
135
|
return (
|
|
75
|
-
<div className="
|
|
76
|
-
<
|
|
77
|
-
|
|
78
|
-
|
|
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}
|
|
79
143
|
</span>
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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" />
|
|
83
218
|
</button>
|
|
84
219
|
) : null}
|
|
220
|
+
</span>
|
|
221
|
+
</div>
|
|
222
|
+
)
|
|
223
|
+
})
|
|
224
|
+
|
|
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 */
|
|
227
|
+
export const GenerateButton = observer(function GenerateButton(p: { st: WebSt }) {
|
|
228
|
+
const run = p.st.run
|
|
229
|
+
return (
|
|
230
|
+
<span className="run-line">
|
|
231
|
+
<button
|
|
232
|
+
type="button"
|
|
233
|
+
className={run.isRunning ? 'primary pulse' : 'primary'}
|
|
234
|
+
data-tip="⌘⏎ / ctrl+⏎ — click again to queue another"
|
|
235
|
+
onClick={() => p.st.generate()}
|
|
236
|
+
>
|
|
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>}
|
|
245
|
+
</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
|
+
</span>
|
|
275
|
+
)
|
|
276
|
+
})
|
|
277
|
+
|
|
278
|
+
/** where the generated images go: the same row shape as a var, because it is one more knob
|
|
279
|
+
* of the run. The toggle and the folder are SERVER settings, so curl sees the same choice */
|
|
280
|
+
const SaveRow = observer(function SaveRow(p: { st: WebSt; module: string }) {
|
|
281
|
+
const on = p.st.saveToDisk
|
|
282
|
+
return (
|
|
283
|
+
<div className="var-row">
|
|
284
|
+
<div className="var-label">
|
|
285
|
+
<span data-tip="save — where this workflow's images go">output</span>
|
|
85
286
|
</div>
|
|
86
|
-
|
|
87
|
-
<div
|
|
88
|
-
<
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
287
|
+
<div className="var-control">
|
|
288
|
+
<div className="row-inline">
|
|
289
|
+
<label className="row-inline" style={{ cursor: 'pointer' }}>
|
|
290
|
+
<input type="checkbox" checked={on} onChange={() => void p.st.toggleSaveToDisk()} />
|
|
291
|
+
<span className="hint">
|
|
292
|
+
<Icon name={on ? 'save' : 'ghost'} size={1} /> {on ? 'write to disk' : 'memory only'}
|
|
293
|
+
</span>
|
|
294
|
+
</label>
|
|
295
|
+
{on ? (
|
|
296
|
+
<>
|
|
297
|
+
<span className="hint">.comfy-ts/outputs/</span>
|
|
298
|
+
<input
|
|
299
|
+
type="text"
|
|
300
|
+
style={{ flex: 1, minWidth: 120 }}
|
|
301
|
+
placeholder={p.module}
|
|
302
|
+
value={p.st.savePrefixDraft(p.module)}
|
|
303
|
+
data-tip="subfolder the images land in — folder names only, a/b allowed"
|
|
304
|
+
onChange={(e) => p.st.setSavePrefix(p.module, e.target.value)}
|
|
305
|
+
/>
|
|
306
|
+
<span className="hint">/…png</span>
|
|
307
|
+
</>
|
|
94
308
|
) : (
|
|
95
|
-
<
|
|
96
|
-
✕
|
|
97
|
-
</button>
|
|
309
|
+
<span className="hint">kept in memory and shown here, lost when the server restarts</span>
|
|
98
310
|
)}
|
|
99
311
|
</div>
|
|
100
|
-
|
|
312
|
+
{p.st.savingError != null ? <div className="error">🔴 {p.st.savingError}</div> : null}
|
|
313
|
+
</div>
|
|
101
314
|
</div>
|
|
102
315
|
)
|
|
103
316
|
})
|
|
104
317
|
|
|
105
318
|
export const VarsForm = observer(function VarsForm(p: { st: WebSt }) {
|
|
106
319
|
const form = p.st.form
|
|
107
|
-
// ⌘⏎ / ctrl+⏎ submits from anywhere, textarea included
|
|
320
|
+
// ⌘⏎ / ctrl+⏎ submits from anywhere, textarea included
|
|
108
321
|
useEffect(() => {
|
|
109
322
|
const onKey = (e: KeyboardEvent): void => {
|
|
110
323
|
// the enhancer modal owns ⌘⏎ while it is open (refine), so a rewrite never queues a run
|
|
@@ -118,67 +331,203 @@ export const VarsForm = observer(function VarsForm(p: { st: WebSt }) {
|
|
|
118
331
|
return () => window.removeEventListener('keydown', onKey)
|
|
119
332
|
}, [p.st])
|
|
120
333
|
if (form == null) return null
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
334
|
+
// YOUR order (drag), falling back to the workflow's own declaration order
|
|
335
|
+
const orderedNames = p.st.orderedVars(
|
|
336
|
+
form.moduleKey,
|
|
337
|
+
form.vars.map((v) => v.name),
|
|
338
|
+
)
|
|
339
|
+
const orderedVars = orderedNames.map((n) => form.vars.find((v) => v.name === n)).filter((v) => v != null)
|
|
125
340
|
return (
|
|
126
341
|
<div>
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
<
|
|
132
|
-
{
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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
|
+
<button
|
|
415
|
+
type="button"
|
|
416
|
+
data-tip="refetch object_info from the host and rewrite sdk.d.ts (the var lists widen in place)"
|
|
417
|
+
onClick={() => void p.st.hostAction('refresh-schema')}
|
|
418
|
+
>
|
|
419
|
+
<Icon name="refresh" />
|
|
420
|
+
</button>
|
|
421
|
+
<button
|
|
422
|
+
type="button"
|
|
423
|
+
className="danger"
|
|
424
|
+
data-tip="restart ComfyUI on that host (manager reboot) — it reconnects when back"
|
|
425
|
+
onClick={() => {
|
|
426
|
+
if (window.confirm(`restart ComfyUI on '${p.st.hostFor(form.moduleKey)}'?`))
|
|
427
|
+
void p.st.hostAction('restart')
|
|
428
|
+
}}
|
|
429
|
+
>
|
|
430
|
+
<Icon name="power" />
|
|
431
|
+
</button>
|
|
432
|
+
</span>
|
|
433
|
+
{p.st.isHostOverridden(form.moduleKey) ? (
|
|
434
|
+
<button
|
|
435
|
+
type="button"
|
|
436
|
+
className="link"
|
|
437
|
+
data-tip={`runs on an override — back to ${p.st.hosts.defaults[form.moduleKey] ?? 'its own host'}`}
|
|
438
|
+
onClick={() => void p.st.setModuleHost({ module: form.moduleKey, host: null })}
|
|
439
|
+
>
|
|
440
|
+
<Icon name="swap" /> reset
|
|
441
|
+
</button>
|
|
442
|
+
) : null}
|
|
443
|
+
</div>
|
|
444
|
+
</div>
|
|
445
|
+
{/* its own box beside host: on a phone, scrolling between the knobs and the image
|
|
446
|
+
is the whole friction, so the corner placement floats the newest one */}
|
|
447
|
+
<div className="head-box">
|
|
448
|
+
<span className="head-label">preview</span>
|
|
449
|
+
{/* first line: WHERE the results sit. second: what shows up while it runs */}
|
|
450
|
+
<div className="head-line">
|
|
451
|
+
<span className="btn-group">
|
|
452
|
+
{LAYOUTS.map((l) => (
|
|
453
|
+
<button
|
|
454
|
+
key={l.id}
|
|
455
|
+
type="button"
|
|
456
|
+
className={p.st.layout === l.id ? 'sel' : ''}
|
|
457
|
+
data-tip={l.title}
|
|
458
|
+
onClick={() => p.st.setLayout(l.id)}
|
|
459
|
+
>
|
|
460
|
+
<Icon name={l.icon} />
|
|
461
|
+
</button>
|
|
462
|
+
))}
|
|
463
|
+
</span>
|
|
464
|
+
</div>
|
|
465
|
+
<div className="head-line">
|
|
466
|
+
<span className="btn-group">
|
|
467
|
+
<button
|
|
468
|
+
type="button"
|
|
469
|
+
className={p.st.showLatent ? 'sel' : ''}
|
|
470
|
+
data-tip={
|
|
471
|
+
p.st.showLatent ? 'hide the latent preview during a run' : 'show the latent preview'
|
|
472
|
+
}
|
|
473
|
+
onClick={() => p.st.toggleLatent()}
|
|
474
|
+
>
|
|
475
|
+
<Icon name="image" />
|
|
476
|
+
</button>
|
|
477
|
+
<button
|
|
478
|
+
type="button"
|
|
479
|
+
className={p.st.showLogs ? 'sel' : ''}
|
|
480
|
+
data-tip={p.st.showLogs ? 'hide the ComfyUI console' : 'show the ComfyUI console'}
|
|
481
|
+
onClick={() => p.st.toggleLogs()}
|
|
482
|
+
>
|
|
483
|
+
<Icon name="terminal" />
|
|
484
|
+
</button>
|
|
485
|
+
</span>
|
|
486
|
+
</div>
|
|
487
|
+
</div>
|
|
488
|
+
</div>
|
|
150
489
|
</div>
|
|
151
|
-
{
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
)
|
|
179
|
-
{
|
|
490
|
+
{/* every host action SAYS what happened: the note was computed and thrown away, which
|
|
491
|
+
is precisely why restart looked like a dead button */}
|
|
492
|
+
{p.st.hostError != null ? <div className="error">🔴 {p.st.hostError}</div> : null}
|
|
493
|
+
{p.st.hostWatch === 'down' ? (
|
|
494
|
+
<div className="host-note pulse">restarting… waiting for the host to answer again</div>
|
|
495
|
+
) : null}
|
|
496
|
+
{p.st.hostNote != null && p.st.hostWatch !== 'down' ? <div className="host-note">{p.st.hostNote}</div> : null}
|
|
497
|
+
{/* the autosave state is the draft box's legend now; only a FAILURE gets a line of
|
|
498
|
+
its own, because that one you must not miss */}
|
|
499
|
+
{form.saveState === 'error' ? <div className="error">🔴 draft save failed: {form.saveError}</div> : null}
|
|
500
|
+
{/* ONE grid for every row (rows are subgrids of it), so the label column can size
|
|
501
|
+
itself to the longest label instead of reserving a fixed slab of the width */}
|
|
502
|
+
<div className="vars">
|
|
503
|
+
{orderedVars.map((v, ix) => (
|
|
504
|
+
// keyed by MODULE and DRAFT: a switch must reset per-row ui state (lora filter,
|
|
505
|
+
// remembered strengths, paused set), not carry the other selection's over.
|
|
506
|
+
// module matters because every workflow has a `default` draft and a `prompt`
|
|
507
|
+
// var, so draft+name alone matches across workflows and react reuses the row
|
|
508
|
+
<VarRow
|
|
509
|
+
key={`${form.moduleKey}/${form.draft}/${v.name}`}
|
|
510
|
+
v={v}
|
|
511
|
+
host={form.host}
|
|
512
|
+
st={p.st}
|
|
513
|
+
module={form.moduleKey}
|
|
514
|
+
index={ix}
|
|
515
|
+
names={orderedNames}
|
|
516
|
+
/>
|
|
517
|
+
))}
|
|
518
|
+
{/* the OUTPUT is a knob like the others: a row, not a lone button in the header */}
|
|
519
|
+
<SaveRow st={p.st} module={form.moduleKey} />
|
|
180
520
|
</div>
|
|
181
|
-
|
|
521
|
+
{/* side and pinned put generate INSIDE the results panel (it sits next to what it
|
|
522
|
+
produces, and on a phone it stays on screen); the form keeps it otherwise. With
|
|
523
|
+
neither a button nor an error there is nothing to bar: rendering it anyway left a
|
|
524
|
+
sticky bordered strip holding nothing */}
|
|
525
|
+
{p.st.generateInResults && p.st.run.error == null ? null : (
|
|
526
|
+
<div className="runbar">
|
|
527
|
+
{p.st.generateInResults ? null : <GenerateButton st={p.st} />}
|
|
528
|
+
{p.st.run.error != null ? <span className="error">🔴 {p.st.run.error}</span> : null}
|
|
529
|
+
</div>
|
|
530
|
+
)}
|
|
182
531
|
</div>
|
|
183
532
|
)
|
|
184
533
|
})
|