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
|
@@ -12,48 +12,58 @@
|
|
|
12
12
|
// WebSt); with both hidden the row collapses to a count. Names come from
|
|
13
13
|
// descriptor optionLabels; the value keeps raw enum keys, replaced by copy
|
|
14
14
|
import { Icon } from 'src/cli/serve/web/components/Icon.tsx'
|
|
15
|
+
import { MenuButton, MenuItem } from 'src/cli/serve/web/components/MenuButton.tsx'
|
|
15
16
|
import { logWebError } from 'src/cli/serve/web/logWeb.ts'
|
|
16
17
|
import { observer, useLocalObservable } from 'mobx-react-lite'
|
|
17
|
-
import { useEffect, useRef, type ReactNode } from 'react'
|
|
18
|
+
import { useEffect, useRef, useState, type DragEvent, type ReactNode } from 'react'
|
|
18
19
|
import { fetchLoraAbout, fetchLoraInfo, loraPreviewSrc, type LoraAbout, type LoraInfo } from 'src/cli/serve/web/api.ts'
|
|
19
|
-
import type { LoraStrength } from 'src/vars/
|
|
20
|
+
import type { LoraStrength } from 'src/vars/loraEntry.ts'
|
|
20
21
|
import type { VarSt } from 'src/cli/serve/web/state/FormSt.ts'
|
|
21
22
|
import type { WebSt } from 'src/cli/serve/web/state/WebSt.ts'
|
|
22
|
-
import { LORA_SORTS, sortLoraMatches } from 'src/cli/serve/web/state/loraSort.ts'
|
|
23
|
+
import { LORA_SORTS, popupCardClick, popupCards, sortLoraMatches } from 'src/cli/serve/web/state/loraSort.ts'
|
|
23
24
|
import {
|
|
24
25
|
loraIsOn,
|
|
25
26
|
paletteOrder,
|
|
27
|
+
pruneLorasRecord,
|
|
26
28
|
reorderLoras,
|
|
27
29
|
loraStrengthPair,
|
|
28
30
|
setLoraEnabled,
|
|
29
31
|
setLoraStrength,
|
|
30
32
|
type LoraStrengthPair,
|
|
31
33
|
} from 'src/cli/serve/web/state/payload.ts'
|
|
34
|
+
import {
|
|
35
|
+
isLoraLanes,
|
|
36
|
+
isLorasInput,
|
|
37
|
+
lorasFromLanes,
|
|
38
|
+
moveLane,
|
|
39
|
+
moveLoraToLane,
|
|
40
|
+
newLaneName,
|
|
41
|
+
patchLane,
|
|
42
|
+
removeLane,
|
|
43
|
+
toLoraLanes,
|
|
44
|
+
type LoraLane,
|
|
45
|
+
type LoraRecord,
|
|
46
|
+
type LorasInput,
|
|
47
|
+
} from 'src/vars/lanes.ts'
|
|
48
|
+
|
|
49
|
+
/** one editable list of loras: the whole var, or one of its lanes (ix -1 = no lanes) */
|
|
50
|
+
type Section = { ix: number; record: LoraRecord; lane: LoraLane | null }
|
|
32
51
|
|
|
33
52
|
/** our own drag payload type: a foreign drag cannot forge it */
|
|
34
53
|
const CARD_DRAG_TYPE = 'application/x-comfy-lora'
|
|
35
54
|
|
|
36
|
-
function asRecord(raw: unknown): Record<string, unknown> {
|
|
37
|
-
if (raw != null && typeof raw === 'object' && !Array.isArray(raw)) return raw as Record<string, unknown>
|
|
38
|
-
return {}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
55
|
type LocalSt = {
|
|
42
56
|
open: boolean
|
|
43
57
|
filter: string
|
|
44
58
|
info: Map<string, LoraInfo | 'loading' | 'error'>
|
|
45
59
|
previewFailed: Set<string>
|
|
46
|
-
/** strength of a PAUSED lora, so resuming restores it (LorasVar.prev) */
|
|
47
|
-
prevStrength: Map<string, LoraStrengthPair>
|
|
48
|
-
/** loras paused in THIS session: they leave the draft record but stay in the palette,
|
|
49
|
-
* which is what makes "a few images with, a few without" one click each way */
|
|
50
|
-
paused: Set<string>
|
|
51
60
|
setOpen(open: boolean): void
|
|
61
|
+
/** the section the popup adds into (-1 = the var itself, no lanes) */
|
|
62
|
+
target: number
|
|
63
|
+
openFor(ix: number): void
|
|
52
64
|
setFilter(raw: string): void
|
|
53
65
|
noteInfo(name: string, v: LoraInfo | 'loading' | 'error'): void
|
|
54
66
|
notePreviewFailed(name: string): void
|
|
55
|
-
notePrevStrength(name: string, pair: LoraStrengthPair): void
|
|
56
|
-
setPaused(name: string, paused: boolean): void
|
|
57
67
|
/** the lora whose details panel is open, null when none */
|
|
58
68
|
details: string | null
|
|
59
69
|
setDetails(name: string | null): void
|
|
@@ -63,19 +73,125 @@ type LocalSt = {
|
|
|
63
73
|
setSplit(name: string, split: boolean): void
|
|
64
74
|
}
|
|
65
75
|
|
|
76
|
+
const LANE_DRAG = 'application/x-comfy-lora-lane'
|
|
77
|
+
|
|
78
|
+
/** a lora lane's bar: a name pill (click = use / leave out, drag = reorder, double-click =
|
|
79
|
+
* rename), the count, and ⋯. It also takes a card dropped on it: the lora moves to its end */
|
|
80
|
+
const LoraLaneBar = observer(function LoraLaneBar(p: {
|
|
81
|
+
v: VarSt
|
|
82
|
+
lanes: LoraLane[]
|
|
83
|
+
ix: number
|
|
84
|
+
count: number
|
|
85
|
+
on: number
|
|
86
|
+
onDropCard: (raw: string) => void
|
|
87
|
+
}) {
|
|
88
|
+
const [renaming, setRenaming] = useState(false)
|
|
89
|
+
const lane = p.lanes[p.ix]
|
|
90
|
+
if (lane == null) return null
|
|
91
|
+
const write = (lanes: LoraLane[]): void => {
|
|
92
|
+
p.v.set({ lanes })
|
|
93
|
+
}
|
|
94
|
+
return (
|
|
95
|
+
<div
|
|
96
|
+
className="lane-bar"
|
|
97
|
+
onDragOver={(e) => {
|
|
98
|
+
const types = e.dataTransfer.types
|
|
99
|
+
if (types.includes(CARD_DRAG_TYPE) || types.includes(LANE_DRAG)) e.preventDefault()
|
|
100
|
+
}}
|
|
101
|
+
onDrop={(e) => {
|
|
102
|
+
const card = e.dataTransfer.getData(CARD_DRAG_TYPE)
|
|
103
|
+
if (card !== '') {
|
|
104
|
+
e.preventDefault()
|
|
105
|
+
p.onDropCard(card)
|
|
106
|
+
return
|
|
107
|
+
}
|
|
108
|
+
const raw = e.dataTransfer.getData(LANE_DRAG)
|
|
109
|
+
const from = Number(raw)
|
|
110
|
+
if (raw === '' || !Number.isInteger(from) || from === p.ix) return
|
|
111
|
+
e.preventDefault()
|
|
112
|
+
write(moveLane(p.lanes, from, p.ix - from))
|
|
113
|
+
}}
|
|
114
|
+
>
|
|
115
|
+
{renaming ? (
|
|
116
|
+
<input
|
|
117
|
+
type="text"
|
|
118
|
+
className="lane-name"
|
|
119
|
+
autoFocus
|
|
120
|
+
defaultValue={lane.name}
|
|
121
|
+
onFocus={(e) => e.currentTarget.select()}
|
|
122
|
+
onKeyDown={(e) => {
|
|
123
|
+
if (e.key === 'Enter') {
|
|
124
|
+
write(patchLane(p.lanes, p.ix, { name: e.currentTarget.value.trim() || lane.name }))
|
|
125
|
+
setRenaming(false)
|
|
126
|
+
}
|
|
127
|
+
if (e.key === 'Escape') setRenaming(false)
|
|
128
|
+
}}
|
|
129
|
+
onBlur={() => setRenaming(false)}
|
|
130
|
+
/>
|
|
131
|
+
) : (
|
|
132
|
+
<button
|
|
133
|
+
type="button"
|
|
134
|
+
className={lane.active ? 'lane-pill' : 'lane-pill off'}
|
|
135
|
+
draggable
|
|
136
|
+
data-tip={`${lane.active ? 'runs' : 'left out'}: click to switch, drag to reorder, double-click to rename`}
|
|
137
|
+
onDragStart={(e) => {
|
|
138
|
+
e.dataTransfer.effectAllowed = 'move'
|
|
139
|
+
e.dataTransfer.setData(LANE_DRAG, String(p.ix))
|
|
140
|
+
}}
|
|
141
|
+
onClick={() => write(patchLane(p.lanes, p.ix, { active: !lane.active }))}
|
|
142
|
+
onDoubleClick={() => setRenaming(true)}
|
|
143
|
+
>
|
|
144
|
+
{lane.name}
|
|
145
|
+
</button>
|
|
146
|
+
)}
|
|
147
|
+
{p.count === 0 ? null : <span className="hint">{`${p.on}/${p.count} on`}</span>}
|
|
148
|
+
<span className="lane-tools">
|
|
149
|
+
<MenuButton tip="lane actions">
|
|
150
|
+
{(close) => (
|
|
151
|
+
<>
|
|
152
|
+
<MenuItem
|
|
153
|
+
label="rename"
|
|
154
|
+
onClick={() => {
|
|
155
|
+
close()
|
|
156
|
+
setRenaming(true)
|
|
157
|
+
}}
|
|
158
|
+
/>
|
|
159
|
+
<MenuItem
|
|
160
|
+
label="remove"
|
|
161
|
+
disabled={p.count > 0 || p.lanes.length === 1}
|
|
162
|
+
tip={p.count > 0 ? 'empty the lane first' : undefined}
|
|
163
|
+
onClick={() => {
|
|
164
|
+
close()
|
|
165
|
+
write(removeLane(p.lanes, p.ix))
|
|
166
|
+
}}
|
|
167
|
+
/>
|
|
168
|
+
</>
|
|
169
|
+
)}
|
|
170
|
+
</MenuButton>
|
|
171
|
+
</span>
|
|
172
|
+
</div>
|
|
173
|
+
)
|
|
174
|
+
})
|
|
175
|
+
|
|
66
176
|
export const LorasControl = observer(function LorasControl(p: {
|
|
67
177
|
v: VarSt
|
|
68
178
|
host: string
|
|
69
179
|
st: WebSt
|
|
70
180
|
hostUrl: string | null
|
|
181
|
+
/** ⌘O opens THIS var's picker: the first loras var of the form */
|
|
182
|
+
jumpTarget: boolean
|
|
71
183
|
}) {
|
|
72
184
|
const local = useLocalObservable<LocalSt>(() => ({
|
|
73
185
|
open: false,
|
|
74
186
|
filter: '',
|
|
75
187
|
info: new Map(),
|
|
76
188
|
previewFailed: new Set(),
|
|
77
|
-
prevStrength: new Map(),
|
|
78
189
|
paused: new Set(),
|
|
190
|
+
target: -1,
|
|
191
|
+
openFor(ix: number) {
|
|
192
|
+
this.target = ix
|
|
193
|
+
this.open = true
|
|
194
|
+
},
|
|
79
195
|
setOpen(open: boolean) {
|
|
80
196
|
this.open = open
|
|
81
197
|
},
|
|
@@ -88,13 +204,6 @@ export const LorasControl = observer(function LorasControl(p: {
|
|
|
88
204
|
notePreviewFailed(name: string) {
|
|
89
205
|
this.previewFailed.add(name)
|
|
90
206
|
},
|
|
91
|
-
notePrevStrength(name: string, pair: LoraStrengthPair) {
|
|
92
|
-
this.prevStrength.set(name, pair)
|
|
93
|
-
},
|
|
94
|
-
setPaused(name: string, paused: boolean) {
|
|
95
|
-
if (paused) this.paused.add(name)
|
|
96
|
-
else this.paused.delete(name)
|
|
97
|
-
},
|
|
98
207
|
details: null,
|
|
99
208
|
setDetails(name: string | null) {
|
|
100
209
|
this.details = name
|
|
@@ -107,54 +216,59 @@ export const LorasControl = observer(function LorasControl(p: {
|
|
|
107
216
|
this.split.set(name, split)
|
|
108
217
|
},
|
|
109
218
|
}))
|
|
110
|
-
const
|
|
219
|
+
const value: LorasInput = isLorasInput(p.v.value) ? p.v.value : {}
|
|
220
|
+
const laned = isLoraLanes(value) ? value : null
|
|
111
221
|
const options = p.v.desc.options ?? []
|
|
112
222
|
const labels = p.v.desc.optionLabels ?? {}
|
|
113
223
|
const label = (name: string): string => labels[name] ?? name
|
|
114
|
-
// the
|
|
115
|
-
//
|
|
116
|
-
//
|
|
117
|
-
//
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
const
|
|
224
|
+
// the row is a list of SECTIONS: one per lane (src/vars/lanes.ts), or a single one without
|
|
225
|
+
// lanes. A section's palette is its loras that are on plus the paused ones, never "every key":
|
|
226
|
+
// `false` is what an untick in the TUI writes, and reading it as a member put the whole
|
|
227
|
+
// catalog in the row. Record order inside a section, so a lora you add lands at the END
|
|
228
|
+
const sections: Section[] = isLoraLanes(value)
|
|
229
|
+
? value.lanes.map((lane, ix) => ({ ix, record: lane.loras, lane }))
|
|
230
|
+
: [{ ix: -1, record: value, lane: null }]
|
|
231
|
+
const namesOf = (sec: Section): string[] => paletteOrder({ record: sec.record, options })
|
|
232
|
+
const allNames = [...new Set(sections.flatMap(namesOf))]
|
|
233
|
+
const isOn = (sec: Section, name: string): boolean => loraIsOn(sec.record[name])
|
|
234
|
+
const onCount = sections.reduce((n, sec) => n + namesOf(sec).filter((name) => isOn(sec, name)).length, 0)
|
|
235
|
+
// the popup adds into ONE section: the lane whose `add` opened it
|
|
236
|
+
const target = sections.find((sec) => sec.ix === local.target) ?? sections[0] ?? null
|
|
237
|
+
const targetNames = target == null ? [] : namesOf(target)
|
|
238
|
+
/** write one section back: the var itself, or its lane. Pruned through the same typed filter
|
|
239
|
+
* a loaded draft goes through, so what lands in the var is always a valid record */
|
|
240
|
+
const writeSection = (ix: number, record: Record<string, unknown>): void => {
|
|
241
|
+
const clean = pruneLorasRecord(record, options)
|
|
242
|
+
if (laned == null) p.v.set(clean)
|
|
243
|
+
else p.v.set({ lanes: patchLane(laned.lanes, ix, { loras: clean }) })
|
|
244
|
+
}
|
|
123
245
|
/** known to the lora manager, absent from ComfyUI's own enum. it is offered rather than
|
|
124
246
|
* hidden, but ComfyUI validates a prompt against the enum it has CACHED, so picking one
|
|
125
|
-
* fails at send time until that host rescans its models
|
|
247
|
+
* fails at send time until that host rescans its models. ComfyUI rescans a folder when its
|
|
248
|
+
* mtime moves, which never happens on exFAT: extra/comfyui-fresh-model-lists fixes that */
|
|
126
249
|
const managerOnly = new Set(p.v.desc.managerOnlyOptions ?? [])
|
|
127
250
|
const MANAGER_ONLY_TIP =
|
|
128
|
-
|
|
251
|
+
"on disk and known to the lora manager, but not in ComfyUI's list yet: it refuses the prompt. the panel refreshes the host by itself when it changes; if this stays, the models drive is probably exFAT (install extra/comfyui-fresh-model-lists) or ComfyUI needs a restart"
|
|
129
252
|
const warnBadge = (name: string): ReactNode =>
|
|
130
253
|
managerOnly.has(name) ? (
|
|
131
254
|
<span className="lora-warn" data-tip={MANAGER_ONLY_TIP}>
|
|
132
255
|
<Icon name="warn" size={0.9} />
|
|
133
256
|
</span>
|
|
134
257
|
) : null
|
|
135
|
-
/** manager-only loras actually IN the palette: those are the ones a run will send, and the
|
|
136
|
-
* ones ComfyUI has no entry for until it rescans its models */
|
|
137
|
-
const managerOnlyInUse = selectedNames.filter((n) => managerOnly.has(n))
|
|
138
258
|
const showImages = p.st.showLoraImages
|
|
139
259
|
const triggers = p.v.desc.optionTriggers ?? {}
|
|
140
260
|
/** the trigger words under a row card, in one of FOUR states that never look alike: the
|
|
141
|
-
* words, a definite none (civitai was asked), never fetched (a button asks it), or not
|
|
142
|
-
* the
|
|
261
|
+
* words, a definite none (civitai was asked), never fetched (a button asks it), or not loaded
|
|
262
|
+
* yet (the local copy of the manager's list predates the lora, a button re-reads it). Titles hidden hides the words, never the state */
|
|
143
263
|
const triggerLine = (name: string): ReactNode => {
|
|
144
264
|
const t = triggers[name]
|
|
145
265
|
if (t == null)
|
|
146
266
|
return (
|
|
147
|
-
<span
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
disabled={p.st.loraSyncing}
|
|
153
|
-
data-tip="re-download the lora manager's list for this host (names, trigger words, previews)"
|
|
154
|
-
onClick={() => void p.st.refreshLoras()}
|
|
155
|
-
>
|
|
156
|
-
{p.st.loraSyncing ? 'syncing…' : 'sync'}
|
|
157
|
-
</button>
|
|
267
|
+
<span
|
|
268
|
+
className="chip-triggers missing"
|
|
269
|
+
data-tip="this lora is newer than the copy of the lora manager's list kept here: the next host refresh brings its trigger words, name and preview (it runs by itself). The lora itself runs fine"
|
|
270
|
+
>
|
|
271
|
+
trigger words not loaded yet
|
|
158
272
|
</span>
|
|
159
273
|
)
|
|
160
274
|
if (t.state === 'unfetched') {
|
|
@@ -208,39 +322,32 @@ export const LorasControl = observer(function LorasControl(p: {
|
|
|
208
322
|
}
|
|
209
323
|
const showTitles = p.st.showLoraTitles
|
|
210
324
|
|
|
211
|
-
/** add to
|
|
212
|
-
const setEntry = (name: string, st: LoraStrength | null): void => {
|
|
213
|
-
|
|
214
|
-
const next = { ...record }
|
|
325
|
+
/** add to a section (a strength) or REMOVE from it entirely (null) */
|
|
326
|
+
const setEntry = (sec: Section, name: string, st: LoraStrength | null): void => {
|
|
327
|
+
const next: Record<string, unknown> = { ...sec.record }
|
|
215
328
|
if (st == null) delete next[name]
|
|
216
329
|
else next[name] = st
|
|
217
|
-
|
|
330
|
+
writeSection(sec.ix, next)
|
|
218
331
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
p.v.set(setLoraEnabled(record, name, on, on ? local.prevStrength.get(name) : undefined))
|
|
332
|
+
// a pause keeps the key and its strengths in the draft, so a reload keeps it off
|
|
333
|
+
const toggleOn = (sec: Section, name: string, on: boolean): void => {
|
|
334
|
+
writeSection(sec.ix, setLoraEnabled(sec.record, name, on))
|
|
223
335
|
}
|
|
224
|
-
const setStrength = (name: string, pair: LoraStrengthPair): void => {
|
|
225
|
-
|
|
226
|
-
// editing an OFF lora's strength remembers it for when it comes back on
|
|
227
|
-
local.notePrevStrength(name, pair)
|
|
228
|
-
return
|
|
229
|
-
}
|
|
230
|
-
p.v.set(setLoraStrength(record, name, pair))
|
|
336
|
+
const setStrength = (sec: Section, name: string, pair: LoraStrengthPair): void => {
|
|
337
|
+
writeSection(sec.ix, setLoraStrength(sec.record, name, pair))
|
|
231
338
|
}
|
|
232
339
|
|
|
233
340
|
/** ONE slider by default, labelled `m+c`: model and clip are the same number in almost every
|
|
234
341
|
* lora, and two sliders for one decision is noise. Clicking the label splits them, and a lora
|
|
235
342
|
* whose values already differ opens split, its setting is someone's work, not a default */
|
|
236
|
-
const strengthInputs = (name: string): ReactNode => {
|
|
237
|
-
const pair =
|
|
343
|
+
const strengthInputs = (sec: Section, name: string): ReactNode => {
|
|
344
|
+
const pair = loraStrengthPair(sec.record[name])
|
|
238
345
|
const split = local.isSplit(name, pair.model !== pair.clip)
|
|
239
346
|
const write = (which: 'model' | 'clip' | 'both', raw: number): void => {
|
|
240
347
|
if (!Number.isFinite(raw)) return
|
|
241
348
|
const n = Math.round(raw * 100) / 100
|
|
242
|
-
if (which === 'both') return setStrength(name, { model: n, clip: n })
|
|
243
|
-
setStrength(name, which === 'model' ? { model: n, clip: pair.clip } : { model: pair.model, clip: n })
|
|
349
|
+
if (which === 'both') return setStrength(sec, name, { model: n, clip: n })
|
|
350
|
+
setStrength(sec, name, which === 'model' ? { model: n, clip: pair.clip } : { model: pair.model, clip: n })
|
|
244
351
|
}
|
|
245
352
|
const line = (which: 'model' | 'clip' | 'both', value: number, text: string, tip: string): ReactNode => (
|
|
246
353
|
<div className="st-line">
|
|
@@ -270,7 +377,7 @@ export const LorasControl = observer(function LorasControl(p: {
|
|
|
270
377
|
// trigger words for the active section load once per open (bounded: active loras only)
|
|
271
378
|
const open = local.open
|
|
272
379
|
const host = p.host
|
|
273
|
-
const activeKey =
|
|
380
|
+
const activeKey = allNames.join('\n')
|
|
274
381
|
useEffect(() => {
|
|
275
382
|
if (!open) return
|
|
276
383
|
for (const name of activeKey.split('\n')) {
|
|
@@ -282,6 +389,14 @@ export const LorasControl = observer(function LorasControl(p: {
|
|
|
282
389
|
}
|
|
283
390
|
}, [open, activeKey, host, local])
|
|
284
391
|
|
|
392
|
+
// ⌘O: a NEW jump opens the picker on the first section, as its own `add` would
|
|
393
|
+
const jump = p.st.jump
|
|
394
|
+
const firstIx = sections[0]?.ix ?? -1
|
|
395
|
+
useEffect(() => {
|
|
396
|
+
if (!p.jumpTarget || jump == null || jump.kind !== 'loras') return
|
|
397
|
+
local.openFor(firstIx)
|
|
398
|
+
}, [jump, p.jumpTarget, firstIx, local])
|
|
399
|
+
|
|
285
400
|
// esc closes wherever focus is, not only inside the filter input
|
|
286
401
|
useEffect(() => {
|
|
287
402
|
if (!open) return
|
|
@@ -302,7 +417,7 @@ export const LorasControl = observer(function LorasControl(p: {
|
|
|
302
417
|
addedAt: p.v.desc.optionAddedAt ?? {},
|
|
303
418
|
})
|
|
304
419
|
const cardCap = p.st.loraCap
|
|
305
|
-
const cards =
|
|
420
|
+
const { cards, enterPick } = popupCards({ matches, picked: targetNames, cap: cardCap })
|
|
306
421
|
/** the enum value IS a path (`krea2\styles\x.safetensors`, separators vary by host and by
|
|
307
422
|
* where the name came from), so the folder is everything before the last separator */
|
|
308
423
|
const folderOf = (name: string): string => {
|
|
@@ -334,24 +449,33 @@ export const LorasControl = observer(function LorasControl(p: {
|
|
|
334
449
|
input.select()
|
|
335
450
|
}, [open])
|
|
336
451
|
|
|
337
|
-
/** enter takes the
|
|
338
|
-
* needle reselected, so adding three loras is type-enter-type-enter
|
|
339
|
-
* is visible at once in the palette section above */
|
|
452
|
+
/** enter takes the first card not picked yet, the one the eye lands on. The popup stays open
|
|
453
|
+
* with the needle reselected, so adding three loras is type-enter-type-enter */
|
|
340
454
|
const addFirstMatch = (): void => {
|
|
341
|
-
const first =
|
|
455
|
+
const first = enterPick
|
|
342
456
|
if (first == null) return
|
|
343
457
|
// the SAME call the card's own click makes, so enter and a tap cannot drift apart
|
|
344
|
-
setEntry(first, [1, 1])
|
|
458
|
+
if (target != null) setEntry(target, first, [1, 1])
|
|
345
459
|
filterRef.current?.select()
|
|
346
460
|
}
|
|
347
461
|
|
|
348
|
-
|
|
462
|
+
// two size factors, each with its own slider: the form's cards follow formScale, the
|
|
463
|
+
// popup's grid follows popupScale. 168/130 and 120/110 are the base card and image sizes
|
|
464
|
+
const formScale = p.st.loraFormScale
|
|
465
|
+
const popupScale = p.st.loraPopupScale
|
|
466
|
+
const cardWidth = Math.round(168 * formScale)
|
|
467
|
+
const gridMin = Math.round(120 * popupScale)
|
|
468
|
+
const thumb = (name: string, height?: number): ReactNode => {
|
|
349
469
|
if (!showImages) return null
|
|
470
|
+
const style = height == null ? undefined : { height }
|
|
350
471
|
return local.previewFailed.has(name) ? (
|
|
351
|
-
<div className="lora-thumb none"
|
|
472
|
+
<div className="lora-thumb none" style={style}>
|
|
473
|
+
no preview
|
|
474
|
+
</div>
|
|
352
475
|
) : (
|
|
353
476
|
<img
|
|
354
477
|
key={name}
|
|
478
|
+
style={style}
|
|
355
479
|
className={p.st.loraFill ? 'lora-thumb fill' : 'lora-thumb'}
|
|
356
480
|
loading="lazy"
|
|
357
481
|
src={loraPreviewSrc({ host: p.host, name })}
|
|
@@ -361,6 +485,28 @@ export const LorasControl = observer(function LorasControl(p: {
|
|
|
361
485
|
)
|
|
362
486
|
}
|
|
363
487
|
|
|
488
|
+
/** a paused lora says so ON its image, the size of a thumb, so a row of cards reads at a glance */
|
|
489
|
+
const pausedMark = (
|
|
490
|
+
<span className="paused-mark" aria-label="paused">
|
|
491
|
+
<Icon name="pause" size={2.6} />
|
|
492
|
+
</span>
|
|
493
|
+
)
|
|
494
|
+
|
|
495
|
+
/** an image size, a small slider: only while images are shown */
|
|
496
|
+
const sizeSlider = (where: string, scale: number, set: (v: number) => void): ReactNode =>
|
|
497
|
+
showImages ? (
|
|
498
|
+
<input
|
|
499
|
+
type="range"
|
|
500
|
+
className="setting-range"
|
|
501
|
+
min={0.6}
|
|
502
|
+
max={2}
|
|
503
|
+
step={0.05}
|
|
504
|
+
value={scale}
|
|
505
|
+
data-tip={`lora image size in the ${where} ×${scale.toFixed(2)}`}
|
|
506
|
+
onChange={(e) => set(parseFloat(e.target.value))}
|
|
507
|
+
/>
|
|
508
|
+
) : null
|
|
509
|
+
|
|
364
510
|
const visibilityToggles = (
|
|
365
511
|
<>
|
|
366
512
|
<button
|
|
@@ -379,6 +525,14 @@ export const LorasControl = observer(function LorasControl(p: {
|
|
|
379
525
|
>
|
|
380
526
|
<Icon name="tag" />
|
|
381
527
|
</button>
|
|
528
|
+
<button
|
|
529
|
+
type="button"
|
|
530
|
+
className={p.st.showLoraTriggers ? 'mode sel' : 'mode'}
|
|
531
|
+
data-tip={p.st.showLoraTriggers ? 'hide the trigger words' : 'show the trigger words'}
|
|
532
|
+
onClick={() => p.st.toggleLoraTriggers()}
|
|
533
|
+
>
|
|
534
|
+
<Icon name="text" />
|
|
535
|
+
</button>
|
|
382
536
|
{/* cover vs contain: a style lora's art crops beautifully and a character sheet does
|
|
383
537
|
not, so which one is right is per collection, not something to decide here */}
|
|
384
538
|
{showImages ? (
|
|
@@ -399,153 +553,268 @@ export const LorasControl = observer(function LorasControl(p: {
|
|
|
399
553
|
{/* the controls sit ABOVE the palette, left aligned: after a row of cards they read as
|
|
400
554
|
an afterthought, and a centred trio of buttons has nothing to align with */}
|
|
401
555
|
<div className="lora-actions">
|
|
402
|
-
<button type="button" className="field-height" onClick={() => local.
|
|
403
|
-
<Icon name="plus" />
|
|
556
|
+
<button type="button" className="field-height accent" onClick={() => local.openFor(sections[0]?.ix ?? -1)}>
|
|
557
|
+
<Icon name="plus" /> add
|
|
404
558
|
</button>
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
559
|
+
{/* everything used now and then lives behind ⋯: the row shows loras, not a strip
|
|
560
|
+
of buttons. The rescan warning stays out, it asks for action */}
|
|
561
|
+
<MenuButton tip="display, lora manager, lanes">
|
|
562
|
+
{(close) => (
|
|
563
|
+
<>
|
|
564
|
+
<MenuItem label="images" checked={showImages} onClick={() => p.st.toggleLoraImages()} />
|
|
565
|
+
<MenuItem label="titles" checked={showTitles} onClick={() => p.st.toggleLoraTitles()} />
|
|
566
|
+
<MenuItem
|
|
567
|
+
label="fill the card"
|
|
568
|
+
checked={p.st.loraFill}
|
|
569
|
+
disabled={!showImages}
|
|
570
|
+
onClick={() => p.st.toggleLoraFill()}
|
|
571
|
+
/>
|
|
572
|
+
<MenuItem
|
|
573
|
+
label="trigger words"
|
|
574
|
+
checked={p.st.showLoraTriggers}
|
|
575
|
+
onClick={() => p.st.toggleLoraTriggers()}
|
|
576
|
+
/>
|
|
577
|
+
{/* a display setting, not a control of the var: it lives in the menu */}
|
|
578
|
+
{showImages ? (
|
|
579
|
+
<label className="menu-item menu-range">
|
|
580
|
+
<span className="menu-check" />
|
|
581
|
+
size
|
|
582
|
+
{sizeSlider('form', formScale, (v) => p.st.setLoraFormScale(v))}
|
|
583
|
+
</label>
|
|
584
|
+
) : null}
|
|
585
|
+
<div className="menu-sep" />
|
|
586
|
+
{p.hostUrl == null ? null : (
|
|
587
|
+
<MenuItem
|
|
588
|
+
label="open the lora manager ↗"
|
|
589
|
+
onClick={() => {
|
|
590
|
+
close()
|
|
591
|
+
window.open(`${p.hostUrl}/loras`, '_blank', 'noreferrer')
|
|
592
|
+
}}
|
|
593
|
+
/>
|
|
594
|
+
)}
|
|
595
|
+
<div className="menu-sep" />
|
|
596
|
+
{/* lanes: named groups merged top to bottom. Back to one row only when that
|
|
597
|
+
loses nothing, a single active lane */}
|
|
598
|
+
{laned == null ? (
|
|
599
|
+
<MenuItem
|
|
600
|
+
label="split into lanes"
|
|
601
|
+
onClick={() => {
|
|
602
|
+
close()
|
|
603
|
+
p.v.set(toLoraLanes(value))
|
|
604
|
+
}}
|
|
605
|
+
/>
|
|
606
|
+
) : (
|
|
607
|
+
<>
|
|
608
|
+
<MenuItem
|
|
609
|
+
label="+ lane"
|
|
610
|
+
onClick={() => {
|
|
611
|
+
close()
|
|
612
|
+
p.v.set({
|
|
613
|
+
lanes: [
|
|
614
|
+
...laned.lanes,
|
|
615
|
+
{ name: newLaneName(laned.lanes), active: true, loras: {} },
|
|
616
|
+
],
|
|
617
|
+
})
|
|
618
|
+
}}
|
|
619
|
+
/>
|
|
620
|
+
<MenuItem
|
|
621
|
+
label="back to a single row"
|
|
622
|
+
disabled={lorasFromLanes(laned) == null}
|
|
623
|
+
tip={
|
|
624
|
+
lorasFromLanes(laned) == null
|
|
625
|
+
? 'only with one active lane: nothing gets merged behind your back'
|
|
626
|
+
: undefined
|
|
627
|
+
}
|
|
628
|
+
onClick={() => {
|
|
629
|
+
close()
|
|
630
|
+
const single = lorasFromLanes(laned)
|
|
631
|
+
if (single != null) p.v.set(single)
|
|
632
|
+
}}
|
|
633
|
+
/>
|
|
634
|
+
</>
|
|
635
|
+
)}
|
|
636
|
+
</>
|
|
637
|
+
)}
|
|
638
|
+
</MenuButton>
|
|
639
|
+
{allNames.length > 0 ? (
|
|
440
640
|
<span className="hint">
|
|
441
|
-
{
|
|
641
|
+
{allNames.length} in the palette · {onCount} on
|
|
442
642
|
</span>
|
|
443
643
|
) : null}
|
|
444
|
-
{/* the workflow's own narrowing, said out loud: a picker that shows 200 loras when
|
|
445
|
-
the var asked for krea2 ones is not explainable */}
|
|
446
|
-
{p.v.desc.optionsFilter == null ? null : (
|
|
447
|
-
<span
|
|
448
|
-
className="hint"
|
|
449
|
-
data-tip="this workflow declared v.loras(<regex>) — only matching loras are offered"
|
|
450
|
-
>
|
|
451
|
-
filter {p.v.desc.optionsFilter}
|
|
452
|
-
</span>
|
|
453
|
-
)}
|
|
454
644
|
</div>
|
|
455
|
-
<div className="
|
|
645
|
+
<div className="lora-lanes">
|
|
456
646
|
{!showImages && !showTitles ? (
|
|
457
647
|
<span className="hint">
|
|
458
|
-
{
|
|
648
|
+
{allNames.length} lora{allNames.length === 1 ? '' : 's'} in the palette
|
|
459
649
|
</span>
|
|
460
650
|
) : (
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
const
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
{/* the ✕ is a child of the PICTURE's own box, never of the card: its
|
|
501
|
-
containing block is then this wrapper whatever else is positioned
|
|
502
|
-
around it, so it cannot take a row of flow nor escape the card */}
|
|
503
|
-
<span className="chip-media">
|
|
504
|
-
{/* the CARD opens what this lora is; only the switch turns it on and off,
|
|
505
|
-
so reading about a lora can never change what the graph runs */}
|
|
506
|
-
<button
|
|
507
|
-
type="button"
|
|
508
|
-
className="lora-toggle"
|
|
509
|
-
data-tip={`${name}\nclick for its details`}
|
|
510
|
-
onClick={() => local.setDetails(name)}
|
|
511
|
-
>
|
|
512
|
-
{thumb(name)}
|
|
513
|
-
</button>
|
|
514
|
-
<button
|
|
515
|
-
type="button"
|
|
516
|
-
className="chip-remove"
|
|
517
|
-
data-tip="remove from the palette (the popup adds it back)"
|
|
518
|
-
onClick={() => setEntry(name, null)}
|
|
519
|
-
>
|
|
520
|
-
<Icon name="close" size={1.05} />
|
|
521
|
-
</button>
|
|
522
|
-
</span>
|
|
523
|
-
{/* the switch sits WITH the title: state and name read as one line */}
|
|
524
|
-
<span className="chip-head">
|
|
525
|
-
<label className="switch" data-tip={isOn(name) ? 'pause this lora' : 'resume this lora'}>
|
|
526
|
-
<input
|
|
527
|
-
type="checkbox"
|
|
528
|
-
checked={isOn(name)}
|
|
529
|
-
onChange={(e) => toggleOn(name, e.target.checked)}
|
|
651
|
+
sections.map((sec) => {
|
|
652
|
+
const names = namesOf(sec)
|
|
653
|
+
/** a card or a lane header takes a dropped card: same lane = reorder, another
|
|
654
|
+
* lane = the lora moves there, before `beforeName` or last */
|
|
655
|
+
const dropHere = (raw: string, beforeName: string | null): void => {
|
|
656
|
+
const [fromRaw, fromName] = raw.split('\n')
|
|
657
|
+
const from = Number(fromRaw)
|
|
658
|
+
if (fromName == null || !Number.isInteger(from) || fromName === beforeName) return
|
|
659
|
+
if (from === sec.ix) {
|
|
660
|
+
const to = beforeName == null ? names.length - 1 : names.indexOf(beforeName)
|
|
661
|
+
const at = names.indexOf(fromName)
|
|
662
|
+
if (at === -1 || to === -1) return
|
|
663
|
+
writeSection(sec.ix, reorderLoras({ record: sec.record, displayed: names, from: at, to }))
|
|
664
|
+
} else if (laned != null)
|
|
665
|
+
p.v.set(
|
|
666
|
+
moveLoraToLane(laned, {
|
|
667
|
+
from,
|
|
668
|
+
name: fromName,
|
|
669
|
+
to: sec.ix,
|
|
670
|
+
beforeName: beforeName ?? undefined,
|
|
671
|
+
}),
|
|
672
|
+
)
|
|
673
|
+
}
|
|
674
|
+
const acceptDrag = (e: DragEvent): void => {
|
|
675
|
+
if (e.dataTransfer.types.includes(CARD_DRAG_TYPE)) e.preventDefault()
|
|
676
|
+
}
|
|
677
|
+
return (
|
|
678
|
+
<div
|
|
679
|
+
key={sec.ix}
|
|
680
|
+
className={`lora-section${sec.lane == null ? '' : ' laned'}${sec.lane == null || sec.lane.active ? '' : ' off'}`}
|
|
681
|
+
>
|
|
682
|
+
{sec.lane == null || laned == null ? null : (
|
|
683
|
+
<LoraLaneBar
|
|
684
|
+
v={p.v}
|
|
685
|
+
lanes={laned.lanes}
|
|
686
|
+
ix={sec.ix}
|
|
687
|
+
count={names.length}
|
|
688
|
+
on={names.filter((n) => isOn(sec, n)).length}
|
|
689
|
+
onDropCard={(raw) => dropHere(raw, null)}
|
|
530
690
|
/>
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
691
|
+
)}
|
|
692
|
+
<div className="row-inline lora-lane">
|
|
693
|
+
{names.map((name) => (
|
|
694
|
+
<span
|
|
695
|
+
key={name}
|
|
696
|
+
className={`${showImages ? 'lora-chip card' : 'lora-chip'}${isOn(sec, name) ? '' : ' off'}`}
|
|
697
|
+
style={showImages ? { width: cardWidth } : undefined}
|
|
698
|
+
draggable
|
|
699
|
+
onMouseDown={(e) => {
|
|
700
|
+
// the WHOLE card drags, so the browser hands it the pointer before any
|
|
701
|
+
// control below sees it, and a slider drag would only reorder the card.
|
|
702
|
+
// disarm for this gesture when it starts on an input: recomputed on every
|
|
703
|
+
// mousedown, so there is no armed/disarmed state to leak
|
|
704
|
+
const from = e.target as HTMLElement
|
|
705
|
+
// buttons too (✕, the m+c label): a press that drifts a pixel would
|
|
706
|
+
// otherwise start a reorder instead of firing the click
|
|
707
|
+
e.currentTarget.draggable = from.closest('input, label, button, select, a') == null
|
|
708
|
+
}}
|
|
709
|
+
// re-arm once the gesture is over, so the grab cursor comes back the
|
|
710
|
+
// moment you leave the slider
|
|
711
|
+
onMouseUp={(e) => {
|
|
712
|
+
e.currentTarget.draggable = true
|
|
713
|
+
}}
|
|
714
|
+
onDragStart={(e) => {
|
|
715
|
+
e.dataTransfer.effectAllowed = 'move'
|
|
716
|
+
// the lane and the name travel in the drag itself: no drag state to leak
|
|
717
|
+
e.dataTransfer.setData(CARD_DRAG_TYPE, `${sec.ix}\n${name}`)
|
|
718
|
+
}}
|
|
719
|
+
// only OUR drag: a desktop file or a var row carries no payload
|
|
720
|
+
onDragOver={acceptDrag}
|
|
721
|
+
onDrop={(e) => {
|
|
722
|
+
const raw = e.dataTransfer.getData(CARD_DRAG_TYPE)
|
|
723
|
+
if (raw === '') return
|
|
724
|
+
e.preventDefault()
|
|
725
|
+
dropHere(raw, name)
|
|
726
|
+
}}
|
|
727
|
+
>
|
|
728
|
+
{/* the ✕ is a child of the PICTURE's own box, never of the card: its
|
|
729
|
+
containing block is then this wrapper whatever else is positioned
|
|
730
|
+
around it, so it cannot take a row of flow nor escape the card */}
|
|
731
|
+
<span className="chip-media">
|
|
732
|
+
{/* the IMAGE is the switch, the biggest target on the card: pausing and
|
|
733
|
+
resuming is what a card is clicked for. The TITLE opens its details */}
|
|
734
|
+
<button
|
|
735
|
+
type="button"
|
|
736
|
+
className="lora-toggle"
|
|
737
|
+
data-tip={`${name}\nclick to ${isOn(sec, name) ? 'pause' : 'resume'}, click the title for details`}
|
|
738
|
+
onClick={() => toggleOn(sec, name, !isOn(sec, name))}
|
|
739
|
+
>
|
|
740
|
+
{thumb(name, Math.round(130 * formScale))}
|
|
741
|
+
{showImages && !isOn(sec, name) ? pausedMark : null}
|
|
742
|
+
</button>
|
|
743
|
+
<button
|
|
744
|
+
type="button"
|
|
745
|
+
className="chip-remove"
|
|
746
|
+
data-tip="remove from the palette (the popup adds it back)"
|
|
747
|
+
onClick={() => setEntry(sec, name, null)}
|
|
748
|
+
>
|
|
749
|
+
<Icon name="close" size={1.35} />
|
|
750
|
+
</button>
|
|
751
|
+
</span>
|
|
752
|
+
{/* the switch sits WITH the title: state and name read as one line */}
|
|
753
|
+
<span className="chip-head">
|
|
754
|
+
<label
|
|
755
|
+
className="switch"
|
|
756
|
+
data-tip={isOn(sec, name) ? 'pause this lora' : 'resume this lora'}
|
|
757
|
+
>
|
|
758
|
+
<input
|
|
759
|
+
type="checkbox"
|
|
760
|
+
checked={isOn(sec, name)}
|
|
761
|
+
onChange={(e) => toggleOn(sec, name, e.target.checked)}
|
|
762
|
+
/>
|
|
763
|
+
<span className="track" />
|
|
764
|
+
</label>
|
|
765
|
+
{showTitles ? (
|
|
766
|
+
<button
|
|
767
|
+
type="button"
|
|
768
|
+
className="chip-title as-text"
|
|
769
|
+
data-tip={`${name}\nclick for its details`}
|
|
770
|
+
onClick={() => local.setDetails(name)}
|
|
771
|
+
>
|
|
772
|
+
{label(name)}
|
|
773
|
+
</button>
|
|
774
|
+
) : null}
|
|
775
|
+
{warnBadge(name)}
|
|
776
|
+
</span>
|
|
777
|
+
<span className="chip-controls">{strengthInputs(sec, name)}</span>
|
|
778
|
+
{p.st.showLoraTriggers ? triggerLine(name) : null}
|
|
779
|
+
</span>
|
|
780
|
+
))}
|
|
781
|
+
{/* a lane adds at its own end: a dashed card, no header button */}
|
|
782
|
+
{sec.lane == null ? null : (
|
|
783
|
+
<button
|
|
784
|
+
type="button"
|
|
785
|
+
className="lora-add-card"
|
|
786
|
+
data-tip={`add loras to ${sec.lane.name}`}
|
|
787
|
+
onDragOver={acceptDrag}
|
|
788
|
+
onDrop={(e) => {
|
|
789
|
+
const raw = e.dataTransfer.getData(CARD_DRAG_TYPE)
|
|
790
|
+
if (raw === '') return
|
|
791
|
+
e.preventDefault()
|
|
792
|
+
dropHere(raw, null)
|
|
793
|
+
}}
|
|
794
|
+
onClick={() => local.openFor(sec.ix)}
|
|
795
|
+
>
|
|
796
|
+
<Icon name="plus" />
|
|
797
|
+
</button>
|
|
798
|
+
)}
|
|
799
|
+
</div>
|
|
800
|
+
</div>
|
|
801
|
+
)
|
|
802
|
+
})
|
|
803
|
+
)}
|
|
804
|
+
{laned == null ? null : (
|
|
805
|
+
<div className="row-inline">
|
|
806
|
+
<button
|
|
807
|
+
type="button"
|
|
808
|
+
onClick={() =>
|
|
809
|
+
p.v.set({
|
|
810
|
+
lanes: [...laned.lanes, { name: newLaneName(laned.lanes), active: true, loras: {} }],
|
|
811
|
+
})
|
|
812
|
+
}
|
|
813
|
+
>
|
|
814
|
+
<Icon name="plus" /> lane
|
|
815
|
+
</button>
|
|
816
|
+
<span className="hint">lanes merge top to bottom · drag a card onto another lane to move it</span>
|
|
817
|
+
</div>
|
|
549
818
|
)}
|
|
550
819
|
</div>
|
|
551
820
|
|
|
@@ -562,13 +831,18 @@ export const LorasControl = observer(function LorasControl(p: {
|
|
|
562
831
|
/>
|
|
563
832
|
)}
|
|
564
833
|
{local.open ? (
|
|
565
|
-
|
|
566
|
-
|
|
834
|
+
// anchored near the TOP at a fixed height: filtering or hiding images changes what is
|
|
835
|
+
// inside, never where the popup sits
|
|
836
|
+
<div className="modal-overlay top" onClick={() => local.setOpen(false)}>
|
|
837
|
+
<div className="modal loras-modal" onClick={(e) => e.stopPropagation()}>
|
|
838
|
+
{/* the display toggles first, the search in the middle, close alone at the end */}
|
|
567
839
|
<div className="modal-head">
|
|
840
|
+
<span className="btn-group">{visibilityToggles}</span>
|
|
841
|
+
{sizeSlider('popup', popupScale, (v) => p.st.setLoraPopupScale(v))}
|
|
568
842
|
<input
|
|
569
843
|
ref={filterRef}
|
|
570
844
|
type="text"
|
|
571
|
-
placeholder={`search ${options.length} loras
|
|
845
|
+
placeholder={`search ${options.length} loras, enter adds the first`}
|
|
572
846
|
value={local.filter}
|
|
573
847
|
onChange={(e) => local.setFilter(e.target.value)}
|
|
574
848
|
onKeyDown={(e) => {
|
|
@@ -577,115 +851,170 @@ export const LorasControl = observer(function LorasControl(p: {
|
|
|
577
851
|
addFirstMatch()
|
|
578
852
|
}}
|
|
579
853
|
/>
|
|
580
|
-
|
|
581
|
-
|
|
854
|
+
<button
|
|
855
|
+
type="button"
|
|
856
|
+
className="modal-close"
|
|
857
|
+
data-tip="close (esc)"
|
|
858
|
+
onClick={() => local.setOpen(false)}
|
|
859
|
+
>
|
|
582
860
|
<Icon name="close" />
|
|
583
861
|
</button>
|
|
584
862
|
</div>
|
|
585
|
-
<div className="
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
<div className="
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
863
|
+
<div className="loras-split">
|
|
864
|
+
<div className="modal-body loras-palette">
|
|
865
|
+
{target == null || targetNames.length === 0 ? (
|
|
866
|
+
<div className="hint">nothing picked yet: tap a lora to add it</div>
|
|
867
|
+
) : (
|
|
868
|
+
<div>
|
|
869
|
+
<div className="section-title">
|
|
870
|
+
{target.lane == null ? 'your palette' : `lane ${target.lane.name}`} (
|
|
871
|
+
{targetNames.length})
|
|
872
|
+
</div>
|
|
873
|
+
{targetNames.map((name) => {
|
|
874
|
+
const info = local.info.get(name)
|
|
875
|
+
return (
|
|
876
|
+
<div
|
|
877
|
+
key={name}
|
|
878
|
+
className={isOn(target, name) ? 'lora-active-row' : 'lora-active-row off'}
|
|
879
|
+
>
|
|
880
|
+
{thumb(name)}
|
|
881
|
+
<div className="lora-active-text">
|
|
882
|
+
<div className="lora-label" data-tip={name}>
|
|
883
|
+
{showTitles ? label(name) : '···'}
|
|
884
|
+
</div>
|
|
885
|
+
{p.st.showLoraTriggers &&
|
|
886
|
+
typeof info === 'object' &&
|
|
887
|
+
info.triggerWords.length > 0 ? (
|
|
888
|
+
<div className="hint">{info.triggerWords.join(', ')}</div>
|
|
889
|
+
) : (
|
|
890
|
+
<div className="hint">{name}</div>
|
|
891
|
+
)}
|
|
597
892
|
</div>
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
893
|
+
<input
|
|
894
|
+
type="checkbox"
|
|
895
|
+
checked={isOn(target, name)}
|
|
896
|
+
data-tip={isOn(target, name) ? 'pause (stays in the palette)' : 'resume'}
|
|
897
|
+
onChange={(e) => toggleOn(target, name, e.target.checked)}
|
|
898
|
+
/>
|
|
899
|
+
{strengthInputs(target, name)}
|
|
900
|
+
<button
|
|
901
|
+
type="button"
|
|
902
|
+
className="chip-remove"
|
|
903
|
+
data-tip="remove from the list"
|
|
904
|
+
onClick={() => setEntry(target, name, null)}
|
|
905
|
+
>
|
|
906
|
+
<Icon name="close" size={1.2} />
|
|
907
|
+
</button>
|
|
603
908
|
</div>
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
onChange={(e) => toggleOn(name, e.target.checked)}
|
|
609
|
-
/>
|
|
610
|
-
{strengthInputs(name)}
|
|
611
|
-
<button
|
|
612
|
-
type="button"
|
|
613
|
-
className="chip-remove"
|
|
614
|
-
data-tip="remove from the list"
|
|
615
|
-
onClick={() => setEntry(name, null)}
|
|
616
|
-
>
|
|
617
|
-
<Icon name="close" size={0.9} />
|
|
618
|
-
</button>
|
|
619
|
-
</div>
|
|
620
|
-
)
|
|
621
|
-
})}
|
|
622
|
-
</div>
|
|
623
|
-
) : null}
|
|
624
|
-
<div className="section-title lora-sort-head">
|
|
625
|
-
all loras — tap to add to the palette
|
|
626
|
-
<span className="lora-sort">
|
|
627
|
-
sort
|
|
628
|
-
{LORA_SORTS.map((s) => (
|
|
629
|
-
<button
|
|
630
|
-
key={s.mode}
|
|
631
|
-
type="button"
|
|
632
|
-
className={p.st.loraSort === s.mode ? 'mode sel' : 'mode'}
|
|
633
|
-
data-tip={s.tip}
|
|
634
|
-
onClick={() => p.st.setLoraSort(s.mode)}
|
|
635
|
-
>
|
|
636
|
-
{s.label}
|
|
637
|
-
</button>
|
|
638
|
-
))}
|
|
639
|
-
</span>
|
|
909
|
+
)
|
|
910
|
+
})}
|
|
911
|
+
</div>
|
|
912
|
+
)}
|
|
640
913
|
</div>
|
|
641
|
-
|
|
642
|
-
<div
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
)}
|
|
648
|
-
<div className="lora-grid">
|
|
649
|
-
{group.names.map((name) => (
|
|
914
|
+
<div className="modal-body loras-gallery">
|
|
915
|
+
<div className="section-title lora-sort-head">
|
|
916
|
+
all loras — tap to add or take out
|
|
917
|
+
<span className="lora-sort">
|
|
918
|
+
sort
|
|
919
|
+
{LORA_SORTS.map((s) => (
|
|
650
920
|
<button
|
|
651
|
-
key={
|
|
921
|
+
key={s.mode}
|
|
652
922
|
type="button"
|
|
653
|
-
className=
|
|
654
|
-
data-tip={
|
|
655
|
-
onClick={() =>
|
|
923
|
+
className={p.st.loraSort === s.mode ? 'mode sel' : 'mode'}
|
|
924
|
+
data-tip={s.tip}
|
|
925
|
+
onClick={() => p.st.setLoraSort(s.mode)}
|
|
656
926
|
>
|
|
657
|
-
{
|
|
658
|
-
<div className="lora-label">
|
|
659
|
-
{showTitles ? label(name) : name.slice(0, 2) + '···'}
|
|
660
|
-
{warnBadge(name)}
|
|
661
|
-
</div>
|
|
927
|
+
{s.label}
|
|
662
928
|
</button>
|
|
663
929
|
))}
|
|
664
|
-
</
|
|
930
|
+
</span>
|
|
665
931
|
</div>
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
932
|
+
{groupedCards.map((group) => (
|
|
933
|
+
<div key={group.folder ?? '*'}>
|
|
934
|
+
{group.folder == null ? null : (
|
|
935
|
+
<div className="section-title">
|
|
936
|
+
{group.folder === '' ? 'loose (no folder)' : `${group.folder}/`} ·{' '}
|
|
937
|
+
{group.names.length}
|
|
938
|
+
</div>
|
|
939
|
+
)}
|
|
940
|
+
<div
|
|
941
|
+
className="lora-grid"
|
|
942
|
+
style={{ gridTemplateColumns: `repeat(auto-fill, minmax(${gridMin}px, 1fr))` }}
|
|
943
|
+
>
|
|
944
|
+
{group.names.map((name) => {
|
|
945
|
+
const picked = targetNames.includes(name)
|
|
946
|
+
const on = target != null && isOn(target, name)
|
|
947
|
+
const action = popupCardClick({ picked, on })
|
|
948
|
+
const cls = !picked ? 'lora-card' : on ? 'lora-card picked' : 'lora-card picked off'
|
|
949
|
+
return (
|
|
950
|
+
<div key={name} className={cls}>
|
|
951
|
+
<button
|
|
952
|
+
type="button"
|
|
953
|
+
className="lora-card-hit"
|
|
954
|
+
data-tip={
|
|
955
|
+
action === 'add'
|
|
956
|
+
? `${name}\nclick to add`
|
|
957
|
+
: `${name}\nclick to ${action}`
|
|
958
|
+
}
|
|
959
|
+
onClick={() => {
|
|
960
|
+
if (target == null) return
|
|
961
|
+
if (action === 'add') setEntry(target, name, [1, 1])
|
|
962
|
+
else toggleOn(target, name, action === 'resume')
|
|
963
|
+
}}
|
|
964
|
+
>
|
|
965
|
+
<span className="thumb-box">
|
|
966
|
+
{thumb(name, Math.round(110 * popupScale))}
|
|
967
|
+
{showImages && picked && !on ? pausedMark : null}
|
|
968
|
+
</span>
|
|
969
|
+
<div className="lora-label">
|
|
970
|
+
{showTitles ? label(name) : name.slice(0, 2) + '···'}
|
|
971
|
+
{warnBadge(name)}
|
|
972
|
+
</div>
|
|
973
|
+
</button>
|
|
974
|
+
{picked && target != null ? (
|
|
975
|
+
<button
|
|
976
|
+
type="button"
|
|
977
|
+
className="chip-remove"
|
|
978
|
+
data-tip="remove from the palette"
|
|
979
|
+
onClick={() => setEntry(target, name, null)}
|
|
980
|
+
>
|
|
981
|
+
<Icon name="close" size={1.35} />
|
|
982
|
+
</button>
|
|
983
|
+
) : null}
|
|
984
|
+
</div>
|
|
985
|
+
)
|
|
986
|
+
})}
|
|
987
|
+
</div>
|
|
988
|
+
</div>
|
|
989
|
+
))}
|
|
990
|
+
{matches.length > cardCap ? (
|
|
991
|
+
<div className="loras-more">
|
|
992
|
+
… {matches.length - cardCap} more — refine the filter, or draw
|
|
993
|
+
<input
|
|
994
|
+
type="number"
|
|
995
|
+
min={1}
|
|
996
|
+
max={2000}
|
|
997
|
+
value={cardCap}
|
|
998
|
+
data-tip="how many cards this popup draws — each one is an image request, so the right number depends on your collection and your box. Kept in this browser"
|
|
999
|
+
// an empty box is mid-edit, not a request for the default: without
|
|
1000
|
+
// this, clearing the field snapped the value to 200 as you typed
|
|
1001
|
+
onChange={(e) => {
|
|
1002
|
+
const n = parseInt(e.target.value, 10)
|
|
1003
|
+
if (Number.isFinite(n)) p.st.setLoraCap(n)
|
|
1004
|
+
}}
|
|
1005
|
+
/>
|
|
1006
|
+
at once
|
|
1007
|
+
</div>
|
|
1008
|
+
) : null}
|
|
1009
|
+
{matches.length === 0 ? (
|
|
1010
|
+
<div className="loras-more">no lora matches '{local.filter}'</div>
|
|
1011
|
+
) : null}
|
|
1012
|
+
</div>
|
|
688
1013
|
</div>
|
|
1014
|
+
{/* the workflow's own narrowing, once, as a quiet footer line */}
|
|
1015
|
+
{p.v.desc.optionsFilter == null ? null : (
|
|
1016
|
+
<div className="modal-foot hint">this workflow offers loras matching {p.v.desc.optionsFilter}</div>
|
|
1017
|
+
)}
|
|
689
1018
|
</div>
|
|
690
1019
|
</div>
|
|
691
1020
|
) : null}
|
|
@@ -796,7 +1125,7 @@ const LoraDetails = observer(function LoraDetails(p: {
|
|
|
796
1125
|
<div className="detail-list">
|
|
797
1126
|
{info.known === false ? (
|
|
798
1127
|
<div className="hint">
|
|
799
|
-
|
|
1128
|
+
newer than the copy of the lora manager's list kept here: sync reads it again
|
|
800
1129
|
</div>
|
|
801
1130
|
) : null}
|
|
802
1131
|
{p.managerOnly ? <div className="hint">⚠ only the lora manager lists it, not comfy</div> : null}
|