comfy-ts 2.13.0 → 2.15.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 (75) hide show
  1. package/README.md +1 -0
  2. package/dist/{LogsSt-CUeo843w.js → LogsSt-C3UIWR-o.js} +2 -2
  3. package/dist/{LogsSt-CUeo843w.js.map → LogsSt-C3UIWR-o.js.map} +1 -1
  4. package/dist/cli.js +4 -4
  5. package/dist/index.cjs +213 -53
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.cts +123 -21
  8. package/dist/index.d.ts +123 -21
  9. package/dist/index.js +207 -54
  10. package/dist/index.js.map +1 -1
  11. package/dist/{run-serve-DlRBv_Nk.js → run-serve-B5PfIuhK.js} +310 -88
  12. package/dist/run-serve-B5PfIuhK.js.map +1 -0
  13. package/dist/{run-tui-B5uxm2_l.js → run-tui-D-N4_yyX.js} +15 -9
  14. package/dist/run-tui-D-N4_yyX.js.map +1 -0
  15. package/dist/{schemaDrift-E95iTF7E.js → schemaDrift-BkN8rLiZ.js} +163 -25
  16. package/dist/schemaDrift-BkN8rLiZ.js.map +1 -0
  17. package/dist/serve-web.js +160 -71
  18. package/dist/{state-CUp2J1Zy.js → state-CZsYJqB6.js} +45 -35
  19. package/dist/state-CZsYJqB6.js.map +1 -0
  20. package/dist/web.d.ts +120 -21
  21. package/dist/web.js +196 -51
  22. package/dist/web.js.map +1 -1
  23. package/examples/media/README.md +8 -0
  24. package/examples/media/sine_440hz_3s.flac +0 -0
  25. package/examples/media/testsrc_256x256_3s.mp4 +0 -0
  26. package/examples/rvion/14-video-soundtrack.cflow.ts +47 -0
  27. package/guide-for-agents.md +2 -1
  28. package/package.json +2 -2
  29. package/src/cli/serve/ServeApp.ts +189 -110
  30. package/src/cli/serve/applyVarPayload.ts +5 -3
  31. package/src/cli/serve/describeVar.ts +5 -3
  32. package/src/cli/serve/resultHistory.ts +141 -0
  33. package/src/cli/serve/run-serve.ts +4 -1
  34. package/src/cli/serve/runError.ts +23 -0
  35. package/src/cli/serve/serveSettings.ts +17 -1
  36. package/src/cli/serve/web/api.ts +33 -2
  37. package/src/cli/serve/web/components/App.tsx +6 -4
  38. package/src/cli/serve/web/components/Gallery.tsx +116 -11
  39. package/src/cli/serve/web/components/Icon.tsx +4 -0
  40. package/src/cli/serve/web/components/MemoryBudget.tsx +98 -0
  41. package/src/cli/serve/web/components/RunError.tsx +19 -0
  42. package/src/cli/serve/web/components/ShortcutsModal.tsx +54 -0
  43. package/src/cli/serve/web/components/SideMenu.tsx +14 -0
  44. package/src/cli/serve/web/components/VarsForm.tsx +75 -55
  45. package/src/cli/serve/web/components/controls/BasicControls.tsx +8 -1
  46. package/src/cli/serve/web/components/controls/LorasControl.tsx +6 -3
  47. package/src/cli/serve/web/components/controls/MediaControl.tsx +111 -0
  48. package/src/cli/serve/web/promptEditor/promptExtensions.ts +3 -1
  49. package/src/cli/serve/web/state/FormSt.ts +70 -2
  50. package/src/cli/serve/web/state/RunSt.ts +61 -3
  51. package/src/cli/serve/web/state/WebSt.ts +26 -2
  52. package/src/cli/serve/web/state/formRows.ts +9 -0
  53. package/src/cli/serve/web/state/host.ts +2 -0
  54. package/src/cli/serve/web/state/keptResults.ts +26 -0
  55. package/src/cli/serve/web/state/lightbox.ts +17 -0
  56. package/src/cli/serve/web/state/mediaDrop.ts +76 -0
  57. package/src/cli/serve/web/state/shortcutCatalog.ts +100 -0
  58. package/src/cli/serve/web/state/shortcuts.ts +10 -0
  59. package/src/cli/serve/web/styles.ts +112 -24
  60. package/src/cli/tui/imagePicker/ImagePickerOverlay.tsx +4 -1
  61. package/src/cli/tui/imagePicker/ImagePickerSt.ts +15 -6
  62. package/src/cli/tui/state/TuiSt.ts +1 -1
  63. package/src/coreExports.ts +10 -0
  64. package/src/exampleAssets.ts +13 -3
  65. package/src/host/ComfyUploader.ts +34 -27
  66. package/src/index.ts +1 -1
  67. package/src/runner/ComfyExecution.ts +38 -20
  68. package/src/runner/ComfyWsApi.ts +3 -0
  69. package/src/runner/mediaKinds.ts +51 -0
  70. package/src/vars/ComfyVars.ts +96 -22
  71. package/dist/run-serve-DlRBv_Nk.js.map +0 -1
  72. package/dist/run-tui-B5uxm2_l.js.map +0 -1
  73. package/dist/schemaDrift-E95iTF7E.js.map +0 -1
  74. package/dist/state-CUp2J1Zy.js.map +0 -1
  75. package/src/cli/serve/web/components/controls/ImageControl.tsx +0 -72
