comfy-ts 2.11.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 (99) hide show
  1. package/README.md +1 -0
  2. package/dist/{LogsSt-qtFzOKpu.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 +473 -62
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.cts +191 -31
  8. package/dist/index.d.ts +191 -31
  9. package/dist/index.js +469 -63
  10. package/dist/index.js.map +1 -1
  11. package/dist/{run-serve-BK7BA2dn.js → run-serve-BeAznay5.js} +461 -43
  12. package/dist/run-serve-BeAznay5.js.map +1 -0
  13. package/dist/{run-tui-CQyvMf0N.js → run-tui-BTGjvnKk.js} +43 -18
  14. package/dist/run-tui-BTGjvnKk.js.map +1 -0
  15. package/dist/{schemaDrift-DjjEtwfx.js → schemaDrift-Cg39vs53.js} +470 -60
  16. package/dist/schemaDrift-Cg39vs53.js.map +1 -0
  17. package/dist/serve-web.js +508 -134
  18. package/dist/{state--wrz0BQc.js → state-C7REnHan.js} +7 -3
  19. package/dist/{state--wrz0BQc.js.map → state-C7REnHan.js.map} +1 -1
  20. package/dist/web.d.ts +191 -31
  21. package/dist/web.js +469 -63
  22. package/dist/web.js.map +1 -1
  23. package/examples/rvion/06-qwen-image-edit.cflow.ts +3 -2
  24. package/examples/rvion/10-anima-t2i.cflow.ts +229 -0
  25. package/extra/README.md +4 -0
  26. package/extra/comfyui-fresh-model-lists/README.md +25 -0
  27. package/extra/comfyui-fresh-model-lists/__init__.py +36 -0
  28. package/extra/comfyui-fresh-model-lists/test_fresh_model_lists.py +97 -0
  29. package/package.json +15 -7
  30. package/src/cli/draftMeta.ts +39 -0
  31. package/src/cli/serve/ServeApp.ts +148 -12
  32. package/src/cli/serve/applyVarPayload.ts +50 -22
  33. package/src/cli/serve/describeVar.ts +42 -6
  34. package/src/cli/serve/llmConfigShape.ts +51 -0
  35. package/src/cli/serve/llmConfigs.ts +52 -0
  36. package/src/cli/serve/tagList.ts +92 -0
  37. package/src/cli/serve/tagSource.ts +69 -0
  38. package/src/cli/serve/web/api.ts +48 -0
  39. package/src/cli/serve/web/components/App.tsx +336 -44
  40. package/src/cli/serve/web/components/Gallery.tsx +105 -28
  41. package/src/cli/serve/web/components/HistoryPicker.tsx +149 -0
  42. package/src/cli/serve/web/components/Icon.tsx +18 -2
  43. package/src/cli/serve/web/components/MenuButton.tsx +53 -0
  44. package/src/cli/serve/web/components/Omnibox.tsx +85 -0
  45. package/src/cli/serve/web/components/PromptEnhancer.tsx +476 -180
  46. package/src/cli/serve/web/components/TooltipLayer.tsx +45 -0
  47. package/src/cli/serve/web/components/VarIcon.tsx +24 -0
  48. package/src/cli/serve/web/components/VarsForm.tsx +341 -188
  49. package/src/cli/serve/web/components/controls/BasicControls.tsx +57 -32
  50. package/src/cli/serve/web/components/controls/LorasControl.tsx +644 -317
  51. package/src/cli/serve/web/components/controls/PresetPicker.tsx +1 -1
  52. package/src/cli/serve/web/components/controls/PromptControl.tsx +279 -0
  53. package/src/cli/serve/web/components/controls/PromptEditor.tsx +113 -0
  54. package/src/cli/serve/web/components/controls/SeedControl.tsx +17 -10
  55. package/src/cli/serve/web/components/controls/SizeControl.tsx +111 -18
  56. package/src/cli/serve/web/components/modKey.ts +2 -0
  57. package/src/cli/serve/web/llm.ts +23 -12
  58. package/src/cli/serve/web/promptEditor/promptExtensions.ts +281 -0
  59. package/src/cli/serve/web/state/EnhancerSt.ts +415 -100
  60. package/src/cli/serve/web/state/FormSt.ts +193 -29
  61. package/src/cli/serve/web/state/OmniboxSt.ts +57 -0
  62. package/src/cli/serve/web/state/WebSt.ts +219 -74
  63. package/src/cli/serve/web/state/choiceButtons.ts +61 -0
  64. package/src/cli/serve/web/state/generateButton.ts +16 -0
  65. package/src/cli/serve/web/state/history.ts +54 -0
  66. package/src/cli/serve/web/state/host.ts +5 -2
  67. package/src/cli/serve/web/state/keptLines.ts +53 -0
  68. package/src/cli/serve/web/state/latentMode.ts +20 -0
  69. package/src/cli/serve/web/state/loraSort.ts +18 -0
  70. package/src/cli/serve/web/state/moduleTree.ts +2 -2
  71. package/src/cli/serve/web/state/omnibox.ts +69 -0
  72. package/src/cli/serve/web/state/payload.ts +38 -58
  73. package/src/cli/serve/web/state/shortcuts.ts +54 -0
  74. package/src/cli/serve/web/state/sizeStars.ts +31 -0
  75. package/src/cli/serve/web/state/stableSlots.ts +21 -0
  76. package/src/cli/serve/web/state/varGroups.ts +24 -0
  77. package/src/cli/serve/web/styles.ts +457 -118
  78. package/src/cli/serve/webBundle.ts +54 -10
  79. package/src/cli/tui/components/PickerOverlays.tsx +9 -2
  80. package/src/cli/tui/imagePicker/ImagePickerSt.ts +1 -1
  81. package/src/cli/tui/state/DraftsSt.ts +18 -2
  82. package/src/cli/tui/state/EditorSt.ts +1 -1
  83. package/src/cli/tui/state/LorasSt.ts +1 -1
  84. package/src/cli/tui/state/PickerSt.ts +25 -7
  85. package/src/cli/tui/state/SettingsSt.ts +1 -1
  86. package/src/cli/tui/state/TuiSt.ts +10 -0
  87. package/src/coreExports.ts +20 -0
  88. package/src/host/loraInfoCache.ts +6 -0
  89. package/src/state.ts +5 -0
  90. package/src/vars/ComfyVars.ts +337 -67
  91. package/src/vars/DefinedWorkflow.ts +40 -19
  92. package/src/vars/lanes.ts +238 -0
  93. package/src/vars/loraEntry.ts +101 -0
  94. package/src/vars/promptSyntax.ts +382 -0
  95. package/dist/LogsSt-qtFzOKpu.js.map +0 -1
  96. package/dist/run-serve-BK7BA2dn.js.map +0 -1
  97. package/dist/run-tui-CQyvMf0N.js.map +0 -1
  98. package/dist/schemaDrift-DjjEtwfx.js.map +0 -1
  99. 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/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'
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 record = asRecord(p.v.value)
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 PALETTE is what the row shows: the loras that are ON, plus the ones paused in this
115
- // session. It is NOT "every key in the record", LorasVar writes `false` for every lora
116
- // ever unticked, so that reading put the whole catalog in the row (a real draft
117
- // with 35 keys and 2 on). A paused lora leaves the record entirely and lives here instead
118
- const isOn = (name: string): boolean => loraIsOn(record[name])
119
- const isInPalette = (name: string): boolean => isOn(name) || local.paused.has(name)
120
- // NEWEST FIRST: the record keeps insertion order, so the lora you just added is the last
121
- // key, reversed, it lands where you are looking instead of at the end of the row
122
- 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
+ }
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
- '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"
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 in
142
- * the mirror at all (a button syncs it). Titles hidden hides the words, never the state */
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 className="chip-triggers missing">
148
- not in the lora manager mirror
149
- <button
150
- type="button"
151
- className="trigger-fetch"
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 the palette (a strength) or REMOVE from it entirely (null) */
212
- const setEntry = (name: string, st: LoraStrength | null): void => {
213
- local.setPaused(name, false)
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
- p.v.set(next)
330
+ writeSection(sec.ix, next)
218
331
  }
