comfy-ts 2.12.0 → 2.14.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-DUqcn0h3.js} +477 -63
- package/dist/run-serve-DUqcn0h3.js.map +1 -0
- package/dist/{run-tui-BTGjvnKk.js → run-tui-D-LaSqgB.js} +4 -4
- package/dist/{run-tui-BTGjvnKk.js.map → run-tui-D-LaSqgB.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 +378 -141
- package/dist/{state-C7REnHan.js → state-BytbdZ8s.js} +122 -14
- package/dist/state-BytbdZ8s.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 +224 -77
- package/src/cli/serve/byteRange.ts +48 -0
- package/src/cli/serve/resultHistory.ts +125 -0
- package/src/cli/serve/run-serve.ts +12 -3
- package/src/cli/serve/runError.ts +23 -0
- package/src/cli/serve/serveSettings.ts +17 -1
- package/src/cli/serve/web/api.ts +53 -2
- package/src/cli/serve/web/components/App.tsx +311 -160
- package/src/cli/serve/web/components/DraftTabs.tsx +167 -0
- package/src/cli/serve/web/components/Gallery.tsx +75 -25
- package/src/cli/serve/web/components/Icon.tsx +44 -0
- package/src/cli/serve/web/components/MemoryBudget.tsx +98 -0
- package/src/cli/serve/web/components/Omnibox.tsx +70 -20
- package/src/cli/serve/web/components/RunError.tsx +19 -0
- package/src/cli/serve/web/components/ShortcutsModal.tsx +54 -0
- package/src/cli/serve/web/components/SideMenu.tsx +428 -0
- package/src/cli/serve/web/components/TooltipLayer.tsx +3 -2
- package/src/cli/serve/web/components/VarsForm.tsx +141 -404
- package/src/cli/serve/web/components/controls/BasicControls.tsx +8 -1
- package/src/cli/serve/web/components/controls/LorasControl.tsx +30 -25
- package/src/cli/serve/web/promptEditor/promptExtensions.ts +9 -4
- 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/RunSt.ts +61 -3
- package/src/cli/serve/web/state/WebSt.ts +198 -35
- 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/formRows.ts +9 -0
- package/src/cli/serve/web/state/generateButton.ts +1 -1
- package/src/cli/serve/web/state/keptResults.ts +26 -0
- package/src/cli/serve/web/state/lightbox.ts +17 -0
- package/src/cli/serve/web/state/omnibox.ts +82 -18
- package/src/cli/serve/web/state/shortcutCatalog.ts +100 -0
- package/src/cli/serve/web/state/shortcuts.ts +66 -7
- package/src/cli/serve/web/styles.ts +327 -93
- 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
|
+
})
|
|
@@ -4,12 +4,39 @@
|
|
|
4
4
|
// the button hides where the clipboard api is absent
|
|
5
5
|
import { Icon } from 'src/cli/serve/web/components/Icon.tsx'
|
|
6
6
|
import { observer, useLocalObservable } from 'mobx-react-lite'
|
|
7
|
-
import { useEffect, useRef } from 'react'
|
|
7
|
+
import { useEffect, useRef, type ReactNode } from 'react'
|
|
8
|
+
import { isEphemeral } from 'src/cli/serve/web/state/keptResults.ts'
|
|
8
9
|
import { runPreviewSrc } from 'src/cli/serve/web/api.ts'
|
|
9
10
|
import { asSizeForm } from 'src/cli/serve/web/state/payload.ts'
|
|
10
|
-
import { lightboxView, type LightboxTarget } from 'src/cli/serve/web/state/lightbox.ts'
|
|
11
|
+
import { lightboxStep, lightboxView, type LightboxTarget } from 'src/cli/serve/web/state/lightbox.ts'
|
|
11
12
|
import { copyImageToClipboard } from 'src/cli/serve/web/clipboard.ts'
|
|
12
13
|
import type { WebSt } from 'src/cli/serve/web/state/WebSt.ts'
|
|
14
|
+
import { MOD_KEY } from 'src/cli/serve/web/components/modKey.ts'
|
|
15
|
+
import { SHORTCUT_KEYS } from 'src/cli/serve/web/state/shortcuts.ts'
|
|
16
|
+
|
|
17
|
+
/** on an output only the serve process holds: a restart, or the memory budget, loses it */
|
|
18
|
+
function EphemeralPill(p: { out: { url: string | null; absPath: string | null } }): ReactNode {
|
|
19
|
+
if (!isEphemeral(p.out)) return null
|
|
20
|
+
return (
|
|
21
|
+
<span
|
|
22
|
+
className="ephemeral-pill"
|
|
23
|
+
data-tip="not saved: kept in the server memory only, lost on a restart or past the memory budget"
|
|
24
|
+
>
|
|
25
|
+
<Icon name="warn" /> ephemeral
|
|
26
|
+
</span>
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** the unblur shortcut, said ON a blurred image: the place you look when you want it gone */
|
|
31
|
+
const BlurHint = observer(function BlurHint(p: { st: WebSt }) {
|
|
32
|
+
if (!p.st.blurResults) return null
|
|
33
|
+
return (
|
|
34
|
+
<span className="blur-hint kbd-hint">
|
|
35
|
+
{MOD_KEY}
|
|
36
|
+
{SHORTCUT_KEYS['toggle-blur']}
|
|
37
|
+
</span>
|
|
38
|
+
)
|
|
39
|
+
})
|
|
13
40
|
|
|
14
41
|
const canCopy = typeof navigator !== 'undefined' && navigator.clipboard != null
|
|
15
42
|
|
|
@@ -84,14 +111,23 @@ const Lightbox = observer(function Lightbox(p: { st: WebSt; local: GalleryLocal
|
|
|
84
111
|
previewTick: p.st.run.previewTick,
|
|
85
112
|
results: p.st.run.results,
|
|
86
113
|
})
|
|
114
|
+
// ↑ / ↓ step from what is SHOWN: a latent that became its image steps from that image
|
|
115
|
+
const url = box?.url
|
|
87
116
|
useEffect(() => {
|
|
88
117
|
if (target == null) return
|
|
89
118
|
const onKey = (e: KeyboardEvent): void => {
|
|
90
|
-
if (e.key === 'Escape') p.local.closeLightbox()
|
|
119
|
+
if (e.key === 'Escape') return p.local.closeLightbox()
|
|
120
|
+
const dir =
|
|
121
|
+
e.key === 'ArrowDown' || e.key === 'ArrowRight' ? 1 : e.key === 'ArrowUp' || e.key === 'ArrowLeft' ? -1 : 0
|
|
122
|
+
if (dir === 0) return
|
|
123
|
+
if (e.metaKey || e.ctrlKey || e.altKey || e.shiftKey || url == null) return
|
|
124
|
+
e.preventDefault()
|
|
125
|
+
const next = lightboxStep({ results: p.st.run.results, url, dir })
|
|
126
|
+
if (next != null) p.local.openLightbox(next)
|
|
91
127
|
}
|
|
92
128
|
window.addEventListener('keydown', onKey)
|
|
93
129
|
return () => window.removeEventListener('keydown', onKey)
|
|
94
|
-
}, [target, p.local])
|
|
130
|
+
}, [target, url, p.local, p.st])
|
|
95
131
|
// wheel is registered BY HAND, non-passive. React attaches wheel at the root as passive, so
|
|
96
132
|
// its onWheel cannot preventDefault: zooming also scrolled the results column behind the
|
|
97
133
|
// lightbox, and every tick logged a console error
|
|
@@ -157,7 +193,7 @@ const Lightbox = observer(function Lightbox(p: { st: WebSt; local: GalleryLocal
|
|
|
157
193
|
{p.local.zoom.toFixed(1)}× · fit
|
|
158
194
|
</button>
|
|
159
195
|
) : (
|
|
160
|
-
<span className="hint">scroll to zoom</span>
|
|
196
|
+
<span className="hint">scroll to zoom, ↑ ↓ for the other images</span>
|
|
161
197
|
)}
|
|
162
198
|
{canCopy ? (
|
|
163
199
|
<button type="button" onClick={copy}>
|
|
@@ -322,6 +358,7 @@ const CornerRun = observer(function CornerRun(p: { st: WebSt; local: GalleryLoca
|
|
|
322
358
|
}
|
|
323
359
|
>
|
|
324
360
|
<img src={runPreviewSrc({ module: p.module, tick: p.st.run.previewTick })} alt="latent preview" />
|
|
361
|
+
<BlurHint st={p.st} />
|
|
325
362
|
</button>
|
|
326
363
|
) : null}
|
|
327
364
|
<div className="corner-run-meta">
|
|
@@ -362,7 +399,7 @@ const RunningCard = observer(function RunningCard(p: { st: WebSt; local: Gallery
|
|
|
362
399
|
const imageGraph = size != null || p.st.run.hasPreview
|
|
363
400
|
const ratio = size == null ? 1 : size.width / size.height
|
|
364
401
|
return (
|
|
365
|
-
<div className=
|
|
402
|
+
<div className={imageGraph ? 'run-card running cell' : 'run-card running'}>
|
|
366
403
|
<div className="meta">
|
|
367
404
|
<span className="run-meta-text">
|
|
368
405
|
generating {moduleKey}…
|
|
@@ -378,11 +415,8 @@ const RunningCard = observer(function RunningCard(p: { st: WebSt; local: Gallery
|
|
|
378
415
|
className="run-frame"
|
|
379
416
|
style={{
|
|
380
417
|
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}))`,
|
|
418
|
+
// one column's width, the box the finished image takes, so it lands in place
|
|
419
|
+
width: '100%',
|
|
386
420
|
}}
|
|
387
421
|
>
|
|
388
422
|
{p.st.run.hasPreview && p.st.latentMode === 'full' ? (
|
|
@@ -398,6 +432,7 @@ const RunningCard = observer(function RunningCard(p: { st: WebSt; local: Gallery
|
|
|
398
432
|
}
|
|
399
433
|
>
|
|
400
434
|
<img src={previewUrl} alt="latent preview" />
|
|
435
|
+
<BlurHint st={p.st} />
|
|
401
436
|
</button>
|
|
402
437
|
) : null}
|
|
403
438
|
<div className="progress-track over">
|
|
@@ -424,15 +459,21 @@ export const Gallery = observer(function Gallery(p: { st: WebSt; compact?: boole
|
|
|
424
459
|
// fit: one per row at the panel's width; grid: the slider's size, wrapping. The corner
|
|
425
460
|
// placement keeps its own compact look
|
|
426
461
|
<div
|
|
427
|
-
className={`gallery${p.st.blurResults ? ' blur' : ''}${p.compact === true ? '' :
|
|
462
|
+
className={`gallery${p.st.blurResults ? ' blur' : ''}${p.compact === true ? '' : ' by-cols'}`}
|
|
463
|
+
style={
|
|
464
|
+
p.compact === true ? undefined : { gridTemplateColumns: `repeat(${p.st.resultsColumns}, minmax(0, 1fr))` }
|
|
465
|
+
}
|
|
428
466
|
>
|
|
429
467
|
<RunningCard st={p.st} local={local} />
|
|
430
468
|
{/* the count and clear-all moved onto the run line beside the generate button: two
|
|
431
469
|
headers for one idea is a header too many */}
|
|
432
470
|
{results.map((r) => (
|
|
433
|
-
<div
|
|
471
|
+
<div
|
|
472
|
+
key={r.promptId}
|
|
473
|
+
className={r.images.some((img) => img.url != null) ? 'run-card has-image' : 'run-card'}
|
|
474
|
+
>
|
|
434
475
|
<div className="meta">
|
|
435
|
-
<span>
|
|
476
|
+
<span className="meta-text">
|
|
436
477
|
{r.at} · {r.module}/{r.draft} · {(r.durationMs / 1000).toFixed(1)}s
|
|
437
478
|
{Object.entries(r.seeds).map(([k, seed]) => ` · ${k}: ${seed}`)}
|
|
438
479
|
</span>
|
|
@@ -463,15 +504,9 @@ export const Gallery = observer(function Gallery(p: { st: WebSt; compact?: boole
|
|
|
463
504
|
})
|
|
464
505
|
}}
|
|
465
506
|
>
|
|
466
|
-
<img
|
|
467
|
-
|
|
468
|
-
|
|
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
|
-
/>
|
|
507
|
+
<img src={img.url} alt={img.filename} loading="lazy" />
|
|
508
|
+
<BlurHint st={p.st} />
|
|
509
|
+
<EphemeralPill out={img} />
|
|
475
510
|
</button>
|
|
476
511
|
{/* the EMBEDDING page's buttons (host protocol): what it does with the
|
|
477
512
|
image is its business — send it somewhere, keep it as something */}
|
|
@@ -509,11 +544,26 @@ export const Gallery = observer(function Gallery(p: { st: WebSt; compact?: boole
|
|
|
509
544
|
</div>
|
|
510
545
|
) : (
|
|
511
546
|
<div key={img.filename} className="noimg">
|
|
512
|
-
{img.filename} (not saved
|
|
547
|
+
{img.filename} (not saved, and no longer in memory)
|
|
548
|
+
</div>
|
|
549
|
+
),
|
|
550
|
+
)}
|
|
551
|
+
{(r.audios ?? []).map((a, ix) =>
|
|
552
|
+
a.url != null ? (
|
|
553
|
+
<div key={`${r.promptId}-audio-${ix}`} className="audio-cell">
|
|
554
|
+
<audio controls preload="metadata" src={a.url} />
|
|
555
|
+
<a className="hint" href={a.url} download={a.filename}>
|
|
556
|
+
{a.filename}
|
|
557
|
+
</a>
|
|
558
|
+
<EphemeralPill out={a} />
|
|
559
|
+
</div>
|
|
560
|
+
) : (
|
|
561
|
+
<div key={`${r.promptId}-audio-${ix}`} className="noimg">
|
|
562
|
+
{a.filename} (not saved, and no longer in memory)
|
|
513
563
|
</div>
|
|
514
564
|
),
|
|
515
565
|
)}
|
|
516
|
-
{r.images.length === 0 && (r.texts ?? []).length === 0 ? (
|
|
566
|
+
{r.images.length === 0 && (r.texts ?? []).length === 0 && (r.audios ?? []).length === 0 ? (
|
|
517
567
|
<div className="noimg">no outputs</div>
|
|
518
568
|
) : null}
|
|
519
569
|
</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,21 @@ 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'
|
|
58
|
+
| 'memory'
|
|
59
|
+
| 'keyboard'
|
|
48
60
|
|
|
49
61
|
/** 24x24 viewBox paths, stroked (fill: none) unless the shape reads better solid */
|
|
50
62
|
const PATHS: Record<IconName, ReactNode> = {
|
|
51
63
|
close: <path d="M6 6l12 12M18 6L6 18" />,
|
|
64
|
+
check: <path d="M5 12.5l4.5 4.5L19 7.5" />,
|
|
52
65
|
trash: <path d="M4 7h16M10 7V5h4v2M6 7l1 12h10l1-12M10 11v5M14 11v5" />,
|
|
53
66
|
copy: <path d="M9 9h10v10H9zM5 15V5h10" />,
|
|
54
67
|
external: <path d="M14 5h5v5M19 5l-8 8M18 14v5H5V6h5" />,
|
|
@@ -78,6 +91,7 @@ const PATHS: Record<IconName, ReactNode> = {
|
|
|
78
91
|
),
|
|
79
92
|
play: <path d="M7 4l13 8-13 8z" fill="currentColor" stroke="none" />,
|
|
80
93
|
pause: <path d="M8 5v14M16 5v14" />,
|
|
94
|
+
stop: <rect x="6" y="6" width="12" height="12" rx="1.5" fill="currentColor" stroke="none" />,
|
|
81
95
|
save: <path d="M5 4h11l3 3v13H5zM8 4v6h7V4M8 20v-6h8v6" />,
|
|
82
96
|
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
97
|
'panel-off': (
|
|
@@ -151,6 +165,36 @@ const PATHS: Record<IconName, ReactNode> = {
|
|
|
151
165
|
search: <path d="M10.5 4a6.5 6.5 0 110 13 6.5 6.5 0 010-13zM15.5 15.5L20 20" />,
|
|
152
166
|
history: <path d="M4 12a8 8 0 102.3-5.6M4 4v4h4M12 8v4l3 2" />,
|
|
153
167
|
dot: <circle cx="12" cy="12" r="5" fill="currentColor" stroke="none" />,
|
|
168
|
+
audio: <path d="M3 12h2M7 8v8M11 4v16M15 7v10M19 10v4M21 12h0" />,
|
|
169
|
+
video: (
|
|
170
|
+
<>
|
|
171
|
+
<rect x="3" y="6" width="13" height="12" rx="2" />
|
|
172
|
+
<path d="M16 10l5-3v10l-5-3z" />
|
|
173
|
+
</>
|
|
174
|
+
),
|
|
175
|
+
workflow: (
|
|
176
|
+
<>
|
|
177
|
+
<rect x="3" y="4" width="6" height="5" rx="1.2" />
|
|
178
|
+
<rect x="15" y="4" width="6" height="5" rx="1.2" />
|
|
179
|
+
<rect x="9" y="15" width="6" height="5" rx="1.2" />
|
|
180
|
+
<path d="M6 9v2.5a1.5 1.5 0 001.5 1.5h9a1.5 1.5 0 001.5-1.5V9M12 13v2" />
|
|
181
|
+
</>
|
|
182
|
+
),
|
|
183
|
+
draft: <path d="M6 3h8l4 4v14H6zM14 3v4h4M9 12h6M9 16h4" />,
|
|
184
|
+
folder: (
|
|
185
|
+
<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" />
|
|
186
|
+
),
|
|
187
|
+
'folder-tree': <path d="M4 4v14a2 2 0 002 2h2M4 10h4M10 7h3l1 1.5h6V12H10zM10 16h3l1 1.5h6V21H10z" />,
|
|
188
|
+
server: (
|
|
189
|
+
<>
|
|
190
|
+
<rect x="3" y="4" width="18" height="7" rx="1.5" />
|
|
191
|
+
<rect x="3" y="13" width="18" height="7" rx="1.5" />
|
|
192
|
+
<path d="M7 7.5h.01M7 16.5h.01M11 7.5h6M11 16.5h6" />
|
|
193
|
+
</>
|
|
194
|
+
),
|
|
195
|
+
menu: <path d="M4 7h16M4 12h16M4 17h16" />,
|
|
196
|
+
memory: <path d="M6 6h12v12H6zM9 9h6v6H9zM9 3v3M15 3v3M9 18v3M15 18v3M3 9h3M3 15h3M18 9h3M18 15h3" />,
|
|
197
|
+
keyboard: <path d="M3 6h18v12H3zM7 10h.01M11 10h.01M15 10h.01M19 10h.01M8 14h8" />,
|
|
154
198
|
}
|
|
155
199
|
|
|
156
200
|
/** `size` is a multiplier of the surrounding font size, so icons scale with their button */
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// beside blur: how much of the server's memory budget the unsaved outputs hold, and a popover to
|
|
2
|
+
// change that budget. The server drops the oldest unsaved outputs first once it is full
|
|
3
|
+
import {
|
|
4
|
+
autoUpdate,
|
|
5
|
+
flip,
|
|
6
|
+
FloatingPortal,
|
|
7
|
+
offset,
|
|
8
|
+
shift,
|
|
9
|
+
useDismiss,
|
|
10
|
+
useFloating,
|
|
11
|
+
useInteractions,
|
|
12
|
+
} from '@floating-ui/react'
|
|
13
|
+
import { observer } from 'mobx-react-lite'
|
|
14
|
+
import { useState } from 'react'
|
|
15
|
+
import { Icon } from 'src/cli/serve/web/components/Icon.tsx'
|
|
16
|
+
import { formatMb } from 'src/cli/serve/web/state/keptResults.ts'
|
|
17
|
+
import type { WebSt } from 'src/cli/serve/web/state/WebSt.ts'
|
|
18
|
+
|
|
19
|
+
const BUDGET_CHOICES_MB = [25, 50, 100, 250, 500, 1000, 2000]
|
|
20
|
+
|
|
21
|
+
export const MemoryBudgetButton = observer(function MemoryBudgetButton(p: { st: WebSt }) {
|
|
22
|
+
const [anchor, setAnchor] = useState<HTMLElement | null>(null)
|
|
23
|
+
const [open, setOpen] = useState(false)
|
|
24
|
+
const memory = p.st.run.memory
|
|
25
|
+
const budgetMb = p.st.settings.memoryBudgetMb
|
|
26
|
+
return (
|
|
27
|
+
<>
|
|
28
|
+
<button
|
|
29
|
+
type="button"
|
|
30
|
+
ref={setAnchor}
|
|
31
|
+
className={open ? 'sel' : ''}
|
|
32
|
+
data-tip="unsaved results kept in the server memory: click to change the budget"
|
|
33
|
+
onClick={() => {
|
|
34
|
+
if (!open) void p.st.run.refreshMemory()
|
|
35
|
+
setOpen(!open)
|
|
36
|
+
}}
|
|
37
|
+
>
|
|
38
|
+
<Icon name="memory" />
|
|
39
|
+
{memory == null ? `${budgetMb} MB` : `${formatMb(memory.usedBytes)}/${budgetMb} MB`}
|
|
40
|
+
</button>
|
|
41
|
+
{open && anchor != null ? <MemoryMenu st={p.st} anchor={anchor} onClose={() => setOpen(false)} /> : null}
|
|
42
|
+
</>
|
|
43
|
+
)
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
const MemoryMenu = observer(function MemoryMenu(p: { st: WebSt; anchor: HTMLElement; onClose: () => void }) {
|
|
47
|
+
const { refs, floatingStyles, context } = useFloating({
|
|
48
|
+
open: true,
|
|
49
|
+
onOpenChange: (open) => {
|
|
50
|
+
if (!open) p.onClose()
|
|
51
|
+
},
|
|
52
|
+
placement: 'bottom-end',
|
|
53
|
+
middleware: [offset(4), flip(), shift({ padding: 8 })],
|
|
54
|
+
whileElementsMounted: autoUpdate,
|
|
55
|
+
elements: { reference: p.anchor },
|
|
56
|
+
})
|
|
57
|
+
const { getFloatingProps } = useInteractions([useDismiss(context)])
|
|
58
|
+
const memory = p.st.run.memory
|
|
59
|
+
const budgetMb = p.st.settings.memoryBudgetMb
|
|
60
|
+
// a hand-written budget off the list still shows as the selected value
|
|
61
|
+
const choices = BUDGET_CHOICES_MB.includes(budgetMb)
|
|
62
|
+
? BUDGET_CHOICES_MB
|
|
63
|
+
: [...BUDGET_CHOICES_MB, budgetMb].sort((a, b) => a - b)
|
|
64
|
+
return (
|
|
65
|
+
<FloatingPortal>
|
|
66
|
+
<div ref={refs.setFloating} style={floatingStyles} className="tab-menu memory-menu" {...getFloatingProps()}>
|
|
67
|
+
<div className="menu-row">
|
|
68
|
+
<Icon name="memory" />
|
|
69
|
+
<span className="menu-value">server memory</span>
|
|
70
|
+
</div>
|
|
71
|
+
<p className="hint memory-note">
|
|
72
|
+
Unsaved results live in the serve process only: a page reload shows them again, a server restart loses
|
|
73
|
+
them. Past the budget, the oldest go first.
|
|
74
|
+
</p>
|
|
75
|
+
<label className="menu-row">
|
|
76
|
+
<span>budget</span>
|
|
77
|
+
<select
|
|
78
|
+
className="menu-select"
|
|
79
|
+
value={budgetMb}
|
|
80
|
+
onChange={(e) => void p.st.setMemoryBudget(Number(e.target.value))}
|
|
81
|
+
>
|
|
82
|
+
{choices.map((mb) => (
|
|
83
|
+
<option key={mb} value={mb}>
|
|
84
|
+
{mb >= 1000 ? `${mb / 1000} GB` : `${mb} MB`}
|
|
85
|
+
</option>
|
|
86
|
+
))}
|
|
87
|
+
</select>
|
|
88
|
+
</label>
|
|
89
|
+
<div className="hint memory-note">
|
|
90
|
+
{memory == null
|
|
91
|
+
? 'usage not read yet'
|
|
92
|
+
: `${formatMb(memory.usedBytes)} MB used by ${memory.outputs} unsaved output${memory.outputs === 1 ? '' : 's'}, ${memory.runs} run${memory.runs === 1 ? '' : 's'} kept`}
|
|
93
|
+
</div>
|
|
94
|
+
{p.st.savingError != null ? <div className="error memory-note">{p.st.savingError}</div> : null}
|
|
95
|
+
</div>
|
|
96
|
+
</FloatingPortal>
|
|
97
|
+
)
|
|
98
|
+
})
|
|
@@ -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>
|