@@ -6,6 +6,15 @@ export const STYLES = /* css */ `
6
6
  --panel: #171a21;
7
7
  --panel-2: #1d2129;
8
8
  --border: #2a2f3a;
9
+ /* the chrome (menu, tabs bar, preview side): lifted off the work area by a cool tint and a
10
+ soft top light, split from it by hairlines instead of solid bands */
11
+ --chrome: linear-gradient(180deg, #1a1f2b 0%, #151922 40%, #13161d 100%);
12
+ --chrome-flat: #171b24;
13
+ --hairline: color-mix(in srgb, var(--border) 70%, transparent);
14
+ /* a picked option (segment, mode toggle): a tint of the accent, never a solid slab */
15
+ --sel-bg: color-mix(in srgb, var(--accent) 22%, var(--panel-2));
16
+ --sel-border: color-mix(in srgb, var(--accent) 55%, transparent);
17
+ --sel-text: #c3d3fb;
9
18
  --text: #e8eaf0;
10
19
  --dim: #8b93a7;
11
20
  --accent: #7aa2f7;
@@ -88,7 +97,7 @@ button.link.load-errors { color: var(--red); font-size: 11px; }
88
97
 
89
98
  /* the menu column: the TUI header on the web, one labelled card per scope, stacked */
90
99
  .menu-layout { flex: 1; min-width: 0; height: 100%; }
91
- .menu-panel { height: 100%; overflow-y: auto; overscroll-behavior: contain; background: var(--panel); border-right: 1px solid var(--border); }
100
+ .menu-panel { height: 100%; overflow-y: auto; overscroll-behavior: contain; background: var(--chrome); }
92
101
  .menu-main { height: 100%; display: flex; min-width: 0; }
93
102
  .menu-main > .main { height: 100%; }
94
103
  /* the open drafts as tabs over the work area. The body below takes the rest: the panel group
@@ -97,20 +106,18 @@ button.link.load-errors { color: var(--red); font-size: 11px; }
97
106
  .tabs-body { flex: 1; min-height: 0; display: flex; }
98
107
  .tabs-body > .main { height: 100%; }
99
108
  .draft-tabs {
100
- display: flex; gap: 0; padding: 4px 8px 0; overflow-x: auto; flex-shrink: 0;
101
- background: var(--panel); border-bottom: 1px solid var(--border);
109
+ display: flex; gap: 0; padding: 0; overflow-x: auto; flex-shrink: 0;
110
+ background: var(--chrome-flat); border-bottom: 1px solid var(--hairline);
102
111
  }
112
+ /* square segments split by hairlines, as tall as the menu head so both bottom lines meet. The
113
+ open one wears the btn-group pick: the accent tint and an accent underline */
103
114
  .draft-tab {
104
- display: inline-flex; align-items: center; gap: 3px; max-width: 220px; padding: 3px 4px 3px 9px;
105
- font-size: 13px; color: var(--dim); cursor: pointer; user-select: none; white-space: nowrap;
106
- border: 1px solid var(--border); border-bottom: 0; border-radius: 6px 6px 0 0; margin-bottom: -1px;
107
- position: relative;
115
+ display: inline-flex; align-items: center; gap: 4px; max-width: 240px; height: 44px; padding: 0 8px 0 14px;
116
+ font-size: 14px; color: var(--dim); cursor: pointer; user-select: none; white-space: nowrap;
117
+ border-right: 1px solid var(--hairline); position: relative;
108
118
  }
109
- /* neighbours share one border line, the open tab draws its own on top */
110
- .draft-tab + .draft-tab { margin-left: -1px; }
111
- .draft-tab.on { z-index: 1; }
112
119
  .draft-tab:hover { color: var(--text); background: var(--panel-2); }
113
- .draft-tab.on { color: var(--text); background: var(--bg); border-color: var(--border); }
120
+ .draft-tab.on { color: var(--sel-text); background: var(--sel-bg); box-shadow: inset 0 -2px 0 var(--accent); }
114
121
  .draft-tab-name { overflow: hidden; text-overflow: ellipsis; }
115
122
  .draft-tab-wf { color: var(--dim); font-size: 11px; }
116
123
  .draft-tab button.draft-tab-close {
@@ -128,7 +135,7 @@ button.link.load-errors { color: var(--red); font-size: 11px; }
128
135
  .tab-menu .menu-action.danger:hover { color: var(--red); }
129
136
  .menu-col { padding: 0 0 14px; }
130
137
  /* ☰ + the name: the same height as the rail's first icon, so folding never moves it */
131
- .menu-head { display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 10px; border-bottom: 1px solid var(--border); }
138
+ .menu-head { display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 10px; border-bottom: 1px solid var(--hairline); }
132
139
  .menu-brand { font-weight: 700; letter-spacing: 0.01em; }
133
140
  .menu-head-key { margin-left: auto; }
134
141
  /* a full-row action (duplicate, new): reads as an entry of the list, its key at the end */
@@ -145,7 +152,7 @@ button.link.load-errors { color: var(--red); font-size: 11px; }
145
152
  .layout-tile:hover { color: var(--text); background: var(--panel-2); }
146
153
  .layout-tile.sel { color: var(--accent); border-color: var(--accent); background: var(--accent-dim); font-weight: 600; }
147
154
  .menu-sections { display: flex; flex-direction: column; }
148
- .menu-section { padding: 10px 10px 12px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
155
+ .menu-section { padding: 10px 10px 12px; border-bottom: 1px solid var(--hairline); display: flex; flex-direction: column; gap: 2px; }
149
156
  .menu-title {
150
157
  display: flex; align-items: center; justify-content: space-between; min-height: 24px; padding: 0 4px;
151
158
  color: var(--dim); font-size: 10.5px; letter-spacing: 0.07em; text-transform: uppercase;
@@ -251,7 +258,12 @@ button.var-reset:disabled { opacity: 0.25; cursor: default; }
251
258
  /* the label IS the drag handle for its row: no separate grip to reveal or aim at */
252
259
  /* labels never wrap: one line at the height of a control, cut with an ellipsis, whole on hover.
253
260
  The icon and the (?) keep their size, only the name gives way */
254
- .var-label { display: flex; align-items: center; justify-content: flex-end; min-height: 28px; min-width: 0; cursor: grab; }
261
+ /* a drag handle never selects its text: WebKit starts a text selection instead of the drag
262
+ when the press lands on selectable text */
263
+ .var-label {
264
+ display: flex; align-items: center; justify-content: flex-end; min-height: 28px; min-width: 0; cursor: grab;
265
+ user-select: none; -webkit-user-select: none; -webkit-user-drag: element;
266
+ }
255
267
  .var-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
256
268
  /* the ⌘ key that jumps to this var, on its own line under the name */
257
269
  .var-label.has-kbd { flex-wrap: wrap; align-content: center; row-gap: 3px; }
@@ -259,7 +271,7 @@ button.var-reset:disabled { opacity: 0.25; cursor: default; }
259
271
  .var-row.inactive .var-control { opacity: 0.18; filter: grayscale(1); }
260
272
  .var-row.inactive .var-label { opacity: 0.45; }
261
273
  .var-label:active { cursor: grabbing; }
262
- .lora-chip[draggable='true'] { cursor: grab; }
274
+ .lora-chip[draggable='true'] { cursor: grab; user-select: none; -webkit-user-select: none; -webkit-user-drag: element; }
263
275
  /* the card drags from anywhere, so its own controls must keep their cursor */
264
276
  .lora-chip input, .lora-chip label, .lora-chip button { cursor: pointer; }
265
277
  .lora-chip input[type='number'] { cursor: text; }
@@ -273,6 +285,9 @@ button.var-reset:disabled { opacity: 0.25; cursor: default; }
273
285
  }
274
286
  .var-label .dirty-dot:hover { background: var(--red); }
275
287
  .var-control { min-width: 0; }
288
+ /* a one-line control sits on the label's 28px line: rows align to the top, so a shorter line
289
+ (a toggle and its word) floated above the label's centre */
290
+ .var-control > .row-inline { min-height: 28px; }
276
291
  /* a workflow's own icons: beside a label, or inside a choice button */
277
292
  .var-icon { width: 15px; height: 15px; margin-right: 5px; flex-shrink: 0; }
278
293
  .btn-group button .var-icon { margin-right: 3px; }
@@ -295,7 +310,35 @@ input[type='range'] { width: 100%; accent-color: var(--accent); }
295
310
  /* a steps or cfg slider across a whole wide row is a long drag for a small number: 320px is
296
311
  still a fine grain for 1..60, and the number box keeps its place right after it */
297
312
  .var-control input[type='range'] { max-width: 320px; }
298
- input[type='checkbox'] { accent-color: var(--accent); width: 16px; height: 16px; }
313
+ /* a number var's slider: a thin dark track, the accent up to the value, a small dot */
314
+ input[type='range'].num-range {
315
+ appearance: none; height: 16px; margin: 0; padding: 0; cursor: pointer; border-radius: 2px;
316
+ background-color: transparent; background-size: 100% 4px; background-position: center; background-repeat: no-repeat;
317
+ }
318
+ input[type='range'].num-range::-webkit-slider-runnable-track { height: 4px; background: transparent; }
319
+ input[type='range'].num-range::-webkit-slider-thumb {
320
+ appearance: none; width: 14px; height: 14px; border-radius: 50%; margin-top: -5px;
321
+ background: var(--accent); border: 2px solid var(--bg); box-shadow: 0 0 0 1px var(--accent-dim);
322
+ }
323
+ input[type='range'].num-range:hover::-webkit-slider-thumb { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent); }
324
+ input[type='range'].num-range::-moz-range-track { height: 4px; background: transparent; }
325
+ input[type='range'].num-range::-moz-range-thumb {
326
+ width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg);
327
+ }
328
+ /* every checkbox is drawn as a toggle, the same pill as .switch: the native box was the one
329
+ control on the page still in the browser's own chrome */
330
+ input[type='checkbox'] {
331
+ appearance: none; position: relative; flex-shrink: 0; width: 36px; height: 20px; margin: 0; align-self: center;
332
+ border-radius: 999px; background: var(--panel-2); border: 1px solid var(--border); cursor: pointer;
333
+ vertical-align: middle; transition: background 0.15s, border-color 0.15s;
334
+ }
335
+ input[type='checkbox']::before {
336
+ content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
337
+ background: var(--dim); transition: transform 0.15s, background 0.15s;
338
+ }
339
+ input[type='checkbox']:checked { background: var(--sel-bg); border-color: var(--sel-border); }
340
+ input[type='checkbox']:checked::before { transform: translateX(16px); background: var(--accent); }
341
+ input[type='checkbox']:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
299
342
  .row-inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
300
343
  /* lanes (src/vars/lanes.ts): named groups merged top to bottom. Each lane is a BAND: a tinted
301
344
  strip, its name as plain small text on the left (clickable, not dressed as a button: click
@@ -410,7 +453,7 @@ button.link { border: 0; background: none; color: var(--accent); padding: 0; }
410
453
  button.link.danger { color: var(--dim); }
411
454
  button.link.danger:hover { color: var(--red); }
412
455
  button.mode { padding: 2px 7px; font-size: 12px; }
413
- button.mode.sel { background: var(--accent); border-color: var(--accent); color: #0d1117; }
456
+ button.mode.sel { background: var(--sel-bg); border-color: var(--sel-border); color: var(--sel-text); }
414
457
  /* the actions that START something (new draft, add loras): accent outline, so the eye finds
415
458
  them before the neutral ones. The lit segment of a group is a solid accent fill */
416
459
  button.accent { color: var(--accent); border-color: var(--accent-dim); }
@@ -439,6 +482,12 @@ button.accent:hover { background: var(--accent-dim); color: #fff; }
439
482
  button.run-end { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; font-size: 13px; }
440
483
  button.run-end:not(:disabled):hover { color: #fff; background: var(--red); border-color: var(--red); }
441
484
  button.run-end:disabled { opacity: 0.45; cursor: default; }
485
+ .run-error-block {
486
+ display: flex; align-items: flex-start; gap: 8px; margin: 8px 0; padding: 8px 10px;
487
+ border: 1px solid var(--red); border-radius: 8px; color: var(--red); font-size: 12px;
488
+ }
489
+ .run-error-block > .icon { flex-shrink: 0; margin-top: 2px; }
490
+ .run-error-text { flex: 1; min-width: 0; margin: 0; font: inherit; white-space: pre-wrap; overflow-wrap: anywhere; user-select: text; }
442
491
  .run-error { flex: 1; min-width: 0; height: 1.4em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--red); font-size: 12px; }
443
492
  input[type='range'].setting-range:disabled { opacity: 0.3; }
444
493
  .live-preview-error { margin-left: 4px; }
@@ -479,6 +528,17 @@ input[type='range'].setting-range:disabled { opacity: 0.3; }
479
528
  .run-card .noimg { color: var(--dim); font-style: italic; }
480
529
  .audio-cell { display: flex; flex-direction: column; gap: 4px; width: min(100%, 480px); }
481
530
  .audio-cell audio { width: 100%; }
531
+ .video-cell { display: flex; flex-direction: column; gap: 4px; width: min(100%, 480px); }
532
+ .gallery.by-cols .video-cell { width: 100%; }
533
+ .video-cell video { width: 100%; max-height: 480px; border-radius: 6px; background: #000; }
534
+ .img-cell[draggable='true'], .audio-cell[draggable='true'], .video-cell[draggable='true'] { cursor: grab; }
535
+ .use-as { display: flex; flex-wrap: wrap; gap: 4px; }
536
+ /* a media var takes desktop files and gallery outputs: the zone lights while one hovers it */
537
+ .media-drop { border: 1px dashed var(--border); border-radius: 6px; padding: 6px; }
538
+ .media-drop.over { border-color: var(--accent); background: var(--accent-dim); }
539
+ .media-drop .error { color: var(--red); font-size: 12px; margin-top: 4px; white-space: pre-wrap; }
540
+ .media-preview-audio audio { width: min(100%, 360px); }
541
+ .media-preview-video video { max-width: 320px; max-height: 220px; border-radius: 6px; border: 1px solid var(--border); background: #000; }
482
542
  .run-card.running { border-color: var(--accent-dim); }
483
543
  /* what the host is on, in the node's own unit — the live signal of a text run, which has
484
544
  neither a latent frame nor an image to show */
@@ -650,6 +710,17 @@ button.live-preview-copy:not(:disabled):hover { color: var(--text); border-color
650
710
  height, so typing a filter or hiding images never moves it */
651
711
  .modal-overlay.top { align-items: flex-start; padding-top: 5vh; }
652
712
  .modal.loras-modal { height: min(86vh, 100%); max-height: none; }
713
+ .modal.shortcuts-modal { width: min(640px, 100%); max-height: min(86vh, 100%); }
714
+ .shortcuts-modal .modal-head { align-items: center; }
715
+ .shortcuts-title { flex: 1; font-weight: 600; }
716
+ .shortcuts-body { overflow-y: auto; padding: 4px 14px 14px; }
717
+ .shortcuts-group { padding-top: 10px; }
718
+ .shortcuts-row { display: flex; align-items: baseline; gap: 12px; padding: 4px 0; font-size: 13px; }
719
+ .shortcuts-keys { display: inline-flex; flex-wrap: wrap; gap: 4px; width: 200px; flex-shrink: 0; }
720
+ .shortcuts-row kbd {
721
+ font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; padding: 1px 6px; border-radius: 5px;
722
+ background: var(--panel-2); border: 1px solid var(--border); border-bottom-width: 2px; color: var(--text);
723
+ }
653
724
  .modal.loras-modal { width: min(1180px, 100%); }
654
725
  /* the palette sits BESIDE the gallery, each scrolling alone: picking a lora grows the palette
655
726
  and never moves a card under the pointer. Narrow: a fixed-height strip above, same reason */
@@ -847,6 +918,9 @@ button.enh-big { font-size: 14px; padding: 8px 18px; }
847
918
  /* blur mode: every result, the latent frame included, stays blurred until the pointer is on it */
848
919
  .gallery.blur img { filter: blur(22px); transition: filter 0.12s, transform 0.12s; }
849
920
  .gallery.blur img:hover, .gallery.blur .img-cell:hover img, .gallery.blur button:hover img { filter: none; }
921
+ /* a video is a picture too: the same privacy blur, lifted while you hover it */
922
+ .gallery.blur .video-cell video { filter: blur(22px); transition: filter 0.12s; }
923
+ .gallery.blur .video-cell:hover video { filter: none; }
850
924
  /* the blur stays inside the image: clipped by its button, and the image scaled up a little while
851
925
  blurred, else the clip shows the blur fading to transparent along every edge */
852
926
  .gallery.blur .img-button { position: relative; overflow: hidden; border-radius: 6px; }
@@ -857,6 +931,17 @@ button.enh-big { font-size: 14px; padding: 8px 18px; }
857
931
  font-size: 13px; padding: 2px 8px; color: #fff; opacity: 0.85; background: rgba(0, 0, 0, 0.35);
858
932
  }
859
933
  .img-button:hover .blur-hint { display: none; }
934
+ /* an unsaved output: only the serve process holds it, so it says so where the eye lands */
935
+ .gallery .img-button, .audio-cell, .video-cell { position: relative; }
936
+ .ephemeral-pill {
937
+ position: absolute; left: 6px; bottom: 6px; pointer-events: auto; display: inline-flex; align-items: center; gap: 4px;
938
+ font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px;
939
+ color: #1a1400; background: var(--amber); opacity: 0.92;
940
+ }
941
+ .audio-cell .ephemeral-pill, .video-cell .ephemeral-pill { position: static; align-self: flex-start; }
942
+ .memory-menu { max-width: 300px; }
943
+ .memory-note { margin: 0; padding: 2px 4px; font-size: 12px; line-height: 1.4; }
944
+ .memory-note.error { color: var(--red); }
860
945
  /* bigger control buttons: the preview head and the menu column, one size with the form rows */
861
946
  .results-head .btn-group > button, .menu-section .btn-group > button, .menu-panel button.head-icon, .drawer button.head-icon {
862
947
  height: 28px; min-width: 28px; font-size: 13px;
@@ -912,13 +997,16 @@ button.enh-big { font-size: 14px; padding: 8px 18px; }
912
997
  .work.split { flex: 1; min-width: 0; height: 100%; gap: 0; align-items: stretch; }
913
998
  .split-panel { height: 100%; overflow-y: auto; overscroll-behavior: contain; }
914
999
  .split-form { padding: 12px 14px 14px; }
915
- .split-results { background: var(--panel); padding: 10px 12px; }
1000
+ .split-results { background: var(--chrome); padding: 10px 12px; }
916
1001
  .work.split .results-col {
917
1002
  position: static; width: auto; max-height: none; overflow: visible;
918
1003
  background: none; border: 0; border-radius: 0; padding: 0;
919
1004
  }
920
- .split-handle { width: 5px; background: var(--border); cursor: col-resize; transition: background 0.1s; }
921
- .split-handle:hover, .split-handle[data-separator-state='drag'] { background: var(--accent); }
1005
+ .split-handle {
1006
+ width: 5px; cursor: col-resize; transition: background 0.1s;
1007
+ background: linear-gradient(90deg, transparent 2px, var(--hairline) 2px, var(--hairline) 3px, transparent 3px);
1008
+ }
1009
+ .split-handle:hover, .split-handle[data-separator-state='drag'] { background: var(--accent-dim); }
922
1010
 
923
1011
  /* the placements. Each one is a BUTTON and nothing else: there is no width rule that quietly
924
1012
  moves the panel somewhere no button is showing */
@@ -985,11 +1073,11 @@ button.enh-big { font-size: 14px; padding: 8px 18px; }
985
1073
  }
986
1074
  .btn-group button:first-child { border-top-left-radius: 6px; border-bottom-left-radius: 6px; }
987
1075
  .btn-group button:last-child { border-right-width: 1px; border-top-right-radius: 6px; border-bottom-right-radius: 6px; }
988
- .btn-group button.sel { background: var(--accent); border-color: var(--accent); color: #0d1117; font-weight: 600; }
1076
+ .btn-group button.sel { background: var(--sel-bg); border-color: var(--sel-border); color: var(--sel-text); font-weight: 600; }
989
1077
  /* the selected segment owns the divider on both sides, else its highlight looks clipped */
990
- .btn-group button.sel + button { border-left-color: var(--accent); }
1078
+ .btn-group button.sel + button { border-left-color: var(--sel-border); }
991
1079
  .btn-group button:hover { background: var(--panel); }
992
- .btn-group button.sel:hover { background: var(--accent); }
1080
+ .btn-group button.sel:hover { background: var(--sel-bg); }
993
1081
  /* ONE height for every button a var row shows in a group or an action line: a choice, the
994
1082
  lora toggles, a lane header, the seed modes. Before, each kind had its own padding and a
995
1083
  choice sat visibly smaller than the toggles beside it */
@@ -1043,7 +1131,7 @@ button.head-icon.danger:hover { color: var(--red); border-color: var(--red); }
1043
1131
  content: ''; position: absolute; top: 1px; left: 1px; width: 12px; height: 12px; border-radius: 50%;
1044
1132
  background: var(--dim); transition: transform 0.15s, background 0.15s;
1045
1133
  }
1046
- .switch input:checked + .track { background: var(--accent-dim); border-color: var(--accent); }
1134
+ .switch input:checked + .track { background: var(--sel-bg); border-color: var(--sel-border); }
1047
1135
  .switch input:checked + .track::after { transform: translateX(12px); background: var(--accent); }
1048
1136
  .switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
1049
1137
 
@@ -64,7 +64,10 @@ export const ImagePickerOverlay = observer((p: { st: TuiSt }) => {
64
64
  })}
65
65
  footer={
66
66
  rows.length === 0 ? (
67
- <Text color="red">{ip.listingError ?? (ip.filter !== '' ? 'no match' : 'no images here')}</Text>
67
+ <Text color="red">
68
+ {ip.listingError ??
69
+ (ip.filter !== '' ? 'no match' : `no ${ip.selectedVar?.kind ?? 'image'} files here`)}
70
+ </Text>
68
71
  ) : undefined
69
72
  }
70
73
  />
@@ -8,7 +8,8 @@ import { extractErrorMessage } from 'src/utils/extractErrorMessage.ts'
8
8
  import { fuzzyMatch } from 'src/utils/fuzzyMatch.ts'
9
9
  import { imageBufferToAnsi } from 'src/utils/ansiImage.ts'
10
10
  import { protocolReadyBytes } from 'src/cli/tui/protocolImage.ts'
11
- import type { ImageVar } from 'src/vars/ComfyVars.ts'
11
+ import type { MediaVar } from 'src/vars/ComfyVars.ts'
12
+ import { extensionOf } from 'src/runner/mediaKinds.ts'
12
13
  import type { TuiSt } from 'src/cli/tui/state/TuiSt.ts'
13
14
 
14
15
  export type PickerPane = 'browse' | 'favorites' | 'recents'
@@ -50,9 +51,9 @@ export class ImagePickerSt {
50
51
  filter: string = ''
51
52
 
52
53
  /** kind-narrowing cast sanctioned (agent/coding.md), `kind` is the tag */
53
- get selectedVar(): ImageVar | null {
54
+ get selectedVar(): MediaVar | null {
54
55
  const sel = this.st.selected?.[1]
55
- return sel?.kind === 'image' ? (sel as ImageVar) : null
56
+ return sel?.kind === 'image' || sel?.kind === 'audio' || sel?.kind === 'video' ? (sel as MediaVar) : null
56
57
  }
57
58
 
58
59
  get folderDisplay(): string {
@@ -60,7 +61,7 @@ export class ImagePickerSt {
60
61
  }
61
62
 
62
63
  /** begin() open order: dirname(value) → persisted lastFolder → opts.folder → cwd */
63
- private initialFolder(iv: ImageVar): string {
64
+ private initialFolder(iv: MediaVar): string {
64
65
  const candidates: (string | null)[] = [
65
66
  iv.isSet() ? dirname(iv.absPath()) : null,
66
67
  pickerPrefs().lastFolder,
@@ -104,7 +105,8 @@ export class ImagePickerSt {
104
105
  }
105
106
  if (this.pane === 'recents')
106
107
  return {
107
- rows: pickerPrefs().recents.map((img) => ({
108
+ // one recents list for every medium: an audio var lists only what it could take
109
+ rows: this.recentsForVar().map((img) => ({
108
110
  kind: 'image',
109
111
  name: contractHome(img),
110
112
  path: img,
@@ -130,6 +132,11 @@ export class ImagePickerSt {
130
132
  }
131
133
  }
132
134
 
135
+ private recentsForVar(): string[] {
136
+ const exts = this.selectedVar?.extensions ?? []
137
+ return pickerPrefs().recents.filter((f) => exts.includes(extensionOf(f)))
138
+ }
139
+
133
140
  get listingError(): string | null {
134
141
  return this.paneListing.error
135
142
  }
@@ -145,8 +152,10 @@ export class ImagePickerSt {
145
152
  return this.rows[this.ix] ?? null
146
153
  }
147
154
 
148
- /** feeds the preview reaction: only a real, present image highlights */
155
+ /** feeds the preview reaction: only a real, present image highlights (an audio or video
156
+ * row has nothing to paint) */
149
157
  get highlightedImage(): string | null {
158
+ if (this.selectedVar?.kind !== 'image') return null
150
159
  const row = this.current
151
160
  return row?.kind === 'image' && !row.missing ? row.path : null
152
161
  }
@@ -317,7 +317,7 @@ export class TuiSt {
317
317
  else if (sel.kind === 'choice') this.picker.beginChoice()
318
318
  else if (sel.kind === 'size') this.picker.beginSize()
319
319
  else if (sel.kind === 'loras') this.loras.begin()
320
- else if (sel.kind === 'image') this.imagePicker.begin()
320
+ else if (sel.kind === 'image' || sel.kind === 'audio' || sel.kind === 'video') this.imagePicker.begin()
321
321
  else this.editor.beginInline() // int / float / seed: type the number
322
322
  }
323
323
 
@@ -36,6 +36,7 @@ export {
36
36
  export {
37
37
  ComfyExecution,
38
38
  type ComfyAudioOutput,
39
+ type ComfyVideoOutput,
39
40
  type ComfyExecutionData,
40
41
  type ComfyTextOutput,
41
42
  type ExecutionProgress,
@@ -90,13 +91,19 @@ export {
90
91
  MultiChoiceVar,
91
92
  LorasVar,
92
93
  SizeVar,
94
+ MediaVar,
93
95
  ImageVar,
96
+ AudioVar,
97
+ VideoVar,
98
+ MediaVarEmptyError,
94
99
  ImageVarEmptyError,
95
100
  DEFAULT_SIZE_PRESETS,
96
101
  SD15_SIZE_PRESETS,
97
102
  DEFAULT_STARRED_SIZES,
98
103
  sizePresetsFor,
99
104
  DEFAULT_IMAGE_EXTENSIONS,
105
+ DEFAULT_AUDIO_EXTENSIONS,
106
+ DEFAULT_VIDEO_EXTENSIONS,
100
107
  activeLoras,
101
108
  } from 'src/vars/ComfyVars.ts'
102
109
  export type {
@@ -114,7 +121,10 @@ export type {
114
121
  ActiveLora,
115
122
  SizeValue,
116
123
  SizePreset,
124
+ MediaVarOpts,
117
125
  ImageVarOpts,
126
+ AudioVarOpts,
127
+ VideoVarOpts,
118
128
  TextVarOpts,
119
129
  PromptVarOpts,
120
130
  PromptTagsOpts,
@@ -44,13 +44,23 @@ export function bundledExamplesDir(moduleUrl: string = import.meta.url): string
44
44
  * or the package's examples/ folder was pruned.
45
45
  */
46
46
  export function exampleImagePath(name: string): string {
47
+ return bundledExampleFile('images', name)
48
+ }
49
+
50
+ /** the same for a bundled `examples/media/` audio or video file, e.g.
51
+ * `exampleMediaPath('sine_440hz_3s.flac')` — the default of audio and video example vars */
52
+ export function exampleMediaPath(name: string): string {
53
+ return bundledExampleFile('media', name)
54
+ }
55
+
56
+ function bundledExampleFile(folder: 'images' | 'media', name: string): string {
47
57
  const examples = bundledExamplesDir()
48
58
  if (examples == null) {
49
59
  throw new Error(
50
- `[comfy-ts] cannot resolve bundled example image '${name}': the package's examples/ folder is not on disk`,
60
+ `[comfy-ts] cannot resolve bundled example file '${name}': the package's examples/ folder is not on disk`,
51
61
  )