219
- const toggleOn = (name: string, on: boolean): void => {
220
- if (!on) local.notePrevStrength(name, loraStrengthPair(record[name]))
221
- local.setPaused(name, !on)
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
- if (!isOn(name)) {
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 = 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])
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 = selectedNames.join('\n')
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 = matches.filter((o) => !isInPalette(o)).slice(0, cardCap)
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,32 @@ export const LorasControl = observer(function LorasControl(p: {
334
449
  input.select()
335
450
  }, [open])
336
451
 
337
- /** enter takes the FIRST card, the one the eye lands on. The popup stays open with the
338
- * needle reselected, so adding three loras is type-enter-type-enter, and the new entry
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 = cards[0]
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
- 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 => {
349
468
  if (!showImages) return null
469
+ const style = height == null ? undefined : { height }
350
470
  return local.previewFailed.has(name) ? (
351
- <div className="lora-thumb none">no preview</div>
471
+ <div className="lora-thumb none" style={style}>
472
+ no preview
473
+ </div>
352
474
  ) : (
353
475
  <img
354
476
  key={name}
477
+ style={style}
355
478
  className={p.st.loraFill ? 'lora-thumb fill' : 'lora-thumb'}
356
479
  loading="lazy"
357
480
  src={loraPreviewSrc({ host: p.host, name })}
@@ -361,6 +484,27 @@ export const LorasControl = observer(function LorasControl(p: {
361
484
  )
362
485
  }
363
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
+
364
508
  const visibilityToggles = (
365
509
  <>
366
510
  <button
@@ -379,6 +523,14 @@ export const LorasControl = observer(function LorasControl(p: {
379
523
  >
380
524
  <Icon name="tag" />
381
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>
382
534
  {/* cover vs contain: a style lora's art crops beautifully and a character sheet does
383
535
  not, so which one is right is per collection, not something to decide here */}
