comfy-ts 2.10.0 → 2.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/{LogsSt-DFxzQfDc.js → LogsSt-U1H0mP1m.js} +35 -5
- package/dist/LogsSt-U1H0mP1m.js.map +1 -0
- package/dist/cli.js +4 -4
- package/dist/index.cjs +565 -62
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +210 -31
- package/dist/index.d.ts +210 -31
- package/dist/index.js +561 -63
- package/dist/index.js.map +1 -1
- package/dist/{run-serve-_nrvJYyt.js → run-serve-BeAznay5.js} +549 -43
- package/dist/run-serve-BeAznay5.js.map +1 -0
- package/dist/{run-tui-Atvf9vb3.js → run-tui-BTGjvnKk.js} +75 -18
- package/dist/run-tui-BTGjvnKk.js.map +1 -0
- package/dist/{DefinedWorkflow-BatWaZO1.js → schemaDrift-Cg39vs53.js} +644 -60
- package/dist/schemaDrift-Cg39vs53.js.map +1 -0
- package/dist/serve-web.js +523 -133
- package/dist/{state-6RFDIQwJ.js → state-C7REnHan.js} +18 -3
- package/dist/{state-6RFDIQwJ.js.map → state-C7REnHan.js.map} +1 -1
- package/dist/web.d.ts +210 -31
- package/dist/web.js +561 -63
- package/dist/web.js.map +1 -1
- package/examples/comfy-cloud/capybara-i2v.cflow.ts +2 -0
- package/examples/comfy-cloud/wan22-5b-t2v.cflow.ts +2 -0
- package/examples/comfy-cloud/wan22-i2v.cflow.ts +2 -0
- package/examples/comfy-cloud/wan22-t2v.cflow.ts +2 -0
- package/examples/rvion/06-qwen-image-edit.cflow.ts +3 -2
- package/examples/rvion/07-local-llm-text-gen.cflow.ts +2 -2
- package/examples/rvion/10-anima-t2i.cflow.ts +229 -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 +17 -7
- package/src/cli/draftMeta.ts +39 -0
- package/src/cli/serve/ServeApp.ts +242 -12
- package/src/cli/serve/applyVarPayload.ts +50 -22
- package/src/cli/serve/describeVar.ts +49 -6
- package/src/cli/serve/favicon.ts +3 -0
- package/src/cli/serve/llmConfigShape.ts +51 -0
- package/src/cli/serve/llmConfigs.ts +52 -0
- package/src/cli/serve/tagList.ts +92 -0
- package/src/cli/serve/tagSource.ts +69 -0
- package/src/cli/serve/web/api.ts +60 -0
- package/src/cli/serve/web/components/App.tsx +336 -44
- package/src/cli/serve/web/components/Gallery.tsx +105 -28
- package/src/cli/serve/web/components/HistoryPicker.tsx +149 -0
- package/src/cli/serve/web/components/Icon.tsx +18 -2
- package/src/cli/serve/web/components/MenuButton.tsx +53 -0
- package/src/cli/serve/web/components/Omnibox.tsx +85 -0
- package/src/cli/serve/web/components/PromptEnhancer.tsx +476 -180
- package/src/cli/serve/web/components/TooltipLayer.tsx +45 -0
- package/src/cli/serve/web/components/VarIcon.tsx +24 -0
- package/src/cli/serve/web/components/VarsForm.tsx +341 -177
- package/src/cli/serve/web/components/controls/BasicControls.tsx +57 -32
- package/src/cli/serve/web/components/controls/LorasControl.tsx +708 -285
- 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 +281 -0
- package/src/cli/serve/web/state/EnhancerSt.ts +415 -100
- package/src/cli/serve/web/state/FormSt.ts +193 -29
- package/src/cli/serve/web/state/OmniboxSt.ts +57 -0
- package/src/cli/serve/web/state/WebSt.ts +281 -57
- package/src/cli/serve/web/state/choiceButtons.ts +61 -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 +57 -0
- package/src/cli/serve/web/state/moduleTree.ts +2 -2
- package/src/cli/serve/web/state/omnibox.ts +69 -0
- package/src/cli/serve/web/state/payload.ts +38 -58
- package/src/cli/serve/web/state/shortcuts.ts +54 -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 +472 -118
- package/src/cli/serve/webBundle.ts +54 -10
- package/src/cli/tui/components/Header.tsx +2 -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 +18 -2
- package/src/cli/tui/state/EditorSt.ts +1 -1
- package/src/cli/tui/state/HostSt.ts +34 -0
- 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 +20 -0
- package/src/host/ComfyHost.ts +15 -0
- package/src/host/loraInfoCache.ts +70 -0
- package/src/host/loraManagerApi.ts +27 -0
- package/src/host/schemaDrift.ts +87 -0
- package/src/state.ts +5 -0
- package/src/vars/ComfyVars.ts +337 -67
- package/src/vars/DefinedWorkflow.ts +40 -19
- package/src/vars/lanes.ts +238 -0
- package/src/vars/loraEntry.ts +101 -0
- package/src/vars/promptSyntax.ts +382 -0
- package/dist/DefinedWorkflow-BatWaZO1.js.map +0 -1
- package/dist/LogsSt-DFxzQfDc.js.map +0 -1
- package/dist/run-serve-_nrvJYyt.js.map +0 -1
- package/dist/run-tui-Atvf9vb3.js.map +0 -1
- package/src/cli/serve/web/components/Sidebar.tsx +0 -66
|
@@ -1,28 +1,252 @@
|
|
|
1
|
-
// ✨ on a prompt row → the refine modal:
|
|
2
|
-
//
|
|
1
|
+
// ✨ on a prompt row → the refine modal: the LLM configs and the master prompts as two lists of
|
|
2
|
+
// vertical tabs on the left, the job (yours → rewrite) alone on the right. A tab's pen opens its
|
|
3
|
+
// editor over the job. Nothing touches the var until APPLY.
|
|
3
4
|
import { Icon } from 'src/cli/serve/web/components/Icon.tsx'
|
|
4
5
|
import { observer } from 'mobx-react-lite'
|
|
5
|
-
import { useEffect } from 'react'
|
|
6
|
+
import { useEffect, useRef, type ReactNode } from 'react'
|
|
7
|
+
import { MOD_KEY } from 'src/cli/serve/web/components/modKey.ts'
|
|
8
|
+
import { HistoryButton } from 'src/cli/serve/web/components/HistoryPicker.tsx'
|
|
6
9
|
import type { ProviderId, ReasoningEffort } from 'src/cli/serve/web/llm.ts'
|
|
7
|
-
import { PROVIDERS, type EnhancerSt } from 'src/cli/serve/web/state/EnhancerSt.ts'
|
|
10
|
+
import { PROVIDERS, type EnhancerSt, type SaveState } from 'src/cli/serve/web/state/EnhancerSt.ts'
|
|
8
11
|
import type { VarSt } from 'src/cli/serve/web/state/FormSt.ts'
|
|
9
12
|
import type { WebSt } from 'src/cli/serve/web/state/WebSt.ts'
|
|
13
|
+
import {
|
|
14
|
+
ENHANCER_KEYS,
|
|
15
|
+
enhancerShortcutOf,
|
|
16
|
+
SHORTCUT_KEYS,
|
|
17
|
+
type EnhancerShortcut,
|
|
18
|
+
} from 'src/cli/serve/web/state/shortcuts.ts'
|
|
10
19
|
|
|
11
20
|
const EFFORTS: ReasoningEffort[] = ['off', 'low', 'medium', 'high']
|
|
12
21
|
|
|
13
22
|
const PROVIDER_LABEL: Record<ProviderId, string> = {
|
|
14
23
|
openrouter: 'openrouter (cloud)',
|
|
15
24
|
openwebui: 'open webui (local)',
|
|
25
|
+
openai: 'llama.cpp / ollama / vllm (openai /v1)',
|
|
16
26
|
}
|
|
17
27
|
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
28
|
+
const BASE_PLACEHOLDER: Record<ProviderId, string> = {
|
|
29
|
+
openrouter: '',
|
|
30
|
+
openwebui: 'http://localhost:3000',
|
|
31
|
+
openai: 'http://localhost:8080/v1',
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** one library of named files (LLM configs, master prompts) as VERTICAL TABS: click a tab to
|
|
35
|
+
* select it, its pen opens its editor over the job, `+ new` closes the list. On a narrow
|
|
36
|
+
* screen the same list is a dropdown (css swaps them) */
|
|
37
|
+
const TabList = observer(function TabList(p: {
|
|
38
|
+
title: string
|
|
39
|
+
names: string[]
|
|
40
|
+
selected: string
|
|
41
|
+
kind: string
|
|
42
|
+
newName: string
|
|
43
|
+
save: SaveState
|
|
44
|
+
saveError: string
|
|
45
|
+
/** its editor is open over the job */
|
|
46
|
+
editing: boolean
|
|
47
|
+
onEdit(): void
|
|
48
|
+
/** a dot before the name (the LLM's up/down), absent = none */
|
|
49
|
+
status?: (name: string) => { cls: string; tip: string } | null
|
|
50
|
+
onSelect(name: string): void
|
|
51
|
+
onCreate(name: string): void
|
|
52
|
+
}) {
|
|
53
|
+
const create = (): void => {
|
|
54
|
+
const name = window.prompt(`name the new ${p.kind}`, p.newName)
|
|
55
|
+
if (name != null) p.onCreate(name)
|
|
56
|
+
}
|
|
57
|
+
const dot = (name: string): ReactNode => {
|
|
58
|
+
const st = p.status?.(name) ?? null
|
|
59
|
+
return st == null ? null : <span className={`enh-dot ${st.cls}`} data-tip={st.tip} />
|
|
60
|
+
}
|
|
61
|
+
return (
|
|
62
|
+
<div className="enh-tabs">
|
|
63
|
+
<div className="enh-tabs-title">
|
|
64
|
+
{p.title}
|
|
65
|
+
{p.save === 'saving' ? <span className="enh-save">saving…</span> : null}
|
|
66
|
+
{p.save === 'error' ? (
|
|
67
|
+
<span className="enh-save error" data-tip={p.saveError}>
|
|
68
|
+
🔴 not saved
|
|
69
|
+
</span>
|
|
70
|
+
) : null}
|
|
71
|
+
</div>
|
|
72
|
+
<select className="enh-tab-select" value={p.selected} onChange={(ev) => p.onSelect(ev.target.value)}>
|
|
73
|
+
{p.names.map((n) => (
|
|
74
|
+
<option key={n} value={n}>
|
|
75
|
+
{n}
|
|
76
|
+
</option>
|
|
77
|
+
))}
|
|
78
|
+
</select>
|
|
79
|
+
<div className="enh-tab-list" role="tablist">
|
|
80
|
+
{p.names.map((n) => (
|
|
81
|
+
<div key={n} className={n === p.selected ? 'enh-tab sel' : 'enh-tab'}>
|
|
82
|
+
<button type="button" role="tab" aria-selected={n === p.selected} onClick={() => p.onSelect(n)}>
|
|
83
|
+
{dot(n)}
|
|
84
|
+
<span className="enh-tab-name">{n}</span>
|
|
85
|
+
</button>
|
|
86
|
+
{n === p.selected ? (
|
|
87
|
+
<button
|
|
88
|
+
type="button"
|
|
89
|
+
className={p.editing ? 'enh-tab-edit sel' : 'enh-tab-edit'}
|
|
90
|
+
data-tip={p.editing ? 'close the editor' : `edit this ${p.kind}`}
|
|
91
|
+
onClick={() => p.onEdit()}
|
|
92
|
+
>
|
|
93
|
+
<Icon name="pen" />
|
|
94
|
+
</button>
|
|
95
|
+
) : null}
|
|
96
|
+
</div>
|
|
97
|
+
))}
|
|
98
|
+
<button type="button" className="enh-tab-new" onClick={create}>
|
|
99
|
+
<Icon name="plus" /> new {p.kind}
|
|
100
|
+
</button>
|
|
101
|
+
</div>
|
|
102
|
+
</div>
|
|
103
|
+
)
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
const Side = observer(function Side(p: { e: EnhancerSt }) {
|
|
107
|
+
const e = p.e
|
|
108
|
+
const entry = e.configEntry
|
|
109
|
+
const preset = e.preset
|
|
110
|
+
return (
|
|
111
|
+
<nav className="enh-side">
|
|
112
|
+
{entry == null ? (
|
|
113
|
+
<div className="enh-tabs">
|
|
114
|
+
<div className="enh-tabs-title">llm</div>
|
|
115
|
+
<button type="button" className="enh-tab-new" onClick={() => e.setEditing('llm')}>
|
|
116
|
+
<Icon name="plus" /> set up an llm
|
|
117
|
+
</button>
|
|
118
|
+
</div>
|
|
119
|
+
) : (
|
|
120
|
+
<TabList
|
|
121
|
+
title="llm"
|
|
122
|
+
names={e.configs.map((c) => c.name)}
|
|
123
|
+
selected={entry.name}
|
|
124
|
+
kind="llm"
|
|
125
|
+
newName="my-llm"
|
|
126
|
+
save={e.configSaveState}
|
|
127
|
+
saveError={e.configSaveError}
|
|
128
|
+
editing={e.editing === 'llm'}
|
|
129
|
+
onEdit={() => e.setEditing(e.editing === 'llm' ? null : 'llm')}
|
|
130
|
+
status={(name) => {
|
|
131
|
+
const st = e.configStatus.get(name)
|
|
132
|
+
if (st == null) return null
|
|
133
|
+
const err = e.configStatusError.get(name)
|
|
134
|
+
return {
|
|
135
|
+
cls: st,
|
|
136
|
+
tip: st === 'up' ? 'answers' : st === 'checking' ? 'checking…' : `does not answer: ${err ?? ''}`,
|
|
137
|
+
}
|
|
138
|
+
}}
|
|
139
|
+
onSelect={(n) => e.selectConfig(n)}
|
|
140
|
+
onCreate={(n) => {
|
|
141
|
+
e.addConfig(n)
|
|
142
|
+
e.setEditing('llm')
|
|
143
|
+
}}
|
|
144
|
+
/>
|
|
145
|
+
)}
|
|
146
|
+
{preset == null ? (
|
|
147
|
+
<div className="enh-tabs">
|
|
148
|
+
<div className="enh-tabs-title">master prompt</div>
|
|
149
|
+
<button type="button" className="enh-tab-new" onClick={() => e.addPreset('refine-prompt')}>
|
|
150
|
+
<Icon name="plus" /> new master prompt
|
|
151
|
+
</button>
|
|
152
|
+
</div>
|
|
153
|
+
) : (
|
|
154
|
+
<TabList
|
|
155
|
+
title="master prompt"
|
|
156
|
+
names={e.presets.map((m) => m.name)}
|
|
157
|
+
selected={preset.name}
|
|
158
|
+
kind="master prompt"
|
|
159
|
+
newName="refine-<model>-prompt"
|
|
160
|
+
save={e.saveState}
|
|
161
|
+
saveError={e.saveError}
|
|
162
|
+
editing={e.editing === 'preset'}
|
|
163
|
+
onEdit={() => e.setEditing(e.editing === 'preset' ? null : 'preset')}
|
|
164
|
+
onSelect={(n) => e.selectPreset(n)}
|
|
165
|
+
onCreate={(n) => {
|
|
166
|
+
e.addPreset(n)
|
|
167
|
+
e.setEditing('preset')
|
|
168
|
+
}}
|
|
169
|
+
/>
|
|
170
|
+
)}
|
|
171
|
+
</nav>
|
|
172
|
+
)
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
/** the editor over the job: a title with the entry's name, its file actions, its fields */
|
|
176
|
+
function EditPanel(p: {
|
|
177
|
+
kind: string
|
|
178
|
+
name: string | null
|
|
179
|
+
tip?: string
|
|
180
|
+
onRename(name: string): void
|
|
181
|
+
onDuplicate(): void
|
|
182
|
+
onDelete(): void
|
|
183
|
+
onClose(): void
|
|
184
|
+
children: ReactNode
|
|
185
|
+
}): ReactNode {
|
|
186
|
+
const rename = (): void => {
|
|
187
|
+
if (p.name == null) return
|
|
188
|
+
const name = window.prompt(`rename this ${p.kind} (renames the file)`, p.name)
|
|
189
|
+
if (name != null) p.onRename(name)
|
|
190
|
+
}
|
|
191
|
+
const remove = (): void => {
|
|
192
|
+
if (p.name == null) return
|
|
193
|
+
if (window.confirm(`delete ${p.kind} '${p.name}'? its file is removed.`)) p.onDelete()
|
|
194
|
+
}
|
|
21
195
|
return (
|
|
22
|
-
<
|
|
23
|
-
<div className="
|
|
24
|
-
|
|
25
|
-
|
|
196
|
+
<section className="enh-edit">
|
|
197
|
+
<div className="enh-edit-head">
|
|
198
|
+
<h3 className="enh-h" data-tip={p.tip}>
|
|
199
|
+
{p.kind} <span className="enh-h-name">{p.name ?? 'new'}</span>
|
|
200
|
+
</h3>
|
|
201
|
+
{p.name == null ? null : (
|
|
202
|
+
<span className="btn-group">
|
|
203
|
+
<button type="button" onClick={() => p.onDuplicate()}>
|
|
204
|
+
duplicate
|
|
205
|
+
</button>
|
|
206
|
+
<button type="button" onClick={rename}>
|
|
207
|
+
rename
|
|
208
|
+
</button>
|
|
209
|
+
<button type="button" className="quiet-danger" onClick={remove}>
|
|
210
|
+
<Icon name="trash" /> delete
|
|
211
|
+
</button>
|
|
212
|
+
</span>
|
|
213
|
+
)}
|
|
214
|
+
<button
|
|
215
|
+
type="button"
|
|
216
|
+
className="enh-edit-close"
|
|
217
|
+
data-tip="done (esc), everything is already saved"
|
|
218
|
+
onClick={() => p.onClose()}
|
|
219
|
+
>
|
|
220
|
+
done
|
|
221
|
+
</button>
|
|
222
|
+
</div>
|
|
223
|
+
<div className="enh-edit-body">{p.children}</div>
|
|
224
|
+
</section>
|
|
225
|
+
)
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
const LlmSettings = observer(function LlmSettings(p: { e: EnhancerSt }) {
|
|
229
|
+
const e = p.e
|
|
230
|
+
const models = e.visibleModels
|
|
231
|
+
const local = e.provider !== 'openrouter'
|
|
232
|
+
const entry = e.configEntry
|
|
233
|
+
return (
|
|
234
|
+
<EditPanel
|
|
235
|
+
kind="llm"
|
|
236
|
+
name={entry?.name ?? null}
|
|
237
|
+
tip={
|
|
238
|
+
entry == null
|
|
239
|
+
? 'any edit creates the config file'
|
|
240
|
+
: `.comfy-ts/llm-configs/${entry.name}.json, saved as you type`
|
|
241
|
+
}
|
|
242
|
+
onRename={(n) => void e.renameConfig(n)}
|
|
243
|
+
onDuplicate={() => e.duplicateConfig()}
|
|
244
|
+
onDelete={() => void e.deleteConfig()}
|
|
245
|
+
onClose={() => e.setEditing(null)}
|
|
246
|
+
>
|
|
247
|
+
<div className="enh-grid">
|
|
248
|
+
<label>provider</label>
|
|
249
|
+
<select value={e.provider} onChange={(ev) => e.setProvider(ev.target.value)}>
|
|
26
250
|
{PROVIDERS.map((id) => (
|
|
27
251
|
<option key={id} value={id}>
|
|
28
252
|
{PROVIDER_LABEL[id]}
|
|
@@ -30,228 +254,300 @@ const Settings = observer(function Settings(p: { e: EnhancerSt }) {
|
|
|
30
254
|
))}
|
|
31
255
|
</select>
|
|
32
256
|
{local ? (
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
257
|
+
<>
|
|
258
|
+
<label>address</label>
|
|
259
|
+
<input
|
|
260
|
+
type="text"
|
|
261
|
+
placeholder={BASE_PLACEHOLDER[e.provider]}
|
|
262
|
+
value={e.baseUrl}
|
|
263
|
+
onChange={(ev) => e.setBaseUrl(ev.target.value)}
|
|
264
|
+
/>
|
|
265
|
+
</>
|
|
40
266
|
) : null}
|
|
267
|
+
<label data-tip="kept in this browser only, never in a file">api key</label>
|
|
41
268
|
<input
|
|
42
269
|
type="password"
|
|
43
|
-
placeholder={local ? '
|
|
44
|
-
value={
|
|
45
|
-
onChange={(ev) =>
|
|
46
|
-
style={{ flex: 1, minWidth: 160 }}
|
|
270
|
+
placeholder={local ? 'blank if none' : 'sk-or-v1-…'}
|
|
271
|
+
value={e.apiKey}
|
|
272
|
+
onChange={(ev) => e.setApiKey(ev.target.value)}
|
|
47
273
|
/>
|
|
48
|
-
<
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
)}
|
|
59
|
-
{models.map((m) => (
|
|
60
|
-
<option key={m.id} value={m.id}>
|
|
61
|
-
{m.id}
|
|
62
|
-
</option>
|
|
63
|
-
))}
|
|
64
|
-
</select>
|
|
65
|
-
) : (
|
|
66
|
-
<input
|
|
67
|
-
type="text"
|
|
68
|
-
placeholder={local ? 'model id, e.g. qwen3:8b' : 'model id, e.g. anthropic/claude-sonnet-5'}
|
|
69
|
-
value={p.e.model}
|
|
70
|
-
onChange={(ev) => p.e.setModel(ev.target.value)}
|
|
71
|
-
style={{ flex: 1 }}
|
|
72
|
-
/>
|
|
73
|
-
)}
|
|
74
|
-
<label className="row-inline" data-tip="hide models that report no reasoning support">
|
|
75
|
-
<input type="checkbox" checked={p.e.thinkingOnly} onChange={() => p.e.toggleThinkingOnly()} />
|
|
76
|
-
<span className="hint">thinking only</span>
|
|
77
|
-
</label>
|
|
78
|
-
{local ? null : (
|
|
79
|
-
<label className="row-inline" data-tip="reasoning effort sent to the model">
|
|
80
|
-
<span className="hint">effort</span>
|
|
81
|
-
<select value={p.e.effort} onChange={(ev) => p.e.setEffort(ev.target.value)}>
|
|
82
|
-
{EFFORTS.map((x) => (
|
|
83
|
-
<option key={x} value={x}>
|
|
84
|
-
{x}
|
|
274
|
+
<label>model</label>
|
|
275
|
+
<div className="enh-inline">
|
|
276
|
+
{models.length > 0 ? (
|
|
277
|
+
<select value={e.model} onChange={(ev) => e.setModel(ev.target.value)}>
|
|
278
|
+
{models.some((m) => m.id === e.model) ? null : (
|
|
279
|
+
<option value={e.model}>{e.model} (not in the list)</option>
|
|
280
|
+
)}
|
|
281
|
+
{models.map((m) => (
|
|
282
|
+
<option key={m.id} value={m.id}>
|
|
283
|
+
{m.id}
|
|
85
284
|
</option>
|
|
86
285
|
))}
|
|
87
286
|
</select>
|
|
88
|
-
|
|
287
|
+
) : (
|
|
288
|
+
<input
|
|
289
|
+
type="text"
|
|
290
|
+
placeholder={local ? 'e.g. qwen3:8b' : 'e.g. anthropic/claude-sonnet-5'}
|
|
291
|
+
value={e.model}
|
|
292
|
+
onChange={(ev) => e.setModel(ev.target.value)}
|
|
293
|
+
/>
|
|
294
|
+
)}
|
|
295
|
+
<button type="button" onClick={() => void e.loadModels()} disabled={e.modelsState === 'loading'}>
|
|
296
|
+
{e.modelsState === 'loading' ? 'asking…' : 'list models'}
|
|
297
|
+
</button>
|
|
298
|
+
</div>
|
|
299
|
+
{e.provider === 'openwebui' ? null : (
|
|
300
|
+
<>
|
|
301
|
+
<label
|
|
302
|
+
data-tip={
|
|
303
|
+
local
|
|
304
|
+
? 'off = no thinking (chat template switch), anything else = think first'
|
|
305
|
+
: 'reasoning effort sent to the model'
|
|
306
|
+
}
|
|
307
|
+
>
|
|
308
|
+
thinking
|
|
309
|
+
</label>
|
|
310
|
+
<div className="enh-inline">
|
|
311
|
+
<span className="btn-group">
|
|
312
|
+
{EFFORTS.map((x) => (
|
|
313
|
+
<button
|
|
314
|
+
key={x}
|
|
315
|
+
type="button"
|
|
316
|
+
className={e.effort === x ? 'mode sel' : 'mode'}
|
|
317
|
+
onClick={() => e.setEffort(x)}
|
|
318
|
+
>
|
|
319
|
+
{x}
|
|
320
|
+
</button>
|
|
321
|
+
))}
|
|
322
|
+
</span>
|
|
323
|
+
<label className="row-inline" data-tip="hide models that report no reasoning support">
|
|
324
|
+
<input type="checkbox" checked={e.thinkingOnly} onChange={() => e.toggleThinkingOnly()} />
|
|
325
|
+
thinking models only
|
|
326
|
+
</label>
|
|
327
|
+
</div>
|
|
328
|
+
</>
|
|
89
329
|
)}
|
|
90
330
|
</div>
|
|
91
|
-
{
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
</div>
|
|
95
|
-
) : null}
|
|
96
|
-
{p.e.modelsError !== '' ? <div className="error">🔴 {p.e.modelsError}</div> : null}
|
|
97
|
-
</div>
|
|
331
|
+
{e.modelsError !== '' ? <div className="error">🔴 {e.modelsError}</div> : null}
|
|
332
|
+
{e.configsError !== '' ? <div className="error">🔴 {e.configsError}</div> : null}
|
|
333
|
+
</EditPanel>
|
|
98
334
|
)
|
|
99
335
|
})
|
|
100
336
|
|
|
101
337
|
const MasterPrompt = observer(function MasterPrompt(p: { e: EnhancerSt }) {
|
|
102
338
|
const preset = p.e.preset
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
339
|
+
return (
|
|
340
|
+
<EditPanel
|
|
341
|
+
kind="master prompt"
|
|
342
|
+
name={preset?.name ?? null}
|
|
343
|
+
tip={preset == null ? undefined : `.comfy-ts/prompt-enhancers/${preset.name}.md, saved as you type`}
|
|
344
|
+
onRename={(n) => void p.e.renamePreset(n)}
|
|
345
|
+
onDuplicate={() => p.e.duplicatePreset()}
|
|
346
|
+
onDelete={() => void p.e.deletePreset()}
|
|
347
|
+
onClose={() => p.e.setEditing(null)}
|
|
348
|
+
>
|
|
349
|
+
{preset == null ? (
|
|
350
|
+
<div className="enh-empty">
|
|
351
|
+
{p.e.presetsState === 'loading' ? 'loading…' : 'no master prompt yet: add one on the left'}
|
|
109
352
|
</div>
|
|
110
|
-
|
|
111
|
-
<
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
353
|
+
) : (
|
|
354
|
+
<textarea
|
|
355
|
+
className="enh-text enh-master"
|
|
356
|
+
rows={18}
|
|
357
|
+
value={preset.text}
|
|
358
|
+
onChange={(ev) => p.e.setPresetText(ev.target.value)}
|
|
359
|
+
/>
|
|
360
|
+
)}
|
|
361
|
+
{p.e.presetsError !== '' ? <div className="error">🔴 {p.e.presetsError}</div> : null}
|
|
362
|
+
</EditPanel>
|
|
363
|
+
)
|
|
364
|
+
})
|
|
365
|
+
|
|
366
|
+
/** the job, top to bottom: the actions, then yours, then the rewrite. The two boxes share the
|
|
367
|
+
* height the modal has, so nothing scrolls and nothing below the buttons ever moves them */
|
|
368
|
+
const Job = observer(function Job(p: { e: EnhancerSt; st: WebSt }) {
|
|
369
|
+
const e = p.e
|
|
370
|
+
const running = e.phase === 'running'
|
|
371
|
+
// opening the enhancer puts you IN the input, the cursor after its last character: the next
|
|
372
|
+
// thing you do is type or press ⌘E
|
|
373
|
+
const inputRef = useRef<HTMLTextAreaElement>(null)
|
|
374
|
+
useEffect(() => {
|
|
375
|
+
const el = inputRef.current
|
|
376
|
+
if (el == null) return
|
|
377
|
+
el.focus()
|
|
378
|
+
el.setSelectionRange(el.value.length, el.value.length)
|
|
379
|
+
}, [])
|
|
380
|
+
const act = actions(e)
|
|
381
|
+
const kbd = (s: EnhancerShortcut): ReactNode => (
|
|
382
|
+
<span className="kbd-hint">
|
|
383
|
+
{MOD_KEY}
|
|
384
|
+
{ENHANCER_KEYS[s]}
|
|
385
|
+
</span>
|
|
386
|
+
)
|
|
387
|
+
const noResult = e.result.trim() === ''
|
|
128
388
|
return (
|
|
129
|
-
<
|
|
130
|
-
<div className="
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
<button
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
389
|
+
<section className="enh-job">
|
|
390
|
+
<div className="enh-actions">
|
|
391
|
+
{/* one width for enhance and stop, so the swap never moves apply */}
|
|
392
|
+
{running ? (
|
|
393
|
+
<button type="button" className="enh-big enh-go" onClick={() => e.cancel()}>
|
|
394
|
+
stop
|
|
395
|
+
</button>
|
|
396
|
+
) : (
|
|
397
|
+
<button type="button" className="primary enh-big enh-go" onClick={act.enhance}>
|
|
398
|
+
<Icon name="sparkle" /> enhance {kbd('enhance')}
|
|
399
|
+
</button>
|
|
400
|
+
)}
|
|
401
|
+
<button
|
|
402
|
+
type="button"
|
|
403
|
+
className="enh-big"
|
|
404
|
+
data-tip="generate the draft with this rewrite in place of the prompt: the prompt itself is not changed"
|
|
405
|
+
onClick={() => p.st.generate(e.tryOverride)}
|
|
406
|
+
disabled={noResult}
|
|
407
|
+
>
|
|
408
|
+
<Icon name="play" size={0.85} /> try it <span className="kbd-hint">{MOD_KEY}⏎</span>
|
|
149
409
|
</button>
|
|
150
|
-
<button
|
|
151
|
-
|
|
410
|
+
<button
|
|
411
|
+
type="button"
|
|
412
|
+
className="accent enh-big"
|
|
413
|
+
data-tip="write this rewrite into the prompt and close"
|
|
414
|
+
onClick={act.apply}
|
|
415
|
+
disabled={noResult}
|
|
416
|
+
>
|
|
417
|
+
apply to prompt {kbd('apply')}
|
|
152
418
|
</button>
|
|
153
|
-
<span className="
|
|
154
|
-
{
|
|
155
|
-
{p.e.saveState === 'saved' ? 'autosaved to disk' : null}
|
|
156
|
-
{p.e.saveState === 'error' ? `🔴 save failed: ${p.e.saveError}` : null}
|
|
419
|
+
<span className="run-error" data-tip={e.error === '' ? undefined : e.error}>
|
|
420
|
+
{e.error === '' ? '' : `🔴 ${e.error}`}
|
|
157
421
|
</span>
|
|
158
422
|
</div>
|
|
159
|
-
<
|
|
160
|
-
|
|
423
|
+
<div className="enh-label enh-label-row">
|
|
424
|
+
<span>yours, what gets sent (the form is untouched)</span>
|
|
425
|
+
<span className="row-inline">
|
|
426
|
+
<button
|
|
427
|
+
type="button"
|
|
428
|
+
className="mini"
|
|
429
|
+
data-tip="replace this text with the prompt you opened the enhancer from"
|
|
430
|
+
onClick={() => e.usePrompt()}
|
|
431
|
+
>
|
|
432
|
+
use the prompt
|
|
433
|
+
</button>
|
|
434
|
+
<HistoryButton entries={e.inputHistory} what="enhance input" onPick={(h) => e.setOriginal(h.value)} />
|
|
435
|
+
</span>
|
|
436
|
+
</div>
|
|
437
|
+
<textarea
|
|
438
|
+
ref={inputRef}
|
|
439
|
+
className="enh-text enh-box"
|
|
440
|
+
value={e.original}
|
|
441
|
+
onChange={(ev) => e.setOriginal(ev.target.value)}
|
|
442
|
+
/>
|
|
443
|
+
<div className="enh-label">
|
|
444
|
+
{running ? `rewriting… ${e.result.length} chars` : 'rewrite, editable before you apply'}
|
|
445
|
+
{e.thinking === '' ? null : (
|
|
446
|
+
<span className="enh-think-tip" data-tip={e.thinking}>
|
|
447
|
+
· thinking ({e.thinking.length} chars)
|
|
448
|
+
</span>
|
|
449
|
+
)}
|
|
450
|
+
</div>
|
|
451
|
+
<textarea
|
|
452
|
+
className="enh-text enh-box enh-result"
|
|
453
|
+
value={e.result}
|
|
454
|
+
placeholder="press enhance"
|
|
455
|
+
onChange={(ev) => e.setResult(ev.target.value)}
|
|
456
|
+
/>
|
|
457
|
+
</section>
|
|
161
458
|
)
|
|
162
459
|
})
|
|
163
460
|
|
|
164
|
-
|
|
461
|
+
/** the enhancer's own actions, shared by the buttons and the keys so they cannot drift apart.
|
|
462
|
+
* try is the global ⌘⏎ (VarsForm), through EnhancerSt.tryOverride like its button */
|
|
463
|
+
function actions(e: EnhancerSt): Record<EnhancerShortcut, () => void> {
|
|
464
|
+
return {
|
|
465
|
+
enhance: () => (e.phase === 'running' ? undefined : e.run()),
|
|
466
|
+
apply: () => e.apply(),
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
const Modal = observer(function Modal(p: { e: EnhancerSt; st: WebSt }) {
|
|
165
471
|
const e = p.e
|
|
472
|
+
const st = p.st
|
|
166
473
|
useEffect(() => {
|
|
167
474
|
const onKey = (ev: KeyboardEvent): void => {
|
|
168
|
-
|
|
169
|
-
if (ev.key === '
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
475
|
+
// esc closes the editor first, the modal only when nothing is open over the job
|
|
476
|
+
if (ev.key === 'Escape') {
|
|
477
|
+
if (e.editing != null) e.setEditing(null)
|
|
478
|
+
else e.close()
|
|
479
|
+
return
|
|
173
480
|
}
|
|
481
|
+
const s = enhancerShortcutOf(ev)
|
|
482
|
+
if (s == null) return
|
|
483
|
+
ev.preventDefault()
|
|
484
|
+
actions(e)[s]()
|
|
174
485
|
}
|
|
175
486
|
window.addEventListener('keydown', onKey)
|
|
176
487
|
return () => window.removeEventListener('keydown', onKey)
|
|
177
|
-
}, [e])
|
|
178
|
-
const running = e.phase === 'running'
|
|
488
|
+
}, [e, st])
|
|
179
489
|
return (
|
|
180
|
-
<div className="modal-overlay" onClick={() => e.close()}>
|
|
181
|
-
<div className="modal" onClick={(ev) => ev.stopPropagation()}>
|
|
490
|
+
<div className="modal-overlay top" onClick={() => e.close()}>
|
|
491
|
+
<div className="modal enh-modal" onClick={(ev) => ev.stopPropagation()}>
|
|
182
492
|
<div className="modal-head">
|
|
183
|
-
<b
|
|
493
|
+
<b className="enh-title">
|
|
184
494
|
<Icon name="sparkle" /> enhance prompt
|
|
185
495
|
</b>
|
|
186
|
-
<button
|
|
496
|
+
<button
|
|
497
|
+
type="button"
|
|
498
|
+
className="modal-close"
|
|
499
|
+
data-tip="close (esc), nothing is applied"
|
|
500
|
+
onClick={() => e.close()}
|
|
501
|
+
>
|
|
187
502
|
<Icon name="close" />
|
|
188
503
|
</button>
|
|
189
504
|
</div>
|
|
190
|
-
<div className="
|
|
191
|
-
<
|
|
192
|
-
<
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
<div>
|
|
196
|
-
<div className="hint">yours (edit before refining, the var is untouched)</div>
|
|
197
|
-
<textarea rows={8} value={e.original} onChange={(ev) => e.setOriginal(ev.target.value)} />
|
|
198
|
-
</div>
|
|
199
|
-
<div>
|
|
200
|
-
<div className="hint">{running ? 'rewriting…' : 'rewritten (editable before apply)'}</div>
|
|
201
|
-
<textarea
|
|
202
|
-
rows={8}
|
|
203
|
-
value={e.result}
|
|
204
|
-
placeholder="hit enhance"
|
|
205
|
-
onChange={(ev) => e.setResult(ev.target.value)}
|
|
206
|
-
/>
|
|
505
|
+
<div className="enh-layout">
|
|
506
|
+
<Side e={e} />
|
|
507
|
+
<div className="enh-right">
|
|
508
|
+
<div className="modal-body enh-main">
|
|
509
|
+
<Job e={e} st={st} />
|
|
207
510
|
</div>
|
|
511
|
+
{/* over the job, never beside it: the job keeps its place and size */}
|
|
512
|
+
{e.editing === 'llm' ? <LlmSettings e={e} /> : null}
|
|
513
|
+
{e.editing === 'preset' ? <MasterPrompt e={e} /> : null}
|
|
208
514
|
</div>
|
|
209
|
-
{e.thinking !== '' ? (
|
|
210
|
-
<div>
|
|
211
|
-
<div className="section-title">thinking</div>
|
|
212
|
-
<div className="enh-think">{e.thinking}</div>
|
|
213
|
-
</div>
|
|
214
|
-
) : null}
|
|
215
|
-
{e.error !== '' ? <div className="error">🔴 {e.error}</div> : null}
|
|
216
|
-
</div>
|
|
217
|
-
<div className="modal-foot">
|
|
218
|
-
{running ? (
|
|
219
|
-
<button type="button" onClick={() => e.cancel()}>
|
|
220
|
-
stop
|
|
221
|
-
</button>
|
|
222
|
-
) : (
|
|
223
|
-
<button type="button" className="primary" onClick={() => e.run()} data-tip="⌘⏎ / ctrl+⏎">
|
|
224
|
-
enhance
|
|
225
|
-
</button>
|
|
226
|
-
)}
|
|
227
|
-
<button type="button" onClick={() => e.apply()} disabled={e.result.trim() === ''}>
|
|
228
|
-
apply to prompt
|
|
229
|
-
</button>
|
|
230
|
-
<span className="hint" style={{ flex: 1 }}>
|
|
231
|
-
{running ? `${e.result.length} chars streamed` : 'nothing is written until you apply'}
|
|
232
|
-
</span>
|
|
233
|
-
<button type="button" className="link" onClick={() => e.close()}>
|
|
234
|
-
cancel
|
|
235
|
-
</button>
|
|
236
515
|
</div>
|
|
237
516
|
</div>
|
|
238
517
|
</div>
|
|
239
518
|
)
|
|
240
519
|
})
|
|
241
520
|
|
|
242
|
-
export const PromptEnhancer = observer(function PromptEnhancer(p: {
|
|
521
|
+
export const PromptEnhancer = observer(function PromptEnhancer(p: {
|
|
522
|
+
v: VarSt
|
|
523
|
+
st: WebSt
|
|
524
|
+
module: string
|
|
525
|
+
/** in lanes mode: refine this lane only */
|
|
526
|
+
lane?: number
|
|
527
|
+
/** the icon alone, for a lane's bar */
|
|
528
|
+
compact?: boolean
|
|
529
|
+
/** ⌘E opens THIS one (the first prompt): say so on the button */
|
|
530
|
+
shortcut?: boolean
|
|
531
|
+
}) {
|
|
243
532
|
const e = p.st.enhancer
|
|
244
533
|
return (
|
|
245
534
|
<>
|
|
246
535
|
<button
|
|
247
536
|
type="button"
|
|
248
|
-
className=
|
|
537
|
+
className={p.compact === true ? 'link' : 'mini'}
|
|
249
538
|
data-tip="rewrite this prompt with an llm"
|
|
250
|
-
onClick={() => e.openFor({ v: p.v, module: p.module })}
|
|
539
|
+
onClick={() => e.openFor({ v: p.v, module: p.module, lane: p.lane })}
|
|
251
540
|
>
|
|
252
|
-
<Icon name="sparkle" />
|
|
541
|
+
<Icon name="sparkle" />
|
|
542
|
+
{p.compact === true ? null : ' enhance'}
|
|
543
|
+
{p.shortcut === true ? (
|
|
544
|
+
<span className="kbd-hint">
|
|
545
|
+
{MOD_KEY}
|
|
546
|
+
{SHORTCUT_KEYS['open-enhancer']}
|
|
547
|
+
</span>
|
|
548
|
+
) : null}
|
|
253
549
|
</button>
|
|
254
|
-
{e.target === p.v ? <Modal e={e} /> : null}
|
|
550
|
+
{e.target === p.v && e.targetLane === (p.lane ?? null) ? <Modal e={e} st={p.st} /> : null}
|
|
255
551
|
</>
|
|
256
552
|
)
|
|
257
553
|
})
|