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.
- package/README.md +1 -0
- package/dist/{LogsSt-qtFzOKpu.js → LogsSt-CUeo843w.js} +51 -7
- package/dist/LogsSt-CUeo843w.js.map +1 -0
- package/dist/cli.js +4 -4
- package/dist/index.cjs +595 -73
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +286 -46
- package/dist/index.d.ts +286 -46
- package/dist/index.js +591 -74
- package/dist/index.js.map +1 -1
- package/dist/{run-serve-BK7BA2dn.js → run-serve-DlRBv_Nk.js} +738 -58
- package/dist/run-serve-DlRBv_Nk.js.map +1 -0
- package/dist/{run-tui-CQyvMf0N.js → run-tui-B5uxm2_l.js} +43 -18
- package/dist/run-tui-B5uxm2_l.js.map +1 -0
- package/dist/{schemaDrift-DjjEtwfx.js → schemaDrift-E95iTF7E.js} +473 -60
- package/dist/schemaDrift-E95iTF7E.js.map +1 -0
- package/dist/serve-web.js +710 -174
- package/dist/{state--wrz0BQc.js → state-CUp2J1Zy.js} +126 -14
- package/dist/state-CUp2J1Zy.js.map +1 -0
- package/dist/web.d.ts +286 -46
- package/dist/web.js +591 -74
- package/dist/web.js.map +1 -1
- package/examples/comfy-cloud/sdk.d.ts +163 -163
- package/examples/rvion/06-qwen-image-edit.cflow.ts +3 -2
- package/examples/rvion/10-anima-t2i.cflow.ts +252 -0
- package/examples/rvion/11-yue2-t2a.cflow.ts +105 -0
- package/examples/rvion/12-stable-audio-3-t2a.cflow.ts +78 -0
- package/examples/rvion/13-ace-step-15-xl-t2a.cflow.ts +153 -0
- package/examples/rvion/stableAudio3Prompts.ts +19 -0
- package/extra/README.md +4 -0
- package/extra/comfyui-fresh-model-lists/README.md +25 -0
- package/extra/comfyui-fresh-model-lists/__init__.py +36 -0
- package/extra/comfyui-fresh-model-lists/test_fresh_model_lists.py +97 -0
- package/package.json +15 -7
- package/src/cli/draftMeta.ts +39 -0
- package/src/cli/serve/ServeApp.ts +305 -30
- package/src/cli/serve/applyVarPayload.ts +50 -22
- package/src/cli/serve/byteRange.ts +48 -0
- package/src/cli/serve/describeVar.ts +42 -6
- package/src/cli/serve/llmConfigShape.ts +51 -0
- package/src/cli/serve/llmConfigs.ts +52 -0
- package/src/cli/serve/run-serve.ts +12 -3
- package/src/cli/serve/tagList.ts +92 -0
- package/src/cli/serve/tagSource.ts +69 -0
- package/src/cli/serve/web/api.ts +72 -0
- package/src/cli/serve/web/components/App.tsx +485 -44
- package/src/cli/serve/web/components/DraftTabs.tsx +167 -0
- package/src/cli/serve/web/components/Gallery.tsx +133 -31
- package/src/cli/serve/web/components/HistoryPicker.tsx +149 -0
- package/src/cli/serve/web/components/Icon.tsx +58 -2
- package/src/cli/serve/web/components/MenuButton.tsx +53 -0
- package/src/cli/serve/web/components/Omnibox.tsx +135 -0
- package/src/cli/serve/web/components/PromptEnhancer.tsx +476 -180
- package/src/cli/serve/web/components/SideMenu.tsx +414 -0
- package/src/cli/serve/web/components/TooltipLayer.tsx +46 -0
- package/src/cli/serve/web/components/VarIcon.tsx +24 -0
- package/src/cli/serve/web/components/VarsForm.tsx +223 -351
- package/src/cli/serve/web/components/controls/BasicControls.tsx +57 -32
- package/src/cli/serve/web/components/controls/LorasControl.tsx +646 -317
- package/src/cli/serve/web/components/controls/PresetPicker.tsx +1 -1
- package/src/cli/serve/web/components/controls/PromptControl.tsx +279 -0
- package/src/cli/serve/web/components/controls/PromptEditor.tsx +113 -0
- package/src/cli/serve/web/components/controls/SeedControl.tsx +17 -10
- package/src/cli/serve/web/components/controls/SizeControl.tsx +111 -18
- package/src/cli/serve/web/components/modKey.ts +2 -0
- package/src/cli/serve/web/llm.ts +23 -12
- package/src/cli/serve/web/promptEditor/promptExtensions.ts +284 -0
- package/src/cli/serve/web/state/EnhancerSt.ts +431 -101
- package/src/cli/serve/web/state/FormSt.ts +214 -30
- package/src/cli/serve/web/state/OmniboxSt.ts +59 -0
- package/src/cli/serve/web/state/WebSt.ts +364 -80
- package/src/cli/serve/web/state/choiceButtons.ts +61 -0
- package/src/cli/serve/web/state/draftNames.ts +16 -0
- package/src/cli/serve/web/state/draftTabs.ts +75 -0
- package/src/cli/serve/web/state/generateButton.ts +16 -0
- package/src/cli/serve/web/state/history.ts +54 -0
- package/src/cli/serve/web/state/host.ts +5 -2
- package/src/cli/serve/web/state/keptLines.ts +53 -0
- package/src/cli/serve/web/state/latentMode.ts +20 -0
- package/src/cli/serve/web/state/loraSort.ts +18 -0
- package/src/cli/serve/web/state/moduleTree.ts +2 -2
- package/src/cli/serve/web/state/omnibox.ts +133 -0
- package/src/cli/serve/web/state/payload.ts +38 -58
- package/src/cli/serve/web/state/shortcuts.ts +103 -0
- package/src/cli/serve/web/state/sizeStars.ts +31 -0
- package/src/cli/serve/web/state/stableSlots.ts +21 -0
- package/src/cli/serve/web/state/varGroups.ts +24 -0
- package/src/cli/serve/web/styles.ts +653 -154
- package/src/cli/serve/webBundle.ts +54 -10
- package/src/cli/serve/workflowTags.ts +42 -0
- package/src/cli/serve/workspaceLabels.ts +23 -0
- package/src/cli/tui/components/PickerOverlays.tsx +9 -2
- package/src/cli/tui/imagePicker/ImagePickerSt.ts +1 -1
- package/src/cli/tui/state/DraftsSt.ts +28 -8
- package/src/cli/tui/state/EditorSt.ts +1 -1
- package/src/cli/tui/state/LorasSt.ts +1 -1
- package/src/cli/tui/state/PickerSt.ts +25 -7
- package/src/cli/tui/state/SettingsSt.ts +1 -1
- package/src/cli/tui/state/TuiSt.ts +10 -0
- package/src/coreExports.ts +21 -0
- package/src/host/ComfyHost.ts +17 -2
- package/src/host/ResilientWebsocket.ts +54 -4
- package/src/host/loraInfoCache.ts +6 -0
- package/src/runner/ComfyExecution.ts +60 -0
- package/src/runner/ComfyWorkflow.ts +4 -0
- package/src/runner/ComfyWsApi.ts +2 -0
- package/src/runner/MediaImage.ts +2 -2
- package/src/sdk-generator/ComfyUIObjectInfoTypes.ts +5 -5
- package/src/sdk-generator/comfyui-sdk-codegen.ts +1 -1
- package/src/state.ts +5 -0
- package/src/utils/copyName.ts +12 -0
- package/src/vars/ComfyVars.ts +337 -67
- package/src/vars/DefinedWorkflow.ts +47 -20
- package/src/vars/lanes.ts +238 -0
- package/src/vars/loraEntry.ts +101 -0
- package/src/vars/promptSyntax.ts +382 -0
- package/dist/LogsSt-qtFzOKpu.js.map +0 -1
- package/dist/run-serve-BK7BA2dn.js.map +0 -1
- package/dist/run-tui-CQyvMf0N.js.map +0 -1
- package/dist/schemaDrift-DjjEtwfx.js.map +0 -1
- package/dist/state--wrz0BQc.js.map +0 -1
- package/src/cli/serve/web/components/Sidebar.tsx +0 -66
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
// the menu column: where you are, widest scope first (workspace, workflow, draft, host, preview).
|
|
2
|
+
// a left Panel above 760px (collapsible to an icon rail), a drawer behind ☰ below
|
|
3
|
+
import { observer, useLocalObservable } from 'mobx-react-lite'
|
|
4
|
+
import type { ReactNode } from 'react'
|
|
5
|
+
import { Icon, type IconName } from 'src/cli/serve/web/components/Icon.tsx'
|
|
6
|
+
import { MOD_KEY } from 'src/cli/serve/web/components/modKey.ts'
|
|
7
|
+
import { SHORTCUT_KEYS, shortcutLabel } from 'src/cli/serve/web/state/shortcuts.ts'
|
|
8
|
+
import type { PathLabel } from 'src/cli/serve/web/api.ts'
|
|
9
|
+
import type { FormSt } from 'src/cli/serve/web/state/FormSt.ts'
|
|
10
|
+
import { LAYOUTS, type WebSt } from 'src/cli/serve/web/state/WebSt.ts'
|
|
11
|
+
|
|
12
|
+
/** a titled block of rows; `actions` sit at the right end of the title */
|
|
13
|
+
function Section(p: { title: string; actions?: ReactNode; children: ReactNode }): ReactNode {
|
|
14
|
+
return (
|
|
15
|
+
<section className="menu-section">
|
|
16
|
+
<div className="menu-title">
|
|
17
|
+
<span>{p.title}</span>
|
|
18
|
+
{p.actions == null ? null : <span className="menu-title-actions">{p.actions}</span>}
|
|
19
|
+
</div>
|
|
20
|
+
{p.children}
|
|
21
|
+
</section>
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** the draft section: the picker with delete, then rename, duplicate and new as full rows. New
|
|
26
|
+
* and duplicate are auto-named and open at once; rename asks INLINE in the picker's place
|
|
27
|
+
* (window.prompt is silently suppressed by browsers after a few dialogs), from the row or F2 */
|
|
28
|
+
const DraftSection = observer(function DraftSection(p: { st: WebSt; form: FormSt }) {
|
|
29
|
+
const drafts = p.st.moduleByKey(p.form.moduleKey)?.drafts ?? [p.form.draft]
|
|
30
|
+
const renaming = p.st.renamingDraft
|
|
31
|
+
const confirm = (): void => {
|
|
32
|
+
const name = (renaming ?? '').trim()
|
|
33
|
+
p.st.stopRename()
|
|
34
|
+
if (name !== '' && name !== p.form.draft) void p.st.renameDraft(name)
|
|
35
|
+
}
|
|
36
|
+
const n = p.form.dirtyCount
|
|
37
|
+
return (
|
|
38
|
+
<Section
|
|
39
|
+
title="draft"
|
|
40
|
+
actions={
|
|
41
|
+
<>
|
|
42
|
+
{n > 0 ? (
|
|
43
|
+
<button
|
|
44
|
+
type="button"
|
|
45
|
+
className="head-icon dirty"
|
|
46
|
+
data-tip={`revert ${n} change${n > 1 ? 's' : ''}: put back the values this draft loaded with`}
|
|
47
|
+
onClick={() => p.form.revertAll()}
|
|
48
|
+
>
|
|
49
|
+
<Icon name="broom" />
|
|
50
|
+
</button>
|
|
51
|
+
) : null}
|
|
52
|
+
<SaveMark form={p.form} />
|
|
53
|
+
</>
|
|
54
|
+
}
|
|
55
|
+
>
|
|
56
|
+
{renaming != null ? (
|
|
57
|
+
<div className="menu-row">
|
|
58
|
+
<Icon name="pen" />
|
|
59
|
+
<input
|
|
60
|
+
type="text"
|
|
61
|
+
autoFocus
|
|
62
|
+
className="head-input"
|
|
63
|
+
value={renaming}
|
|
64
|
+
// enter is the ONLY commit, so it has to be said
|
|
65
|
+
placeholder="new name, then enter"
|
|
66
|
+
onFocus={(e) => e.currentTarget.select()}
|
|
67
|
+
onChange={(e) => p.st.setRenaming(e.target.value)}
|
|
68
|
+
onKeyDown={(e) => {
|
|
69
|
+
if (e.key === 'Enter') confirm()
|
|
70
|
+
if (e.key === 'Escape') p.st.stopRename()
|
|
71
|
+
}}
|
|
72
|
+
// blur CANCELS, it does not commit: picking another draft blurs this input, and a
|
|
73
|
+
// rename committed on blur raced that selection, renameDraft bails when the form
|
|
74
|
+
// has already moved on, leaving a duplicate instead of a rename, silently
|
|
75
|
+
onBlur={() => p.st.stopRename()}
|
|
76
|
+
/>
|
|
77
|
+
</div>
|
|
78
|
+
) : (
|
|
79
|
+
/* the name IS the picker; delete acts ON it, so it sits at its end */
|
|
80
|
+
<div className="menu-row">
|
|
81
|
+
<select
|
|
82
|
+
className="menu-select draft"
|
|
83
|
+
value={p.form.draft}
|
|
84
|
+
data-tip="switch draft"
|
|
85
|
+
onChange={(e) => void p.st.select({ module: p.form.moduleKey, draft: e.target.value })}
|
|
86
|
+
>
|
|
87
|
+
{drafts.map((d) => (
|
|
88
|
+
<option key={d} value={d}>
|
|
89
|
+
{d}
|
|
90
|
+
</option>
|
|
91
|
+
))}
|
|
92
|
+
</select>
|
|
93
|
+
<span className="menu-row-actions">
|
|
94
|
+
<button
|
|
95
|
+
type="button"
|
|
96
|
+
className="head-icon danger"
|
|
97
|
+
data-tip="delete this draft's file (default resets to the workflow's own values)"
|
|
98
|
+
onClick={() => {
|
|
99
|
+
if (
|
|
100
|
+
window.confirm(`delete draft '${p.form.draft}' of ${p.form.moduleKey}? the file is removed.`)
|
|
101
|
+
)
|
|
102
|
+
void p.st.deleteDraft({ module: p.form.moduleKey, draft: p.form.draft })
|
|
103
|
+
}}
|
|
104
|
+
>
|
|
105
|
+
<Icon name="trash" />
|
|
106
|
+
</button>
|
|
107
|
+
</span>
|
|
108
|
+
</div>
|
|
109
|
+
)}
|
|
110
|
+
<button
|
|
111
|
+
type="button"
|
|
112
|
+
className="menu-row menu-action"
|
|
113
|
+
data-tip="rename this draft (the file is renamed)"
|
|
114
|
+
onClick={() => p.st.startRename()}
|
|
115
|
+
>
|
|
116
|
+
<Icon name="pen" />
|
|
117
|
+
<span>rename</span>
|
|
118
|
+
<span className="kbd-hint">{shortcutLabel('rename-draft')}</span>
|
|
119
|
+
</button>
|
|
120
|
+
<button
|
|
121
|
+
type="button"
|
|
122
|
+
className="menu-row menu-action"
|
|
123
|
+
data-tip="a copy of the values on screen, as a new draft"
|
|
124
|
+
onClick={() => void p.st.duplicateCurrentDraft()}
|
|
125
|
+
>
|
|
126
|
+
<Icon name="copy-plus" />
|
|
127
|
+
<span>duplicate</span>
|
|
128
|
+
<span className="kbd-hint">
|
|
129
|
+
{MOD_KEY}
|
|
130
|
+
{SHORTCUT_KEYS['duplicate-draft']}
|
|
131
|
+
</span>
|
|
132
|
+
</button>
|
|
133
|
+
<button
|
|
134
|
+
type="button"
|
|
135
|
+
className="menu-row menu-action"
|
|
136
|
+
data-tip="a new draft with the workflow's own default values"
|
|
137
|
+
onClick={() => void p.st.newDraftFromDefaults()}
|
|
138
|
+
>
|
|
139
|
+
<Icon name="plus" />
|
|
140
|
+
<span>new default</span>
|
|
141
|
+
</button>
|
|
142
|
+
</Section>
|
|
143
|
+
)
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
/** where the draft file stands: a tiny spinner while the values on screen are not on disk yet,
|
|
147
|
+
* a grey check once they are, the error in words when a write failed */
|
|
148
|
+
const SaveMark = observer(function SaveMark(p: { form: FormSt }) {
|
|
149
|
+
if (p.form.saveState === 'error')
|
|
150
|
+
return (
|
|
151
|
+
<span className="menu-note error" data-tip={p.form.saveError ?? 'the last write failed'}>
|
|
152
|
+
NOT SAVED
|
|
153
|
+
</span>
|
|
154
|
+
)
|
|
155
|
+
if (p.form.unsaved)
|
|
156
|
+
return (
|
|
157
|
+
<span className="save-mark" data-tip="saving…">
|
|
158
|
+
<span className="spinner" />
|
|
159
|
+
</span>
|
|
160
|
+
)
|
|
161
|
+
return (
|
|
162
|
+
<span className="save-mark" data-tip="saved">
|
|
163
|
+
<Icon name="check" />
|
|
164
|
+
</span>
|
|
165
|
+
)
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
/** read-only for now: the label fits the row, a click copies the full path */
|
|
169
|
+
function PathRow(p: { what: string; icon: IconName; value: PathLabel | null }): ReactNode {
|
|
170
|
+
if (p.value == null) return null
|
|
171
|
+
const value = p.value
|
|
172
|
+
return (
|
|
173
|
+
<button
|
|
174
|
+
type="button"
|
|
175
|
+
className="menu-row path-row"
|
|
176
|
+
data-tip={`${p.what}: ${value.path} (click to copy)`}
|
|
177
|
+
data-tip-side="right"
|
|
178
|
+
onClick={() => void navigator.clipboard.writeText(value.path)}
|
|
179
|
+
>
|
|
180
|
+
<Icon name={p.icon} />
|
|
181
|
+
{/* rtl cuts a long path at its START; the bdi keeps the path itself left to right, or rtl
|
|
182
|
+
reorders the neutral `~` and `/` and `~/dev/x` reads `dev/x/~` */}
|
|
183
|
+
<span className="path-text">
|
|
184
|
+
<bdi>{value.label}</bdi>
|
|
185
|
+
</span>
|
|
186
|
+
</button>
|
|
187
|
+
)
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** ☰ + the name. ☰ folds the column (⌘B), in the drawer it closes it */
|
|
191
|
+
export function MenuHead(p: { onBurger: () => void; tip: string; keyHint?: string }): ReactNode {
|
|
192
|
+
return (
|
|
193
|
+
<div className="menu-head">
|
|
194
|
+
<button type="button" className="head-icon" data-tip={p.tip} aria-label="menu" onClick={p.onBurger}>
|
|
195
|
+
<Icon name="menu" />
|
|
196
|
+
</button>
|
|
197
|
+
<span className="menu-brand">comfy-ts</span>
|
|
198
|
+
{p.keyHint == null ? null : <span className="kbd-hint menu-head-key">{p.keyHint}</span>}
|
|
199
|
+
</div>
|
|
200
|
+
)
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export const MenuCards = observer(function MenuCards(p: { st: WebSt }) {
|
|
204
|
+
const form = p.st.form
|
|
205
|
+
const failed = Object.keys(p.st.loadErrors).length
|
|
206
|
+
return (
|
|
207
|
+
<div className="menu-sections">
|
|
208
|
+
<Section title="workspace">
|
|
209
|
+
<PathRow what="workspace (where .comfy-ts/ lives)" icon="folder" value={p.st.workspace} />
|
|
210
|
+
<PathRow what="root (the folder serve scans)" icon="folder-tree" value={p.st.root} />
|
|
211
|
+
</Section>
|
|
212
|
+
{form == null ? null : (
|
|
213
|
+
<>
|
|
214
|
+
<Section
|
|
215
|
+
title="workflow"
|
|
216
|
+
actions={
|
|
217
|
+
<>
|
|
218
|
+
{failed > 0 ? (
|
|
219
|
+
<button
|
|
220
|
+
type="button"
|
|
221
|
+
className="link load-errors"
|
|
222
|
+
data-tip="some workflows failed to load: the list is at the bottom of the search"
|
|
223
|
+
onClick={() => p.st.omnibox.open()}
|
|
224
|
+
>
|
|
225
|
+
<Icon name="warn" /> {failed}
|
|
226
|
+
</button>
|
|
227
|
+
) : null}
|
|
228
|
+
<button
|
|
229
|
+
type="button"
|
|
230
|
+
className="head-icon"
|
|
231
|
+
data-tip={`search every workflow and draft (${MOD_KEY}K or ${MOD_KEY}J)`}
|
|
232
|
+
onClick={() => p.st.omnibox.open()}
|
|
233
|
+
>
|
|
234
|
+
<Icon name="search" /> <span className="kbd-hint">{MOD_KEY}K</span>
|
|
235
|
+
</button>
|
|
236
|
+
</>
|
|
237
|
+
}
|
|
238
|
+
>
|
|
239
|
+
{/* the workflow name IS the way into the omnibox, and so is ⌘K / ⌘J */}
|
|
240
|
+
<button
|
|
241
|
+
type="button"
|
|
242
|
+
className="menu-row workflow-row"
|
|
243
|
+
data-tip={`search every workflow and draft (${MOD_KEY}K)`}
|
|
244
|
+
onClick={() => p.st.omnibox.open()}
|
|
245
|
+
>
|
|
246
|
+
<Icon name="workflow" />
|
|
247
|
+
<span className="menu-value">{form.moduleKey}</span>
|
|
248
|
+
</button>
|
|
249
|
+
</Section>
|
|
250
|
+
<DraftSection st={p.st} form={form} />
|
|
251
|
+
<Section
|
|
252
|
+
title={
|
|
253
|
+
p.st.hostWatch === 'down'
|
|
254
|
+
? 'host · restarting…'
|
|
255
|
+
: p.st.hostWatch === 'back'
|
|
256
|
+
? 'host · back up'
|
|
257
|
+
: 'host'
|
|
258
|
+
}
|
|
259
|
+
actions={
|
|
260
|
+
<>
|
|
261
|
+
{/* the ONE refresh: models, nodes and the lora list. It also runs by itself
|
|
262
|
+
when the host changes, pulsing while it works */}
|
|
263
|
+
<button
|
|
264
|
+
type="button"
|
|
265
|
+
className={p.st.refreshing ? 'head-icon pulse' : 'head-icon'}
|
|
266
|
+
data-tip={
|
|
267
|
+
p.st.refreshing
|
|
268
|
+
? 'refreshing what the host has…'
|
|
269
|
+
: 'refresh what the host has (models, nodes, loras). It also refreshes by itself when something new appears'
|
|
270
|
+
}
|
|
271
|
+
onClick={() => void p.st.refreshHost()}
|
|
272
|
+
>
|
|
273
|
+
<Icon name="refresh" />
|
|
274
|
+
</button>
|
|
275
|
+
<button
|
|
276
|
+
type="button"
|
|
277
|
+
className="head-icon danger"
|
|
278
|
+
data-tip="restart ComfyUI on that host (manager reboot) — it reconnects when back"
|
|
279
|
+
onClick={() => {
|
|
280
|
+
if (window.confirm(`restart ComfyUI on '${p.st.hostFor(form.moduleKey)}'?`))
|
|
281
|
+
void p.st.hostAction('restart')
|
|
282
|
+
}}
|
|
283
|
+
>
|
|
284
|
+
<Icon name="power" />
|
|
285
|
+
</button>
|
|
286
|
+
</>
|
|
287
|
+
}
|
|
288
|
+
>
|
|
289
|
+
<div className="menu-row">
|
|
290
|
+
{/* pick where this workflow RUNS (the TUI's host override), remembered per module */}
|
|
291
|
+
{p.st.hosts.hosts.length > 1 ? (
|
|
292
|
+
<select
|
|
293
|
+
className="menu-select host"
|
|
294
|
+
value={p.st.hostFor(form.moduleKey)}
|
|
295
|
+
data-tip="run this workflow on another host"
|
|
296
|
+
onChange={(e) => void p.st.setModuleHost({ module: form.moduleKey, host: e.target.value })}
|
|
297
|
+
>
|
|
298
|
+
{p.st.hosts.hosts.map((h) => (
|
|
299
|
+
<option key={h.id} value={h.id}>
|
|
300
|
+
{h.id === (p.st.hosts.defaults[form.moduleKey] ?? '') ? `${h.id} (its own)` : h.id}
|
|
301
|
+
</option>
|
|
302
|
+
))}
|
|
303
|
+
</select>
|
|
304
|
+
) : (
|
|
305
|
+
<span className="menu-value host">{p.st.hostFor(form.moduleKey) || form.host}</span>
|
|
306
|
+
)}
|
|
307
|
+
{p.st.isHostOverridden(form.moduleKey) ? (
|
|
308
|
+
<span className="menu-row-actions">
|
|
309
|
+
<button
|
|
310
|
+
type="button"
|
|
311
|
+
className="head-icon"
|
|
312
|
+
data-tip={`runs on an override — back to ${p.st.hosts.defaults[form.moduleKey] ?? 'its own host'}`}
|
|
313
|
+
onClick={() => void p.st.setModuleHost({ module: form.moduleKey, host: null })}
|
|
314
|
+
>
|
|
315
|
+
<Icon name="swap" />
|
|
316
|
+
</button>
|
|
317
|
+
</span>
|
|
318
|
+
) : null}
|
|
319
|
+
</div>
|
|
320
|
+
{/* stopping the run and emptying the queue are different decisions, and the
|
|
321
|
+
destructive one wears its warning color */}
|
|
322
|
+
<div className="menu-row menu-buttons">
|
|
323
|
+
<button
|
|
324
|
+
type="button"
|
|
325
|
+
data-tip="interrupt the prompt running now"
|
|
326
|
+
onClick={() => void p.st.hostAction('interrupt')}
|
|
327
|
+
>
|
|
328
|
+
<Icon name="pause" /> stop
|
|
329
|
+
</button>
|
|
330
|
+
<button
|
|
331
|
+
type="button"
|
|
332
|
+
className="quiet-danger"
|
|
333
|
+
data-tip="drop everything still pending in the host queue"
|
|
334
|
+
onClick={() => void p.st.hostAction('clear-queue')}
|
|
335
|
+
>
|
|
336
|
+
<Icon name="trash" /> clear
|
|
337
|
+
</button>
|
|
338
|
+
{/* the console is the HOST's output, so it opens from here */}
|
|
339
|
+
<button
|
|
340
|
+
type="button"
|
|
341
|
+
className={p.st.showLogs ? 'sel' : ''}
|
|
342
|
+
data-tip={p.st.showLogs ? 'hide the ComfyUI console' : 'show the ComfyUI console of this host'}
|
|
343
|
+
onClick={() => p.st.toggleLogs()}
|
|
344
|
+
>
|
|
345
|
+
<Icon name="terminal" /> console
|
|
346
|
+
</button>
|
|
347
|
+
</div>
|
|
348
|
+
{p.st.hostError != null ? <div className="error menu-error">🔴 {p.st.hostError}</div> : null}
|
|
349
|
+
</Section>
|
|
350
|
+
</>
|
|
351
|
+
)}
|
|
352
|
+
{/* where the results sit: page layout, so it is here rather than in the preview head */}
|
|
353
|
+
<Section title="preview">
|
|
354
|
+
{/* one tile per placement, the word under the icon: an icon alone did not say where the
|
|
355
|
+
results go. The long explanation stays in the tooltip */}
|
|
356
|
+
<div className="layout-tiles">
|
|
357
|
+
{LAYOUTS.map((l) => (
|
|
358
|
+
<button
|
|
359
|
+
key={l.id}
|
|
360
|
+
type="button"
|
|
361
|
+
className={p.st.layout === l.id ? 'layout-tile sel' : 'layout-tile'}
|
|
362
|
+
data-tip={l.title}
|
|
363
|
+
onClick={() => p.st.setLayout(l.id)}
|
|
364
|
+
>
|
|
365
|
+
<Icon name={l.icon} size={1.8} />
|
|
366
|
+
<span>{l.label}</span>
|
|
367
|
+
</button>
|
|
368
|
+
))}
|
|
369
|
+
</div>
|
|
370
|
+
</Section>
|
|
371
|
+
</div>
|
|
372
|
+
)
|
|
373
|
+
})
|
|
374
|
+
|
|
375
|
+
/** the folded rail: ☰, search, then one icon per row, a click unfolds the column */
|
|
376
|
+
export const MenuRail = observer(function MenuRail(p: { st: WebSt; onExpand: () => void }) {
|
|
377
|
+
const items: { icon: IconName; tip: string }[] = [
|
|
378
|
+
{ icon: 'folder', tip: `workspace: ${p.st.workspace?.label ?? '?'}` },
|
|
379
|
+
{ icon: 'folder-tree', tip: `root: ${p.st.root?.label ?? '?'}` },
|
|
380
|
+
{ icon: 'workflow', tip: `workflow: ${p.st.form?.moduleKey ?? 'none'}` },
|
|
381
|
+
{ icon: 'draft', tip: `draft: ${p.st.form?.draft ?? 'none'}` },
|
|
382
|
+
{ icon: 'server', tip: `host: ${p.st.hostFor(p.st.form?.moduleKey ?? '') || 'none'}` },
|
|
383
|
+
{
|
|
384
|
+
icon: LAYOUTS.find((l) => l.id === p.st.layout)?.icon ?? 'panel-side',
|
|
385
|
+
tip: `preview: ${LAYOUTS.find((l) => l.id === p.st.layout)?.title ?? p.st.layout}`,
|
|
386
|
+
},
|
|
387
|
+
]
|
|
388
|
+
return (
|
|
389
|
+
<div className="menu-rail">
|
|
390
|
+
<button
|
|
391
|
+
type="button"
|
|
392
|
+
className="head-icon"
|
|
393
|
+
data-tip={`unfold the menu (${MOD_KEY}B)`}
|
|
394
|
+
aria-label="menu"
|
|
395
|
+
onClick={p.onExpand}
|
|
396
|
+
>
|
|
397
|
+
<Icon name="menu" />
|
|
398
|
+
</button>
|
|
399
|
+
<button
|
|
400
|
+
type="button"
|
|
401
|
+
className="head-icon"
|
|
402
|
+
data-tip={`search (${MOD_KEY}K)`}
|
|
403
|
+
onClick={() => p.st.omnibox.open()}
|
|
404
|
+
>
|
|
405
|
+
<Icon name="search" />
|
|
406
|
+
</button>
|
|
407
|
+
{items.map((it) => (
|
|
408
|
+
<button key={it.icon} type="button" className="head-icon" data-tip={it.tip} onClick={p.onExpand}>
|
|
409
|
+
<Icon name={it.icon} />
|
|
410
|
+
</button>
|
|
411
|
+
))}
|
|
412
|
+
</div>
|
|
413
|
+
)
|
|
414
|
+
})
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// ONE tooltip for the whole panel: any element carrying `data-tip` gets it, so no component
|
|
2
|
+
// wires anything. floating-ui places it in a portal, flips and shifts it at the screen edges,
|
|
3
|
+
// and it never lives inside a scroll box, where a pseudo-element tooltip got clipped and even
|
|
4
|
+
// made the box scroll. Instant, like the css tooltips it replaces: a delay was never wanted.
|
|
5
|
+
// `data-tip-side="right"` puts it beside the element instead of under it
|
|
6
|
+
import { autoUpdate, flip, FloatingPortal, offset, shift, useFloating } from '@floating-ui/react'
|
|
7
|
+
import { useEffect, useState, type ReactNode } from 'react'
|
|
8
|
+
|
|
9
|
+
export function TooltipLayer(): ReactNode {
|
|
10
|
+
const [tip, setTip] = useState<{ el: Element; text: string } | null>(null)
|
|
11
|
+
const { refs, floatingStyles } = useFloating({
|
|
12
|
+
placement: tip?.el.getAttribute('data-tip-side') === 'right' ? 'right' : 'bottom-start',
|
|
13
|
+
middleware: [offset(6), flip(), shift({ padding: 8 })],
|
|
14
|
+
whileElementsMounted: autoUpdate,
|
|
15
|
+
elements: { reference: tip?.el ?? null },
|
|
16
|
+
})
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const over = (e: PointerEvent): void => {
|
|
19
|
+
// a finger has no hover: a tip on touch would stay stuck over what you just tapped
|
|
20
|
+
if (e.pointerType === 'touch') return
|
|
21
|
+
const target = e.target
|
|
22
|
+
const el = target instanceof Element ? target.closest('[data-tip]') : null
|
|
23
|
+
const text = el?.getAttribute('data-tip') ?? ''
|
|
24
|
+
setTip((cur) => (el == null || text === '' ? null : cur?.el === el && cur.text === text ? cur : { el, text }))
|
|
25
|
+
}
|
|
26
|
+
const hide = (): void => setTip(null)
|
|
27
|
+
document.addEventListener('pointerover', over)
|
|
28
|
+
document.addEventListener('pointerdown', hide)
|
|
29
|
+
document.addEventListener('keydown', hide)
|
|
30
|
+
window.addEventListener('scroll', hide, true)
|
|
31
|
+
return () => {
|
|
32
|
+
document.removeEventListener('pointerover', over)
|
|
33
|
+
document.removeEventListener('pointerdown', hide)
|
|
34
|
+
document.removeEventListener('keydown', hide)
|
|
35
|
+
window.removeEventListener('scroll', hide, true)
|
|
36
|
+
}
|
|
37
|
+
}, [])
|
|
38
|
+
if (tip == null) return null
|
|
39
|
+
return (
|
|
40
|
+
<FloatingPortal>
|
|
41
|
+
<div ref={refs.setFloating} style={floatingStyles} className="tooltip" role="tooltip">
|
|
42
|
+
{tip.text}
|
|
43
|
+
</div>
|
|
44
|
+
</FloatingPortal>
|
|
45
|
+
)
|
|
46
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// the icons a WORKFLOW gives its vars and their choices (VarUi.icon, VarUi.options[x].icon)
|
|
2
|
+
import type { ReactNode } from 'react'
|
|
3
|
+
|
|
4
|
+
/** a workflow's own icon for a var: a 24×24 path drawn in the icon color, or a whole svg. A
|
|
5
|
+
* whole svg goes through an <img> data url, so markup from a workflow never reaches the dom */
|
|
6
|
+
export function VarIcon(p: { icon: string; color: string | undefined }): ReactNode {
|
|
7
|
+
if (p.icon.trimStart().startsWith('<svg'))
|
|
8
|
+
return <img className="var-icon" alt="" src={`data:image/svg+xml;utf8,${encodeURIComponent(p.icon)}`} />
|
|
9
|
+
return (
|
|
10
|
+
<svg
|
|
11
|
+
className="var-icon"
|
|
12
|
+
viewBox="0 0 24 24"
|
|
13
|
+
fill="none"
|
|
14
|
+
stroke="currentColor"
|
|
15
|
+
strokeWidth={2}
|
|
16
|
+
strokeLinecap="round"
|
|
17
|
+
strokeLinejoin="round"
|
|
18
|
+
style={p.color == null ? undefined : { color: p.color }}
|
|
19
|
+
aria-hidden="true"
|
|
20
|
+
>
|
|
21
|
+
<path d={p.icon} />
|
|
22
|
+
</svg>
|
|
23
|
+
)
|
|
24
|
+
}
|