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
@@ -6,12 +6,14 @@ with bun, or browse them all in the TUI (`bunx comfy-ts tui` lists them under
6
6
 
7
7
  ## Layout
8
8
 
9
- - `01…04-*.cflow.ts` — the didactic sequence against a LOCAL ComfyUI host
10
- (edit the `comfy.host({...})` line to point at yours, then first run
9
+ - `rvion/01…04-*.cflow.ts` — the didactic sequence against a LOCAL ComfyUI
10
+ host (edit the `comfy.host({...})` line to point at yours, then first run
11
11
  generates a typed SDK for it).
12
- - `05-comfy-cloud.cflow.ts` — the same t2i against [Comfy Cloud]
12
+ - `rvion/05-comfy-cloud.cflow.ts` — the same t2i against [Comfy Cloud]
13
13
  (https://cloud.comfy.org): no local GPU needed, the typed catalog ships
14
14
  committed at `comfy-cloud/sdk.d.ts`.
15
+ - `rvion/06-qwen-image-edit.cflow.ts` — image editing (qwen image edit 2511)
16
+ against the same local host.
15
17
  - `comfy-cloud/<family>-<mode>.cflow.ts` — the model zoo: one clean example
16
18
  per model family × mode (`t2i`, `i2i`, `t2v`, `i2v`, `t2a`), each mirroring
17
19
  an official ComfyUI template (flux, qwen-image, z-image, wan, hidream,
@@ -24,7 +26,7 @@ paid tiers). Without it everything still loads and typechecks — only `run()`
24
26
  needs the key:
25
27
 
26
28
  ```sh
27
- COMFY_CLOUD_API_KEY=… bun examples/05-comfy-cloud.cflow.ts "a fox in the snow" 42
29
+ COMFY_CLOUD_API_KEY=… bun examples/rvion/05-comfy-cloud.cflow.ts "a fox in the snow" 42
28
30
  ```
29
31
 
30
32
  Cloud runs bill compute to your account — start with a small t2i.
@@ -1,5 +1,5 @@
1
1
  // generate an image from text, fully typed against the 'windows-1' host sdk
2
- // run directly: bun examples/01-txt2img.cflow.ts ["prompt"] [seed]
2
+ // run directly: bun examples/rvion/01-txt2img.cflow.ts ["prompt"] [seed]
3
3
  // in the TUI: bun run tui (scans **/*.cflow.ts, tweak vars, r to run)
4
4
  import { ComfyTS, v } from 'comfy-ts'
5
5
 
@@ -1,5 +1,5 @@
1
1
  // upload a local image (hash-named, deduped) and run img2img on it
2
- // run directly: bun examples/02-img2img-upload.cflow.ts [path/to/image.png]
2
+ // run directly: bun examples/rvion/02-img2img-upload.cflow.ts [path/to/image.png]
3
3
  // in the TUI: bun run tui — activate the `image` var to open the picker (browse, favorites, preview)
4
4
  import { asAbsolutePath, ComfyTS, exampleImagePath, MediaImage, v } from 'comfy-ts'
5
5
 
@@ -1,6 +1,6 @@
1
1
  // build a graph OFFLINE (schema from .comfy-ts/ cache) and export both ComfyUI
2
2
  // JSON formats: api.json (prompt) + workflow.json (readable litegraph, autolayouted)
3
- // run directly: bun examples/03-export-workflow-json.cflow.ts (no server needed)
3
+ // run directly: bun examples/rvion/03-export-workflow-json.cflow.ts (no server needed)
4
4
  // in the TUI: bun run tui — r runs it live (PreviewImage), c/C copy the JSONs
5
5
  import { mkdirSync, writeFileSync } from 'node:fs'
6
6
  import { ComfyTS, v } from 'comfy-ts'
@@ -2,8 +2,8 @@
2
2
  // (rabbits-vs-sheeps "unified"). krea2 turbo UNET + standard LoraLoader chain
3
3
  // → KSampler(8 steps, cfg 1) → RMBG cutout → transparent png game sprite.
4
4
  //
5
- // run directly: bun examples/04-krea2-turbo-t2i.cflow.ts ["prompt"] [seed]
6
- // in the TUI: bun src/cli/comfy-ts-cli.ts tui examples/04-krea2-turbo-t2i.cflow.ts
5
+ // run directly: bun examples/rvion/04-krea2-turbo-t2i.cflow.ts ["prompt"] [seed]
6
+ // in the TUI: bun src/cli/comfy-ts-cli.ts tui examples/rvion/04-krea2-turbo-t2i.cflow.ts
7
7
  // tui browser: bun src/cli/comfy-ts-cli.ts tui examples/ (scans **/*.cflow.ts)
8
8
  import { activeLoras, ComfyTS } from 'comfy-ts'
9
9
 
@@ -1,9 +1,9 @@
1
1
  // sd15 t2i on Comfy Cloud — the reference zoo example (agent/examples.md)
2
2
  // source template: default.json (official workflow-templates)
3
3
  // needs COMFY_CLOUD_API_KEY (https://cloud.comfy.org, paid tiers) — loads fine without, run() needs it
4
- // run directly: bun examples/05-comfy-cloud.cflow.ts ["prompt"] [seed]
4
+ // run directly: bun examples/rvion/05-comfy-cloud.cflow.ts ["prompt"] [seed]
5
5
  import { v } from 'comfy-ts'
6
- import { cloudHost, requireCloudKey } from './comfy-cloud/cloudHost.ts'
6
+ import { cloudHost, requireCloudKey } from '../comfy-cloud/cloudHost.ts'
7
7
 
8
8
  const host = await cloudHost()
9
9
 
@@ -0,0 +1,89 @@
1
+ // qwen image edit 2511 on windows-1 — instruction-driven image editing
2
+ // mirrors the official image_qwen_image_edit_2511 template, single reference
3
+ // image; the lightning toggle switches the 4-step Lightning lora (cfg 1) vs
4
+ // full sampling (cfg 4 — raise steps to ~40 yourself when you flip it off)
5
+ // run directly: bun examples/rvion/06-qwen-image-edit.cflow.ts [path/to/image.png] ["edit instruction"]
6
+ import { asAbsolutePath, ComfyTS, exampleImagePath, MediaImage, v } from 'comfy-ts'
7
+
8
+ const comfy = ComfyTS.create()
9
+ const host = comfy.host({ id: 'windows-1', host: 'desktop-im18794', port: 8085 })
10
+ await host.loadSchemaFromCache() // offline import; run() connects lazily
11
+
12
+ // bundled default input (examples/images/, ships in the tarball) — the TUI picker or argv[2] swap it
13
+ const image = v.image(exampleImagePath('bear_1024x1024.jpg'))
14
+
15
+ export const qwenImageEdit = host.defineWorkflow({
16
+ id: 'qwen-image-edit',
17
+ vars: {
18
+ image,
19
+ // `- ` lines are the negative prompt (template default: empty negative encode)
20
+ prompt: v.prompt('turn this photo into a detailed watercolor painting'),
21
+ seed: v.seed(42),
22
+ steps: v.int(4, { min: 1, max: 60 }),
23
+ lightning: v.toggle(true, '4-step lightning lora'),
24
+ prefix: v.text('qwen-image-edit'),
25
+ },
26
+ // async build: the reference image is uploaded (hash-named, deduped) per run
27
+ build: async (b, vars, wf) => {
28
+ const img = new MediaImage({ path: asAbsolutePath(image.absPath()) })
29
+ const loaded = await img.loadInWorkflow_viaLoadImageNode(wf)
30
+ const scaled = b.FluxKontextImageScale({ image: loaded })
31
+
32
+ const unet = b.UNETLoader({ unet_name: 'qwen_image_edit_2511_bf16.safetensors', weight_dtype: 'default' })
33
+ const clip = b.CLIPLoader({
34
+ clip_name: 'qwen_2.5_vl_7b_fp8_scaled.safetensors',
35
+ type: 'qwen_image',
36
+ device: 'default',
37
+ })
38
+ const vae = b.VAELoader({ vae_name: 'qwen_image_vae.safetensors' })
39
+
40
+ let model = b.CFGNorm({
41
+ model: b.ModelSamplingAuraFlow({ model: unet, shift: 3.1 }),
42
+ strength: 1,
43
+ pre_cfg: false,
44
+ })._MODEL
45
+ if (vars.lightning) {
46
+ model = b.LoraLoaderModelOnly({
47
+ model,
48
+ lora_name: 'Qwen-Image-Edit-2511-Lightning-4steps-V1.0-bf16.safetensors',
49
+ strength_model: 1,
50
+ })._MODEL
51
+ }
52
+
53
+ // both branches carry the reference through the kontext latent method (template shape)
54
+ const positive = b.FluxKontextMultiReferenceLatentMethod({
55
+ reference_latents_method: 'index_timestep_zero',
56
+ conditioning: b.TextEncodeQwenImageEditPlus({ clip, prompt: vars.prompt.positive, vae, image1: scaled }),
57
+ })
58
+ const negative = b.FluxKontextMultiReferenceLatentMethod({
59
+ reference_latents_method: 'index_timestep_zero',
60
+ conditioning: b.TextEncodeQwenImageEditPlus({ clip, prompt: vars.prompt.negative, vae, image1: scaled }),
61
+ })
62
+
63
+ const samples = b.KSampler({
64
+ model,
65
+ positive,
66
+ negative,
67
+ latent_image: b.VAEEncode({ pixels: scaled, vae }),
68
+ seed: vars.seed,
69
+ steps: vars.steps,
70
+ cfg: vars.lightning ? 1 : 4,
71
+ sampler_name: 'euler',
72
+ scheduler: 'simple',
73
+ denoise: 1,
74
+ })
75
+ b.SaveImage({ images: b.VAEDecode({ samples, vae }), filename_prefix: vars.prefix })
76
+ },
77
+ })
78
+
79
+ export default qwenImageEdit
80
+
81
+ // standalone run (skipped when another driver — e.g. the TUI — imports this module)
82
+ if (import.meta.main) {
83
+ if (process.argv[2]) qwenImageEdit.vars.image.set(process.argv[2])
84
+ if (process.argv[3]) qwenImageEdit.vars.prompt.set(process.argv[3])
85
+
86
+ const execution = await qwenImageEdit.run({ log: true })
87
+ for (const img of execution.images) console.log(`🟢 ${img.absPath}`)
88
+ host.disconnect()
89
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "comfy-ts",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "The complete TypeScript toolkit for ComfyUI and generative AI. Fully type-safe SDK with autocomplete on every node, companion CLI, TUI, agentic docs, and 50+ examples. Design, run and deploy creative pipelines for image, video, audio, 3d and text on any ComfyUI, local, cloud or hosted.",
5
5
  "keywords": [
6
6
  "comfyui",
@@ -21,6 +21,7 @@
21
21
  ],
22
22
  "author": "Rémi Vion <vion.remi@gmail.com>",
23
23
  "license": "MIT",
24
+ "funding": "https://github.com/sponsors/rvion",
24
25
  "repository": {
25
26
  "type": "git",
26
27
  "url": "https://github.com/rvion/comfy-ts.git"
@@ -81,6 +82,8 @@
81
82
  "templates:fetch": "bun scripts/fetch-templates.ts",
82
83
  "templates:check": "bun scripts/check-templates.ts",
83
84
  "hooks:install": "git config core.hooksPath .githooks",
85
+ "release": "bun scripts/release.ts",
86
+ "release:dry": "bun scripts/release.ts --dry-run",
84
87
  "prepublishOnly": "bun run ci && bun run build",
85
88
  "tui": "bun src/cli/comfy-ts-cli.ts tui"
86
89
  },
@@ -0,0 +1,25 @@
1
+ import { Box, Text } from 'ink'
2
+ import { observer } from 'mobx-react-lite'
3
+ import { KeyHints } from 'src/cli/tui/components/StatusBar.tsx'
4
+ import type { TuiSt } from 'src/cli/tui/state/TuiSt.ts'
5
+
6
+ /** `c`/`C` confirmation popup: WHAT landed in the clipboard (or the loud
7
+ * failure) — a copy is never silent again. ⏎/esc closes. */
8
+ export const CopyOverlay = observer((p: { st: TuiSt }) => {
9
+ const popup = p.st.exec.copyPopup
10
+ if (popup == null) return null
11
+ return (
12
+ <Box borderStyle="double" borderColor={popup.ok ? 'green' : 'red'} paddingX={1} flexDirection="column">
13
+ <Text bold color={popup.ok ? 'green' : 'red'}>
14
+ {popup.ok ? '✓ ' : '✗ '}
15
+ {popup.title}
16
+ </Text>
17
+ {popup.lines.slice(0, p.st.overlayLines).map((line, ix) => (
18
+ <Text key={`${ix}·${line.slice(0, 12)}`} color={popup.ok ? undefined : 'red'} wrap="truncate">
19
+ {line}
20
+ </Text>
21
+ ))}
22
+ <KeyHints hints={[['⏎/esc', 'close']]} />
23
+ </Box>
24
+ )
25
+ })
@@ -15,9 +15,10 @@ const HeaderBox = (p: { title?: string; children: ReactNode }): ReactNode => (
15
15
  </Box>
16
16
  )
17
17
 
18
- /** labeled header boxes: brand · (w)orkflow · (d)raft · (h)ost — the keys open each surface */
18
+ /** labeled header boxes: brand · (w)orkflow · (d)raft · (h)ost·(a)ctions — the keys open each surface */
19
19
  export const Header = observer((p: { st: TuiSt }) => {
20
20
  const s = p.st
21
+ const runHost = s.runHost
21
22
  return (
22
23
  <Box flexDirection="row">
23
24
  <HeaderBox>
@@ -35,16 +36,20 @@ export const Header = observer((p: { st: TuiSt }) => {
35
36
  {s.drafts.active ?? 'default'}
36
37
  </Text>
37
38
  </HeaderBox>
38
- <HeaderBox title="(h)ost">
39
+ <HeaderBox title="(h)ost · (a)ctions">
39
40
  <Text>
40
41
  <Text color={s.host.status === 'up' ? 'green' : s.host.status === 'down' ? 'red' : 'gray'}>● </Text>
41
42
  <Text bold color="green">
42
- {s.wf.host.data.id}
43
+ {runHost.data.id}
43
44
  </Text>
44
45
  <Text color="gray">
45
46
  {' '}
46
- ({s.wf.host.data.host}:{s.wf.host.data.port})
47
+ ({runHost.base.host}:{runHost.base.port})
47
48
  </Text>
49
+ {/* the override must stay loud: every run bypasses the workflow's own host */}
50
+ {s.hostOverride != null && s.hostOverride !== s.wf.host && (
51
+ <Text color="yellow"> ⇄ overrides {s.wf.host.data.id}</Text>
52
+ )}
48
53
  {/* while down, show the probe loop living: spinner in flight, countdown between tries */}
49
54
  {s.host.status === 'down' && (
50
55
  <Text color="red"> {s.host.probing ? s.host.spinner : `↻ ${s.host.retryInS}s`}</Text>
@@ -9,10 +9,11 @@ export const HostPanel = observer((p: { st: TuiSt }) => {
9
9
  return (
10
10
  <Box borderStyle="double" paddingX={1} flexDirection="column">
11
11
  <Text bold>
12
- host · <Text color="green">{h.host.data.id}</Text>{' '}
12
+ host actions · <Text color="green">{h.host.data.id}</Text>{' '}
13
13
  <Text color="gray">
14
- ({h.host.data.host}:{h.host.data.port})
14
+ ({h.host.base.host}:{h.host.base.port})
15
15
  </Text>
16
+ {s.hostOverride != null && <Text color="yellow"> ⇄ override</Text>}
16
17
  </Text>
17
18
  {h.stats.map((row) => (
18
19
  <Text key={row.label}>
@@ -0,0 +1,33 @@
1
+ import { Text } from 'ink'
2
+ import { observer } from 'mobx-react-lite'
3
+ import { OverlayList } from 'src/cli/tui/components/OverlayList.tsx'
4
+ import type { TuiSt } from 'src/cli/tui/state/TuiSt.ts'
5
+
6
+ /** modal host picker (`h`): row 0 restores the workflow's own host, the rest
7
+ * override where runs are built and sent (every registered host is listed) */
8
+ export const HostsOverlay = observer((p: { st: TuiSt }) => {
9
+ const s = p.st
10
+ const h = s.host
11
+ const rows = h.pickerRows.map((row, ix) => ({
12
+ key: row.host?.data.id ?? '·default·',
13
+ node: (
14
+ <Text key={row.host?.data.id ?? '·default·'} inverse={ix === h.pickerIx}>
15
+ {ix === h.pickerIx ? '▸ ' : ' '}
16
+ {row.active ? '● ' : ' '}
17
+ {row.label}
18
+ </Text>
19
+ ),
20
+ }))
21
+ return (
22
+ <OverlayList
23
+ title={
24
+ <>
25
+ run host <Text color="gray">· overrides the workflow's configured host</Text>
26
+ </>
27
+ }
28
+ selectedIx={h.pickerIx}
29
+ lines={s.overlayLines}
30
+ rows={rows}
31
+ />
32
+ )
33
+ })
@@ -130,11 +130,26 @@ const MODE_KEYS: Partial<Record<string, Hint[]>> = {
130
130
  ['esc', 'cancel'],
131
131
  ],
132
132
  'overlay-drafts': [['⏎', 'load / new'], ...DRAFT_OP_HINTS, ['↑↓', 'move'], ['esc', 'cancel']],
133
- tree: [['⏎', 'load'], ['↑↓', 'move'], ['←', 'fold'], ['→', 'unfold / vars'], ...DRAFT_OP_HINTS, ['t/esc', 'back']],
133
+ 'overlay-hosts': [
134
+ ['⏎', 'pick run host'],
135
+ ['↑↓', 'move'],
136
+ ['esc', 'cancel'],
137
+ ],
138
+ 'overlay-copy': [['⏎/esc', 'close']],
139
+ tree: [
140
+ ['⏎', 'load'],
141
+ ['↑↓', 'move'],
142
+ ['←', 'fold'],
143
+ ['→', 'unfold / vars'],
144
+ ['/', 'filter'],
145
+ ...DRAFT_OP_HINTS,
146
+ ['t/esc', 'back'],
147
+ ],
134
148
  host: [
135
149
  ['⏎', 'run action'],
136
150
  ['↑↓', 'move'],
137
- ['h/esc', 'back'],
151
+ ['h', 'change host'],
152
+ ['a/esc', 'back'],
138
153
  ],
139
154
  preview: [
140
155
  ['←→', 'change'],
@@ -147,15 +162,19 @@ const MODE_KEYS: Partial<Record<string, Hint[]>> = {
147
162
  export const KeyBar = observer((p: { st: TuiSt }) => {
148
163
  const s = p.st
149
164
  const kind = s.selected?.[1].kind
150
- const modeHints: Hint[] = MODE_KEYS[s.mode] ?? [
151
- ['↑↓', 'select'],
152
- ['←', 'tree'],
153
- ...(kind ? (KIND_KEYS[kind] ?? []) : []),
154
- ]
155
- // keys already advertised by a panel title (t/v/p) or a header box (w/d/h)
165
+ const treeFiltering = s.mode === 'tree' && s.tree.filtering
166
+ const modeHints: Hint[] = treeFiltering
167
+ ? [
168
+ ['type', 'filter'],
169
+ ['⏎', 'load'],
170
+ ['↑↓', 'move'],
171
+ ['esc', 'clear'],
172
+ ]
173
+ : (MODE_KEYS[s.mode] ?? [['↑↓', 'select'], ['←', 'tree'], ...(kind ? (KIND_KEYS[kind] ?? []) : [])])
174
+ // keys already advertised by a panel title (t/v/p) or a header box (w/d/h/a)
156
175
  // are NOT repeated here — one letter, one place
157
176
  const globalHints: Hint[] =
158
- s.mode === 'nav' || s.mode === 'tree' || s.mode === 'host' || s.mode === 'preview'
177
+ !treeFiltering && (s.mode === 'nav' || s.mode === 'tree' || s.mode === 'host' || s.mode === 'preview')
159
178
  ? [
160
179
  ['r', 'run'],
161
180
  ['s', 'reroll+run'],
@@ -2,7 +2,8 @@ import { Box, Text } from 'ink'
2
2
  import { observer } from 'mobx-react-lite'
3
3
  import type { TuiSt } from 'src/cli/tui/state/TuiSt.ts'
4
4
 
5
- /** persistent left panel: workflows with their drafts nested; `t` (or ← from vars) focuses it */
5
+ /** persistent left panel: directory hierarchy + workflows with their drafts
6
+ * nested; `t` (or ← from vars) focuses it, `/` filters it */
6
7
  export const TreePanel = observer((p: { st: TuiSt }) => {
7
8
  const s = p.st
8
9
  const tree = s.tree
@@ -22,12 +23,20 @@ export const TreePanel = observer((p: { st: TuiSt }) => {
22
23
  (t)ree
23
24
  </Text>
24
25
  </Box>
26
+ {(tree.filtering || tree.filter !== '') && (
27
+ <Text color="yellow" wrap="truncate">
28
+ /{tree.filter}
29
+ {tree.filtering ? '▌' : ''}
30
+ </Text>
31
+ )}
25
32
  {tree.rows.map((row, ix) => {
26
33
  const sel = focused && ix === tree.ix
27
- if (row.kind === 'section') {
34
+ const indent = ' '.repeat(row.depth * 2)
35
+ if (row.kind === 'dir') {
28
36
  return (
29
- <Text key={`section·${row.label}`} color="gray" dimColor wrap="truncate">
30
- ─ {row.label}
37
+ <Text key={`dir·${row.path}`} inverse={sel} color="gray" bold wrap="truncate">
38
+ {indent}
39
+ {row.expanded ? '▾' : '▸'} {row.label}
31
40
  </Text>
32
41
  )
33
42
  }
@@ -38,9 +47,11 @@ export const TreePanel = observer((p: { st: TuiSt }) => {
38
47
  <Text
39
48
  key={row.file}
40
49
  inverse={sel}
41
- color={row.error != null ? 'red' : row.current ? 'green' : undefined}
50
+ bold={row.current}
51
+ color={row.error != null ? 'red' : row.color}
42
52
  wrap="truncate"
43
53
  >
54
+ {indent}
44
55
  {arrow}
45
56
  {marker} {row.name}
46
57
  </Text>
@@ -53,8 +64,7 @@ export const TreePanel = observer((p: { st: TuiSt }) => {
53
64
  color={row.active ? 'cyan' : 'gray'}
54
65
  wrap="truncate"
55
66
  >
56
- {' '}
57
- {row.active ? '●' : '·'} {row.draft}
67
+ {indent} {row.active ? '●' : '·'} {row.draft}
58
68
  </Text>
59
69
  )
60
70
  })}
@@ -1,9 +1,11 @@
1
1
  import { Box, Text, useApp, useInput, useStdin } from 'ink'
2
2
  import { observer } from 'mobx-react-lite'
3
3
  import { basename } from 'pathe'
4
+ import { CopyOverlay } from 'src/cli/tui/components/CopyOverlay.tsx'
4
5
  import { DraftsOverlay } from 'src/cli/tui/components/DraftsOverlay.tsx'
5
6
  import { Header } from 'src/cli/tui/components/Header.tsx'
6
7
  import { HostPanel } from 'src/cli/tui/components/HostPanel.tsx'
8
+ import { HostsOverlay } from 'src/cli/tui/components/HostsOverlay.tsx'
7
9
  import { LorasOverlay } from 'src/cli/tui/components/LorasOverlay.tsx'
8
10
  import { ChoiceOverlay, SizeOverlay } from 'src/cli/tui/components/PickerOverlays.tsx'
9
11
  import { PreviewPanel } from 'src/cli/tui/components/PreviewPanel.tsx'
@@ -115,7 +117,21 @@ export const TuiApp = observer((p: { st: TuiSt }) => {
115
117
  }
116
118
  if (s.mode === 'tree') {
117
119
  const tr = s.tree
118
- if (key.escape || input === 't') return tr.blur()
120
+ // the `/` filter owns plain keys while active (letters type into it)
121
+ if (tr.filtering) {
122
+ if (key.escape) return tr.clearFilter()
123
+ if (key.return) return void tr.commit()
124
+ if (key.upArrow) return tr.move(-1)
125
+ if (key.downArrow) return tr.move(1)
126
+ if (key.leftArrow) return tr.fold()
127
+ if (key.rightArrow) return tr.unfold()
128
+ if (key.backspace || key.delete) return tr.filterBackspace()
129
+ if (input && !key.ctrl && !key.meta) return tr.filterInput(input)
130
+ return
131
+ }
132
+ if (key.escape) return tr.filter !== '' ? tr.clearFilter() : tr.blur()
133
+ if (input === 't') return tr.blur()
134
+ if (input === '/') return tr.beginFilter()
119
135
  if (key.return || input === ' ') return void tr.commit()
120
136
  if (key.upArrow) return tr.move(-1)
121
137
  if (key.downArrow) return tr.move(1)
@@ -130,7 +146,8 @@ export const TuiApp = observer((p: { st: TuiSt }) => {
130
146
  if (input === 'r') return void s.exec.run()
131
147
  if (input === 's') return s.exec.randomizeSeedAndRun()
132
148
  if (input === 'd') return s.drafts.begin()
133
- if (input === 'h') return s.host.begin()
149
+ if (input === 'h') return s.host.beginPicker()
150
+ if (input === 'a') return s.host.begin()
134
151
  if (input === 'p') return s.preview.beginMenu()
135
152
  if (input === 'o') return s.exec.openLastOutput()
136
153
  if (input === 'q') {
@@ -141,7 +158,8 @@ export const TuiApp = observer((p: { st: TuiSt }) => {
141
158
  }
142
159
  if (s.mode === 'host') {
143
160
  const h = s.host
144
- if (key.escape || input === 'h' || input === 'v') return h.blur()
161
+ if (key.escape || input === 'a' || input === 'v') return h.blur()
162
+ if (input === 'h') return h.beginPicker()
145
163
  if (key.return || input === ' ') return void h.commit()
146
164
  if (key.upArrow) return h.move(-1)
147
165
  if (key.downArrow) return h.move(1)
@@ -151,6 +169,20 @@ export const TuiApp = observer((p: { st: TuiSt }) => {
151
169
  }
152
170
  return
153
171
  }
172
+ if (s.mode === 'overlay-hosts') {
173
+ const h = s.host
174
+ if (key.escape || input === 'h') return h.cancelPicker()
175
+ if (key.return || input === ' ') return h.commitPicker()
176
+ if (key.upArrow) return h.pickerMove(-1)
177
+ if (key.downArrow) return h.pickerMove(1)
178
+ return
179
+ }
180
+ if (s.mode === 'overlay-copy') {
181
+ // any close-ish key ends it — a confirmation must never trap
182
+ if (key.escape || key.return || input === ' ' || input === 'c' || input === 'C' || input === 'q')
183
+ return s.exec.closeCopyPopup()
184
+ return
185
+ }
154
186
  if (s.mode === 'preview') {
155
187
  const pv = s.preview
156
188
  // ⏎ CONFIRMS (closes): ←→ already changed the value in place
@@ -163,7 +195,8 @@ export const TuiApp = observer((p: { st: TuiSt }) => {
163
195
  if (input === 'r') return void s.exec.run()
164
196
  if (input === 's') return s.exec.randomizeSeedAndRun()
165
197
  if (input === 'd') return s.drafts.begin()
166
- if (input === 'h') return s.host.begin()
198
+ if (input === 'h') return s.host.beginPicker()
199
+ if (input === 'a') return s.host.begin()
167
200
  if (input === 'o') return s.exec.openLastOutput()
168
201
  if (input === 'q') {
169
202
  s.onExit()
@@ -198,11 +231,16 @@ export const TuiApp = observer((p: { st: TuiSt }) => {
198
231
  if (key.leftArrow) return s.tree.focus()
199
232
  if (key.rightArrow || key.return || input === ' ') return s.activate()
200
233
  if (s.navKey(input)) return
234
+ if (input === '/') {
235
+ s.tree.focus()
236
+ return s.tree.beginFilter()
237
+ }
201
238
  if (input === 'e') return s.drafts.beginRename()
202
239
  if (input === 'r') return void s.exec.run()
203
240
  if (input === 's') return s.exec.randomizeSeedAndRun()
204
241
  if (input === 't' || input === 'w') return s.tree.focus()
205
- if (input === 'h') return s.host.begin()
242
+ if (input === 'h') return s.host.beginPicker()
243
+ if (input === 'a') return s.host.begin()
206
244
  if (input === 'd') return s.drafts.begin()
207
245
  if (input === 'p') return s.preview.beginMenu()
208
246
  if (input === 'o') return s.exec.openLastOutput()
@@ -238,6 +276,10 @@ export const TuiApp = observer((p: { st: TuiSt }) => {
238
276
  <ImagePickerOverlay st={s} />
239
277
  ) : s.mode === 'overlay-drafts' ? (
240
278
  <DraftsOverlay st={s} />
279
+ ) : s.mode === 'overlay-hosts' ? (
280
+ <HostsOverlay st={s} />
281
+ ) : s.mode === 'overlay-copy' ? (
282
+ <CopyOverlay st={s} />
241
283
  ) : (
242
284
  <VarsPanel st={s} />
243
285
  )}
@@ -12,15 +12,15 @@ export function hasImageExtension(name: string, extensions: readonly string[]):
12
12
 
13
13
  /**
14
14
  * ONE folder for the picker: dirs first then images, both alphabetical,
15
- * dotfiles skipped, images filtered by extension. Symlinks are followed
16
- * (a dangling one is skipped). Pure over fs — an unreadable dir THROWS,
17
- * the caller surfaces it (never a silent empty listing).
15
+ * images filtered by extension. Dot FILES are junk (.DS_Store) and skipped;
16
+ * dot DIRS are listed — .comfy-ts/outputs must be browsable. Symlinks are
17
+ * followed (a dangling one is skipped). Pure over fs — an unreadable dir
18
+ * THROWS, the caller surfaces it (never a silent empty listing).
18
19
  */
19
20
  export function listImageDir(dir: string, extensions: readonly string[]): DirListing {
20
21
  const dirs: string[] = []
21
22
  const images: string[] = []
22
23
  for (const entry of readdirSync(dir, { withFileTypes: true })) {
23
- if (entry.name.startsWith('.')) continue
24
24
  let isDir = entry.isDirectory()
25
25
  let isFile = entry.isFile()
26
26
  if (entry.isSymbolicLink()) {
@@ -32,6 +32,8 @@ export function listImageDir(dir: string, extensions: readonly string[]): DirLis
32
32
  continue // dangling symlink: neither dir nor image
33
33
  }
34
34
  }
35
+ // after symlink resolution, so a dot-named link to a real dir stays listed
36
+ if (entry.name.startsWith('.') && !isDir) continue
35
37
  if (isDir) dirs.push(entry.name)
36
38
  else if (isFile && hasImageExtension(entry.name, extensions)) images.push(entry.name)
37
39
  }