comfy-ts 1.1.0 → 1.2.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 (48) hide show
  1. package/README.md +21 -8
  2. package/dist/cli.js +4 -4552
  3. package/dist/cli.js.map +1 -1
  4. package/dist/index.cjs +53 -12
  5. package/dist/index.cjs.map +1 -1
  6. package/dist/index.d.cts +49 -23
  7. package/dist/index.d.ts +49 -23
  8. package/dist/index.js +53 -12
  9. package/dist/index.js.map +1 -1
  10. package/dist/{run-tui-DZ22HDHI.js → run-tui-BAdizWsO.js} +722 -130
  11. package/dist/run-tui-BAdizWsO.js.map +1 -0
  12. package/dist/state-BYbxDgfr.js +5258 -0
  13. package/dist/state-BYbxDgfr.js.map +1 -0
  14. package/examples/README.md +6 -4
  15. package/examples/{01-txt2img.cflow.ts → rvion/01-txt2img.cflow.ts} +1 -1
  16. package/examples/{02-img2img-upload.cflow.ts → rvion/02-img2img-upload.cflow.ts} +1 -1
  17. package/examples/{03-export-workflow-json.cflow.ts → rvion/03-export-workflow-json.cflow.ts} +1 -1
  18. package/examples/{04-krea2-turbo-t2i.cflow.ts → rvion/04-krea2-turbo-t2i.cflow.ts} +2 -2
  19. package/examples/{05-comfy-cloud.cflow.ts → rvion/05-comfy-cloud.cflow.ts} +2 -2
  20. package/examples/rvion/06-qwen-image-edit.cflow.ts +89 -0
  21. package/package.json +4 -1
  22. package/src/cli/tui/components/CopyOverlay.tsx +25 -0
  23. package/src/cli/tui/components/Header.tsx +9 -4
  24. package/src/cli/tui/components/HostPanel.tsx +3 -2
  25. package/src/cli/tui/components/HostsOverlay.tsx +33 -0
  26. package/src/cli/tui/components/StatusBar.tsx +28 -9
  27. package/src/cli/tui/components/TreePanel.tsx +17 -7
  28. package/src/cli/tui/components/TuiApp.tsx +47 -5
  29. package/src/cli/tui/imagePicker/fsListing.ts +6 -4
  30. package/src/cli/tui/run-tui.tsx +47 -7
  31. package/src/cli/tui/state/DraftsSt.ts +3 -2
  32. package/src/cli/tui/state/ExecSt.ts +108 -12
  33. package/src/cli/tui/state/HostSt.ts +94 -10
  34. package/src/cli/tui/state/PickerSt.ts +8 -2
  35. package/src/cli/tui/state/QueueSt.ts +2 -2
  36. package/src/cli/tui/state/SettingsSt.ts +25 -7
  37. package/src/cli/tui/state/TreeSt.ts +139 -36
  38. package/src/cli/tui/state/TuiSt.ts +47 -6
  39. package/src/cli/tui/state/WorkflowsSt.ts +14 -2
  40. package/src/cli/tui/treeRows.ts +165 -0
  41. package/src/host/ComfyHost.ts +7 -0
  42. package/src/runner/ComfyWorkflowLayout.ts +6 -4
  43. package/src/state.ts +7 -1
  44. package/src/vars/ComfyVars.ts +25 -4
  45. package/src/vars/DefinedWorkflow.ts +21 -8
  46. package/dist/DefinedWorkflow-BYyu5dK9.js +0 -669
  47. package/dist/DefinedWorkflow-BYyu5dK9.js.map +0 -1
  48. package/dist/run-tui-DZ22HDHI.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { a as setLoraKeyword, c as stripAnsi, i as getLoraKeyword, n as LorasVar, o as extractErrorMessage, r as PromptVar, t as DefinedWorkflow, u as logError } from "./DefinedWorkflow-BYyu5dK9.js";
1
+ import { a as PromptVar, f as logError, i as LorasVar, l as extractErrorMessage, n as settingsPathFor, o as getLoraKeyword, r as DefinedWorkflow, s as setLoraKeyword, u as stripAnsi } from "./state-BYbxDgfr.js";
2
2
  import { spawn } from "node:child_process";
3
3
  import { fileURLToPath, pathToFileURL } from "node:url";
4
4
  import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
@@ -450,35 +450,6 @@ function installProtocolImagePainter(st) {
450
450
  };
451
451
  }
452
452
  //#endregion
453
- //#region src/cli/tui/components/OverlayList.tsx
454
- /** generic modal list: title + rows windowed around the selected index */
455
- const OverlayList = (p) => {
456
- const winStart = Math.max(0, Math.min(p.selectedIx - Math.floor(p.lines / 2), p.rows.length - p.lines));
457
- const visible = p.rows.slice(winStart, winStart + p.lines);
458
- return /* @__PURE__ */ jsxs(Box, {
459
- borderStyle: "double",
460
- paddingX: 1,
461
- flexDirection: "column",
462
- children: [
463
- /* @__PURE__ */ jsx(Text, {
464
- bold: true,
465
- children: p.title
466
- }),
467
- p.extraHeader,
468
- winStart > 0 && /* @__PURE__ */ jsx(Text, {
469
- color: "gray",
470
- children: "…"
471
- }),
472
- visible.map((r) => r.node),
473
- winStart + p.lines < p.rows.length && /* @__PURE__ */ jsx(Text, {
474
- color: "gray",
475
- children: "…"
476
- }),
477
- p.footer
478
- ]
479
- });
480
- };
481
- //#endregion
482
453
  //#region src/cli/tui/components/StatusBar.tsx
483
454
  /** keys cyan, labels gray — shared by the keybar and overlay footers */
