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