comfy-ts 2.10.0 → 2.11.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 (45) hide show
  1. package/dist/{LogsSt-DFxzQfDc.js → LogsSt-qtFzOKpu.js} +2 -2
  2. package/dist/{LogsSt-DFxzQfDc.js.map → LogsSt-qtFzOKpu.js.map} +1 -1
  3. package/dist/cli.js +4 -4
  4. package/dist/index.cjs +93 -1
  5. package/dist/index.cjs.map +1 -1
  6. package/dist/index.d.cts +19 -0
  7. package/dist/index.d.ts +19 -0
  8. package/dist/index.js +93 -1
  9. package/dist/index.js.map +1 -1
  10. package/dist/{run-serve-_nrvJYyt.js → run-serve-BK7BA2dn.js} +91 -3
  11. package/dist/run-serve-BK7BA2dn.js.map +1 -0
  12. package/dist/{run-tui-Atvf9vb3.js → run-tui-CQyvMf0N.js} +36 -4
  13. package/dist/run-tui-CQyvMf0N.js.map +1 -0
  14. package/dist/{DefinedWorkflow-BatWaZO1.js → schemaDrift-DjjEtwfx.js} +176 -2
  15. package/dist/schemaDrift-DjjEtwfx.js.map +1 -0
  16. package/dist/serve-web.js +32 -16
  17. package/dist/{state-6RFDIQwJ.js → state--wrz0BQc.js} +14 -3
  18. package/dist/{state-6RFDIQwJ.js.map → state--wrz0BQc.js.map} +1 -1
  19. package/dist/web.d.ts +19 -0
  20. package/dist/web.js +93 -1
  21. package/dist/web.js.map +1 -1
  22. package/examples/comfy-cloud/capybara-i2v.cflow.ts +2 -0
  23. package/examples/comfy-cloud/wan22-5b-t2v.cflow.ts +2 -0
  24. package/examples/comfy-cloud/wan22-i2v.cflow.ts +2 -0
  25. package/examples/comfy-cloud/wan22-t2v.cflow.ts +2 -0
  26. package/examples/rvion/07-local-llm-text-gen.cflow.ts +2 -2
  27. package/package.json +4 -2
  28. package/src/cli/serve/ServeApp.ts +94 -0
  29. package/src/cli/serve/describeVar.ts +7 -0
  30. package/src/cli/serve/favicon.ts +3 -0
  31. package/src/cli/serve/web/api.ts +12 -0
  32. package/src/cli/serve/web/components/VarsForm.tsx +18 -7
  33. package/src/cli/serve/web/components/controls/LorasControl.tsx +102 -6
  34. package/src/cli/serve/web/state/WebSt.ts +79 -0
  35. package/src/cli/serve/web/state/loraSort.ts +39 -0
  36. package/src/cli/serve/web/styles.ts +15 -0
  37. package/src/cli/tui/components/Header.tsx +2 -0
  38. package/src/cli/tui/state/HostSt.ts +34 -0
  39. package/src/host/ComfyHost.ts +15 -0
  40. package/src/host/loraInfoCache.ts +64 -0
  41. package/src/host/loraManagerApi.ts +27 -0
  42. package/src/host/schemaDrift.ts +87 -0
  43. package/dist/DefinedWorkflow-BatWaZO1.js.map +0 -1
  44. package/dist/run-serve-_nrvJYyt.js.map +0 -1
  45. package/dist/run-tui-Atvf9vb3.js.map +0 -1
@@ -73,6 +73,8 @@ export const capybaraI2v = host.defineWorkflow({
73
73
  b.SaveVideo({
74
74
  video: b.CreateVideo({ images: b.VAEDecode({ samples, vae }), fps: vars.fps }),
75
75
  filename_prefix: 'comfy-ts-zoo/capybara-i2v',
76
+ format: 'auto',
77
+ codec: 'auto',
76
78
  })
77
79
  },
78
80
  })
@@ -52,6 +52,8 @@ export const wan225bT2v = host.defineWorkflow({
52
52
  b.SaveVideo({
53
53
  video: b.CreateVideo({ images: b.VAEDecode({ samples, vae }), fps: vars.fps }),
54
54
  filename_prefix: 'comfy-ts-zoo/wan22-5b-t2v',
55
+ format: 'auto',
56
+ codec: 'auto',
55
57
  })
56
58
  },
57
59
  })