52
62
  }
53
- const abs = join(examples, 'images', name)
54
- if (!existsSync(abs)) throw new Error(`[comfy-ts] bundled example image not found: ${abs}`)
63
+ const abs = join(examples, folder, name)
64
+ if (!existsSync(abs)) throw new Error(`[comfy-ts] bundled example file not found: ${abs}`)
55
65
  return abs
56
66
  }
@@ -21,7 +21,11 @@ export const ComfyUploadImageResult_ark = type({
21
21
  export class ComfyUploader {
22
22
  constructor(public host: ComfyHost) {}
23
23
 
24
- /** upload a blob */
24
+ /** names this process already uploaded to this host: a LoadAudio or LoadVideo list is not
25
+ * reloaded after an upload, so without it every run re-sent the same file */
26
+ private uploaded = new Set<string>()
27
+
28
+ /** upload an image (hash-named, deduped against the host's LoadImage list) */
25
29
  uploadImage = async (
26
30
  //
27
31
  img: MediaImage,
@@ -31,46 +35,49 @@ export class ComfyUploader {
31
35
  subfolder?: string
32
36
  },
33
37
  ): Promise<ComfyImageName> => {
34
- const uniqFileName = img.enumName as ComfyImageName
35
- // console.warn(`[🌁] UPLOAD: ${img.relPath} required as "${uniqFileName}"...`)
38
+ const name = await this.uploadInput({ blob: img.getAsBlob(), name: img.enumName, ...p, slot: 'LoadImage.image' })
39
+ return name as ComfyImageName
40
+ }
36
41
 
37
- const expectedFinalName = p.subfolder //
38
- ? `${p.subfolder}/${uniqFileName}`
39
- : uniqFileName
40
- // 2. if image already exists, return it
41
- if (this.host.schema.hasImage(expectedFinalName)) {
42
- console.log(`[🌁] UPLOAD: 🩶 "${img.absPath}" already exists on current ComfyUI instance`)
43
- return expectedFinalName as ComfyImageName
42
+ /**
43
+ * THE upload path: any file a loader node reads from the host's input folder. ComfyUI routes
44
+ * audio and video through `/upload/image` too. `slot` is the loader input whose value list
45
+ * says the file is already there (`LoadImage.image`, `LoadAudio.audio`, `LoadVideo.file`)
46
+ */
47
+ uploadInput = async (p: {
48
+ blob: Blob
49
+ /** the name the file should get on the host, hash-derived by callers so reruns dedupe */
50
+ name: string
51
+ slot: string
52
+ type?: Maybe<'input' | 'temp' | 'output'>
53
+ override?: Maybe<boolean>
54
+ subfolder?: string
55
+ }): Promise<string> => {
56
+ const expectedFinalName = p.subfolder ? `${p.subfolder}/${p.name}` : p.name
57
+ if (this.uploaded.has(expectedFinalName) || this.host.schema.stringValues(p.slot).includes(expectedFinalName)) {
58
+ console.log(`[🌁] UPLOAD: 🩶 "${expectedFinalName}" already exists on current ComfyUI instance`)
59
+ return expectedFinalName
44
60
  }
45
61
 
46
- // 3. upload
47
62
  const form = new FormData()
48
- form.set('image', img.getAsBlob(), uniqFileName)
63
+ form.set('image', p.blob, p.name)
49
64
  if (p.type) form.set('type', p.type)
50
65
  if (p.override ?? true) form.set('override', 'true')
51
- // const subfolder = p.subfolder ?? 'comfyts-upload'
52
66
  if (p.subfolder) form.set('subfolder', p.subfolder)
53
67
  const resp = await this.host.fetch('/upload/image', { method: 'POST', body: form })
54
68
  const result: ComfyUploadImageResult = softValidate(ComfyUploadImageResult_ark, await resp.json())
55
69
 
56
- // 4. check upload is successfull
57
70
  console.log('[🌁] UPLOAD: ✅ got', result)
58
- if (result.name == null) throw new Error('upload failed')
59
-
60
- const finalName = result.subfolder //
61
- ? (`${result.subfolder}/${result.name}` as ComfyImageName)
62
- : result.name
71
+ if (result.name == null) throw new Error(`upload of '${p.name}' failed: the host answered no name`)
63
72
 
64
- if (finalName !== expectedFinalName) {
73
+ const finalName = result.subfolder ? `${result.subfolder}/${result.name}` : result.name
74
+ if (finalName !== expectedFinalName)
65
75
  console.warn(`[🌁] UPLOAD: ⚠️ expected "${expectedFinalName}" but got "${finalName}"`)
66
- } else {
67
- console.log(`[🌁] UPLOAD: ✅ finalName is "${finalName}"`)
68
- }
69
-
70
- // 5. patch the local ComfyUI schema locally
71
- this.host.schema.unsafely_addImageInSchemaWithoutReloading(finalName)
72
76
 
73
- // 6. return the image
77
+ // the image list IS a known union: patch it so the next LoadImage typechecks against it
78
+ if (p.slot === 'LoadImage.image')
79
+ this.host.schema.unsafely_addImageInSchemaWithoutReloading(finalName as ComfyImageName)
80
+ this.uploaded.add(finalName)
74
81
  return finalName
75
82
  }
76
83
 
package/src/index.ts CHANGED
@@ -12,7 +12,7 @@ setDefaultComfyStorage(createNodeStorage())
12
12
  export * from 'src/coreExports.ts'
13
13
 
14
14
  // node-only surface: fs-backed example assets + the TUI env contract
15
- export { exampleImagePath } from 'src/exampleAssets.ts'
15
+ export { exampleImagePath, exampleMediaPath } from 'src/exampleAssets.ts'
16
16
  // the prompt-enhancer library on disk, offered as var presets (fs, so never in the web entry)
17
17
  export { promptEnhancerPresets, readPromptEnhancers, type PromptEnhancer } from 'src/promptEnhancers.ts'
18
18
  export { isTuiActive } from 'src/cli/tui-env.ts'
@@ -21,6 +21,7 @@ import type {
21
21
  WsMsgExecutionSuccess,
22
22
  } from 'src/runner/ComfyWsApi.ts'
23
23
  import { MediaImage } from 'src/runner/MediaImage.ts'
24
+ import { isVideoFilename, mediaMime } from 'src/runner/mediaKinds.ts'
24
25
 
25
26
  /** paths claimed by in-flight retrievals: two same-second runs on a
26
27
  * counter-resetting cloud host compute the same name before either writes.
@@ -46,19 +47,9 @@ export type ComfyAudioOutput = {
46
47
  absPath: AbsolutePath | null
47
48
  }
48
49
 
49
- const AUDIO_MIMES: Record<string, string> = {
50
- flac: 'audio/flac',
51
- mp3: 'audio/mpeg',
52
- opus: 'audio/ogg',
53
- ogg: 'audio/ogg',
54
- wav: 'audio/wav',
55
- m4a: 'audio/mp4',
56
- }
57
-
58
- export function audioMime(filename: string): string {
59
- const ext = filename.split('.').pop()?.toLowerCase() ?? ''
60
- return AUDIO_MIMES[ext] ?? 'application/octet-stream'
61
- }
50
+ /** one video file an output node published (SaveVideo, SaveWEBM, VHS_VideoCombine), same
51
+ * shape and same retrieval as an audio file */
52
+ export type ComfyVideoOutput = ComfyAudioOutput
62
53
 
63
54
  /** one text output as an output node published it (`nodeKey` is null when the node left the snapshot) */
64
55
  export type ComfyTextOutput = {
@@ -167,6 +158,7 @@ export class ComfyExecution {
167
158
  const p = this.progress
168
159
  const outputs = [`${this.images.length} image(s)`]
169
160
  if (this.audios.length > 0) outputs.push(`${this.audios.length} audio(s)`)
161
+ if (this.videos.length > 0) outputs.push(`${this.videos.length} video(s)`)
170
162
  if (this.texts.length > 0) outputs.push(`${this.texts.length} text(s)`)
171
163
  const line = `${this.status === 'Failure' ? '🔴' : '🟢'} ${this.status.toLowerCase()} in ${(p.elapsedMs / 1000).toFixed(1)}s · ${outputs.join(' · ')}`
172
164
  if (globalThis.process?.stdout?.isTTY) process.stdout.write(`\r\x1b[2K${line}\n`)
@@ -252,8 +244,23 @@ export class ComfyExecution {
252
244
  const nodeKey = this.workflow.data.apiJson?.[promptNodeID]?.class_type ?? null
253
245
  this.texts.push({ nodeId: promptNodeID, nodeKey, text: entry })
254
246
  }
255
- const images = msg.data.output?.images
256
- if (images) {
247
+ // a video file rides `images` (SaveVideo), `video` or `gifs` (VideoHelperSuite): the
248
+ // extension decides, so an animated webp or gif stays an image
249
+ const out = msg.data.output
250
+ // a loader (LoadVideo) echoes the file it READ, typed 'input': a preview, never an output
251
+ const listed = [...(out?.images ?? []), ...(out?.video ?? []), ...(out?.gifs ?? [])].filter(
252
+ (f) => f.type !== 'input',
253
+ )
254
+ for (const video of listed.filter((f) => isVideoFilename(f.filename))) {
255
+ this.pendingPromises.push(
256
+ this.retrieveFile('video', video, promptNodeID).catch((e: unknown) => {
257
+ console.error(`🔴 failed to retrieve ${video.filename}:`, e)
258
+ this.videoErrors.push({ video, error: e })
259
+ }),
260
+ )
261
+ }
262
+ const images = listed.filter((f) => !isVideoFilename(f.filename))
263
+ if (images.length > 0) {
257
264
  for (const img of images) {
258
265
  // guard every retrieval: one failed download must not hang `done`
259
266
  this.pendingPromises.push(
@@ -266,7 +273,7 @@ export class ComfyExecution {
266
273
  }
267
274
  for (const audio of msg.data.output?.audio ?? []) {
268
275
  this.pendingPromises.push(
269
- this.retrieveAudio(audio, promptNodeID).catch((e: unknown) => {
276
+ this.retrieveFile('audio', audio, promptNodeID).catch((e: unknown) => {
270
277
  console.error(`🔴 failed to retrieve ${audio.filename}:`, e)
271
278
  this.audioErrors.push({ audio, error: e })
272
279
  }),
@@ -281,13 +288,24 @@ export class ComfyExecution {
281
288
  /** audio files retrieved for this execution, in arrival order (final once `done` resolves) */
282
289
  audios: ComfyAudioOutput[] = []
283
290
 
284
- private retrieveAudio = async (info: ComfyImageInfo, promptNodeID: ComfyNodeId): Promise<void> => {
291
+ /** video retrievals that failed (their files are missing from `videos`) */
292
+ videoErrors: { video: ComfyImageInfo; error: unknown }[] = []
293
+
294
+ /** video files retrieved for this execution, in arrival order (final once `done` resolves) */
295
+ videos: ComfyVideoOutput[] = []
296
+
297
+ private retrieveFile = async (
298
+ kind: 'audio' | 'video',
299
+ info: ComfyImageInfo,
300
+ promptNodeID: ComfyNodeId,
301
+ ): Promise<void> => {
285
302
  const response = await this.host.fetchFile('/view?' + new URLSearchParams(info).toString())
286
303
  const bytes = new Uint8Array(await response.arrayBuffer())
287
- const mime = audioMime(info.filename)
304
+ const mime = mediaMime(info.filename)
305
+ const list = kind === 'audio' ? this.audios : this.videos
288
306
  const sf = this.save
289
307
  if (sf == null) {
290
- this.audios.push({ nodeId: promptNodeID, filename: info.filename, mime, bytes, absPath: null })
308
+ list.push({ nodeId: promptNodeID, filename: info.filename, mime, bytes, absPath: null })
291
309
  return
292
310
  }
293
311
  const promptPrefix = this.workflow.data.apiJson?.[promptNodeID]?.inputs['filename_prefix']
@@ -299,7 +317,7 @@ export class ComfyExecution {
299
317
  subfolder: info.subfolder,
300
318
  filename: info.filename,
301
319
  })
302
- this.audios.push({ nodeId: promptNodeID, filename: info.filename, mime, bytes, absPath: written.path })
320
+ list.push({ nodeId: promptNodeID, filename: info.filename, mime, bytes, absPath: written.path })
303
321
  }
304
322
 
305
323
  /** image retrievals that failed (their images are missing from `images`);
@@ -66,6 +66,9 @@ const tempScope = scope({
66
66
  'images?': 'ComfyImageInfo[]',
67
67
  // SaveAudio*, PreviewAudio: same file triple as an image
68
68
  'audio?': 'ComfyImageInfo[]',
69
+ // VideoHelperSuite's VHS_VideoCombine, and savers that name their list `video`
70
+ 'video?': 'ComfyImageInfo[]',
71
+ 'gifs?': 'ComfyImageInfo[]',
69
72
  // ui payload of a text output node (PreviewAny, and how TextGenerate
70
73
  // results reach the client); entries are soft, non-strings are dropped
71
74
  'text?': 'unknown[]',