484
455
  const KeyHints = (p) => /* @__PURE__ */ jsx(Text, {
@@ -627,18 +598,26 @@ const MODE_KEYS = {
627
598
  ["↑↓", "move"],
628
599
  ["esc", "cancel"]
629
600
  ],
601
+ "overlay-hosts": [
602
+ ["⏎", "pick run host"],
603
+ ["↑↓", "move"],
604
+ ["esc", "cancel"]
605
+ ],
606
+ "overlay-copy": [["⏎/esc", "close"]],
630
607
  tree: [
631
608
  ["⏎", "load"],
632
609
  ["↑↓", "move"],
633
610
  ["←", "fold"],
634
611
  ["→", "unfold / vars"],
612
+ ["/", "filter"],
635
613
  ...DRAFT_OP_HINTS,
636
614
  ["t/esc", "back"]
637
615
  ],
638
616
  host: [
639
617
  ["⏎", "run action"],
640
618
  ["↑↓", "move"],
641
- ["h/esc", "back"]
619
+ ["h", "change host"],
620
+ ["a/esc", "back"]
642
621
  ],
643
622
  preview: [
644
623
  ["←→", "change"],
@@ -650,12 +629,18 @@ const MODE_KEYS = {
650
629
  const KeyBar = observer((p) => {
651
630
  const s = p.st;
652
631
  const kind = s.selected?.[1].kind;
653
- const modeHints = MODE_KEYS[s.mode] ?? [
632
+ const treeFiltering = s.mode === "tree" && s.tree.filtering;
633
+ const modeHints = treeFiltering ? [
634
+ ["type", "filter"],
635
+ ["⏎", "load"],
636
+ ["↑↓", "move"],
637
+ ["esc", "clear"]
638
+ ] : MODE_KEYS[s.mode] ?? [
654
639
  ["↑↓", "select"],
655
640
  ["←", "tree"],
656
641
  ...kind ? KIND_KEYS[kind] ?? [] : []
657
642
  ];
658
- const globalHints = s.mode === "nav" || s.mode === "tree" || s.mode === "host" || s.mode === "preview" ? [
643
+ const globalHints = !treeFiltering && (s.mode === "nav" || s.mode === "tree" || s.mode === "host" || s.mode === "preview") ? [
659
644
  ["r", "run"],
660
645
  ["s", "reroll+run"],
661
646
  ...s.mode === "nav" ? [["e", "rename draft"]] : [],
@@ -671,6 +656,62 @@ const KeyBar = observer((p) => {
671
656
  });
672
657
  });
673
658
  //#endregion
659
+ //#region src/cli/tui/components/CopyOverlay.tsx
660
+ /** `c`/`C` confirmation popup: WHAT landed in the clipboard (or the loud
661
+ * failure) — a copy is never silent again. ⏎/esc closes. */
662
+ const CopyOverlay = observer((p) => {
663
+ const popup = p.st.exec.copyPopup;
664
+ if (popup == null) return null;
665
+ return /* @__PURE__ */ jsxs(Box, {
666
+ borderStyle: "double",
667
+ borderColor: popup.ok ? "green" : "red",
668
+ paddingX: 1,
669
+ flexDirection: "column",
670
+ children: [
671
+ /* @__PURE__ */ jsxs(Text, {
672
+ bold: true,
673
+ color: popup.ok ? "green" : "red",
674
+ children: [popup.ok ? "✓ " : "✗ ", popup.title]
675
+ }),
676
+ popup.lines.slice(0, p.st.overlayLines).map((line, ix) => /* @__PURE__ */ jsx(Text, {
677
+ color: popup.ok ? void 0 : "red",
678
+ wrap: "truncate",
679
+ children: line
680
+ }, `${ix}·${line.slice(0, 12)}`)),
681
+ /* @__PURE__ */ jsx(KeyHints, { hints: [["⏎/esc", "close"]] })
682
+ ]
683
+ });
684
+ });
685
+ //#endregion
686
+ //#region src/cli/tui/components/OverlayList.tsx
687
+ /** generic modal list: title + rows windowed around the selected index */
688
+ const OverlayList = (p) => {
689
+ const winStart = Math.max(0, Math.min(p.selectedIx - Math.floor(p.lines / 2), p.rows.length - p.lines));
690
+ const visible = p.rows.slice(winStart, winStart + p.lines);
691
+ return /* @__PURE__ */ jsxs(Box, {
692
+ borderStyle: "double",
693
+ paddingX: 1,
694
+ flexDirection: "column",
695
+ children: [
696
+ /* @__PURE__ */ jsx(Text, {
697
+ bold: true,
698
+ children: p.title
699
+ }),
700
+ p.extraHeader,
701
+ winStart > 0 && /* @__PURE__ */ jsx(Text, {
702
+ color: "gray",
703
+ children: "…"
704
+ }),
705
+ visible.map((r) => r.node),
706
+ winStart + p.lines < p.rows.length && /* @__PURE__ */ jsx(Text, {
707
+ color: "gray",
708
+ children: "…"
709
+ }),
710
+ p.footer
711
+ ]
712
+ });
713
+ };
714
+ //#endregion
674
715
  //#region src/cli/tui/components/DraftsOverlay.tsx
675
716
  /** modal draft picker: row 0 creates a new draft, the rest load existing ones */
676
717
  const DraftsOverlay = observer((p) => {
@@ -720,9 +761,10 @@ const HeaderBox = (p) => /* @__PURE__ */ jsxs(Box, {
720
761
  })
721
762
  }), /* @__PURE__ */ jsx(Box, { children: p.children })]
722
763
  });
723
- /** labeled header boxes: brand · (w)orkflow · (d)raft · (h)ost — the keys open each surface */
764
+ /** labeled header boxes: brand · (w)orkflow · (d)raft · (h)ost·(a)ctions — the keys open each surface */
724
765
  const Header = observer((p) => {
725
766
  const s = p.st;
767
+ const runHost = s.runHost;
726
768
  return /* @__PURE__ */ jsxs(Box, {
727
769
  flexDirection: "row",
728
770
  children: [
@@ -748,7 +790,7 @@ const Header = observer((p) => {
748
790
  })
749
791
  }),
750
792
  /* @__PURE__ */ jsx(HeaderBox, {
751
- title: "(h)ost",
793
+ title: "(h)ost · (a)ctions",
752
794
  children: /* @__PURE__ */ jsxs(Text, { children: [
753
795
  /* @__PURE__ */ jsx(Text, {
754
796
  color: s.host.status === "up" ? "green" : s.host.status === "down" ? "red" : "gray",
@@ -757,19 +799,23 @@ const Header = observer((p) => {
757
799
  /* @__PURE__ */ jsx(Text, {
758
800
  bold: true,
759
801
  color: "green",
760
- children: s.wf.host.data.id
802
+ children: runHost.data.id
761
803
  }),
762
804
  /* @__PURE__ */ jsxs(Text, {
763
805
  color: "gray",
764
806
  children: [
765
807
  " ",
766
808
  "(",
767
- s.wf.host.data.host,
809
+ runHost.base.host,
768
810
  ":",
769
- s.wf.host.data.port,
811
+ runHost.base.port,
770
812
  ")"
771
813
  ]
772
814
  }),
815
+ s.hostOverride != null && s.hostOverride !== s.wf.host && /* @__PURE__ */ jsxs(Text, {
816
+ color: "yellow",
817
+ children: [" ⇄ overrides ", s.wf.host.data.id]
818
+ }),
773
819
  s.host.status === "down" && /* @__PURE__ */ jsxs(Text, {
774
820
  color: "red",
775
821
  children: [" ", s.host.probing ? s.host.spinner : `↻ ${s.host.retryInS}s`]
@@ -783,7 +829,8 @@ const Header = observer((p) => {
783
829
  //#region src/cli/tui/components/HostPanel.tsx
784
830
  /** host stats + maintenance actions (mode 'host', key `h`) */
785
831
  const HostPanel = observer((p) => {
786
- const h = p.st.host;
832
+ const s = p.st;
833
+ const h = s.host;
787
834
  return /* @__PURE__ */ jsxs(Box, {
788
835
  borderStyle: "double",
789
836
  paddingX: 1,
@@ -792,7 +839,7 @@ const HostPanel = observer((p) => {
792
839
  /* @__PURE__ */ jsxs(Text, {
793
840
  bold: true,
794
841
  children: [
795
- "host · ",
842
+ "host actions · ",
796
843
  /* @__PURE__ */ jsx(Text, {
797
844
  color: "green",
798
845
  children: h.host.data.id
@@ -802,11 +849,15 @@ const HostPanel = observer((p) => {
802
849
  color: "gray",
803
850
  children: [
804
851
  "(",
805
- h.host.data.host,
852
+ h.host.base.host,
806
853
  ":",
807
- h.host.data.port,
854
+ h.host.base.port,
808
855
  ")"
809
856
  ]
857
+ }),
858
+ s.hostOverride != null && /* @__PURE__ */ jsx(Text, {
859
+ color: "yellow",
860
+ children: " ⇄ override"
810
861
  })
811
862
  ]
812
863
  }),
@@ -832,6 +883,34 @@ const HostPanel = observer((p) => {
832
883
  });
833
884
  });
834
885
  //#endregion
886
+ //#region src/cli/tui/components/HostsOverlay.tsx
887
+ /** modal host picker (`h`): row 0 restores the workflow's own host, the rest
888
+ * override where runs are built and sent (every registered host is listed) */
889
+ const HostsOverlay = observer((p) => {
890
+ const s = p.st;
891
+ const h = s.host;
892
+ const rows = h.pickerRows.map((row, ix) => ({
893
+ key: row.host?.data.id ?? "·default·",
894
+ node: /* @__PURE__ */ jsxs(Text, {
895
+ inverse: ix === h.pickerIx,
896
+ children: [
897
+ ix === h.pickerIx ? "▸ " : " ",
898
+ row.active ? "● " : " ",
899
+ row.label
900
+ ]
901
+ }, row.host?.data.id ?? "·default·")
902
+ }));
903
+ return /* @__PURE__ */ jsx(OverlayList, {
904
+ title: /* @__PURE__ */ jsxs(Fragment, { children: ["run host ", /* @__PURE__ */ jsx(Text, {
905
+ color: "gray",
906
+ children: "· overrides the workflow's configured host"
907
+ })] }),
908
+ selectedIx: h.pickerIx,
909
+ lines: s.overlayLines,
910
+ rows
911
+ });
912
+ });
913
+ //#endregion
835
914
  //#region src/cli/tui/components/LorasOverlay.tsx
836
915
  /** modal multi-select: tick/untick loras, filter, bulk ops, step strengths */
837
916
  const LorasOverlay = observer((p) => {
@@ -1115,15 +1194,15 @@ function hasImageExtension(name, extensions) {
1115
1194
  }
1116
1195
  /**
1117
1196
  * ONE folder for the picker: dirs first then images, both alphabetical,
1118
- * dotfiles skipped, images filtered by extension. Symlinks are followed
1119
- * (a dangling one is skipped). Pure over fs — an unreadable dir THROWS,
1120
- * the caller surfaces it (never a silent empty listing).
1197
+ * images filtered by extension. Dot FILES are junk (.DS_Store) and skipped;
1198
+ * dot DIRS are listed — .comfy-ts/outputs must be browsable. Symlinks are
1199
+ * followed (a dangling one is skipped). Pure over fs — an unreadable dir
1200
+ * THROWS, the caller surfaces it (never a silent empty listing).
1121
1201
  */
1122
1202
  function listImageDir(dir, extensions) {
1123
1203
  const dirs = [];
1124
1204
  const images = [];
1125
1205
  for (const entry of readdirSync(dir, { withFileTypes: true })) {
1126
- if (entry.name.startsWith(".")) continue;
1127
1206
  let isDir = entry.isDirectory();
1128
1207
  let isFile = entry.isFile();
1129
1208
  if (entry.isSymbolicLink()) try {
@@ -1133,6 +1212,7 @@ function listImageDir(dir, extensions) {
1133
1212
  } catch {
1134
1213
  continue;
1135
1214
  }
1215
+ if (entry.name.startsWith(".") && !isDir) continue;
1136
1216
  if (isDir) dirs.push(entry.name);
1137
1217
  else if (isFile && hasImageExtension(entry.name, extensions)) images.push(entry.name);
1138
1218
  }
@@ -1656,7 +1736,8 @@ const TextOverlay = observer((p) => {
1656
1736
  });
1657
1737
  //#endregion
1658
1738
  //#region src/cli/tui/components/TreePanel.tsx
1659
- /** persistent left panel: workflows with their drafts nested; `t` (or ← from vars) focuses it */
1739
+ /** persistent left panel: directory hierarchy + workflows with their drafts
1740
+ * nested; `t` (or ← from vars) focuses it, `/` filters it */
1660
1741
  const TreePanel = observer((p) => {
1661
1742
  const s = p.st;
1662
1743
  const tree = s.tree;
@@ -1677,22 +1758,40 @@ const TreePanel = observer((p) => {
1677
1758
  children: "(t)ree"
1678
1759
  })
1679
1760
  }),
1761
+ (tree.filtering || tree.filter !== "") && /* @__PURE__ */ jsxs(Text, {
1762
+ color: "yellow",
1763
+ wrap: "truncate",
1764
+ children: [
1765
+ "/",
1766
+ tree.filter,
1767
+ tree.filtering ? "▌" : ""
1768
+ ]
1769
+ }),
1680
1770
  tree.rows.map((row, ix) => {
1681
1771
  const sel = focused && ix === tree.ix;
1682
- if (row.kind === "section") return /* @__PURE__ */ jsxs(Text, {
1772
+ const indent = " ".repeat(row.depth * 2);
1773
+ if (row.kind === "dir") return /* @__PURE__ */ jsxs(Text, {
1774
+ inverse: sel,
1683
1775
  color: "gray",
1684
- dimColor: true,
1776
+ bold: true,
1685
1777
  wrap: "truncate",
1686
- children: ["─ ", row.label]
1687
- }, `section·${row.label}`);
1778
+ children: [
1779
+ indent,
1780
+ row.expanded ? "▾" : "▸",
1781
+ " ",
1782
+ row.label
1783
+ ]
1784
+ }, `dir·${row.path}`);
1688
1785
  if (row.kind === "workflow") {
1689
1786
  const arrow = row.hasDrafts ? row.expanded ? "▾" : "▸" : " ";
1690
1787
  const marker = row.error != null ? "✗" : row.current ? "●" : " ";
1691
1788
  return /* @__PURE__ */ jsxs(Text, {
1692
1789
  inverse: sel,
1693
- color: row.error != null ? "red" : row.current ? "green" : void 0,
1790
+ bold: row.current,
1791
+ color: row.error != null ? "red" : row.color,
1694
1792
  wrap: "truncate",
1695
1793
  children: [
1794
+ indent,
1696
1795
  arrow,
1697
1796
  marker,
1698
1797
  " ",
@@ -1705,7 +1804,8 @@ const TreePanel = observer((p) => {
1705
1804
  color: row.active ? "cyan" : "gray",
1706
1805
  wrap: "truncate",
1707
1806
  children: [
1708
- " ",
1807
+ indent,
1808
+ " ",
1709
1809
  row.active ? "●" : "·",
1710
1810
  " ",
1711
1811
  row.draft
@@ -1922,7 +2022,20 @@ const TuiApp = observer((p) => {
1922
2022
  }
1923
2023
  if (s.mode === "tree") {
1924
2024
  const tr = s.tree;
1925
- if (key.escape || input === "t") return tr.blur();
2025
+ if (tr.filtering) {
2026
+ if (key.escape) return tr.clearFilter();
2027
+ if (key.return) return void tr.commit();
2028
+ if (key.upArrow) return tr.move(-1);
2029
+ if (key.downArrow) return tr.move(1);
2030
+ if (key.leftArrow) return tr.fold();
2031
+ if (key.rightArrow) return tr.unfold();
2032
+ if (key.backspace || key.delete) return tr.filterBackspace();
2033
+ if (input && !key.ctrl && !key.meta) return tr.filterInput(input);
2034
+ return;
2035
+ }
2036
+ if (key.escape) return tr.filter !== "" ? tr.clearFilter() : tr.blur();
2037
+ if (input === "t") return tr.blur();
2038
+ if (input === "/") return tr.beginFilter();
1926
2039
  if (key.return || input === " ") return void tr.commit();
1927
2040
  if (key.upArrow) return tr.move(-1);
1928
2041
  if (key.downArrow) return tr.move(1);
@@ -1936,7 +2049,8 @@ const TuiApp = observer((p) => {
1936
2049
  if (input === "r") return void s.exec.run();
1937
2050
  if (input === "s") return s.exec.randomizeSeedAndRun();
1938
2051
  if (input === "d") return s.drafts.begin();
1939
- if (input === "h") return s.host.begin();
2052
+ if (input === "h") return s.host.beginPicker();
2053
+ if (input === "a") return s.host.begin();
1940
2054
  if (input === "p") return s.preview.beginMenu();
1941
2055
  if (input === "o") return s.exec.openLastOutput();
1942
2056
  if (input === "q") {
@@ -1947,7 +2061,8 @@ const TuiApp = observer((p) => {
1947
2061
  }
1948
2062
  if (s.mode === "host") {
1949
2063
  const h = s.host;
1950
- if (key.escape || input === "h" || input === "v") return h.blur();
2064
+ if (key.escape || input === "a" || input === "v") return h.blur();
2065
+ if (input === "h") return h.beginPicker();
1951
2066
  if (key.return || input === " ") return void h.commit();
1952
2067
  if (key.upArrow) return h.move(-1);
1953
2068
  if (key.downArrow) return h.move(1);
@@ -1957,6 +2072,18 @@ const TuiApp = observer((p) => {
1957
2072
  }
1958
2073
  return;
1959
2074
  }
2075
+ if (s.mode === "overlay-hosts") {
2076
+ const h = s.host;
2077
+ if (key.escape || input === "h") return h.cancelPicker();
2078
+ if (key.return || input === " ") return h.commitPicker();
2079
+ if (key.upArrow) return h.pickerMove(-1);
2080
+ if (key.downArrow) return h.pickerMove(1);
2081
+ return;
2082
+ }
2083
+ if (s.mode === "overlay-copy") {
2084
+ if (key.escape || key.return || input === " " || input === "c" || input === "C" || input === "q") return s.exec.closeCopyPopup();
2085
+ return;
2086
+ }
1960
2087
  if (s.mode === "preview") {
1961
2088
  const pv = s.preview;
1962
2089
  if (key.escape || key.return || input === "p" || input === "v") return pv.blurMenu();
@@ -1967,7 +2094,8 @@ const TuiApp = observer((p) => {
1967
2094
  if (input === "r") return void s.exec.run();
1968
2095
  if (input === "s") return s.exec.randomizeSeedAndRun();
1969
2096
  if (input === "d") return s.drafts.begin();
1970
- if (input === "h") return s.host.begin();
2097
+ if (input === "h") return s.host.beginPicker();
2098
+ if (input === "a") return s.host.begin();
1971
2099
  if (input === "o") return s.exec.openLastOutput();
1972
2100
  if (input === "q") {
1973
2101
  s.onExit();
@@ -1999,11 +2127,16 @@ const TuiApp = observer((p) => {
1999
2127
  if (key.leftArrow) return s.tree.focus();
2000
2128
  if (key.rightArrow || key.return || input === " ") return s.activate();
2001
2129
  if (s.navKey(input)) return;
2130
+ if (input === "/") {
2131
+ s.tree.focus();
2132
+ return s.tree.beginFilter();
2133
+ }
2002
2134
  if (input === "e") return s.drafts.beginRename();
2003
2135
  if (input === "r") return void s.exec.run();
2004
2136
  if (input === "s") return s.exec.randomizeSeedAndRun();
2005
2137
  if (input === "t" || input === "w") return s.tree.focus();
2006
- if (input === "h") return s.host.begin();
2138
+ if (input === "h") return s.host.beginPicker();
2139
+ if (input === "a") return s.host.begin();
2007
2140
  if (input === "d") return s.drafts.begin();
2008
2141
  if (input === "p") return s.preview.beginMenu();
2009
2142
  if (input === "o") return s.exec.openLastOutput();
@@ -2024,7 +2157,7 @@ const TuiApp = observer((p) => {
2024
2157
  flexDirection: "column",
2025
2158
  flexGrow: 1,
2026
2159
  children: [
2027
- s.mode === "edit" && s.editor.isCustom ? /* @__PURE__ */ jsx(PromptOverlay, { st: s }) : s.mode === "host" ? /* @__PURE__ */ jsx(HostPanel, { st: s }) : s.mode === "overlay-text" ? /* @__PURE__ */ jsx(TextOverlay, { st: s }) : s.mode === "overlay-choice" ? /* @__PURE__ */ jsx(ChoiceOverlay, { st: s }) : s.mode === "overlay-size" ? /* @__PURE__ */ jsx(SizeOverlay, { st: s }) : s.mode === "overlay-loras" ? /* @__PURE__ */ jsx(LorasOverlay, { st: s }) : s.mode === "overlay-image" ? /* @__PURE__ */ jsx(ImagePickerOverlay, { st: s }) : s.mode === "overlay-drafts" ? /* @__PURE__ */ jsx(DraftsOverlay, { st: s }) : /* @__PURE__ */ jsx(VarsPanel, { st: s }),
2160
+ s.mode === "edit" && s.editor.isCustom ? /* @__PURE__ */ jsx(PromptOverlay, { st: s }) : s.mode === "host" ? /* @__PURE__ */ jsx(HostPanel, { st: s }) : s.mode === "overlay-text" ? /* @__PURE__ */ jsx(TextOverlay, { st: s }) : s.mode === "overlay-choice" ? /* @__PURE__ */ jsx(ChoiceOverlay, { st: s }) : s.mode === "overlay-size" ? /* @__PURE__ */ jsx(SizeOverlay, { st: s }) : s.mode === "overlay-loras" ? /* @__PURE__ */ jsx(LorasOverlay, { st: s }) : s.mode === "overlay-image" ? /* @__PURE__ */ jsx(ImagePickerOverlay, { st: s }) : s.mode === "overlay-drafts" ? /* @__PURE__ */ jsx(DraftsOverlay, { st: s }) : s.mode === "overlay-hosts" ? /* @__PURE__ */ jsx(HostsOverlay, { st: s }) : s.mode === "overlay-copy" ? /* @__PURE__ */ jsx(CopyOverlay, { st: s }) : /* @__PURE__ */ jsx(VarsPanel, { st: s }),
2028
2161
  /* @__PURE__ */ jsx(Box, {
2029
2162
  paddingX: 1,
2030
2163
  children: /* @__PURE__ */ jsx(ProgressLine, { st: s })
@@ -2057,10 +2190,183 @@ const TuiApp = observer((p) => {
2057
2190
  });
2058
2191
  });
2059
2192
  //#endregion
2193
+ //#region src/cli/tui/treeRows.ts
2194
+ /** module display name — also the drafts folder key (DraftsSt delegates here) */
2195
+ function moduleName(file) {
2196
+ return basename(file).replace(/\.cflow\.tsx?$/, "");
2197
+ }
2198
+ /** the color word: everything before the first `-` (`flux1-i2i` → `flux1`) */
2199
+ function familyOf(name) {
2200
+ const dash = name.indexOf("-");
2201
+ return dash === -1 ? name : name.slice(0, dash);
2202
+ }
2203
+ /** hue-spread so CONSECUTIVE families land on clearly distinct colors */
2204
+ const FAMILY_PALETTE = [
2205
+ "#61afef",
2206
+ "#e5c07b",
2207
+ "#c678dd",
2208
+ "#98c379",
2209
+ "#e06c75",
2210
+ "#56b6c2",
2211
+ "#d19a66",
2212
+ "#a5b4fc",
2213
+ "#a5e075",
2214
+ "#f28fad"
2215
+ ];
2216
+ /** family → color, palette cycled in first-appearance order over the FULL
2217
+ * (unfiltered) file list — stable while filtering/folding */
2218
+ function assignFamilyColors(files) {
2219
+ const colors = /* @__PURE__ */ new Map();
2220
+ for (const file of files) {
2221
+ const family = familyOf(moduleName(file));
2222
+ if (colors.has(family)) continue;
2223
+ colors.set(family, FAMILY_PALETTE[colors.size % FAMILY_PALETTE.length] ?? "#61afef");
2224
+ }
2225
+ return colors;
2226
+ }
2227
+ function commonDir(files) {
2228
+ const first = files[0];
2229
+ if (first == null) return "";
2230
+ let prefix = dirname(first).split("/");
2231
+ for (const f of files.slice(1)) {
2232
+ const segs = dirname(f).split("/");
2233
+ let i = 0;
2234
+ while (i < prefix.length && i < segs.length && prefix[i] === segs[i]) i++;
2235
+ prefix = prefix.slice(0, i);
2236
+ }
2237
+ return prefix.join("/");
2238
+ }
2239
+ function insert(root, rootDir, file) {
2240
+ const rel = dirname(file).slice(rootDir.length).replace(/^\//, "");
2241
+ const segs = rel === "" ? [] : rel.split("/");
2242
+ let node = root;
2243
+ for (const seg of segs) {
2244
+ let child = node.dirs.get(seg);
2245
+ if (child == null) {
2246
+ child = {
2247
+ path: `${node.path}/${seg}`,
2248
+ label: seg,
2249
+ files: [],
2250
+ dirs: /* @__PURE__ */ new Map()
2251
+ };
2252
+ node.dirs.set(seg, child);
2253
+ }
2254
+ node = child;
2255
+ }
2256
+ node.files.push(file);
2257
+ }
2258
+ /** a dir holding NOTHING but one subdir shows as one `a/b` row */
2259
+ function mergeChains(node) {
2260
+ const entries = [...node.dirs];
2261
+ for (const [key, child] of entries) {
2262
+ mergeChains(child);
2263
+ if (child.files.length === 0 && child.dirs.size === 1) {
2264
+ const only = [...child.dirs.values()][0];
2265
+ const label = `${child.label}/${only.label}`;
2266
+ node.dirs.delete(key);
2267
+ node.dirs.set(label, {
2268
+ ...only,
2269
+ label
2270
+ });
2271
+ }
2272
+ }
2273
+ }
2274
+ function matches(file, rootDir, filter) {
2275
+ if (filter === "") return true;
2276
+ return `${dirname(file).slice(rootDir.length)}/${moduleName(file)}`.toLowerCase().includes(filter.toLowerCase());
2277
+ }
2278
+ function emit(p) {
2279
+ for (const file of p.node.files) {
2280
+ if (!matches(file, p.rootDir, p.filter)) continue;
2281
+ p.out.push({
2282
+ kind: "file",
2283
+ file,
2284
+ name: moduleName(file),
2285
+ depth: p.depth
2286
+ });
2287
+ }
2288
+ for (const dir of [...p.node.dirs.values()].sort((a, b) => a.label.localeCompare(b.label))) {
2289
+ const kept = [];
2290
+ const expanded = p.filter !== "" || !p.collapsedDirs.has(dir.path);
2291
+ emit({
2292
+ ...p,
2293
+ node: dir,
2294
+ depth: p.depth + 1,
2295
+ out: kept
2296
+ });
2297
+ if (p.filter !== "" && kept.length === 0) continue;
2298
+ p.out.push({
2299
+ kind: "dir",
2300
+ path: dir.path,
2301
+ label: dir.label,
2302
+ depth: p.depth,
2303
+ expanded
2304
+ });
2305
+ if (expanded) p.out.push(...kept);
2306
+ }
2307
+ }
2308
+ /**
2309
+ * hierarchy rows over the discovered files: user files under their common
2310
+ * root, packaged examples LAST under one foldable 'comfy-ts examples' node.
2311
+ */
2312
+ function buildFileRows(p) {
2313
+ const out = [];
2314
+ if (p.userFiles.length > 0) {
2315
+ const rootDir = commonDir(p.userFiles);
2316
+ const root = {
2317
+ path: rootDir,
2318
+ label: "",
2319
+ files: [],
2320
+ dirs: /* @__PURE__ */ new Map()
2321
+ };
2322
+ for (const f of p.userFiles) insert(root, rootDir, f);
2323
+ mergeChains(root);
2324
+ emit({
2325
+ node: root,
2326
+ depth: 0,
2327
+ rootDir,
2328
+ collapsedDirs: p.collapsedDirs,
2329
+ filter: p.filter,
2330
+ out
2331
+ });
2332
+ }
2333
+ if (p.bundledFiles.length > 0) {
2334
+ const rootDir = commonDir(p.bundledFiles);
2335
+ const root = {
2336
+ path: rootDir,
2337
+ label: "comfy-ts examples",
2338
+ files: [],
2339
+ dirs: /* @__PURE__ */ new Map()
2340
+ };
2341
+ for (const f of p.bundledFiles) insert(root, rootDir, f);
2342
+ mergeChains(root);
2343
+ const kept = [];
2344
+ const expanded = p.filter !== "" || !p.collapsedDirs.has(rootDir);
2345
+ emit({
2346
+ node: root,
2347
+ depth: 1,
2348
+ rootDir,
2349
+ collapsedDirs: p.collapsedDirs,
2350
+ filter: p.filter,
2351
+ out: kept
2352
+ });
2353
+ if (p.filter !== "" && kept.length === 0) return out;
2354
+ out.push({
2355
+ kind: "dir",
2356
+ path: rootDir,
2357
+ label: root.label,
2358
+ depth: 0,
2359
+ expanded
2360
+ });
2361
+ if (expanded) out.push(...kept);
2362
+ }
2363
+ return out;
2364
+ }
2365
+ //#endregion
2060
2366
  //#region src/cli/tui/state/DraftsSt.ts
2061
2367
  /** module basename (`01-txt2img`) keys the draft folder — knowable for EVERY tree file without importing it */
2062
2368
  function draftKeyForFile(file) {
2063
- return basename(file).replace(/\.cflow\.tsx?$/, "");
2369
+ return moduleName(file);
2064
2370
  }
2065
2371
  function draftsDirForFile(file) {
2066
2372
  return comfyts.resolveFromDrafts(draftKeyForFile(file));
@@ -2524,6 +2830,13 @@ var EditorSt = class EditorSt {
2524
2830
  };
2525
2831
  //#endregion
2526
2832
  //#region src/cli/tui/state/ExecSt.ts
2833
+ /** popup body: summary + the head of the copied json (proof of WHAT is in the clipboard) */
2834
+ function jsonHead(text, maxLines) {
2835
+ const lines = text.split("\n");
2836
+ const head = lines.slice(0, maxLines).map((l) => l.length > 76 ? `${l.slice(0, 75)}…` : l);
2837
+ if (lines.length > maxLines) head.push("…");
2838
+ return head;
2839
+ }
2527
2840
  /** run lifecycle + outputs + status line + clipboard/open actions */
2528
2841
  var ExecSt = class {
2529
2842
  constructor(st) {
@@ -2536,6 +2849,9 @@ var ExecSt = class {
2536
2849
  this.error = null;
2537
2850
  this.notice = null;
2538
2851
  this.currentPromptId = null;
2852
+ this.latentHosts = /* @__PURE__ */ new Set();
2853
+ this.copyPopup = null;
2854
+ this.copying = false;
2539
2855
  makeAutoObservable(this, { st: false });
2540
2856
  }
2541
2857
  get running() {
@@ -2552,7 +2868,7 @@ var ExecSt = class {
2552
2868
  /** every run takes THIS path, queued ones included: same progress, outputs, previews */
2553
2869
  async run() {
2554
2870
  const queued = this.running;
2555
- const host = this.st.wf.host;
2871
+ const host = this.st.runHost;
2556
2872
  runInAction(() => {
2557
2873
  this.inFlight++;
2558
2874
  this.error = null;
@@ -2562,11 +2878,15 @@ var ExecSt = class {
2562
2878
  this.notice = null;
2563
2879
  this.currentPromptId = null;
2564
2880
  this.st.preview.clearLatent();
2565
- host.onLatentPreview = (p) => void this.st.preview.renderLatent(p.bytes);
2566
2881
  }
2882
+ host.onLatentPreview = (p) => void this.st.preview.renderLatent(p.bytes);
2883
+ this.latentHosts.add(host);
2567
2884
  });
2568
2885
  try {
2569
- const execution = await this.st.wf.run({ onProgress: (p) => runInAction(() => this.onProgress(p)) });
2886
+ const execution = await this.st.wf.run({
2887
+ host: this.st.hostOverride ?? void 0,
2888
+ onProgress: (p) => runInAction(() => this.onProgress(p))
2889
+ });
2570
2890
  runInAction(() => {
2571
2891
  this.outputs = execution.images.map((i) => i.absPath);
2572
2892
  this.lastStatus = execution.status;
@@ -2584,7 +2904,10 @@ var ExecSt = class {
2584
2904
  this.progress = null;
2585
2905
  this.currentPromptId = null;
2586
2906
  this.st.preview.clearLatent();
2587
- if (this.inFlight === 0) host.onLatentPreview = null;
2907
+ if (this.inFlight === 0) {
2908
+ for (const h of this.latentHosts) h.onLatentPreview = null;
2909
+ this.latentHosts.clear();
2910
+ }
2588
2911
  });
2589
2912
  }
2590
2913
  }
@@ -2621,6 +2944,23 @@ var ExecSt = class {
2621
2944
  proc.unref();
2622
2945
  this.notice = `opened ${basename(last)}`;
2623
2946
  }
2947
+ closeCopyPopup() {
2948
+ this.copyPopup = null;
2949
+ this.st.mode = "nav";
2950
+ }
2951
+ showCopyPopup(title, ok, lines) {
2952
+ const m = this.st.mode;
2953
+ if (m === "edit" || m.startsWith("overlay-")) {
2954
+ this.notice = `${ok ? "✓" : "✗"} ${title}`;
2955
+ return;
2956
+ }
2957
+ this.copyPopup = {
2958
+ title,
2959
+ ok,
2960
+ lines
2961
+ };
2962
+ this.st.mode = "overlay-copy";
2963
+ }
2624
2964
  toClipboard(text) {
2625
2965
  const [cmd, ...args] = process.platform === "darwin" ? ["pbcopy"] : process.platform === "win32" ? ["clip"] : [
2626
2966
  "xclip",
@@ -2641,29 +2981,67 @@ var ExecSt = class {
2641
2981
  }
2642
2982
  /** 'c': copy workflow.json (litegraph, drag into the ComfyUI editor) */
2643
2983
  async copyWorkflowJson() {
2984
+ if (this.copying) return;
2985
+ runInAction(() => {
2986
+ this.copying = true;
2987
+ this.notice = "building for copy… (i2i workflows upload their input image first)";
2988
+ });
2644
2989
  try {
2645
- const json = await (await this.st.wf.build()).toWorkflowJson();
2646
- const ok = await this.toClipboard(JSON.stringify(json, null, 2));
2990
+ const json = await (await this.st.wf.build({ host: this.st.hostOverride ?? void 0 })).toWorkflowJson();
2991
+ const text = JSON.stringify(json, null, 2);
2992
+ const ok = await this.toClipboard(text);
2647
2993
  runInAction(() => {
2648
- this.notice = ok ? `workflow.json copied (${json.nodes.length} nodes)` : "clipboard copy failed";
2994
+ this.showCopyPopup("workflow.json → clipboard", ok, ok ? [
2995
+ `${json.nodes.length} nodes · ${text.length} chars — paste into the ComfyUI editor`,
2996
+ "",
2997
+ ...jsonHead(text, 10)
2998
+ ] : ["CLIPBOARD COPY FAILED — is a clipboard tool available (pbcopy/clip/xclip) ?"]);
2649
2999
  });
2650
3000
  } catch (e) {
2651
3001
  runInAction(() => {
2652
- this.notice = `${extractErrorMessage(e)}`;
3002
+ this.showCopyPopup("workflow.json copy FAILED", false, [
3003
+ extractErrorMessage(e),
3004
+ "",
3005
+ "nothing was copied. i2i/i2v builds upload their input image first —",
3006
+ "an unreachable host fails the build itself, not just the run."
3007
+ ]);
3008
+ });
3009
+ } finally {
3010
+ runInAction(() => {
3011
+ this.copying = false;
2653
3012
  });
2654
3013
  }
2655
3014
  }
2656
3015
  /** 'C': copy api.json (the POST /prompt payload) */
2657
3016
  async copyApiJson() {
3017
+ if (this.copying) return;
3018
+ runInAction(() => {
3019
+ this.copying = true;
3020
+ this.notice = "building for copy… (i2i workflows upload their input image first)";
3021
+ });
2658
3022
  try {
2659
- const json = (await this.st.wf.build()).toApiJson("use_stringified_numbers_only");
2660
- const ok = await this.toClipboard(JSON.stringify(json, null, 2));
3023
+ const json = (await this.st.wf.build({ host: this.st.hostOverride ?? void 0 })).toApiJson("use_stringified_numbers_only");
3024
+ const text = JSON.stringify(json, null, 2);
3025
+ const ok = await this.toClipboard(text);
2661
3026
  runInAction(() => {
2662
- this.notice = ok ? `api.json copied (${Object.keys(json).length} nodes)` : "clipboard copy failed";
3027
+ this.showCopyPopup("api.json → clipboard", ok, ok ? [
3028
+ `${Object.keys(json).length} nodes · ${text.length} chars — the POST /prompt payload`,
3029
+ "",
3030
+ ...jsonHead(text, 10)
3031
+ ] : ["CLIPBOARD COPY FAILED — is a clipboard tool available (pbcopy/clip/xclip) ?"]);
2663
3032
  });
2664
3033
  } catch (e) {
2665
3034
  runInAction(() => {
2666
- this.notice = `${extractErrorMessage(e)}`;
3035
+ this.showCopyPopup("api.json copy FAILED", false, [
3036
+ extractErrorMessage(e),
3037
+ "",
3038
+ "nothing was copied. i2i/i2v builds upload their input image first —",
3039
+ "an unreachable host fails the build itself, not just the run."
3040
+ ]);
3041
+ });
3042
+ } finally {
3043
+ runInAction(() => {
3044
+ this.copying = false;
2667
3045
  });
2668
3046
  }
2669
3047
  }
@@ -2684,12 +3062,35 @@ const SPIN_FRAMES = [
2684
3062
  "⠇",
2685
3063
  "⠏"
2686
3064
  ];
3065
+ /**
3066
+ * PURE probe verdict (headless-tested). http ok is proof enough; on http
3067
+ * failure a RECENTLY TALKING open ws still means up — ComfyUI is
3068
+ * single-threaded and stalls new connects mid-generation while established
3069
+ * sockets stream (his repro 2026-07-30: 'windows-1 offline' in the header
3070
+ * while the browser tab generated fine). A half-open socket receives
3071
+ * nothing, so the recency window never revives one.
3072
+ */
3073
+ function probeVerdict(p) {
3074
+ if (p.httpOk) return {
3075
+ status: "up",
3076
+ via: p.wsOpen ? "ws" : "http"
3077
+ };
3078
+ if (p.wsOpen && p.lastWsMessageAt != null && p.now - p.lastWsMessageAt < 1e4) return {
3079
+ status: "up",
3080
+ via: "ws"
3081
+ };
3082
+ return {
3083
+ status: "down",
3084
+ via: null
3085
+ };
3086
+ }
2687
3087
  /** host panel (`h`): stats about the connected host + maintenance actions */
2688
3088
  var HostSt = class {
2689
3089
  constructor(st) {
2690
3090
  this.st = st;
2691
3091
  this.status = "unknown";
2692
3092
  this.statusVia = null;
3093
+ this.lastProbeError = null;
2693
3094
  this.probing = false;
2694
3095
  this.retryInS = 0;
2695
3096
  this.spinFrame = 0;
@@ -2718,6 +3119,7 @@ var HostSt = class {
2718
3119
  label: "interrupt current run"
2719
3120
  }
2720
3121
  ];
3122
+ this.pickerIx = 0;
2721
3123
  makeAutoObservable(this, { st: false });
2722
3124
  this.probeLoop();
2723
3125
  this.st.disposers.push(() => {
@@ -2726,10 +3128,11 @@ var HostSt = class {
2726
3128
  if (this.spinTimer != null) clearInterval(this.spinTimer);
2727
3129
  if (this.countdownTimer != null) clearInterval(this.countdownTimer);
2728
3130
  });
2729
- this.st.disposers.push(reaction(() => this.st.wf, () => {
3131
+ this.st.disposers.push(reaction(() => this.st.runHost, () => {
2730
3132
  runInAction(() => {
2731
3133
  this.status = "unknown";
2732
3134
  this.statusVia = null;
3135
+ this.lastProbeError = null;
2733
3136
  });
2734
3137
  this.probeGen++;
2735
3138
  if (this.loopTimer != null) clearTimeout(this.loopTimer);
@@ -2762,8 +3165,9 @@ var HostSt = class {
2762
3165
  }, PROBE_EVERY_MS);
2763
3166
  this.loopTimer.unref?.();
2764
3167
  }
2765
- /** http is the ground truth: a half-open ws keeps isOpen=true forever, and
2766
- * trusting it would re-create the exact silent-death this dot exists to expose */
3168
+ /** http first — a half-open ws keeps isOpen=true forever, so isOpen alone
3169
+ * is never trusted. RECENT MESSAGES are: probeVerdict lets a talking ws
3170
+ * beat a stalled http probe (busy single-threaded server) */
2767
3171
  async probe() {
2768
3172
  const host = this.host;
2769
3173
  runInAction(() => {
@@ -2777,12 +3181,15 @@ var HostSt = class {
2777
3181
  spin.unref?.();
2778
3182
  this.spinTimer = spin;
2779
3183
  let ok = false;
3184
+ let probeError = null;
2780
3185
  try {
2781
3186
  const res = await host.fetch("/prompt", { signal: AbortSignal.timeout(PROBE_TIMEOUT_MS) });
2782
3187
  res.body?.cancel();
2783
3188
  ok = res.ok;
2784
- } catch {
3189
+ if (!ok) probeError = `http ${res.status}`;
3190
+ } catch (e) {
2785
3191
  ok = false;
3192
+ probeError = extractErrorMessage(e);
2786
3193
  } finally {
2787
3194
  clearInterval(spin);
2788
3195
  if (this.spinTimer === spin) {
@@ -2793,13 +3200,20 @@ var HostSt = class {
2793
3200
  }
2794
3201
  }
2795
3202
  if (this.host !== host) return;
3203
+ const verdict = probeVerdict({
3204
+ httpOk: ok,
3205
+ wsOpen: host.isConnected,
3206
+ lastWsMessageAt: host.lastWsMessageAt,
3207
+ now: Date.now()
3208
+ });
2796
3209
  runInAction(() => {
2797
- this.status = ok ? "up" : "down";
2798
- this.statusVia = ok ? host.isConnected ? "ws" : "http" : null;
3210
+ this.status = verdict.status;
3211
+ this.statusVia = verdict.via;
3212
+ this.lastProbeError = probeError;
2799
3213
  });
2800
3214
  }
2801
3215
  get host() {
2802
- return this.st.wf.host;
3216
+ return this.st.runHost;
2803
3217
  }
2804
3218
  get stats() {
2805
3219
  const schema = this.host.schema;
@@ -2808,6 +3222,10 @@ var HostSt = class {
2808
3222
  label: "status",
2809
3223
  value: this.status === "down" ? `down · ${this.probing ? `${this.spinner} probing…` : `retry in ${this.retryInS}s`}` : this.status + (this.statusVia != null ? ` (${this.statusVia})` : "")
2810
3224
  },
3225
+ ...this.lastProbeError != null ? [{
3226
+ label: "http probe",
3227
+ value: this.lastProbeError
3228
+ }] : [],
2811
3229
  {
2812
3230
  label: "node types",
2813
3231
  value: String(schema.nodes.length)
@@ -2837,6 +3255,39 @@ var HostSt = class {
2837
3255
  blur() {
2838
3256
  this.st.mode = "nav";
2839
3257
  }
3258
+ get pickerRows() {
3259
+ const rows = [{
3260
+ host: null,
3261
+ label: `workflow default (${this.st.wf.host.data.id})`,
3262
+ active: this.st.hostOverride == null
3263
+ }];
3264
+ for (const host of comfyts.hosts.values()) rows.push({
3265
+ host,
3266
+ label: `${host.data.id} (${host.base.host}:${host.base.port})`,
3267
+ active: this.st.hostOverride === host
3268
+ });
3269
+ return rows;
3270
+ }
3271
+ beginPicker() {
3272
+ this.st.mode = "overlay-hosts";
3273
+ const active = this.pickerRows.findIndex((r) => r.active);
3274
+ this.pickerIx = active === -1 ? 0 : active;
3275
+ }
3276
+ cancelPicker() {
3277
+ this.st.mode = "nav";
3278
+ }
3279
+ pickerMove(delta) {
3280
+ const len = this.pickerRows.length;
3281
+ if (len === 0) return;
3282
+ this.pickerIx = (this.pickerIx + delta + len) % len;
3283
+ }
3284
+ commitPicker() {
3285
+ const row = this.pickerRows[this.pickerIx];
3286
+ if (row == null) return;
3287
+ this.st.setHostOverride(row.host);
3288
+ this.st.mode = "nav";
3289
+ this.st.exec.notice = row.host == null ? `host override cleared — runs target the workflow's own host (${this.st.wf.host.data.id})` : `runs now target ${row.host.data.id} (overrides ${this.st.wf.host.data.id})`;
3290
+ }
2840
3291
  move(delta) {
2841
3292
  const len = this.actions.length;
2842
3293
  this.ix = (this.ix + delta + len) % len;
@@ -3293,6 +3744,7 @@ var PickerSt = class {
3293
3744
  this.filter = "";
3294
3745
  this.ix = 0;
3295
3746
  this.invalid = false;
3747
+ this.imageSizeRow = null;
3296
3748
  makeAutoObservable(this, { st: false });
3297
3749
  }
3298
3750
  get choiceVar() {
@@ -3312,6 +3764,7 @@ var PickerSt = class {
3312
3764
  const sv = this.sizeVar;
3313
3765
  if (sv != null) {
3314
3766
  const labels = sv.presets.map((p) => `${p.width}×${p.height} ${p.label}`);
3767
+ if (this.imageSizeRow != null) labels.unshift(this.imageSizeRow);
3315
3768
  if (this.filter === "") return labels;
3316
3769
  return labels.filter((l) => fuzzyMatch(this.filter, l));
3317
3770
  }
@@ -3331,8 +3784,10 @@ var PickerSt = class {
3331
3784
  this.st.mode = "overlay-size";
3332
3785
  this.filter = "";
3333
3786
  this.invalid = false;
3334
- const ix = sv.presets.findIndex((p) => p.width === sv.value.width && p.height === sv.value.height);
3335
- this.ix = ix === -1 ? 0 : ix;
3787
+ const img = sv.imageSize();
3788
+ this.imageSizeRow = img == null ? null : `${img.width}×${img.height} size of image '${img.name}'`;
3789
+ const presetIx = sv.presets.findIndex((p) => p.width === sv.value.width && p.height === sv.value.height);
3790
+ this.ix = presetIx === -1 ? 0 : presetIx + (this.imageSizeRow != null ? 1 : 0);
3336
3791
  }
3337
3792
  move(delta) {
3338
3793
  const len = this.options.length;
@@ -3408,7 +3863,7 @@ var QueueSt = class {
3408
3863
  }
3409
3864
  async clearPending() {
3410
3865
  try {
3411
- await this.st.wf.host.clearQueue();
3866
+ await this.st.runHost.clearQueue();
3412
3867
  runInAction(() => {
3413
3868
  this.st.exec.notice = "pending queue cleared";
3414
3869
  });
@@ -3420,7 +3875,7 @@ var QueueSt = class {
3420
3875
  }
3421
3876
  async interrupt() {
3422
3877
  try {
3423
- await this.st.wf.host.interrupt();
3878
+ await this.st.runHost.interrupt();
3424
3879
  runInAction(() => {
3425
3880
  this.st.exec.notice = "interrupt requested";
3426
3881
  });
@@ -3454,15 +3909,25 @@ var SettingsSt = class {
3454
3909
  this.previewRenderer = protocolCapable() ? "native" : "pixel";
3455
3910
  this.previewDuringRun = "latent";
3456
3911
  this.lastDraft = {};
3912
+ this.lastWorkflow = null;
3913
+ this.hostOverrideId = null;
3914
+ this.collapsedDirs = [];
3457
3915
  this.load();
3458
3916
  if (this.previewRenderer === "native" && !protocolCapable()) this.previewRenderer = "pixel";
3459
3917
  makeAutoObservable(this, { st: false });
3460
- this.st.disposers.push(reaction(() => JSON.stringify({
3918
+ this.st.disposers.push(reaction(() => this.snapshotJson(), (json) => this.write(json), { delay: 300 }));
3919
+ this.st.disposers.push(() => this.write(this.snapshotJson()));
3920
+ }
3921
+ snapshotJson() {
3922
+ return JSON.stringify({
3461
3923
  previewPanel: this.previewPanel,
3462
3924
  previewRenderer: this.previewRenderer,
3463
3925
  previewDuringRun: this.previewDuringRun,
3464
- lastDraft: this.lastDraft
3465
- }), (json) => this.write(json), { delay: 300 }));
3926
+ lastDraft: this.lastDraft,
3927
+ lastWorkflow: this.lastWorkflow,
3928
+ hostOverrideId: this.hostOverrideId,
3929
+ collapsedDirs: this.collapsedDirs
3930
+ });
3466
3931
  }
3467
3932
  rememberDraft(moduleKey, draft) {
3468
3933
  this.lastDraft[moduleKey] = draft;
@@ -3483,6 +3948,9 @@ var SettingsSt = class {
3483
3948
  this.previewRenderer = preview.previewRenderer;
3484
3949
  this.previewDuringRun = preview.previewDuringRun;
3485
3950
  if (o.lastDraft != null && typeof o.lastDraft === "object") this.lastDraft = { ...o.lastDraft };
3951
+ if (typeof o.lastWorkflow === "string") this.lastWorkflow = o.lastWorkflow;
3952
+ if (typeof o.hostOverrideId === "string") this.hostOverrideId = o.hostOverrideId;
3953
+ if (Array.isArray(o.collapsedDirs)) this.collapsedDirs = o.collapsedDirs.filter((d) => typeof d === "string");
3486
3954
  } catch {}
3487
3955
  }
3488
3956
  write(json) {
@@ -3499,45 +3967,62 @@ var SettingsSt = class {
3499
3967
  };
3500
3968
  //#endregion
3501
3969
  //#region src/cli/tui/state/TreeSt.ts
3502
- /** the left `(t)ree`: workflows with their drafts nested under them */
3970
+ /** the left `(t)ree`: directory hierarchy + workflows with their drafts nested */
3503
3971
  var TreeSt = class {
3504
3972
  constructor(st) {
3505
3973
  this.st = st;
3506
3974
  this.ix = 0;
3507
3975
  this.expandedFiles = /* @__PURE__ */ new Set();
3976
+ this.filter = "";
3977
+ this.filtering = false;
3978
+ this.collapsedDirs = new Set(st.settings.collapsedDirs);
3508
3979
  makeAutoObservable(this, { st: false });
3509
3980
  }
3981
+ /** fold state is hand-tuned: mirror every change into the settings file */
3982
+ persistFolds() {
3983
+ this.st.settings.collapsedDirs = [...this.collapsedDirs];
3984
+ }
3985
+ /** family → color over the FULL file list (stable under filter/fold) */
3986
+ get familyColors() {
3987
+ return assignFamilyColors(this.st.workflows.files);
3988
+ }
3510
3989
  get rows() {
3511
3990
  this.st.drafts.version;
3512
3991
  const w = this.st.workflows;
3992
+ const fileRows = buildFileRows({
3993
+ userFiles: w.files.filter((f) => !w.bundled.has(f)),
3994
+ bundledFiles: w.files.filter((f) => w.bundled.has(f)),
3995
+ collapsedDirs: this.collapsedDirs,
3996
+ filter: this.filter
3997
+ });
3998
+ const colors = this.familyColors;
3513
3999
  const rows = [];
3514
- let sectionPushed = false;
3515
- for (const file of w.files) {
3516
- if (!sectionPushed && w.bundled.has(file)) {
3517
- rows.push({
3518
- kind: "section",
3519
- label: "comfy-ts examples"
3520
- });
3521
- sectionPushed = true;
4000
+ for (const row of fileRows) {
4001
+ if (row.kind === "dir") {
4002
+ rows.push(row);
4003
+ continue;
3522
4004
  }
3523
- const current = file === w.currentPath;
3524
- const expanded = this.expandedFiles.has(file);
3525
- const drafts = listDraftsForFile(file);
4005
+ const current = row.file === w.currentPath;
4006
+ const expanded = this.expandedFiles.has(row.file);
4007
+ const drafts = listDraftsForFile(row.file);
3526
4008
  rows.push({
3527
4009
  kind: "workflow",
3528
- file,
3529
- name: draftKeyForFile(file),
4010
+ file: row.file,
4011
+ name: row.name,
4012
+ depth: row.depth,
3530
4013
  expanded,
3531
4014
  current,
3532
4015
  hasDrafts: drafts.length > 0,
3533
- error: w.loadErrors.get(file) ?? null
4016
+ error: w.loadErrors.get(row.file) ?? null,
4017
+ color: w.specColors.get(row.file) ?? colors.get(familyOf(row.name)) ?? "white"
3534
4018
  });
3535
4019
  if (!expanded) continue;
3536
4020
  for (const draft of drafts) rows.push({
3537
4021
  kind: "draft",
3538
- file,
4022
+ file: row.file,
3539
4023
  draft,
3540
- active: current && draft === this.st.drafts.active
4024
+ active: current && draft === this.st.drafts.active,
4025
+ depth: row.depth + 1
3541
4026
  });
3542
4027
  }
3543
4028
  return rows;
@@ -3552,7 +4037,16 @@ var TreeSt = class {
3552
4037
  this.st.exec.notice = "no workflow tree — start the tui in a folder containing **/*.cflow.ts";
3553
4038
  return;
3554
4039
  }
3555
- if (w.currentPath != null) this.expandedFiles.add(w.currentPath);
4040
+ if (w.currentPath != null) {
4041
+ this.expandedFiles.add(w.currentPath);
4042
+ let changed = false;
4043
+ const collapsed = [...this.collapsedDirs];
4044
+ for (const dir of collapsed) if (w.currentPath.startsWith(`${dir}/`)) {
4045
+ this.collapsedDirs.delete(dir);
4046
+ changed = true;
4047
+ }
4048
+ if (changed) this.persistFolds();
4049
+ }
3556
4050
  this.st.mode = "tree";
3557
4051
  const rows = this.rows;
3558
4052
  const draftIx = rows.findIndex((r) => r.kind === "draft" && r.active);
@@ -3561,48 +4055,98 @@ var TreeSt = class {
3561
4055
  }
3562
4056
  /** esc/t inside the tree, → on a draft row, `v` anywhere: back to the vars list */
3563
4057
  blur() {
4058
+ this.filtering = false;
3564
4059
  this.st.mode = "nav";
3565
4060
  }
3566
4061
  move(delta) {
3567
- const rows = this.rows;
3568
- const len = rows.length;
4062
+ const len = this.rows.length;
3569
4063
  if (len === 0) return;
3570
- let ix = this.ix;
3571
- for (let step = 0; step < len; step++) {
3572
- ix = (ix + delta + len) % len;
3573
- if (rows[ix]?.kind !== "section") break;
4064
+ this.ix = (this.ix + delta + len) % len;
4065
+ }
4066
+ beginFilter() {
4067
+ this.filtering = true;
4068
+ }
4069
+ filterInput(ch) {
4070
+ this.filter += ch;
4071
+ this.clampToSelectable();
4072
+ }
4073
+ filterBackspace() {
4074
+ this.filter = this.filter.slice(0, -1);
4075
+ this.clampToSelectable();
4076
+ }
4077
+ /** esc while the filter owns the keys: drop it, stay in the tree */
4078
+ clearFilter() {
4079
+ this.filter = "";
4080
+ this.filtering = false;
4081
+ this.clampToSelectable();
4082
+ }
4083
+ /** filter edits reshape rows: keep the cursor on a workflow row when one exists */
4084
+ clampToSelectable() {
4085
+ const rows = this.rows;
4086
+ this.ix = Math.min(this.ix, Math.max(0, rows.length - 1));
4087
+ if (rows[this.ix]?.kind !== "workflow") {
4088
+ const first = rows.findIndex((r) => r.kind === "workflow");
4089
+ if (first !== -1) this.ix = first;
3574
4090
  }
3575
- this.ix = ix;
3576
4091
  }
3577
- /** →: unfold the workflow under the cursor; on a draft row there is nothing
3578
- * left to unfold, so → continues rightwards into the vars panel */
4092
+ /** →: unfold the dir/workflow under the cursor; on a draft row there is
4093
+ * nothing left to unfold, so → continues rightwards into the vars panel */
3579
4094
  unfold() {
3580
4095
  const row = this.selected;
3581
- if (row == null || row.kind === "section") return;
3582
- if (row.kind === "workflow") this.expandedFiles.add(row.file);
4096
+ if (row == null) return;
4097
+ if (row.kind === "dir") {
4098
+ this.collapsedDirs.delete(row.path);
4099
+ this.persistFolds();
4100
+ } else if (row.kind === "workflow") this.expandedFiles.add(row.file);
3583
4101
  else this.blur();
3584
4102
  }
3585
- /** ←: fold the workflow under the cursor; on a draft row, jump to (and fold) its parent */
4103
+ /** ←: fold under the cursor; on an already-folded row, jump to the parent */
3586
4104
  fold() {
3587
4105
  const row = this.selected;
3588
- if (row == null || row.kind === "section") return;
3589
- this.expandedFiles.delete(row.file);
4106
+ if (row == null) return;
4107
+ if (row.kind === "dir") {
4108
+ this.collapsedDirs.add(row.path);
4109
+ this.persistFolds();
4110
+ return;
4111
+ }
3590
4112
  if (row.kind === "draft") {
3591
4113
  const ix = this.rows.findIndex((r) => r.kind === "workflow" && r.file === row.file);
3592
4114
  if (ix !== -1) this.ix = ix;
4115
+ this.expandedFiles.delete(row.file);
4116
+ return;
4117
+ }
4118
+ if (row.expanded) {
4119
+ this.expandedFiles.delete(row.file);
4120
+ return;
4121
+ }
4122
+ for (let ix = this.ix - 1; ix >= 0; ix--) {
4123
+ const r = this.rows[ix];
4124
+ if (r?.kind === "dir" && r.depth < row.depth) {
4125
+ this.ix = ix;
4126
+ return;
4127
+ }
3593
4128
  }
3594
4129
  }
3595
- /** ⏎: load the workflow (into 'default'), or the exact draft under the cursor */
4130
+ /** ⏎: toggle a dir, load the workflow (into 'default'), or load the exact draft */
3596
4131
  async commit() {
3597
4132
  const row = this.selected;
3598
- if (row == null || row.kind === "section") return;
4133
+ if (row == null) return;
4134
+ if (row.kind === "dir") {
4135
+ if (this.filter !== "") return;
4136
+ if (row.expanded) this.collapsedDirs.add(row.path);
4137
+ else this.collapsedDirs.delete(row.path);
4138
+ this.persistFolds();
4139
+ return;
4140
+ }
4141
+ this.filter = "";
4142
+ this.filtering = false;
3599
4143
  if (row.kind === "workflow") return this.st.workflows.commit(row.file);
3600
4144
  return this.st.workflows.commit(row.file, row.draft);
3601
4145
  }
3602
4146
  /** n: new draft — current workflow only (a draft snapshots its LIVE var values) */
3603
4147
  promptNewDraft() {
3604
4148
  const row = this.selected;
3605
- if (row?.kind === "section") return;
4149
+ if (row?.kind === "dir") return;
3606
4150
  if (row != null && row.file !== this.st.workflows.currentPath) {
3607
4151
  this.st.exec.notice = "load that workflow first (⏎) — a new draft snapshots its live vars";
3608
4152
  return;
@@ -3630,12 +4174,16 @@ var WorkflowsSt = class {
3630
4174
  this.st = st;
3631
4175
  this.files = files;
3632
4176
  this.loading = false;
4177
+ this.specColors = /* @__PURE__ */ new Map();
3633
4178
  this.loadedHosts = /* @__PURE__ */ new Set();
3634
4179
  this.currentPath = currentPath;
3635
4180
  this.bundled = bundled;
3636
4181
  this.loadErrors = loadErrors;
3637
4182
  makeAutoObservable(this, { st: false });
3638
4183
  }
4184
+ recordSpecColor(path, wf) {
4185
+ if (wf.spec.color != null) this.specColors.set(path, wf.spec.color);
4186
+ }
3639
4187
  disconnectAllHosts() {
3640
4188
  this.loadedHosts.add(this.st.wf.host);
3641
4189
  for (const host of this.loadedHosts) host.disconnect();
@@ -3670,10 +4218,13 @@ var WorkflowsSt = class {
3670
4218
  this.loadErrors.delete(path);
3671
4219
  this.loadedHosts.add(this.st.wf.host);
3672
4220
  this.loadedHosts.add(wf.host);
4221
+ this.recordSpecColor(path, wf);
3673
4222
  this.st.wf = wf;
3674
- this.st.queue.attach(wf.host);
3675
- this.st.logs.attach(wf.host);
4223
+ this.st.applyPersistedHostOverride();
4224
+ this.st.queue.attach(this.st.runHost);
4225
+ this.st.logs.attach(this.st.runHost);
3676
4226
  this.currentPath = path;
4227
+ this.st.settings.lastWorkflow = path;
3677
4228
  this.st.selIx = 0;
3678
4229
  this.st.mode = "nav";
3679
4230
  this.st.exec.resetForWorkflow(`${basename(path)}`);
@@ -3702,9 +4253,28 @@ var WorkflowsSt = class {
3702
4253
  * classes with an `st` backref; components are stateless views over this.
3703
4254
  */
3704
4255
  var TuiSt = class {
4256
+ /** the host runs actually target right now */
4257
+ get runHost() {
4258
+ return this.hostOverride ?? this.wf.host;
4259
+ }
4260
+ setHostOverride(host) {
4261
+ this.hostOverride = host;
4262
+ if (host != null) this.workflows.loadedHosts.add(host);
4263
+ this.queue.attach(this.runHost);
4264
+ this.logs.attach(this.runHost);
4265
+ this.settings.hostOverrideId = host?.data.id ?? null;
4266
+ }
4267
+ /** re-resolve a persisted override id — hosts register as modules import */
4268
+ applyPersistedHostOverride() {
4269
+ const id = this.settings.hostOverrideId;
4270
+ if (id == null || this.hostOverride != null) return;
4271
+ const host = comfyts.hosts.get(id);
4272
+ if (host != null) this.setHostOverride(host);
4273
+ }
3705
4274
  constructor(wf, opts = {}) {
3706
4275
  this.mode = "nav";
3707
4276
  this.selIx = 0;
4277
+ this.hostOverride = null;
3708
4278
  this.disposers = [];
3709
4279
  this.onExit = () => {};
3710
4280
  this.termCols = process.stdout.columns ?? 80;
@@ -3712,6 +4282,7 @@ var TuiSt = class {
3712
4282
  this.wf = wf;
3713
4283
  makeAutoObservable(this, {
3714
4284
  wf: observable.ref,
4285
+ hostOverride: observable.ref,
3715
4286
  onExit: false,
3716
4287
  editor: false,
3717
4288
  picker: false,
@@ -3740,8 +4311,13 @@ var TuiSt = class {
3740
4311
  this.host = new HostSt(this);
3741
4312
  this.queue = new QueueSt(this);
3742
4313
  this.logs = new LogsSt(this);
4314
+ this.applyPersistedHostOverride();
3743
4315
  this.drafts.activateRemembered();
3744
- if (opts.currentFile != null) this.tree.expandedFiles.add(opts.currentFile);
4316
+ if (opts.currentFile != null) {
4317
+ this.tree.expandedFiles.add(opts.currentFile);
4318
+ this.workflows.recordSpecColor(opts.currentFile, wf);
4319
+ this.settings.lastWorkflow = opts.currentFile;
4320
+ }
3745
4321
  const onResize = () => {
3746
4322
  runInAction(() => {
3747
4323
  this.termCols = process.stdout.columns ?? 80;
@@ -3759,10 +4335,10 @@ var TuiSt = class {
3759
4335
  get overlayLines() {
3760
4336
  return Math.max(8, this.termRows - 12);
3761
4337
  }
3762
- /** left tree panel width: longest row (workflow or indented draft), clamped */
4338
+ /** left tree panel width: longest row (depth-indented), clamped */
3763
4339
  get treeWidth() {
3764
- const longest = Math.max(8, ...this.tree.rows.map((r) => r.kind === "workflow" ? r.name.length : r.kind === "draft" ? r.draft.length + 3 : r.label.length));
3765
- return Math.min(32, longest + 7);
4340
+ const longest = Math.max(8, ...this.tree.rows.map((r) => r.depth * 2 + (r.kind === "workflow" ? r.name.length : r.kind === "draft" ? r.draft.length + 3 : r.label.length + 2)));
4341
+ return Math.min(34, longest + 7);
3766
4342
  }
3767
4343
  get entries() {
3768
4344
  return this.wf.entries();
@@ -3805,6 +4381,18 @@ var TuiSt = class {
3805
4381
  };
3806
4382
  //#endregion
3807
4383
  //#region src/cli/tui/run-tui.tsx
4384
+ /** the module the last session was on, IF it is still in this run's tree
4385
+ * (settings write: SettingsSt; exported for the headless test) */
4386
+ function rememberedWorkflow(workflowFiles, settingsPath = settingsPathFor(process.cwd())) {
4387
+ try {
4388
+ const raw = JSON.parse(readFileSync(settingsPath, "utf8"));
4389
+ if (raw == null || typeof raw !== "object") return null;
4390
+ const last = raw.lastWorkflow;
4391
+ return typeof last === "string" && workflowFiles.includes(last) ? last : null;
4392
+ } catch {
4393
+ return null;
4394
+ }
4395
+ }
3808
4396
  async function runTui(args) {
3809
4397
  const target = args.find((a) => !a.startsWith("--"));
3810
4398
  process.env[COMFY_TS_TUI_ENV] = "1";
@@ -3816,17 +4404,19 @@ async function runTui(args) {
3816
4404
  const canImportBundled = process.versions.bun != null;
3817
4405
  const examplesDir = canImportBundled ? bundledExamplesDir() : null;
3818
4406
  if (!canImportBundled && target == null) logError("packaged examples skipped: importing .cflow.ts from node_modules needs bun (bunx --bun comfy-ts tui)");
4407
+ const bundledFiles = examplesDir == null ? [] : scanCflowFiles(realpathSync(examplesDir)).sort((a, b) => Number(!a.includes("/rvion/")) - Number(!b.includes("/rvion/")) || a.localeCompare(b));
3819
4408
  const discovery = mergeWorkflowSources({
3820
4409
  explicitTarget: target != null,
3821
4410
  scanned: scannedPlusArg,
3822
- bundledFiles: examplesDir == null ? [] : scanCflowFiles(realpathSync(examplesDir))
4411
+ bundledFiles
3823
4412
  });
3824
4413
  const workflowFiles = discovery.files;
3825
4414
  if (workflowFiles.length === 0) {
3826
4415
  console.error(`[comfy-ts tui] no **/*.cflow.ts found under ${abs}`);
3827
4416
  return 1;
3828
4417
  }
3829
- const candidates = !isDir && workflowFiles.includes(abs) ? [abs, ...workflowFiles.filter((f) => f !== abs)] : workflowFiles;
4418
+ const preferred = !isDir && workflowFiles.includes(abs) ? abs : target == null ? rememberedWorkflow(workflowFiles) : null;
4419
+ const candidates = preferred != null ? [preferred, ...workflowFiles.filter((f) => f !== preferred)] : workflowFiles;
3830
4420
  const loadErrors = /* @__PURE__ */ new Map();
3831
4421
  let first = null;
3832
4422
  let wf = null;
@@ -3854,11 +4444,13 @@ async function runTui(args) {
3854
4444
  if (altScreen) process.stdout.write("\x1B[?1049h\x1B[H\x1B[>4;1m");
3855
4445
  const uninstallPainter = installProtocolImagePainter(st);
3856
4446
  try {
4447
+ if (process.stdin.isTTY === true) process.stdin.setRawMode(true);
3857
4448
  const app = render(/* @__PURE__ */ jsx(TuiApp, { st }), { kittyKeyboard: { mode: "auto" } });
3858
4449
  st.onExit = () => st.dispose();
3859
4450
  await app.waitUntilExit();
3860
4451
  st.dispose();
3861
4452
  } finally {
4453
+ if (process.stdin.isTTY === true) process.stdin.setRawMode(false);
3862
4454
  uninstallPainter();
3863
4455
  if (altScreen) process.stdout.write("\x1B[0m\x1B[2J\x1B[H\x1B[>4;0m\x1B[?1049l");
3864
4456
  }
@@ -3867,4 +4459,4 @@ async function runTui(args) {
3867
4459
  //#endregion
3868
4460
  export { runTui };
3869
4461
 
3870
- //# sourceMappingURL=run-tui-DZ22HDHI.js.map
4462
+ //# sourceMappingURL=run-tui-BAdizWsO.js.map