comfy-ts 2.12.0 → 2.13.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.
- package/dist/{LogsSt-U1H0mP1m.js → LogsSt-CUeo843w.js} +18 -4
- package/dist/LogsSt-CUeo843w.js.map +1 -0
- package/dist/cli.js +4 -4
- package/dist/index.cjs +123 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +96 -16
- package/dist/index.d.ts +96 -16
- package/dist/index.js +123 -12
- package/dist/index.js.map +1 -1
- package/dist/{run-serve-BeAznay5.js → run-serve-DlRBv_Nk.js} +281 -19
- package/dist/run-serve-DlRBv_Nk.js.map +1 -0
- package/dist/{run-tui-BTGjvnKk.js → run-tui-B5uxm2_l.js} +4 -4
- package/dist/{run-tui-BTGjvnKk.js.map → run-tui-B5uxm2_l.js.map} +1 -1
- package/dist/{schemaDrift-Cg39vs53.js → schemaDrift-E95iTF7E.js} +4 -1
- package/dist/{schemaDrift-Cg39vs53.js.map → schemaDrift-E95iTF7E.js.map} +1 -1
- package/dist/serve-web.js +291 -129
- package/dist/{state-C7REnHan.js → state-CUp2J1Zy.js} +122 -14
- package/dist/state-CUp2J1Zy.js.map +1 -0
- package/dist/web.d.ts +96 -16
- package/dist/web.js +123 -12
- package/dist/web.js.map +1 -1
- package/examples/comfy-cloud/sdk.d.ts +163 -163
- package/examples/rvion/10-anima-t2i.cflow.ts +48 -25
- package/examples/rvion/11-yue2-t2a.cflow.ts +105 -0
- package/examples/rvion/12-stable-audio-3-t2a.cflow.ts +78 -0
- package/examples/rvion/13-ace-step-15-xl-t2a.cflow.ts +153 -0
- package/examples/rvion/stableAudio3Prompts.ts +19 -0
- package/package.json +2 -2
- package/src/cli/serve/ServeApp.ts +157 -18
- package/src/cli/serve/byteRange.ts +48 -0
- package/src/cli/serve/run-serve.ts +12 -3
- package/src/cli/serve/web/api.ts +24 -0
- package/src/cli/serve/web/components/App.tsx +305 -156
- package/src/cli/serve/web/components/DraftTabs.tsx +167 -0
- package/src/cli/serve/web/components/Gallery.tsx +44 -19
- package/src/cli/serve/web/components/Icon.tsx +40 -0
- package/src/cli/serve/web/components/Omnibox.tsx +70 -20
- package/src/cli/serve/web/components/SideMenu.tsx +414 -0
- package/src/cli/serve/web/components/TooltipLayer.tsx +3 -2
- package/src/cli/serve/web/components/VarsForm.tsx +70 -351
- package/src/cli/serve/web/components/controls/LorasControl.tsx +24 -22
- package/src/cli/serve/web/promptEditor/promptExtensions.ts +6 -3
- package/src/cli/serve/web/state/EnhancerSt.ts +17 -2
- package/src/cli/serve/web/state/FormSt.ts +22 -2
- package/src/cli/serve/web/state/OmniboxSt.ts +3 -1
- package/src/cli/serve/web/state/WebSt.ts +172 -33
- package/src/cli/serve/web/state/draftNames.ts +16 -0
- package/src/cli/serve/web/state/draftTabs.ts +75 -0
- package/src/cli/serve/web/state/generateButton.ts +1 -1
- package/src/cli/serve/web/state/omnibox.ts +82 -18
- package/src/cli/serve/web/state/shortcuts.ts +56 -7
- package/src/cli/serve/web/styles.ts +242 -82
- package/src/cli/serve/workflowTags.ts +42 -0
- package/src/cli/serve/workspaceLabels.ts +23 -0
- package/src/cli/tui/state/DraftsSt.ts +10 -6
- package/src/coreExports.ts +1 -0
- package/src/host/ComfyHost.ts +17 -2
- package/src/host/ResilientWebsocket.ts +54 -4
- package/src/runner/ComfyExecution.ts +60 -0
- package/src/runner/ComfyWorkflow.ts +4 -0
- package/src/runner/ComfyWsApi.ts +2 -0
- package/src/runner/MediaImage.ts +2 -2
- package/src/sdk-generator/ComfyUIObjectInfoTypes.ts +5 -5
- package/src/sdk-generator/comfyui-sdk-codegen.ts +1 -1
- package/src/utils/copyName.ts +12 -0
- package/src/vars/DefinedWorkflow.ts +7 -1
- package/dist/LogsSt-U1H0mP1m.js.map +0 -1
- package/dist/run-serve-BeAznay5.js.map +0 -1
- package/dist/state-C7REnHan.js.map +0 -1
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
// the open drafts as tabs over the work area: a click opens one (a click on the open one shows
|
|
2
|
+
// its actions), × or a middle click closes it, ⌘1 to ⌘8 pick one, ⌘9 the last, ⌘PageUp and
|
|
3
|
+
// ⌘PageDown step (ctrl elsewhere), from any focus
|
|
4
|
+
import {
|
|
5
|
+
autoUpdate,
|
|
6
|
+
flip,
|
|
7
|
+
FloatingPortal,
|
|
8
|
+
offset,
|
|
9
|
+
shift,
|
|
10
|
+
useDismiss,
|
|
11
|
+
useFloating,
|
|
12
|
+
useInteractions,
|
|
13
|
+
} from '@floating-ui/react'
|
|
14
|
+
import { observer } from 'mobx-react-lite'
|
|
15
|
+
import { useEffect, useState } from 'react'
|
|
16
|
+
import { Icon } from 'src/cli/serve/web/components/Icon.tsx'
|
|
17
|
+
import { MOD_KEY } from 'src/cli/serve/web/components/modKey.ts'
|
|
18
|
+
import { tabForKey, tabStepForKey, type DraftTab } from 'src/cli/serve/web/state/draftTabs.ts'
|
|
19
|
+
import { shortcutLabel } from 'src/cli/serve/web/state/shortcuts.ts'
|
|
20
|
+
import type { WebSt } from 'src/cli/serve/web/state/WebSt.ts'
|
|
21
|
+
|
|
22
|
+
export function useTabShortcuts(st: WebSt): void {
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
const onKey = (e: KeyboardEvent): void => {
|
|
25
|
+
const t = tabForKey(st.tabs, e) ?? tabStepForKey(st.tabs, st.activeTab, e)
|
|
26
|
+
if (t == null) return
|
|
27
|
+
e.preventDefault()
|
|
28
|
+
void st.select(t)
|
|
29
|
+
}
|
|
30
|
+
window.addEventListener('keydown', onKey)
|
|
31
|
+
return () => window.removeEventListener('keydown', onKey)
|
|
32
|
+
}, [st])
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const DraftTabs = observer(function DraftTabs(p: { st: WebSt }) {
|
|
36
|
+
const active = p.st.activeTab
|
|
37
|
+
const tabs = p.st.tabs
|
|
38
|
+
/** the open tab's element while its actions show, null when they do not */
|
|
39
|
+
const [menuAt, setMenuAt] = useState<HTMLElement | null>(null)
|
|
40
|
+
if (tabs.length === 0) return null
|
|
41
|
+
return (
|
|
42
|
+
<div className="draft-tabs" role="tablist">
|
|
43
|
+
{tabs.map((t, ix) => {
|
|
44
|
+
const on = active != null && active.module === t.module && active.draft === t.draft
|
|
45
|
+
const key = ix < 8 ? `${MOD_KEY}${ix + 1}` : ix === tabs.length - 1 ? `${MOD_KEY}9` : null
|
|
46
|
+
return (
|
|
47
|
+
<div
|
|
48
|
+
key={`${t.module}/${t.draft}`}
|
|
49
|
+
role="tab"
|
|
50
|
+
aria-selected={on}
|
|
51
|
+
className={on ? 'draft-tab on' : 'draft-tab'}
|
|
52
|
+
data-tip={`${t.module} / ${t.draft}${key == null ? '' : `\n${key}`}${on ? '\nclick: rename, duplicate, delete' : ''}`}
|
|
53
|
+
onClick={(e) => {
|
|
54
|
+
// another tab is a jump; the open one has nowhere to jump, so it shows its actions
|
|
55
|
+
if (on) setMenuAt(e.currentTarget)
|
|
56
|
+
else void p.st.select(t)
|
|
57
|
+
}}
|
|
58
|
+
onAuxClick={(e) => {
|
|
59
|
+
if (e.button !== 1) return
|
|
60
|
+
e.preventDefault()
|
|
61
|
+
p.st.closeTab(t)
|
|
62
|
+
}}
|
|
63
|
+
>
|
|
64
|
+
<span className="draft-tab-name">
|
|
65
|
+
{t.draft}
|
|
66
|
+
{/* two open drafts share the name (default, default): the workflow tells them apart */}
|
|
67
|
+
{tabs.some((o) => o.draft === t.draft && o.module !== t.module) ? (
|
|
68
|
+
<span className="draft-tab-wf"> · {t.module}</span>
|
|
69
|
+
) : null}
|
|
70
|
+
</span>
|
|
71
|
+
{tabs.length > 1 ? (
|
|
72
|
+
<button
|
|
73
|
+
type="button"
|
|
74
|
+
className="draft-tab-close"
|
|
75
|
+
aria-label={`close ${t.draft}`}
|
|
76
|
+
onClick={(e) => {
|
|
77
|
+
e.stopPropagation()
|
|
78
|
+
p.st.closeTab(t)
|
|
79
|
+
}}
|
|
80
|
+
>
|
|
81
|
+
<Icon name="close" size={0.8} />
|
|
82
|
+
</button>
|
|
83
|
+
) : null}
|
|
84
|
+
</div>
|
|
85
|
+
)
|
|
86
|
+
})}
|
|
87
|
+
{menuAt != null && active != null ? (
|
|
88
|
+
<TabMenu st={p.st} tab={active} anchor={menuAt} onClose={() => setMenuAt(null)} />
|
|
89
|
+
) : null}
|
|
90
|
+
</div>
|
|
91
|
+
)
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
/** under the open tab: its name to edit (focused, enter renames), then the other draft actions.
|
|
95
|
+
* In a portal: the tab bar scrolls sideways and would clip it */
|
|
96
|
+
const TabMenu = observer(function TabMenu(p: { st: WebSt; tab: DraftTab; anchor: HTMLElement; onClose: () => void }) {
|
|
97
|
+
const [name, setName] = useState(p.tab.draft)
|
|
98
|
+
const { refs, floatingStyles, context } = useFloating({
|
|
99
|
+
open: true,
|
|
100
|
+
onOpenChange: (open) => {
|
|
101
|
+
if (!open) p.onClose()
|
|
102
|
+
},
|
|
103
|
+
placement: 'bottom-start',
|
|
104
|
+
middleware: [offset(4), flip(), shift({ padding: 8 })],
|
|
105
|
+
whileElementsMounted: autoUpdate,
|
|
106
|
+
elements: { reference: p.anchor },
|
|
107
|
+
})
|
|
108
|
+
const { getFloatingProps } = useInteractions([useDismiss(context)])
|
|
109
|
+
const run = (action: () => unknown): void => {
|
|
110
|
+
p.onClose()
|
|
111
|
+
void action()
|
|
112
|
+
}
|
|
113
|
+
const rename = (): void => {
|
|
114
|
+
const next = name.trim()
|
|
115
|
+
run(() => (next !== '' && next !== p.tab.draft ? p.st.renameDraft(next) : undefined))
|
|
116
|
+
}
|
|
117
|
+
return (
|
|
118
|
+
<FloatingPortal>
|
|
119
|
+
<div ref={refs.setFloating} style={floatingStyles} className="tab-menu" {...getFloatingProps()}>
|
|
120
|
+
<input
|
|
121
|
+
type="text"
|
|
122
|
+
className="head-input"
|
|
123
|
+
autoFocus
|
|
124
|
+
value={name}
|
|
125
|
+
aria-label="draft name"
|
|
126
|
+
placeholder="new name, then enter"
|
|
127
|
+
onFocus={(e) => e.currentTarget.select()}
|
|
128
|
+
onChange={(e) => setName(e.target.value)}
|
|
129
|
+
onKeyDown={(e) => {
|
|
130
|
+
if (e.key === 'Enter') rename()
|
|
131
|
+
if (e.key === 'Escape') p.onClose()
|
|
132
|
+
}}
|
|
133
|
+
/>
|
|
134
|
+
<button
|
|
135
|
+
type="button"
|
|
136
|
+
className="menu-row menu-action"
|
|
137
|
+
onClick={() => run(() => p.st.duplicateCurrentDraft())}
|
|
138
|
+
>
|
|
139
|
+
<Icon name="copy-plus" />
|
|
140
|
+
<span>duplicate</span>
|
|
141
|
+
<span className="kbd-hint">{shortcutLabel('duplicate-draft')}</span>
|
|
142
|
+
</button>
|
|
143
|
+
<button
|
|
144
|
+
type="button"
|
|
145
|
+
className="menu-row menu-action"
|
|
146
|
+
onClick={() => run(() => p.st.newDraftFromDefaults())}
|
|
147
|
+
>
|
|
148
|
+
<Icon name="plus" />
|
|
149
|
+
<span>new default</span>
|
|
150
|
+
</button>
|
|
151
|
+
<button
|
|
152
|
+
type="button"
|
|
153
|
+
className="menu-row menu-action danger"
|
|
154
|
+
onClick={() =>
|
|
155
|
+
run(() => {
|
|
156
|
+
if (window.confirm(`delete draft '${p.tab.draft}' of ${p.tab.module}? the file is removed.`))
|
|
157
|
+
return p.st.deleteDraft(p.tab)
|
|
158
|
+
})
|
|
159
|
+
}
|
|
160
|
+
>
|
|
161
|
+
<Icon name="trash" />
|
|
162
|
+
<span>delete</span>
|
|
163
|
+
</button>
|
|
164
|
+
</div>
|
|
165
|
+
</FloatingPortal>
|
|
166
|
+
)
|
|
167
|
+
})
|
|
@@ -10,6 +10,19 @@ import { asSizeForm } from 'src/cli/serve/web/state/payload.ts'
|
|
|
10
10
|
import { lightboxView, type LightboxTarget } from 'src/cli/serve/web/state/lightbox.ts'
|
|
11
11
|
import { copyImageToClipboard } from 'src/cli/serve/web/clipboard.ts'
|
|
12
12
|
import type { WebSt } from 'src/cli/serve/web/state/WebSt.ts'
|
|
13
|
+
import { MOD_KEY } from 'src/cli/serve/web/components/modKey.ts'
|
|
14
|
+
import { SHORTCUT_KEYS } from 'src/cli/serve/web/state/shortcuts.ts'
|
|
15
|
+
|
|
16
|
+
/** the unblur shortcut, said ON a blurred image: the place you look when you want it gone */
|
|
17
|
+
const BlurHint = observer(function BlurHint(p: { st: WebSt }) {
|
|
18
|
+
if (!p.st.blurResults) return null
|
|
19
|
+
return (
|
|
20
|
+
<span className="blur-hint kbd-hint">
|
|
21
|
+
{MOD_KEY}
|
|
22
|
+
{SHORTCUT_KEYS['toggle-blur']}
|
|
23
|
+
</span>
|
|
24
|
+
)
|
|
25
|
+
})
|
|
13
26
|
|
|
14
27
|
const canCopy = typeof navigator !== 'undefined' && navigator.clipboard != null
|
|
15
28
|
|
|
@@ -322,6 +335,7 @@ const CornerRun = observer(function CornerRun(p: { st: WebSt; local: GalleryLoca
|
|
|
322
335
|
}
|
|
323
336
|
>
|
|
324
337
|
<img src={runPreviewSrc({ module: p.module, tick: p.st.run.previewTick })} alt="latent preview" />
|
|
338
|
+
<BlurHint st={p.st} />
|
|
325
339
|
</button>
|
|
326
340
|
) : null}
|
|
327
341
|
<div className="corner-run-meta">
|
|
@@ -362,7 +376,7 @@ const RunningCard = observer(function RunningCard(p: { st: WebSt; local: Gallery
|
|
|
362
376
|
const imageGraph = size != null || p.st.run.hasPreview
|
|
363
377
|
const ratio = size == null ? 1 : size.width / size.height
|
|
364
378
|
return (
|
|
365
|
-
<div className=
|
|
379
|
+
<div className={imageGraph ? 'run-card running cell' : 'run-card running'}>
|
|
366
380
|
<div className="meta">
|
|
367
381
|
<span className="run-meta-text">
|
|
368
382
|
generating {moduleKey}…
|
|
@@ -378,11 +392,8 @@ const RunningCard = observer(function RunningCard(p: { st: WebSt; local: Gallery
|
|
|
378
392
|
className="run-frame"
|
|
379
393
|
style={{
|
|
380
394
|
aspectRatio: String(ratio),
|
|
381
|
-
// the box the finished image
|
|
382
|
-
width:
|
|
383
|
-
p.st.resultsView === 'fit'
|
|
384
|
-
? '100%'
|
|
385
|
-
: `min(100%, ${p.st.resultsSize}px, calc(${p.st.resultsSize}px * ${ratio}))`,
|
|
395
|
+
// one column's width, the box the finished image takes, so it lands in place
|
|
396
|
+
width: '100%',
|
|
386
397
|
}}
|
|
387
398
|
>
|
|
388
399
|
{p.st.run.hasPreview && p.st.latentMode === 'full' ? (
|
|
@@ -398,6 +409,7 @@ const RunningCard = observer(function RunningCard(p: { st: WebSt; local: Gallery
|
|
|
398
409
|
}
|
|
399
410
|
>
|
|
400
411
|
<img src={previewUrl} alt="latent preview" />
|
|
412
|
+
<BlurHint st={p.st} />
|
|
401
413
|
</button>
|
|
402
414
|
) : null}
|
|
403
415
|
<div className="progress-track over">
|
|
@@ -424,15 +436,21 @@ export const Gallery = observer(function Gallery(p: { st: WebSt; compact?: boole
|
|
|
424
436
|
// fit: one per row at the panel's width; grid: the slider's size, wrapping. The corner
|
|
425
437
|
// placement keeps its own compact look
|
|
426
438
|
<div
|
|
427
|
-
className={`gallery${p.st.blurResults ? ' blur' : ''}${p.compact === true ? '' :
|
|
439
|
+
className={`gallery${p.st.blurResults ? ' blur' : ''}${p.compact === true ? '' : ' by-cols'}`}
|
|
440
|
+
style={
|
|
441
|
+
p.compact === true ? undefined : { gridTemplateColumns: `repeat(${p.st.resultsColumns}, minmax(0, 1fr))` }
|
|
442
|
+
}
|
|
428
443
|
>
|
|
429
444
|
<RunningCard st={p.st} local={local} />
|
|
430
445
|
{/* the count and clear-all moved onto the run line beside the generate button: two
|
|
431
446
|
headers for one idea is a header too many */}
|
|
432
447
|
{results.map((r) => (
|
|
433
|
-
<div
|
|
448
|
+
<div
|
|
449
|
+
key={r.promptId}
|
|
450
|
+
className={r.images.some((img) => img.url != null) ? 'run-card has-image' : 'run-card'}
|
|
451
|
+
>
|
|
434
452
|
<div className="meta">
|
|
435
|
-
<span>
|
|
453
|
+
<span className="meta-text">
|
|
436
454
|
{r.at} · {r.module}/{r.draft} · {(r.durationMs / 1000).toFixed(1)}s
|
|
437
455
|
{Object.entries(r.seeds).map(([k, seed]) => ` · ${k}: ${seed}`)}
|
|
438
456
|
</span>
|
|
@@ -463,15 +481,8 @@ export const Gallery = observer(function Gallery(p: { st: WebSt; compact?: boole
|
|
|
463
481
|
})
|
|
464
482
|
}}
|
|
465
483
|
>
|
|
466
|
-
<img
|
|
467
|
-
|
|
468
|
-
alt={img.filename}
|
|
469
|
-
style={
|
|
470
|
-
p.st.resultsView === 'grid' && p.compact !== true
|
|
471
|
-
? { maxWidth: `min(100%, ${p.st.resultsSize}px)`, maxHeight: p.st.resultsSize }
|
|
472
|
-
: undefined
|
|
473
|
-
}
|
|
474
|
-
/>
|
|
484
|
+
<img src={img.url} alt={img.filename} />
|
|
485
|
+
<BlurHint st={p.st} />
|
|
475
486
|
</button>
|
|
476
487
|
{/* the EMBEDDING page's buttons (host protocol): what it does with the
|
|
477
488
|
image is its business — send it somewhere, keep it as something */}
|
|
@@ -513,7 +524,21 @@ export const Gallery = observer(function Gallery(p: { st: WebSt; compact?: boole
|
|
|
513
524
|
</div>
|
|
514
525
|
),
|
|
515
526
|
)}
|
|
516
|
-
{
|
|
527
|
+
{(r.audios ?? []).map((a, ix) =>
|
|
528
|
+
a.url != null ? (
|
|
529
|
+
<div key={`${r.promptId}-audio-${ix}`} className="audio-cell">
|
|
530
|
+
<audio controls preload="metadata" src={a.url} />
|
|
531
|
+
<a className="hint" href={a.url} download={a.filename}>
|
|
532
|
+
{a.filename}
|
|
533
|
+
</a>
|
|
534
|
+
</div>
|
|
535
|
+
) : (
|
|
536
|
+
<div key={`${r.promptId}-audio-${ix}`} className="noimg">
|
|
537
|
+
{a.filename} (not kept — no preview)
|
|
538
|
+
</div>
|
|
539
|
+
),
|
|
540
|
+
)}
|
|
541
|
+
{r.images.length === 0 && (r.texts ?? []).length === 0 && (r.audios ?? []).length === 0 ? (
|
|
517
542
|
<div className="noimg">no outputs</div>
|
|
518
543
|
) : null}
|
|
519
544
|
</div>
|
|
@@ -6,6 +6,7 @@ import type { ReactNode } from 'react'
|
|
|
6
6
|
|
|
7
7
|
export type IconName =
|
|
8
8
|
| 'close'
|
|
9
|
+
| 'check'
|
|
9
10
|
| 'trash'
|
|
10
11
|
| 'copy'
|
|
11
12
|
| 'external'
|
|
@@ -15,6 +16,7 @@ export type IconName =
|
|
|
15
16
|
| 'sparkle'
|
|
16
17
|
| 'play'
|
|
17
18
|
| 'pause'
|
|
19
|
+
| 'stop'
|
|
18
20
|
| 'save'
|
|
19
21
|
| 'ghost'
|
|
20
22
|
| 'panel-off'
|
|
@@ -45,10 +47,19 @@ export type IconName =
|
|
|
45
47
|
| 'more'
|
|
46
48
|
| 'text'
|
|
47
49
|
| 'dot'
|
|
50
|
+
| 'audio'
|
|
51
|
+
| 'video'
|
|
52
|
+
| 'workflow'
|
|
53
|
+
| 'draft'
|
|
54
|
+
| 'folder'
|
|
55
|
+
| 'folder-tree'
|
|
56
|
+
| 'server'
|
|
57
|
+
| 'menu'
|
|
48
58
|
|
|
49
59
|
/** 24x24 viewBox paths, stroked (fill: none) unless the shape reads better solid */
|
|
50
60
|
const PATHS: Record<IconName, ReactNode> = {
|
|
51
61
|
close: <path d="M6 6l12 12M18 6L6 18" />,
|
|
62
|
+
check: <path d="M5 12.5l4.5 4.5L19 7.5" />,
|
|
52
63
|
trash: <path d="M4 7h16M10 7V5h4v2M6 7l1 12h10l1-12M10 11v5M14 11v5" />,
|
|
53
64
|
copy: <path d="M9 9h10v10H9zM5 15V5h10" />,
|
|
54
65
|
external: <path d="M14 5h5v5M19 5l-8 8M18 14v5H5V6h5" />,
|
|
@@ -78,6 +89,7 @@ const PATHS: Record<IconName, ReactNode> = {
|
|
|
78
89
|
),
|
|
79
90
|
play: <path d="M7 4l13 8-13 8z" fill="currentColor" stroke="none" />,
|
|
80
91
|
pause: <path d="M8 5v14M16 5v14" />,
|
|
92
|
+
stop: <rect x="6" y="6" width="12" height="12" rx="1.5" fill="currentColor" stroke="none" />,
|
|
81
93
|
save: <path d="M5 4h11l3 3v13H5zM8 4v6h7V4M8 20v-6h8v6" />,
|
|
82
94
|
ghost: <path d="M5 20V10a7 7 0 0114 0v10l-2.3-2-2.4 2-2.3-2-2.4 2zM9.5 10h.01M14.5 10h.01" />,
|
|
83
95
|
'panel-off': (
|
|
@@ -151,6 +163,34 @@ const PATHS: Record<IconName, ReactNode> = {
|
|
|
151
163
|
search: <path d="M10.5 4a6.5 6.5 0 110 13 6.5 6.5 0 010-13zM15.5 15.5L20 20" />,
|
|
152
164
|
history: <path d="M4 12a8 8 0 102.3-5.6M4 4v4h4M12 8v4l3 2" />,
|
|
153
165
|
dot: <circle cx="12" cy="12" r="5" fill="currentColor" stroke="none" />,
|
|
166
|
+
audio: <path d="M3 12h2M7 8v8M11 4v16M15 7v10M19 10v4M21 12h0" />,
|
|
167
|
+
video: (
|
|
168
|
+
<>
|
|
169
|
+
<rect x="3" y="6" width="13" height="12" rx="2" />
|
|
170
|
+
<path d="M16 10l5-3v10l-5-3z" />
|
|
171
|
+
</>
|
|
172
|
+
),
|
|
173
|
+
workflow: (
|
|
174
|
+
<>
|
|
175
|
+
<rect x="3" y="4" width="6" height="5" rx="1.2" />
|
|
176
|
+
<rect x="15" y="4" width="6" height="5" rx="1.2" />
|
|
177
|
+
<rect x="9" y="15" width="6" height="5" rx="1.2" />
|
|
178
|
+
<path d="M6 9v2.5a1.5 1.5 0 001.5 1.5h9a1.5 1.5 0 001.5-1.5V9M12 13v2" />
|
|
179
|
+
</>
|
|
180
|
+
),
|
|
181
|
+
draft: <path d="M6 3h8l4 4v14H6zM14 3v4h4M9 12h6M9 16h4" />,
|
|
182
|
+
folder: (
|
|
183
|
+
<path d="M3 6.5A1.5 1.5 0 014.5 5H9l2 2h8.5A1.5 1.5 0 0121 8.5v9a1.5 1.5 0 01-1.5 1.5h-15A1.5 1.5 0 013 17.5z" />
|
|
184
|
+
),
|
|
185
|
+
'folder-tree': <path d="M4 4v14a2 2 0 002 2h2M4 10h4M10 7h3l1 1.5h6V12H10zM10 16h3l1 1.5h6V21H10z" />,
|
|
186
|
+
server: (
|
|
187
|
+
<>
|
|
188
|
+
<rect x="3" y="4" width="18" height="7" rx="1.5" />
|
|
189
|
+
<rect x="3" y="13" width="18" height="7" rx="1.5" />
|
|
190
|
+
<path d="M7 7.5h.01M7 16.5h.01M11 7.5h6M11 16.5h6" />
|
|
191
|
+
</>
|
|
192
|
+
),
|
|
193
|
+
menu: <path d="M4 7h16M4 12h16M4 17h16" />,
|
|
154
194
|
}
|
|
155
195
|
|
|
156
196
|
/** `size` is a multiplier of the surrounding font size, so icons scale with their button */
|
|
@@ -1,16 +1,68 @@
|
|
|
1
|
-
// ⌘K / ⌘J: type a few letters of any folder, workflow or
|
|
2
|
-
//
|
|
1
|
+
// ⌘K / ⌘J: type a few letters of any folder, workflow, draft or tag, Enter opens it.
|
|
2
|
+
// a workflow row (icon, path, tag chips) then its drafts indented. Modules that failed to
|
|
3
|
+
// load are listed under the matches, since nothing else shows them
|
|
3
4
|
import { observer } from 'mobx-react-lite'
|
|
4
5
|
import { useEffect, useRef } from 'react'
|
|
6
|
+
import { Icon, type IconName } from 'src/cli/serve/web/components/Icon.tsx'
|
|
7
|
+
import { entryKey, type OmniboxEntry } from 'src/cli/serve/web/state/omnibox.ts'
|
|
8
|
+
import { isOmniboxKey } from 'src/cli/serve/web/state/shortcuts.ts'
|
|
5
9
|
import type { WebSt } from 'src/cli/serve/web/state/WebSt.ts'
|
|
6
10
|
|
|
11
|
+
/** the first media tag picks the icon: what the workflow makes */
|
|
12
|
+
const ICON_BY_TAG: Record<string, IconName> = { image: 'image', audio: 'audio', video: 'video', text: 'text' }
|
|
13
|
+
|
|
14
|
+
function workflowIcon(tags: readonly string[]): IconName {
|
|
15
|
+
for (const t of tags) {
|
|
16
|
+
const icon = ICON_BY_TAG[t]
|
|
17
|
+
if (icon != null) return icon
|
|
18
|
+
}
|
|
19
|
+
return 'workflow'
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** the tags with their own color; any other tag is a neutral chip */
|
|
23
|
+
const TINTED = new Set(['image', 'audio', 'video', 'text', 'llm', 'edit'])
|
|
24
|
+
|
|
25
|
+
function OmniRow(p: { entry: OmniboxEntry; sel: boolean; open: boolean; words: string[]; onPick: () => void }) {
|
|
26
|
+
const e = p.entry
|
|
27
|
+
const cls = ['omni-row', e.kind, p.sel ? 'sel' : '', p.open ? 'open' : ''].join(' ')
|
|
28
|
+
if (e.kind === 'draft')
|
|
29
|
+
return (
|
|
30
|
+
<button type="button" className={cls} onClick={p.onPick}>
|
|
31
|
+
<Icon name="draft" size={0.95} />
|
|
32
|
+
<span className="omni-draft">{e.draft}</span>
|
|
33
|
+
{p.open ? <span className="omni-open">open</span> : null}
|
|
34
|
+
</button>
|
|
35
|
+
)
|
|
36
|
+
return (
|
|
37
|
+
<button type="button" className={cls} onClick={p.onPick}>
|
|
38
|
+
<span className={`omni-icon tint-${workflowIcon(e.tags)}`}>
|
|
39
|
+
<Icon name={workflowIcon(e.tags)} />
|
|
40
|
+
</span>
|
|
41
|
+
<span className="omni-path">
|
|
42
|
+
{e.folder === '' ? null : <span className="omni-folder">{e.folder} / </span>}
|
|
43
|
+
<span className="omni-name">{e.module}</span>
|
|
44
|
+
</span>
|
|
45
|
+
<span className="omni-tags">
|
|
46
|
+
{e.tags.map((t) => (
|
|
47
|
+
<span
|
|
48
|
+
key={t}
|
|
49
|
+
className={['omni-tag', TINTED.has(t) ? `tint-${t}` : '', p.words.includes(t) ? 'hit' : ''].join(' ')}
|
|
50
|
+
>
|
|
51
|
+
{t}
|
|
52
|
+
</span>
|
|
53
|
+
))}
|
|
54
|
+
<span className="omni-host">{e.host}</span>
|
|
55
|
+
</span>
|
|
56
|
+
</button>
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
|
|
7
60
|
/** ⌘K and ⌘J (ctrl on other systems) from ANY focus, a text field included: it is a jump,
|
|
8
61
|
* not an edit, and the prompt textarea is where the focus usually is */
|
|
9
62
|
export function useOmniboxShortcut(st: WebSt): void {
|
|
10
63
|
useEffect(() => {
|
|
11
64
|
const onKey = (e: KeyboardEvent): void => {
|
|
12
|
-
if (!(e
|
|
13
|
-
if (e.key !== 'k' && e.key !== 'K' && e.key !== 'j' && e.key !== 'J') return
|
|
65
|
+
if (!isOmniboxKey(e)) return
|
|
14
66
|
e.preventDefault()
|
|
15
67
|
st.omnibox.toggle()
|
|
16
68
|
}
|
|
@@ -30,6 +82,7 @@ export const Omnibox = observer(function Omnibox(p: { st: WebSt }) {
|
|
|
30
82
|
const results = o.results
|
|
31
83
|
const errors = Object.entries(p.st.loadErrors)
|
|
32
84
|
const current = p.st.form
|
|
85
|
+
const words = o.query.trim().toLowerCase().split(/\s+/)
|
|
33
86
|
return (
|
|
34
87
|
<div className="modal-overlay omni-overlay" onClick={() => o.close()}>
|
|
35
88
|
<div className="modal omni" onClick={(e) => e.stopPropagation()}>
|
|
@@ -37,7 +90,7 @@ export const Omnibox = observer(function Omnibox(p: { st: WebSt }) {
|
|
|
37
90
|
<input
|
|
38
91
|
type="text"
|
|
39
92
|
autoFocus
|
|
40
|
-
placeholder="workflow or
|
|
93
|
+
placeholder="workflow, draft or tag (audio, image, edit…)"
|
|
41
94
|
value={o.query}
|
|
42
95
|
onChange={(e) => o.setQuery(e.target.value)}
|
|
43
96
|
onKeyDown={(e) => {
|
|
@@ -52,21 +105,18 @@ export const Omnibox = observer(function Omnibox(p: { st: WebSt }) {
|
|
|
52
105
|
</div>
|
|
53
106
|
<div className="modal-body omni-list" ref={listRef}>
|
|
54
107
|
{results.length === 0 ? <div className="hint">no workflow or draft matches</div> : null}
|
|
55
|
-
{results.map((entry, ix) =>
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
</button>
|
|
68
|
-
)
|
|
69
|
-
})}
|
|
108
|
+
{results.map((entry, ix) => (
|
|
109
|
+
<OmniRow
|
|
110
|
+
key={entryKey(entry)}
|
|
111
|
+
entry={entry}
|
|
112
|
+
sel={ix === o.cursor}
|
|
113
|
+
open={
|
|
114
|
+
entry.kind === 'draft' && current?.moduleKey === entry.module && current.draft === entry.draft
|
|
115
|
+
}
|
|
116
|
+
words={words}
|
|
117
|
+
onPick={() => o.pick(entry)}
|
|
118
|
+
/>
|
|
119
|
+
))}
|
|
70
120
|
{errors.length > 0 ? (
|
|
71
121
|
<div className="omni-errors">
|
|
72
122
|
<div className="section-title">failed to load</div>
|