@@ -90,6 +90,8 @@ export const wan22I2v = host.defineWorkflow({
90
90
  b.SaveVideo({
91
91
  video: b.CreateVideo({ images: b.VAEDecode({ samples, vae }), fps: vars.fps }),
92
92
  filename_prefix: 'comfy-ts-zoo/wan22-i2v',
93
+ format: 'auto',
94
+ codec: 'auto',
93
95
  })
94
96
  },
95
97
  })
@@ -81,6 +81,8 @@ export const wan22T2v = host.defineWorkflow({
81
81
  b.SaveVideo({
82
82
  video: b.CreateVideo({ images: b.VAEDecode({ samples, vae }), fps: vars.fps }),
83
83
  filename_prefix: 'comfy-ts-zoo/wan22-t2v',
84
+ format: 'auto',
85
+ codec: 'auto',
84
86
  })
85
87
  },
86
88
  })
@@ -38,7 +38,6 @@ const GENERATIVE = [
38
38
  const SWEEP_CANDIDATES = [
39
39
  ...GENERATIVE,
40
40
  'qwen_3_8b_fp8mixed.safetensors',
41
- 'mistral_3_small_flux2_bf16.safetensors',
42
41
  'qwen_2.5_vl_7b_fp8_scaled.safetensors',
43
42
  'clip_l.safetensors',
44
43
  't5\\t5xxl_fp8_e4m3fn_scaled.safetensors',
@@ -108,7 +107,8 @@ const buildTextGen = (b: Comfy.Windows1.Builder, p: TextGenParams): void => {
108
107
  'sampling_mode.seed': p.seed,
109
108
  } as const
110
109
  const generated = p.streaming ? b[STREAMING_NODE_KEY]({ ...shared, stream_every: 4 }) : b.TextGenerate({ ...shared })
111
- b.PreviewAny({ source: generated._STRING })
110
+ // TextGenerate has TWO string outputs (generated_text, thinking), so there is no `_STRING`
111
+ b.PreviewAny({ source: generated.outputs.generated_text })
112
112
  }
113
113
 
114
114
  export const localLlmTextGen = host.defineWorkflow({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "comfy-ts",
3
- "version": "2.10.0",
3
+ "version": "2.11.0",
4
4
  "description": "The complete TypeScript toolkit for ComfyUI and generative AI. Fully type-safe SDK with autocomplete on every node, companion CLI, TUI, agentic docs, and 50+ examples. Design, run and deploy creative pipelines for image, video, audio, 3d and text on any ComfyUI, local, cloud or hosted.",
5
5
  "keywords": [
6
6
  "comfyui",
@@ -87,6 +87,7 @@
87
87
  "sdk:outline": "bun scripts/sdk-outline.ts",
88
88
  "loras": "bun src/cli/comfy-ts-cli.ts loras",
89
89
  "examples:images": "bun scripts/fetch-example-images.ts",
90
+ "gen:favicon": "bun scripts/gen-favicon.ts",
90
91
  "templates:fetch": "bun scripts/fetch-templates.ts",
91
92
  "templates:check": "bun scripts/check-templates.ts",
92
93
  "hooks:install": "git config core.hooksPath .githooks",
@@ -97,7 +98,8 @@
97
98
  "serve": "bun src/cli/comfy-ts-cli.ts serve",
98
99
  "serve:watch": "bun --watch src/cli/comfy-ts-cli.ts serve",
99
100
  "serve:0000": "bun src/cli/comfy-ts-cli.ts serve --host 0.0.0.0",
100
- "serve:0000:rvion": "bun src/cli/comfy-ts-cli.ts serve --host 0.0.0.0 examples/rvion"
101
+ "serve:0000:rvion": "bun src/cli/comfy-ts-cli.ts serve --host 0.0.0.0 examples/rvion",
102
+ "serve:rvion": "bun --watch src/cli/comfy-ts-cli.ts serve examples/rvion"
101
103
  },
102
104
  "rvt": {
103
105
  "skip": [
@@ -19,12 +19,18 @@ import { applyVarPayload } from 'src/cli/serve/applyVarPayload.ts'
19
19
  import { describeVar, type VarDescriptor } from 'src/cli/serve/describeVar.ts'
20
20
  import { deletePromptEnhancer, listPromptEnhancers, writePromptEnhancer } from 'src/promptEnhancers.ts'
21
21
  import { managerOnlyLoraOptions } from 'src/cli/serve/managerOnlyLoras.ts'
22
+ import { FAVICON_DATA_URI } from 'src/cli/serve/favicon.ts'
23
+ import { driftChanged, summarizeDrift } from 'src/host/schemaDrift.ts'
22
24
  import { validSavePrefix, validStoreName } from 'src/utils/safeName.ts'
23
25
  import { readServeSettings, writeServeSettings, type ServeSettings } from 'src/cli/serve/serveSettings.ts'
24
26
  import { assembleLogChunks } from 'src/cli/tui/state/LogsSt.ts'
25
27
  import { draftsDirForFile, listDraftsForFile } from 'src/cli/tui/state/DraftsSt.ts'
26
28
  import {
27
29
  buildLoraMirror,
30
+ getLoraAddedAt,
31
+ getLoraTriggers,
32
+ type LoraTriggers,
33
+ recordCivitaiMiss,
28
34
  getLoraDisplayName,
29
35
  getLoraInfo,
30
36
  getLoraPreviewUrl,
@@ -34,6 +40,7 @@ import {
34
40
  writeLoraMirror,
35
41
  } from 'src/host/loraInfoCache.ts'
36
42
  import {
43
+ fetchLoraCivitai,
37
44
  fetchLoraDescription,
38
45
  fetchLoraExampleImages,
39
46
  fetchLoraList,
@@ -254,7 +261,9 @@ const USAGE = [
254
261
  'DELETE /drafts/<module>/<draft> — delete that draft file',
255
262
  'GET /run/<module> — live run status · /run/<module>/preview — latent preview bytes',
256
263
  'POST /upload with {"name","dataBase64"} — store a browser file for an image var',
264
+ 'GET /hosts/<hostId>/drift[?full=1] — what changed on the host since the schema was loaded (model files; node types with full=1)',
257
265
  'GET /lora-info/<hostId>/<lora> — display name + trigger words (local mirror)',
266
+ 'POST /hosts/<hostId>/lora-civitai/<lora> — fetch its civitai metadata (trigger words) through the lora manager, then re-sync the mirror',
258
267
  'GET /lora-preview/<hostId>/<lora> — preview image bytes',
259
268
  'GET /lora-about/<hostId>/<lora> — civitai description + example images (live from the extension)',
260
269
  'GET /prompt-enhancers — the web ui master prompts (.comfy-ts/prompt-enhancers/*.md)',
@@ -284,6 +293,7 @@ const WEB_SHELL = `<!doctype html>
284
293
  <meta charset="utf-8">
285
294
  <meta name="viewport" content="width=device-width, initial-scale=1">
286
295
  <title>comfy-ts serve</title>
296
+ <link rel="icon" type="image/png" href="${FAVICON_DATA_URI}">
287
297
  <style>html{background:#101217;color:#e8eaf0}</style>
288
298
  </head>
289
299
  <body>
@@ -384,6 +394,8 @@ export class ServeApp {
384
394
  return await this.replyHostLogs(segs[1])
385
395
  if (segs[0] === 'hosts' && segs.length === 3 && segs[1] != null && segs[2] === 'ping')
386
396
  return await this.replyHostPing(segs[1])
397
+ if (segs[0] === 'hosts' && segs.length === 3 && segs[1] != null && segs[2] === 'drift')
398
+ return await this.replyHostDrift(segs[1], req.url.includes('full=1'))
387
399
  if (segs[0] === 'images' && segs.length === 3 && segs[1] != null && segs[2] != null)
388
400
  return this.replyMemoryImage(`${segs[1]}/${segs[2]}`)
389
401
  if (segs[0] === 'outputs') return this.replyOutput(segs.slice(1))
@@ -404,6 +416,15 @@ export class ServeApp {
404
416
  return this.replySetHost(segs[1], req)
405
417
  if (req.method === 'POST' && segs[0] === 'hosts' && segs.length === 3 && segs[1] != null && segs[2] != null)
406
418
  return await this.replyHostAction(segs[1], segs[2])
419
+ if (
420
+ req.method === 'POST' &&
421
+ segs[0] === 'hosts' &&
422
+ segs.length === 4 &&
423
+ segs[1] != null &&
424
+ segs[2] === 'lora-civitai' &&
425
+ segs[3] != null
426
+ )
427
+ return await this.replyLoraCivitaiFetch(segs[1], segs[3])
407
428
  if (req.method === 'PUT' && segs[0] === 'prompt-enhancers' && segs.length === 2 && segs[1] != null)
408
429
  return this.replySavePromptEnhancer(segs[1], req)
409
430
  if (req.method === 'DELETE' && segs[0] === 'prompt-enhancers' && segs.length === 2 && segs[1] != null)
@@ -520,6 +541,18 @@ export class ServeApp {
520
541
  if (kw !== '') keywords[option] = kw
521
542
  }
522
543
  if (Object.keys(keywords).length > 0) desc.optionKeywords = keywords
544
+ const addedAt: Record<string, number> = {}
545
+ for (const option of desc.options) {
546
+ const t = getLoraAddedAt(option, hostId)
547
+ if (t != null) addedAt[option] = t
548
+ }
549
+ if (Object.keys(addedAt).length > 0) desc.optionAddedAt = addedAt
550
+ const triggers: Record<string, LoraTriggers> = {}
551
+ for (const option of desc.options) {
552
+ const t = getLoraTriggers(option, hostId)
553
+ if (t != null) triggers[option] = t
554
+ }
555
+ if (Object.keys(triggers).length > 0) desc.optionTriggers = triggers
523
556
  }
524
557
  vars[name] = desc
525
558
  }
@@ -818,6 +851,67 @@ export class ServeApp {
818
851
  })
819
852
  }
820
853
 
854
+ /** fetch ONE lora's civitai metadata through the lora manager, then re-sync the mirror so its
855
+ * trigger words reach every surface. The extension keys the request by the file path ON THE
856
+ * HOST, which only the mirror knows, so a lora outside the mirror needs a sync first */
857
+ private async replyLoraCivitaiFetch(hostId: string, lora: string): Promise<ServeReply> {
858
+ const host = comfyts.hosts.get(hostId)
859
+ if (host == null) return json(404, { error: `unknown host '${hostId}'` })
860
+ const info = getLoraInfo(lora, hostId)
861
+ const filePath = info == null ? null : lmFilePath(info)
862
+ if (filePath == null)
863
+ return json(404, { error: `'${lora}' is not in the lora manager mirror of ${hostId}: sync the mirror first` })
864
+ const fetched = await fetchLoraCivitai(host, filePath)
865
+ const sha256 = info == null ? null : lmSha256(info)
866
+ // civitai ANSWERED that it has no version for this hash: a definite result, kept so the
867
+ // card stops offering a fetch. Any other failure (network, the extension) stays an error
868
+ if (!fetched.ok && /no version data found/i.test(fetched.reason) && sha256 != null) {
869
+ recordCivitaiMiss({ hostId, sha256, miss: true })
870
+ return json(200, {
871
+ ok: true,
872
+ host: hostId,
873
+ lora,
874
+ triggers: { state: 'not-on-civitai' },
875
+ note: `civitai does not know '${lora}' (a private or local lora): no trigger words to fetch`,
876
+ })
877
+ }
878
+ if (!fetched.ok) return json(502, { error: `civitai fetch failed for '${lora}': ${fetched.reason}` })
879
+ if (sha256 != null) recordCivitaiMiss({ hostId, sha256, miss: false })
880
+ const synced = await this.refreshLoraMirror(hostId, host)
881
+ if (synced.status !== 200) return synced
882
+ const t = getLoraTriggers(lora, hostId)
883
+ const note =
884
+ t?.state === 'words'
885
+ ? `trigger words: ${t.words.join(', ')}`
886
+ : t?.state === 'none'
887
+ ? `civitai lists no trigger words for '${lora}'`
888
+ : `civitai has no metadata for '${lora}'`
889
+ return json(200, { ok: true, host: hostId, lora, triggers: t, note })
890
+ }
891
+
892
+ /** has the host changed since this process loaded its schema: new or removed model files (and
893
+ * node types on a full check). A host whose catalog is COMMITTED rather than live-synced
894
+ * (sdkAutoWrite: false, the cloud catalog) is not compared: its live list moves on purpose */
895
+ private async replyHostDrift(hostId: string, full: boolean): Promise<ServeReply> {
896
+ const host = comfyts.hosts.get(hostId)
897
+ if (host == null) return json(404, { error: `unknown host '${hostId}'` })
898
+ if (host.data.sdkAutoWrite === false)
899
+ return json(200, { host: hostId, checked: false, changed: false, summary: '' })
900
+ try {
901
+ const drift = await host.checkSchemaDrift({ full })
902
+ return json(200, {
903
+ host: hostId,
904
+ checked: true,
905
+ full,
906
+ changed: driftChanged(drift),
907
+ summary: summarizeDrift(drift),
908
+ drift,
909
+ })
910
+ } catch (e) {
911
+ return json(502, { error: `${hostId} unreachable: ${extractErrorMessage(e)}` })
912
+ }
913
+ }
914
+
821
915
  /** is the host answering RIGHT NOW: what the panel polls while a restart is in flight, so
822
916
  * "restarting…" ends on a fact rather than on a guess */
823
917
  private async replyHostPing(hostId: string): Promise<ServeReply> {
@@ -16,6 +16,7 @@ import type {
16
16
  VarKind,
17
17
  } from 'src/vars/ComfyVars.ts'
18
18
  import type { VarPreset } from 'src/vars/presets.ts'
19
+ import type { LoraTriggers } from 'src/host/loraInfoCache.ts'
19
20
 
20
21
  export type VarDescriptor = {
21
22
  kind: VarKind
@@ -41,6 +42,12 @@ export type VarDescriptor = {
41
42
  * the picker with a warning, because a lora present on disk usually runs even when the
42
43
  * server has not rescanned its list, filled by ServeApp.describeModule */
43
44
  managerOnlyOptions?: readonly string[]
45
+ /** loras: when each file landed on the host (epoch seconds, the lora manager's date), entries
46
+ * only where the mirror has one. The popup's `date added` sort reads it */
47
+ optionAddedAt?: Record<string, number>
48
+ /** loras: trigger words per option as the mirror knows them (words, fetched and empty, or
49
+ * civitai never asked). An option ABSENT from this record is not in the mirror at all */
50
+ optionTriggers?: Record<string, LoraTriggers>
44
51
  /** text: this one wants a box, not a line (`v.text(…, { multiline: true })`) */
45
52
  multiline?: boolean
46
53
  /** text + prompt: named starting texts (`{ presets: { label: text } }`). NOT `presets`, which
@@ -0,0 +1,3 @@
1
+ // generated by scripts/gen-favicon.ts from .shipkit/identity/icon.png, never edited by hand
2
+ export const FAVICON_DATA_URI =
3
+ 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAACXBIWXMAAAPoAAAD6AG1e1JrAAAKUklEQVR42u1aaWxU1xW2DWEJZCENNgaK8iNRU5UAAYKBWW1ImwbaoqiuQkrUVlRdlDZSGpqAcTKrFyAoJRCRKmpRidKA98Sm0MQhRClOs7CIggiTtniZN4sZe8AeL/Puvef23LeMnwePQdWw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QqRDj4u6wb9X4FsoQjVsFIA4HrZ8LHY1TUXbiXcUtHHbeWRTpvj7D1XvsO7qspw5NhsH4wVYB3KuwYNmAZw5UvS3bh8brW4gvvRKL/zlQKfSiEqCcaR/HnWzfWfZMX6snq1evtMZCITmchEJjKRiUxkIhM3ZfwPK9dyLD4coj4AAAAASUVORK5CYII='
@@ -176,6 +176,18 @@ export function postHostAction(p: { host: string; action: HostAction }): Promise
176
176
  return jsonFetch(`/hosts/${encodeURIComponent(p.host)}/${p.action}`, { method: 'POST' })
177
177
  }
178
178
 
179
+ export type HostDrift = { host: string; checked: boolean; changed: boolean; summary: string }
180
+
181
+ export function fetchHostDrift(p: { host: string; full: boolean }): Promise<HostDrift> {
182
+ return jsonFetch(`/hosts/${encodeURIComponent(p.host)}/drift${p.full ? '?full=1' : ''}`)
183
+ }
184
+
185
+ export function postLoraCivitai(p: { host: string; lora: string }): Promise<{ ok: true; note: string }> {
186
+ return jsonFetch(`/hosts/${encodeURIComponent(p.host)}/lora-civitai/${encodeURIComponent(p.lora)}`, {
187
+ method: 'POST',
188
+ })
189
+ }
190
+
179
191
  export function fetchHostLogs(p: { host: string }): Promise<{ lines: string[] }> {
180
192
  return jsonFetch(`/hosts/${encodeURIComponent(p.host)}/logs`)
181
193
  }
@@ -411,13 +411,24 @@ export const VarsForm = observer(function VarsForm(p: { st: WebSt }) {
411
411
  >
412
412
  <Icon name="trash" />
413
413
  </button>
414
- <button
415
- type="button"
416
- data-tip="refetch object_info from the host and rewrite sdk.d.ts (the var lists widen in place)"
417
- onClick={() => void p.st.hostAction('refresh-schema')}
418
- >
419
- <Icon name="refresh" />
420
- </button>
414
+ {p.st.drift != null && p.st.drift.host === p.st.hostFor(form.moduleKey) ? (
415
+ <button
416
+ type="button"
417
+ className="attention"
418
+ data-tip={`the host changed since this panel loaded its schema (${p.st.drift.summary}): refetch to use it`}
419
+ onClick={() => void p.st.hostAction('refresh-schema')}
420
+ >
421
+ <Icon name="refresh" /> {p.st.drift.summary}
422
+ </button>
423
+ ) : (
424
+ <button
425
+ type="button"
426
+ data-tip="refetch object_info from the host and rewrite sdk.d.ts (the var lists widen in place)"
427
+ onClick={() => void p.st.hostAction('refresh-schema')}
428
+ >
429
+ <Icon name="refresh" />
430
+ </button>
431
+ )}
421
432
  <button
422
433
  type="button"
423
434
  className="danger"
@@ -19,6 +19,7 @@ import { fetchLoraAbout, fetchLoraInfo, loraPreviewSrc, type LoraAbout, type Lor
19
19
  import type { LoraStrength } from 'src/vars/ComfyVars.ts'
20
20
  import type { VarSt } from 'src/cli/serve/web/state/FormSt.ts'
21
21
  import type { WebSt } from 'src/cli/serve/web/state/WebSt.ts'
22
+ import { LORA_SORTS, sortLoraMatches } from 'src/cli/serve/web/state/loraSort.ts'
22
23
  import {
23
24
  loraIsOn,
24
25
  paletteOrder,
@@ -135,6 +136,76 @@ export const LorasControl = observer(function LorasControl(p: {
135
136
  * ones ComfyUI has no entry for until it rescans its models */
136
137
  const managerOnlyInUse = selectedNames.filter((n) => managerOnly.has(n))
137
138
  const showImages = p.st.showLoraImages
139
+ const triggers = p.v.desc.optionTriggers ?? {}
140
+ /** 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 */
143
+ const triggerLine = (name: string): ReactNode => {
144
+ const t = triggers[name]
145
+ if (t == null)
146
+ 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>
158
+ </span>
159
+ )
160
+ if (t.state === 'unfetched') {
161
+ const busy = p.st.loraFetching.has(name)
162
+ return (
163
+ <span className="chip-triggers missing">
164
+ trigger words never fetched
165
+ <button
166
+ type="button"
167
+ className="trigger-fetch"
168
+ disabled={busy}
169
+ data-tip="ask the lora manager to fetch this lora's civitai metadata, trigger words included"
170
+ onClick={() => void p.st.fetchLoraTriggers(name)}
171
+ >
172
+ {busy ? 'fetching…' : 'fetch'}
173
+ </button>
174
+ </span>
175
+ )
176
+ }
177
+ if (t.state === 'not-on-civitai') {
178
+ const busy = p.st.loraFetching.has(name)
179
+ return (
180
+ <span
181
+ className="chip-triggers missing"
182
+ data-tip="civitai was asked and has no version for this file: a private or local lora, so no trigger words exist there"
183
+ >
184
+ not on civitai
185
+ <button
186
+ type="button"
187
+ className="trigger-fetch"
188
+ disabled={busy}
189
+ data-tip="ask civitai again (it may have been published since)"
190
+ onClick={() => void p.st.fetchLoraTriggers(name)}
191
+ >
192
+ {busy ? 'asking…' : 'retry'}
193
+ </button>
194
+ </span>
195
+ )
196
+ }
197
+ if (t.state === 'none')
198
+ return (
199
+ <span className="chip-triggers none" data-tip="civitai was asked, and this lora has no trigger words">
200
+ no trigger words
201
+ </span>
202
+ )
203
+ return (
204
+ <span className="chip-triggers words" data-tip={showTitles ? t.words.join('\n') : 'titles are hidden'}>
205
+ {showTitles ? t.words.join(', ') : `${t.words.length} trigger word${t.words.length === 1 ? '' : 's'}`}
206
+ </span>
207
+ )
208
+ }
138
209
  const showTitles = p.st.showLoraTitles
139
210
 
140
211
  /** add to the palette (a strength) or REMOVE from it entirely (null) */
@@ -224,7 +295,12 @@ export const LorasControl = observer(function LorasControl(p: {
224
295
  const needle = local.filter.toLowerCase()
225
296
  const matchesFilter = (name: string): boolean =>
226
297
  name.toLowerCase().includes(needle) || label(name).toLowerCase().includes(needle)
227
- const matches = options.filter(matchesFilter)
298
+ const matches = sortLoraMatches({
299
+ names: options.filter(matchesFilter),
300
+ mode: p.st.loraSort,
301
+ label,
302
+ addedAt: p.v.desc.optionAddedAt ?? {},
303
+ })
228
304
  const cardCap = p.st.loraCap
229
305
  const cards = matches.filter((o) => !isInPalette(o)).slice(0, cardCap)
230
306
  /** the enum value IS a path (`krea2\styles\x.safetensors`, separators vary by host and by
@@ -234,6 +310,7 @@ export const LorasControl = observer(function LorasControl(p: {
234
310
  return parts.length <= 1 ? '' : parts.slice(0, -1).join('/')
235
311
  }
236
312
  const groupedCards = (() => {
313
+ if (p.st.loraSort !== 'folder') return [{ folder: null, names: cards }]
237
314
  const byFolder = new Map<string, string[]>()
238
315
  for (const name of cards) {
239
316
  const folder = folderOf(name)
@@ -466,6 +543,7 @@ export const LorasControl = observer(function LorasControl(p: {
466
543
  {warnBadge(name)}
467
544
  </span>
468
545
  <span className="chip-controls">{strengthInputs(name)}</span>
546
+ {triggerLine(name)}
469
547
  </span>
470
548
  ))
471
549
  )}
@@ -543,12 +621,30 @@ export const LorasControl = observer(function LorasControl(p: {
543
621
  })}
544
622
  </div>
545
623
  ) : null}
546
- <div className="section-title">all loras — tap to add to the palette</div>
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>
640
+ </div>
547
641
  {groupedCards.map((group) => (
548
- <div key={group.folder}>
549
- <div className="section-title">
550
- {group.folder === '' ? 'loose (no folder)' : `${group.folder}/`} · {group.names.length}
551
- </div>
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
+ )}
552
648
  <div className="lora-grid">
553
649
  {group.names.map((name) => (
554
650
  <button
@@ -10,6 +10,8 @@ import {
10
10
  fetchSettings,
11
11
  pingHost,
12
12
  postHostAction,
13
+ postLoraCivitai,
14
+ fetchHostDrift,
13
15
  saveDraft,
14
16
  saveSettings,
15
17
  setModuleHost,
@@ -24,6 +26,7 @@ import { logWebError } from 'src/cli/serve/web/logWeb.ts'
24
26
  import { asSeedForm } from 'src/cli/serve/web/state/payload.ts'
25
27
  import { readUrlSelection, resolveSelection, writeUrlSelection } from 'src/cli/serve/web/state/urlSelection.ts'
26
28
  import { RunSt } from 'src/cli/serve/web/state/RunSt.ts'
29
+ import { asLoraSort, type LoraSort } from 'src/cli/serve/web/state/loraSort.ts'
27
30
  import {
28
31
  coerceHostValue,
29
32
  isEmbedded,
@@ -73,6 +76,7 @@ type StoredSelection = {
73
76
  loraTitles?: boolean
74
77
  /** lora previews fill their card (cover) instead of fitting inside it (contain) */
75
78
  loraFill?: boolean
79
+ loraSort?: string
76
80
  /** how many lora cards the popup draws before it stops */
77
81
  loraCap?: number
78
82
  /** the one-shot 60 → 200 default bump already happened for this browser */
@@ -134,6 +138,7 @@ export class WebSt {
134
138
  showLoraTitles: boolean
135
139
  /** cover vs contain for every lora preview: art crops well, a character sheet does not */
136
140
  loraFill: boolean
141
+ loraSort: LoraSort
137
142
  /** how many lora cards the popup draws. A cap exists because each card is an image
138
143
  * request; how many is a MACHINE question (your box, your collection), so it is yours */
139
144
  loraCap: number
@@ -210,6 +215,7 @@ export class WebSt {
210
215
  this.showLoraImages = stored.loraImages ?? true
211
216
  this.showLoraTitles = stored.loraTitles ?? true
212
217
  this.loraFill = stored.loraFill ?? true
218
+ this.loraSort = asLoraSort(stored.loraSort)
213
219
  // marked in the blob, so the bump happens once and a deliberate 60 sticks after it
214
220
  this.loraCap = clampLoraCap(
215
221
  stored.loraCapMigrated !== true && stored.loraCap === LEGACY_LORA_CAP ? DEFAULT_LORA_CAP : stored.loraCap,
@@ -255,6 +261,11 @@ export class WebSt {
255
261
  this.persist()
256
262
  }
257
263
 
264
+ setLoraSort(mode: LoraSort): void {
265
+ this.loraSort = mode
266
+ this.persist()
267
+ }
268
+
258
269
  toggleLoraFill(): void {
259
270
  this.loraFill = !this.loraFill
260
271
  this.persist()
@@ -319,6 +330,7 @@ export class WebSt {
319
330
  loraImages: this.showLoraImages,
320
331
  loraTitles: this.showLoraTitles,
321
332
  loraFill: this.loraFill,
333
+ loraSort: this.loraSort,
322
334
  loraCap: this.loraCap,
323
335
  loraCapMigrated: true,
324
336
  layout: this.layout,
@@ -374,6 +386,7 @@ export class WebSt {
374
386
  if (urlPrompt != null) this.setPromptText(urlPrompt)
375
387
  // last: the host replies with its buttons + its prompt, and both need a form
376
388
  this.postHost({ comfyTs: 'ready' })
389
+ this.startDriftWatch()
377
390
  } catch (e) {
378
391
  const message = e instanceof Error ? e.message : String(e)
379
392
  runInAction(() => {
@@ -765,6 +778,70 @@ export class WebSt {
765
778
  await this.trackSwitch(this.reloadIndexAndForm())
766
779
  }
767
780
 
781
+ /** what changed on a host since the server loaded its schema, shown on the refetch button of
782
+ * that host only. A light check (the loaders, a few KB) runs every minute while the tab is
783
+ * visible; a full one (node types too) at boot, after a refetch or a restart, and when a host
784
+ * that stopped answering answers again, which is how a restart nobody announced is noticed */
785
+ drift: { host: string; summary: string } | null = null
786
+ driftDown = false
787
+
788
+ private startDriftWatch(): void {
789
+ void this.checkDrift(true)
790
+ setInterval(() => {
791
+ if (document.visibilityState === 'visible') void this.checkDrift(false)
792
+ }, 60_000)
793
+ }
794
+
795
+ async checkDrift(full: boolean): Promise<void> {
796
+ const host = this.form == null ? null : this.hostFor(this.form.moduleKey)
797
+ if (host == null || host === '') return
798
+ try {
799
+ const r = await fetchHostDrift({ host, full })
800
+ const cameBack = this.driftDown
801
+ runInAction(() => {
802
+ this.driftDown = false
803
+ // a clean LIGHT check cannot clear what a full one found (node types it does not see)
804
+ if (r.changed) this.drift = { host, summary: r.summary }
805
+ else if (full || this.drift?.host !== host) this.drift = null
806
+ })
807
+ if (cameBack && !full) await this.checkDrift(true)
808
+ } catch {
809
+ runInAction(() => {
810
+ this.driftDown = true
811
+ })
812
+ }
813
+ }
814
+
815
+ /** loras whose civitai fetch is in flight: their card says so instead of offering it twice */
816
+ loraFetching = new Set<string>()
817
+
818
+ /** one lora's trigger words, fetched from civitai by the lora manager, then the mirror and
819
+ * the descriptors re-read so the card shows what came back (words, or a definite none) */
820
+ async fetchLoraTriggers(lora: string): Promise<void> {
821
+ const host = this.form == null ? null : this.hostFor(this.form.moduleKey)
822
+ if (host == null || host === '' || this.loraFetching.has(lora)) return
823
+ runInAction(() => {
824
+ this.loraFetching.add(lora)
825
+ this.hostError = null
826
+ this.hostNote = null
827
+ })
828
+ try {
829
+ const reply = await postLoraCivitai({ host, lora })
830
+ runInAction(() => {
831
+ this.hostNote = reply.note
832
+ })
833
+ await this.trackSwitch(this.reloadIndexAndForm())
834
+ } catch (e) {
835
+ runInAction(() => {
836
+ this.hostError = e instanceof Error ? e.message : String(e)
837
+ })
838
+ } finally {
839
+ runInAction(() => {
840
+ this.loraFetching.delete(lora)
841
+ })
842
+ }
843
+ }
844
+
768
845
  private async reloadIndexAndForm(): Promise<void> {
769
846
  // the option lists (and the manager-only union) live in the descriptors: re-read them,
770
847
  // then re-select the same draft so the form is rebuilt against the new options
@@ -823,6 +900,7 @@ export class WebSt {
823
900
  this.hostWatch = 'back'
824
901
  this.hostNote = `${host} is back up`
825
902
  })
903
+ void this.checkDrift(true)
826
904
  setTimeout(() => runInAction(() => (this.hostWatch = 'idle')), 4000)
827
905
  return
828
906
  }
@@ -843,6 +921,7 @@ export class WebSt {
843
921
  })
844
922
  // a reboot is the one action whose result arrives LATER: watch for it
845
923
  if (action === 'restart') void this.watchHostComeBack()
924
+ if (action === 'refresh-schema') await this.checkDrift(true)
846
925
  } catch (e) {
847
926
  runInAction(() => {
848
927
  this.hostError = e instanceof Error ? e.message : String(e)