384
536
  {showImages ? (
@@ -399,153 +551,268 @@ export const LorasControl = observer(function LorasControl(p: {
399
551
  {/* the controls sit ABOVE the palette, left aligned: after a row of cards they read as
400
552
  an afterthought, and a centred trio of buttons has nothing to align with */}
401
553
  <div className="lora-actions">
402
- <button type="button" className="field-height" onClick={() => local.setOpen(true)}>
403
- <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
404
556
  </button>
405
- <span className="btn-group field-height">{visibilityToggles}</span>
406
- {/* the host's OWN lora manager: where you tag, rename and re-scan them. Same host
407
- the runs go to, so the page you open is the one that owns these files */}
408
- <button
409
- type="button"
410
- className="field-height"
411
- disabled={p.st.loraSyncing}
412
- data-tip="re-download the lora metadata from the lora manager on this host (names, trigger words, previews)"
413
- onClick={() => void p.st.refreshLoras()}
414
- >
415
- <Icon name="refresh" /> {p.st.loraSyncing ? 'syncing…' : 'sync'}
416
- </button>
417
- {managerOnlyInUse.length > 0 ? (
418
- <button
419
- type="button"
420
- className="field-height warn-action"
421
- disabled={p.st.hostWatch === 'down'}
422
- 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`}
423
- onClick={() => void p.st.hostAction('restart')}
424
- >
425
- <Icon name="power" /> restart ComfyUI
426
- </button>
427
- ) : null}
428
- {p.hostUrl == null ? null : (
429
- <a
430
- className="button-link field-height"
431
- href={`${p.hostUrl}/loras`}
432
- target="_blank"
433
- rel="noreferrer"
434
- data-tip="open the lora manager of this host in a new tab"
435
- >
436
- <Icon name="external" /> manager
437
- </a>
438
- )}
439
- {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 ? (
440
638
  <span className="hint">
441
- {selectedNames.length} in the palette · {selectedNames.filter(isOn).length} on
639
+ {allNames.length} in the palette · {onCount} on
442
640
  </span>
443
641
  ) : 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
642
  </div>
455
- <div className="row-inline">
643
+ <div className="lora-lanes">
456
644
  {!showImages && !showTitles ? (
457
645
  <span className="hint">
458
- {selectedNames.length} lora{selectedNames.length === 1 ? '' : 's'} in the palette
646
+ {allNames.length} lora{allNames.length === 1 ? '' : 's'} in the palette
459
647
  </span>
460
648
  ) : (
461
- selectedNames.map((name, ix) => (
462
- <span
463
- key={name}
464
- className={`${showImages ? 'lora-chip card' : 'lora-chip'}${isOn(name) ? '' : ' off'}`}
465
- draggable
466
- onMouseDown={(e) => {
467
- // the WHOLE card drags, so the browser hands it the pointer before any
468
- // control below sees it, and a slider drag would only reorder the card.
469
- // disarm for this gesture when it starts on an input: recomputed on every
470
- // mousedown, so there is no armed/disarmed state to leak
471
- const from = e.target as HTMLElement
472
- // buttons too (✕, the m+c label): a press that drifts a pixel would
473
- // otherwise start a reorder instead of firing the click
474
- e.currentTarget.draggable = from.closest('input, label, button, select, a') == null
475
- }}
476
- // re-arm once the gesture is over, so the grab cursor comes back the
477
- // moment you leave the slider
478
- onMouseUp={(e) => {
479
- e.currentTarget.draggable = true
480
- }}
481
- onDragStart={(e) => {
482
- e.dataTransfer.effectAllowed = 'move'
483
- // the index travels in the drag itself: no drag state to leak or reset
484
- e.dataTransfer.setData(CARD_DRAG_TYPE, String(ix))
485
- }}
486
- // only OUR drag: a desktop file or a var row carries no index, and
487
- // Number('') is 0, so a foreign drop would reorder from slot 0
488
- onDragOver={(e) => {
489
- if (e.dataTransfer.types.includes(CARD_DRAG_TYPE)) e.preventDefault()
490
- }}
491
- onDrop={(e) => {
492
- const raw = e.dataTransfer.getData(CARD_DRAG_TYPE)
493
- if (raw === '') return
494
- e.preventDefault()
495
- const from = Number(raw)
496
- if (Number.isInteger(from) && from !== ix)
497
- p.v.set(reorderLoras({ record, displayed: selectedNames, from, to: ix }))
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)}
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)}
530
688
  />
531
- <span className="track" />
532
- </label>
533
- {showTitles ? (
534
- <button
535
- type="button"
536
- className="chip-title as-text"
537
- data-tip={`${name}\nclick for its details`}
538
- onClick={() => local.setDetails(name)}
539
- >
540
- {label(name)}
541
- </button>
542
- ) : null}
543
- {warnBadge(name)}
544
- </span>
545
- <span className="chip-controls">{strengthInputs(name)}</span>
546
- {triggerLine(name)}
547
- </span>
548
- ))
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>
549
816
  )}
550
817
  </div>
551
818
 
@@ -562,13 +829,18 @@ export const LorasControl = observer(function LorasControl(p: {
562
829
  />
563
830
  )}
564
831
  {local.open ? (
565
- <div className="modal-overlay" onClick={() => local.setOpen(false)}>
566
- <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 */}
567
837
  <div className="modal-head">
838
+ <span className="btn-group">{visibilityToggles}</span>
839
+ {sizeSlider}
568
840
  <input
569
841
  ref={filterRef}
570
842
  type="text"
571
- 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`}
572
844
  value={local.filter}
573
845
  onChange={(e) => local.setFilter(e.target.value)}
574
846
  onKeyDown={(e) => {
@@ -577,115 +849,170 @@ export const LorasControl = observer(function LorasControl(p: {
577
849
  addFirstMatch()
578
850
  }}
579
851
  />
580
- {visibilityToggles}
581
- <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
+ >
582
858
  <Icon name="close" />
583
859
  </button>
584
860
  </div>
585
- <div className="modal-body">
586
- {selectedNames.length > 0 ? (
587
- <div>
588
- <div className="section-title">your palette ({selectedNames.length})</div>
589
- {selectedNames.filter(matchesFilter).map((name) => {
590
- const info = local.info.get(name)
591
- return (
592
- <div key={name} className={isOn(name) ? 'lora-active-row' : 'lora-active-row off'}>
593
- {thumb(name)}
594
- <div className="lora-active-text">
595
- <div className="lora-label" data-tip={name}>
596
- {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
+ )}
597
890
  </div>
598
- {typeof info === 'object' && info.triggerWords.length > 0 ? (
599
- <div className="hint">{info.triggerWords.join(', ')}</div>
600
- ) : (
601
- <div className="hint">{name}</div>
602
- )}
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>
603
906
  </div>
604
- <input
605
- type="checkbox"
606
- checked={isOn(name)}
607
- data-tip={isOn(name) ? 'pause (stays in the palette)' : 'resume'}
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>
907
+ )
908
+ })}
909
+ </div>
910
+ )}
640
911
  </div>
641
- {groupedCards.map((group) => (
642
- <div key={group.folder ?? '*'}>
643
- {group.folder == null ? null : (
644
- <div className="section-title">
645
- {group.folder === '' ? 'loose (no folder)' : `${group.folder}/`} · {group.names.length}
646
- </div>
647
- )}
648
- <div className="lora-grid">
649
- {group.names.map((name) => (
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) => (
650
918
  <button
651
- key={name}
919
+ key={s.mode}
652
920
  type="button"
653
- className="lora-card"
654
- data-tip={name}
655
- 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)}
656
924
  >
657
- {thumb(name)}
658
- <div className="lora-label">
659
- {showTitles ? label(name) : name.slice(0, 2) + '···'}
660
- {warnBadge(name)}
661
- </div>
925
+ {s.label}
662
926
  </button>
663
927
  ))}
664
- </div>
665
- </div>
666
- ))}
667
- {matches.length - selectedNames.filter(matchesFilter).length > cardCap ? (
668
- <div className="loras-more">
669
- … {matches.length - selectedNames.filter(matchesFilter).length - cardCap} more — refine the
670
- filter, or draw
671
- <input
672
- type="number"
673
- min={1}
674
- max={2000}
675
- value={cardCap}
676
- 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"
677
- // an empty box is mid-edit, not a request for the default: without
678
- // this, clearing the field snapped the value to 200 as you typed
679
- onChange={(e) => {
680
- const n = parseInt(e.target.value, 10)
681
- if (Number.isFinite(n)) p.st.setLoraCap(n)
682
- }}
683
- />
684
- at once
928
+ </span>
685
929
  </div>
686
- ) : null}
687
- {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>
688
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
+ )}
689
1016
  </div>
690
1017
  </div>
691
1018
  ) : null}
@@ -796,7 +1123,7 @@ const LoraDetails = observer(function LoraDetails(p: {
796
1123
  <div className="detail-list">
797
1124
  {info.known === false ? (
798
1125
  <div className="hint">
799
- 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
800
1127
  </div>
801
1128
  ) : null}
802
1129
  {p.managerOnly ? <div className="hint">⚠ only the lora manager lists it, not comfy</div> : null}