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
|
@@ -57,7 +57,8 @@ export const NumberControl = observer(function NumberControl(p: { v: VarSt }) {
|
|
|
57
57
|
{min != null && max != null ? (
|
|
58
58
|
<input
|
|
59
59
|
type="range"
|
|
60
|
-
|
|
60
|
+
className="num-range"
|
|
61
|
+
style={{ flex: 1, minWidth: 120, backgroundImage: rangeFill(num, min, max) }}
|
|
61
62
|
value={num}
|
|
62
63
|
min={min}
|
|
63
64
|
max={max}
|
|
@@ -70,6 +71,12 @@ export const NumberControl = observer(function NumberControl(p: { v: VarSt }) {
|
|
|
70
71
|
)
|
|
71
72
|
})
|
|
72
73
|
|
|
74
|
+
// the accent up to the value, drawn on the input: the track itself is transparent
|
|
75
|
+
function rangeFill(num: number, min: number, max: number): string {
|
|
76
|
+
const pct = max > min ? ((Math.min(max, Math.max(min, num)) - min) / (max - min)) * 100 : 0
|
|
77
|
+
return `linear-gradient(90deg, var(--accent) ${pct}%, var(--border) ${pct}%)`
|
|
78
|
+
}
|
|
79
|
+
|
|
73
80
|
export const ToggleControl = observer(function ToggleControl(p: { v: VarSt }) {
|
|
74
81
|
return (
|
|
75
82
|
<label className="row-inline" style={{ cursor: 'pointer' }}>
|
|
@@ -16,6 +16,7 @@ import { MenuButton, MenuItem } from 'src/cli/serve/web/components/MenuButton.ts
|
|
|
16
16
|
import { logWebError } from 'src/cli/serve/web/logWeb.ts'
|
|
17
17
|
import { observer, useLocalObservable } from 'mobx-react-lite'
|
|
18
18
|
import { useEffect, useRef, useState, type DragEvent, type ReactNode } from 'react'
|
|
19
|
+
import { isNewJump } from 'src/cli/serve/web/state/shortcuts.ts'
|
|
19
20
|
import { fetchLoraAbout, fetchLoraInfo, loraPreviewSrc, type LoraAbout, type LoraInfo } from 'src/cli/serve/web/api.ts'
|
|
20
21
|
import type { LoraStrength } from 'src/vars/loraEntry.ts'
|
|
21
22
|
import type { VarSt } from 'src/cli/serve/web/state/FormSt.ts'
|
|
@@ -356,8 +357,8 @@ export const LorasControl = observer(function LorasControl(p: {
|
|
|
356
357
|
</button>
|
|
357
358
|
<input
|
|
358
359
|
type="range"
|
|
359
|
-
min={
|
|
360
|
-
max={
|
|
360
|
+
min={0}
|
|
361
|
+
max={1}
|
|
361
362
|
step={0.05}
|
|
362
363
|
value={value}
|
|
363
364
|
onChange={(e) => write(which, parseFloat(e.target.value))}
|
|
@@ -392,8 +393,10 @@ export const LorasControl = observer(function LorasControl(p: {
|
|
|
392
393
|
// ⌘O: a NEW jump opens the picker on the first section, as its own `add` would
|
|
393
394
|
const jump = p.st.jump
|
|
394
395
|
const firstIx = sections[0]?.ix ?? -1
|
|
396
|
+
const seenJump = useRef(jump?.seq ?? 0)
|
|
395
397
|
useEffect(() => {
|
|
396
|
-
if (!p.jumpTarget || jump
|
|
398
|
+
if (!p.jumpTarget || !isNewJump(jump, 'loras', seenJump.current)) return
|
|
399
|
+
seenJump.current = jump?.seq ?? 0
|
|
397
400
|
local.openFor(firstIx)
|
|
398
401
|
}, [jump, p.jumpTarget, firstIx, local])
|
|
399
402
|
|
|
@@ -459,11 +462,12 @@ export const LorasControl = observer(function LorasControl(p: {
|
|
|
459
462
|
filterRef.current?.select()
|
|
460
463
|
}
|
|
461
464
|
|
|
462
|
-
//
|
|
463
|
-
// popup's grid
|
|
464
|
-
const
|
|
465
|
-
const
|
|
466
|
-
const
|
|
465
|
+
// two size factors, each with its own slider: the form's cards follow formScale, the
|
|
466
|
+
// popup's grid follows popupScale. 168/130 and 120/110 are the base card and image sizes
|
|
467
|
+
const formScale = p.st.loraFormScale
|
|
468
|
+
const popupScale = p.st.loraPopupScale
|
|
469
|
+
const cardWidth = Math.round(168 * formScale)
|
|
470
|
+
const gridMin = Math.round(120 * popupScale)
|
|
467
471
|
const thumb = (name: string, height?: number): ReactNode => {
|
|
468
472
|
if (!showImages) return null
|
|
469
473
|
const style = height == null ? undefined : { height }
|
|
@@ -491,19 +495,20 @@ export const LorasControl = observer(function LorasControl(p: {
|
|
|
491
495
|
</span>
|
|
492
496
|
)
|
|
493
497
|
|
|
494
|
-
/**
|
|
495
|
-
const sizeSlider =
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
498
|
+
/** an image size, a small slider: only while images are shown */
|
|
499
|
+
const sizeSlider = (where: string, scale: number, set: (v: number) => void): ReactNode =>
|
|
500
|
+
showImages ? (
|
|
501
|
+
<input
|
|
502
|
+
type="range"
|
|
503
|
+
className="setting-range"
|
|
504
|
+
min={0.6}
|
|
505
|
+
max={2}
|
|
506
|
+
step={0.05}
|
|
507
|
+
value={scale}
|
|
508
|
+
data-tip={`lora image size in the ${where} ×${scale.toFixed(2)}`}
|
|
509
|
+
onChange={(e) => set(parseFloat(e.target.value))}
|
|
510
|
+
/>
|
|
511
|
+
) : null
|
|
507
512
|
|
|
508
513
|
const visibilityToggles = (
|
|
509
514
|
<>
|
|
@@ -577,7 +582,7 @@ export const LorasControl = observer(function LorasControl(p: {
|
|
|
577
582
|
<label className="menu-item menu-range">
|
|
578
583
|
<span className="menu-check" />
|
|
579
584
|
size
|
|
580
|
-
{sizeSlider}
|
|
585
|
+
{sizeSlider('form', formScale, (v) => p.st.setLoraFormScale(v))}
|
|
581
586
|
</label>
|
|
582
587
|
) : null}
|
|
583
588
|
<div className="menu-sep" />
|
|
@@ -735,7 +740,7 @@ export const LorasControl = observer(function LorasControl(p: {
|
|
|
735
740
|
data-tip={`${name}\nclick to ${isOn(sec, name) ? 'pause' : 'resume'}, click the title for details`}
|
|
736
741
|
onClick={() => toggleOn(sec, name, !isOn(sec, name))}
|
|
737
742
|
>
|
|
738
|
-
{thumb(name, Math.round(130 *
|
|
743
|
+
{thumb(name, Math.round(130 * formScale))}
|
|
739
744
|
{showImages && !isOn(sec, name) ? pausedMark : null}
|
|
740
745
|
</button>
|
|
741
746
|
<button
|
|
@@ -836,7 +841,7 @@ export const LorasControl = observer(function LorasControl(p: {
|
|
|
836
841
|
{/* the display toggles first, the search in the middle, close alone at the end */}
|
|
837
842
|
<div className="modal-head">
|
|
838
843
|
<span className="btn-group">{visibilityToggles}</span>
|
|
839
|
-
{sizeSlider}
|
|
844
|
+
{sizeSlider('popup', popupScale, (v) => p.st.setLoraPopupScale(v))}
|
|
840
845
|
<input
|
|
841
846
|
ref={filterRef}
|
|
842
847
|
type="text"
|
|
@@ -961,7 +966,7 @@ export const LorasControl = observer(function LorasControl(p: {
|
|
|
961
966
|
}}
|
|
962
967
|
>
|
|
963
968
|
<span className="thumb-box">
|
|
964
|
-
{thumb(name, Math.round(110 *
|
|
969
|
+
{thumb(name, Math.round(110 * popupScale))}
|
|
965
970
|
{showImages && picked && !on ? pausedMark : null}
|
|
966
971
|
</span>
|
|
967
972
|
<div className="lora-label">
|
|
@@ -153,8 +153,11 @@ function applyTag(insert: string): Completion['apply'] {
|
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
-
/** the options for one search text: lora words containing it, then the tag list's hits
|
|
157
|
-
|
|
156
|
+
/** the options for one search text: lora words containing it, then the tag list's hits. Only
|
|
157
|
+
* for a prompt that declares a tag list (v.prompt(…, { tags })): completion is opt in per
|
|
158
|
+
* workflow, the loras words included */
|
|
159
|
+
export async function optionsFor(c: PromptEditorCtx, text: string, signal: AbortSignal): Promise<Completion[]> {
|
|
160
|
+
if (c.tags == null) return []
|
|
158
161
|
const q = text.trim().toLowerCase()
|
|
159
162
|
const options: Completion[] = []
|
|
160
163
|
const seenWords = new Set<string>()
|
|
@@ -164,7 +167,7 @@ async function optionsFor(c: PromptEditorCtx, text: string, signal: AbortSignal)
|
|
|
164
167
|
seenWords.add(lower)
|
|
165
168
|
options.push({ label: w.word, detail: w.source, type: 'lora', boost: 50, apply: applyTag(w.word) })
|
|
166
169
|
}
|
|
167
|
-
if (
|
|
170
|
+
if (q === '') return options
|
|
168
171
|
const hits = await c.searchTags(text.trim(), signal)
|
|
169
172
|
c.onTagError(null)
|
|
170
173
|
hits.forEach((h, ix) => {
|
|
@@ -221,8 +224,10 @@ const theme = EditorView.theme(
|
|
|
221
224
|
'.cm-content': { padding: '6px 0', caretColor: 'var(--text)' },
|
|
222
225
|
'.cm-line': { padding: '0 8px' },
|
|
223
226
|
'.cm-cursor': { borderLeftColor: 'var(--text)' },
|
|
227
|
+
// opaque on purpose: webkit blends a translucent selection down to near the background
|
|
224
228
|
'&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection': {
|
|
225
|
-
background: '
|
|
229
|
+
background: '#c3d1f4 !important',
|
|
230
|
+
color: '#000 !important',
|
|
226
231
|
},
|
|
227
232
|
'.cm-placeholder': { color: 'var(--dim)' },
|
|
228
233
|
'.pe-comment': { color: 'var(--dim)', fontStyle: 'italic' },
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
// normalizeSettings/nextPresetName are PURE and headless-tested.
|
|
8
8
|
import { makeAutoObservable, reaction, runInAction, type IReactionDisposer } from 'mobx'
|
|
9
9
|
import { stringMap } from 'src/utils/stringMap.ts'
|
|
10
|
+
import { copyName } from 'src/utils/copyName.ts'
|
|
10
11
|
import {
|
|
11
12
|
deleteLlmConfig,
|
|
12
13
|
deletePromptEnhancer,
|
|
@@ -405,7 +406,14 @@ export class EnhancerSt {
|
|
|
405
406
|
|
|
406
407
|
duplicateConfig(): void {
|
|
407
408
|
const c = this.configEntry
|
|
408
|
-
if (c != null)
|
|
409
|
+
if (c != null)
|
|
410
|
+
this.addConfig(
|
|
411
|
+
copyName(
|
|
412
|
+
c.name,
|
|
413
|
+
this.configs.map((x) => x.name),
|
|
414
|
+
),
|
|
415
|
+
c.config,
|
|
416
|
+
)
|
|
409
417
|
}
|
|
410
418
|
|
|
411
419
|
/** rename = write the new file, delete the old one (the filename IS the identity) */
|
|
@@ -568,7 +576,14 @@ export class EnhancerSt {
|
|
|
568
576
|
|
|
569
577
|
duplicatePreset(): void {
|
|
570
578
|
const p = this.preset
|
|
571
|
-
if (p != null)
|
|
579
|
+
if (p != null)
|
|
580
|
+
this.addPreset(
|
|
581
|
+
copyName(
|
|
582
|
+
p.name,
|
|
583
|
+
this.presets.map((x) => x.name),
|
|
584
|
+
),
|
|
585
|
+
p.text,
|
|
586
|
+
)
|
|
572
587
|
}
|
|
573
588
|
|
|
574
589
|
/** rename = write the new file, delete the old one (the filename IS the identity) */
|
|
@@ -52,6 +52,21 @@ export class VarSt {
|
|
|
52
52
|
this.uploadedUrl = url
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
/** the workflow's declared default, in the shape the controls hold */
|
|
56
|
+
get defaultValue(): unknown {
|
|
57
|
+
return normalizeInitial(this.desc, this.desc.default)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** by value: a size or a choice list is a fresh object every time */
|
|
61
|
+
get isAtDefault(): boolean {
|
|
62
|
+
return JSON.stringify(this.value) === JSON.stringify(this.defaultValue)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** back to what the workflow declares; an edit like any other (autosaved, revertable) */
|
|
66
|
+
resetToDefault(): void {
|
|
67
|
+
this.set(this.defaultValue)
|
|
68
|
+
}
|
|
69
|
+
|
|
55
70
|
revert(): void {
|
|
56
71
|
this.value = this.initial
|
|
57
72
|
this.dirty = false
|
|
@@ -76,7 +91,7 @@ export class FormSt {
|
|
|
76
91
|
private disposers: IReactionDisposer[] = []
|
|
77
92
|
/** saves are chained so two PUTs can never land out of order */
|
|
78
93
|
private saveChain: Promise<boolean> = Promise.resolve(true)
|
|
79
|
-
/** the values json the server last CONFIRMED — what is really on disk */
|
|
94
|
+
/** the values json the server last CONFIRMED — what is really on disk. Observable: `unsaved` reads it */
|
|
80
95
|
private lastSaved: string
|
|
81
96
|
/** the values json last HANDED to the chain, confirmed or still in flight. save() no-ops
|
|
82
97
|
* against this one, never against lastSaved: while a PUT is open the disk does not hold
|
|
@@ -120,7 +135,7 @@ export class FormSt {
|
|
|
120
135
|
host: false,
|
|
121
136
|
disposers: false,
|
|
122
137
|
saveChain: false,
|
|
123
|
-
lastSaved:
|
|
138
|
+
lastSaved: true,
|
|
124
139
|
lastQueued: false,
|
|
125
140
|
queueSeq: false,
|
|
126
141
|
onSettled: false,
|
|
@@ -348,6 +363,11 @@ export class FormSt {
|
|
|
348
363
|
found.source.set(updateLora(found.value, lora, withLora(loraSetting(found.value, lora), { mute })))
|
|
349
364
|
}
|
|
350
365
|
|
|
366
|
+
/** the values on screen are not on disk yet: inside the autosave debounce, or a PUT still open */
|
|
367
|
+
get unsaved(): boolean {
|
|
368
|
+
return JSON.stringify(this.valuesJSON()) !== this.lastSaved
|
|
369
|
+
}
|
|
370
|
+
|
|
351
371
|
get dirtyCount(): number {
|
|
352
372
|
return this.vars.filter((v) => v.dirty).length
|
|
353
373
|
}
|
|
@@ -25,7 +25,9 @@ export class OmniboxSt {
|
|
|
25
25
|
const ix =
|
|
26
26
|
current == null
|
|
27
27
|
? -1
|
|
28
|
-
: this.results.findIndex(
|
|
28
|
+
: this.results.findIndex(
|
|
29
|
+
(e) => e.kind === 'draft' && e.module === current.moduleKey && e.draft === current.draft,
|
|
30
|
+
)
|
|
29
31
|
this.cursor = Math.max(0, ix)
|
|
30
32
|
}
|
|
31
33
|
|
|
@@ -3,10 +3,23 @@
|
|
|
3
3
|
// ever reaches the host: queued prompts must be clearable, singly or
|
|
4
4
|
// all). Progress + latent preview are polled ~700ms while a prompt is in flight
|
|
5
5
|
import { makeAutoObservable, observableShallow, runInAction } from 'mobx'
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
deleteKeptResults,
|
|
8
|
+
fetchKeptResults,
|
|
9
|
+
fetchRunStatus,
|
|
10
|
+
postGenerate,
|
|
11
|
+
type GenerateOk,
|
|
12
|
+
type MemoryUsage,
|
|
13
|
+
} from 'src/cli/serve/web/api.ts'
|
|
14
|
+
import { mergeKept } from 'src/cli/serve/web/state/keptResults.ts'
|
|
15
|
+
import { logWebError } from 'src/cli/serve/web/logWeb.ts'
|
|
7
16
|
|
|
8
17
|
export type RunResult = GenerateOk & { at: string }
|
|
9
18
|
|
|
19
|
+
function asRunResult(r: GenerateOk): RunResult {
|
|
20
|
+
return { ...r, at: new Date(r.finishedAt ?? Date.now()).toLocaleTimeString() }
|
|
21
|
+
}
|
|
22
|
+
|
|
10
23
|
/** one enqueued prompt. `sent` marks the one on the host — that one is past cancelling */
|
|
11
24
|
export type QueueEntry = {
|
|
12
25
|
id: string
|
|
@@ -24,6 +37,8 @@ export class RunSt {
|
|
|
24
37
|
queue: QueueEntry[] = []
|
|
25
38
|
error: string | null = null
|
|
26
39
|
results: RunResult[] = []
|
|
40
|
+
/** the serve process's unsaved outputs against its budget. null = not read yet */
|
|
41
|
+
memory: MemoryUsage | null = null
|
|
27
42
|
progressPercent: number | null = null
|
|
28
43
|
/** what the host is doing right now, in the node's own unit — `TextGenerate 427/1024`.
|
|
29
44
|
* A text graph has no latent preview and no image, so this is all there is to watch */
|
|
@@ -71,16 +86,58 @@ export class RunSt {
|
|
|
71
86
|
this.queue = this.queue.filter((e) => e.id !== id || e.sent)
|
|
72
87
|
}
|
|
73
88
|
|
|
89
|
+
dismissError(): void {
|
|
90
|
+
this.error = null
|
|
91
|
+
}
|
|
92
|
+
|
|
74
93
|
clearQueue(): void {
|
|
75
94
|
this.queue = this.queue.filter((e) => e.sent)
|
|
76
95
|
}
|
|
77
96
|
|
|
97
|
+
/** the server forgets it too: a reload must not bring back what was removed */
|
|
78
98
|
remove(promptId: string): void {
|
|
79
99
|
this.results = this.results.filter((r) => r.promptId !== promptId)
|
|
100
|
+
void this.forget({ promptId })
|
|
80
101
|
}
|
|
81
102
|
|
|
82
103
|
clear(): void {
|
|
83
104
|
this.results = []
|
|
105
|
+
void this.forget({})
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** what the serve process kept: the last runs survive a page reload */
|
|
109
|
+
async loadKept(): Promise<void> {
|
|
110
|
+
try {
|
|
111
|
+
const kept = await fetchKeptResults()
|
|
112
|
+
runInAction(() => {
|
|
113
|
+
this.results = mergeKept(this.results, kept.runs.map(asRunResult))
|
|
114
|
+
this.memory = kept.memory
|
|
115
|
+
})
|
|
116
|
+
} catch (e) {
|
|
117
|
+
logWebError('could not read the kept results', e)
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
async refreshMemory(): Promise<void> {
|
|
122
|
+
try {
|
|
123
|
+
const kept = await fetchKeptResults()
|
|
124
|
+
runInAction(() => {
|
|
125
|
+
this.memory = kept.memory
|
|
126
|
+
})
|
|
127
|
+
} catch (e) {
|
|
128
|
+
logWebError('could not read the memory usage', e)
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
private async forget(p: { promptId?: string }): Promise<void> {
|
|
133
|
+
try {
|
|
134
|
+
const reply = await deleteKeptResults(p)
|
|
135
|
+
runInAction(() => {
|
|
136
|
+
this.memory = reply.memory
|
|
137
|
+
})
|
|
138
|
+
} catch (e) {
|
|
139
|
+
logWebError('could not delete the kept result', e)
|
|
140
|
+
}
|
|
84
141
|
}
|
|
85
142
|
|
|
86
143
|
/** one prompt at a time: a queued entry stays cancellable until its turn comes */
|
|
@@ -105,9 +162,10 @@ export class RunSt {
|
|
|
105
162
|
try {
|
|
106
163
|
const result = await postGenerate(next)
|
|
107
164
|
runInAction(() => {
|
|
108
|
-
// capped: full-size <img>s per run would eat the tab
|
|
109
|
-
this.results = [
|
|
165
|
+
// capped like the server's list: full-size <img>s per run would eat the tab
|
|
166
|
+
this.results = mergeKept([asRunResult(result)], this.results)
|
|
110
167
|
})
|
|
168
|
+
void this.refreshMemory()
|
|
111
169
|
// named, because the panel may be on another draft by the time this resolves
|
|
112
170
|
this.onSeeds?.({ module: next.module, draft: next.draft, seeds: result.seeds })
|
|
113
171
|
} catch (e) {
|