comfy-ts 2.13.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.
Files changed (37) hide show
  1. package/dist/cli.js +3 -3
  2. package/dist/index.cjs +1 -1
  3. package/dist/index.js +1 -1
  4. package/dist/{run-serve-DlRBv_Nk.js → run-serve-DUqcn0h3.js} +211 -59
  5. package/dist/run-serve-DUqcn0h3.js.map +1 -0
  6. package/dist/{run-tui-B5uxm2_l.js → run-tui-D-LaSqgB.js} +2 -2
  7. package/dist/{run-tui-B5uxm2_l.js.map → run-tui-D-LaSqgB.js.map} +1 -1
  8. package/dist/serve-web.js +146 -71
  9. package/dist/{state-CUp2J1Zy.js → state-BytbdZ8s.js} +2 -2
  10. package/dist/{state-CUp2J1Zy.js.map → state-BytbdZ8s.js.map} +1 -1
  11. package/dist/web.js +1 -1
  12. package/package.json +1 -1
  13. package/src/cli/serve/ServeApp.ts +90 -82
  14. package/src/cli/serve/resultHistory.ts +125 -0
  15. package/src/cli/serve/runError.ts +23 -0
  16. package/src/cli/serve/serveSettings.ts +17 -1
  17. package/src/cli/serve/web/api.ts +29 -2
  18. package/src/cli/serve/web/components/App.tsx +6 -4
  19. package/src/cli/serve/web/components/Gallery.tsx +33 -8
  20. package/src/cli/serve/web/components/Icon.tsx +4 -0
  21. package/src/cli/serve/web/components/MemoryBudget.tsx +98 -0
  22. package/src/cli/serve/web/components/RunError.tsx +19 -0
  23. package/src/cli/serve/web/components/ShortcutsModal.tsx +54 -0
  24. package/src/cli/serve/web/components/SideMenu.tsx +14 -0
  25. package/src/cli/serve/web/components/VarsForm.tsx +71 -53
  26. package/src/cli/serve/web/components/controls/BasicControls.tsx +8 -1
  27. package/src/cli/serve/web/components/controls/LorasControl.tsx +6 -3
  28. package/src/cli/serve/web/promptEditor/promptExtensions.ts +3 -1
  29. package/src/cli/serve/web/state/RunSt.ts +61 -3
  30. package/src/cli/serve/web/state/WebSt.ts +26 -2
  31. package/src/cli/serve/web/state/formRows.ts +9 -0
  32. package/src/cli/serve/web/state/keptResults.ts +26 -0
  33. package/src/cli/serve/web/state/lightbox.ts +17 -0
  34. package/src/cli/serve/web/state/shortcutCatalog.ts +100 -0
  35. package/src/cli/serve/web/state/shortcuts.ts +10 -0
  36. package/src/cli/serve/web/styles.ts +98 -24
  37. package/dist/run-serve-DlRBv_Nk.js.map +0 -1
@@ -4,15 +4,29 @@
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'
13
14
  import { MOD_KEY } from 'src/cli/serve/web/components/modKey.ts'
14
15
  import { SHORTCUT_KEYS } from 'src/cli/serve/web/state/shortcuts.ts'
15
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
+
16
30
  /** the unblur shortcut, said ON a blurred image: the place you look when you want it gone */
17
31
  const BlurHint = observer(function BlurHint(p: { st: WebSt }) {
18
32
  if (!p.st.blurResults) return null
@@ -97,14 +111,23 @@ const Lightbox = observer(function Lightbox(p: { st: WebSt; local: GalleryLocal
97
111
  previewTick: p.st.run.previewTick,
98
112
  results: p.st.run.results,
99
113
  })
114
+ // ↑ / ↓ step from what is SHOWN: a latent that became its image steps from that image
115
+ const url = box?.url
100
116
  useEffect(() => {
101
117
  if (target == null) return
102
118
  const onKey = (e: KeyboardEvent): void => {
103
- 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)
104
127
  }
105
128
  window.addEventListener('keydown', onKey)
106
129
  return () => window.removeEventListener('keydown', onKey)
107
- }, [target, p.local])
130
+ }, [target, url, p.local, p.st])
108
131
  // wheel is registered BY HAND, non-passive. React attaches wheel at the root as passive, so
109
132
  // its onWheel cannot preventDefault: zooming also scrolled the results column behind the
110
133
  // lightbox, and every tick logged a console error
@@ -170,7 +193,7 @@ const Lightbox = observer(function Lightbox(p: { st: WebSt; local: GalleryLocal
170
193
  {p.local.zoom.toFixed(1)}× · fit
171
194
  </button>
172
195
  ) : (
173
- <span className="hint">scroll to zoom</span>
196
+ <span className="hint">scroll to zoom, ↑ ↓ for the other images</span>
174
197
  )}
175
198
  {canCopy ? (
176
199
  <button type="button" onClick={copy}>
@@ -481,8 +504,9 @@ export const Gallery = observer(function Gallery(p: { st: WebSt; compact?: boole
481
504
  })
482
505
  }}
483
506
  >
484
- <img src={img.url} alt={img.filename} />
507
+ <img src={img.url} alt={img.filename} loading="lazy" />
485
508
  <BlurHint st={p.st} />
509
+ <EphemeralPill out={img} />
486
510
  </button>
487
511
  {/* the EMBEDDING page's buttons (host protocol): what it does with the
488
512
  image is its business — send it somewhere, keep it as something */}
@@ -520,7 +544,7 @@ export const Gallery = observer(function Gallery(p: { st: WebSt; compact?: boole
520
544
  </div>
521
545
  ) : (
522
546
  <div key={img.filename} className="noimg">
523
- {img.filename} (not saved locally — no preview)
547
+ {img.filename} (not saved, and no longer in memory)
524
548
  </div>
525
549
  ),
526
550
  )}
@@ -531,10 +555,11 @@ export const Gallery = observer(function Gallery(p: { st: WebSt; compact?: boole
531
555
  <a className="hint" href={a.url} download={a.filename}>
532
556
  {a.filename}
533
557
  </a>
558
+ <EphemeralPill out={a} />
534
559
  </div>
535
560
  ) : (
536
561
  <div key={`${r.promptId}-audio-${ix}`} className="noimg">
537
- {a.filename} (not kept — no preview)
562
+ {a.filename} (not saved, and no longer in memory)
538
563
  </div>
539
564
  ),
540
565
  )}
@@ -55,6 +55,8 @@ export type IconName =
55
55
  | 'folder-tree'
56
56
  | 'server'
57
57
  | 'menu'
58
+ | 'memory'
59
+ | 'keyboard'
58
60
 
59
61
  /** 24x24 viewBox paths, stroked (fill: none) unless the shape reads better solid */
60
62
  const PATHS: Record<IconName, ReactNode> = {
@@ -191,6 +193,8 @@ const PATHS: Record<IconName, ReactNode> = {
191
193
  </>
192
194
  ),
193
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" />,
194
198
  }
195
199
 
196
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
+ })
@@ -0,0 +1,19 @@
1
+ // the last failed run, in full: ComfyUI's message names the node and often a file path, so it
2
+ // wraps instead of being cut to one line. Under the prompt preview, where the eye is after a run
3
+ import { observer } from 'mobx-react-lite'
4
+ import { Icon } from 'src/cli/serve/web/components/Icon.tsx'
5
+ import type { WebSt } from 'src/cli/serve/web/state/WebSt.ts'
6
+
7
+ export const RunError = observer(function RunError(p: { st: WebSt }) {
8
+ const error = p.st.run.error
9
+ if (error == null) return null
10
+ return (
11
+ <div className="run-error-block" role="alert">
12
+ <Icon name="warn" />
13
+ <pre className="run-error-text">{error}</pre>
14
+ <button type="button" className="link danger" data-tip="dismiss" onClick={() => p.st.run.dismissError()}>
15
+ <Icon name="close" />
16
+ </button>
17
+ </div>
18
+ )
19
+ })
@@ -0,0 +1,54 @@
1
+ // every key the panel binds, one popup, opened from the menu
2
+ import { observer } from 'mobx-react-lite'
3
+ import { useEffect } from 'react'
4
+ import { Icon } from 'src/cli/serve/web/components/Icon.tsx'
5
+ import { shortcutCatalog } from 'src/cli/serve/web/state/shortcutCatalog.ts'
6
+ import type { WebSt } from 'src/cli/serve/web/state/WebSt.ts'
7
+
8
+ export const ShortcutsModal = observer(function ShortcutsModal(p: { st: WebSt }) {
9
+ const open = p.st.showShortcuts
10
+ useEffect(() => {
11
+ if (!open) return
12
+ const onKey = (e: KeyboardEvent): void => {
13
+ if (e.key === 'Escape') p.st.setShowShortcuts(false)
14
+ }
15
+ window.addEventListener('keydown', onKey)
16
+ return () => window.removeEventListener('keydown', onKey)
17
+ }, [open, p.st])
18
+ if (!open) return null
19
+ return (
20
+ <div className="modal-overlay top" onClick={() => p.st.setShowShortcuts(false)}>
21
+ <div className="modal shortcuts-modal" onClick={(e) => e.stopPropagation()}>
22
+ <div className="modal-head">
23
+ <Icon name="keyboard" />
24
+ <span className="shortcuts-title">shortcuts</span>
25
+ <button
26
+ type="button"
27
+ className="modal-close"
28
+ data-tip="close (esc)"
29
+ onClick={() => p.st.setShowShortcuts(false)}
30
+ >
31
+ <Icon name="close" />
32
+ </button>
33
+ </div>
34
+ <div className="shortcuts-body">
35
+ {shortcutCatalog().map((g) => (
36
+ <section key={g.title} className="shortcuts-group">
37
+ <div className="menu-title">{g.title}</div>
38
+ {g.rows.map((r) => (
39
+ <div key={r.what} className="shortcuts-row">
40
+ <span className="shortcuts-keys">
41
+ {r.keys.map((k) => (
42
+ <kbd key={k}>{k}</kbd>
43
+ ))}
44
+ </span>
45
+ <span>{r.what}</span>
46
+ </div>
47
+ ))}
48
+ </section>
49
+ ))}
50
+ </div>
51
+ </div>
52
+ </div>
53
+ )
54
+ })
@@ -368,6 +368,17 @@ export const MenuCards = observer(function MenuCards(p: { st: WebSt }) {
368
368
  ))}
369
369
  </div>
370
370
  </Section>
371
+ <Section title="help">
372
+ <button
373
+ type="button"
374
+ className="menu-row menu-action"
375
+ data-tip="every key the panel binds"
376
+ onClick={() => p.st.setShowShortcuts(true)}
377
+ >
378
+ <Icon name="keyboard" />
379
+ <span>shortcuts</span>
380
+ </button>
381
+ </Section>
371
382
  </div>
372
383
  )
373
384
  })
@@ -409,6 +420,9 @@ export const MenuRail = observer(function MenuRail(p: { st: WebSt; onExpand: ()
409
420
  <Icon name={it.icon} />
410
421
  </button>
411
422
  ))}
423
+ <button type="button" className="head-icon" data-tip="shortcuts" onClick={() => p.st.setShowShortcuts(true)}>
424
+ <Icon name="keyboard" />
425
+ </button>
412
426
  </div>
413
427
  )
414
428
  })
@@ -1,11 +1,13 @@
1
1
  // the var rows: each kind dispatches to its matching control (the point of the
2
2
  // web ui — architecture item 12) + the sticky run bar
3
3
  import { observer } from 'mobx-react-lite'
4
- import { useEffect, useRef, type ReactNode } from 'react'
4
+ import { useEffect, useRef, type HTMLAttributes, type ReactNode } from 'react'
5
5
  import { MOD_KEY } from 'src/cli/serve/web/components/modKey.ts'
6
+ import { RunError } from 'src/cli/serve/web/components/RunError.tsx'
6
7
  import { runChipText } from 'src/cli/serve/web/state/stableSlots.ts'
7
- import { jumpTargets, SHORTCUT_KEYS, shortcutOf } from 'src/cli/serve/web/state/shortcuts.ts'
8
+ import { isNewJump, jumpTargets, SHORTCUT_KEYS, shortcutOf } from 'src/cli/serve/web/state/shortcuts.ts'
8
9
  import { isPromptLanes } from 'src/vars/lanes.ts'
10
+ import { formRowNames, OUTPUT_ROW } from 'src/cli/serve/web/state/formRows.ts'
9
11
  import {
10
12
  ChoiceControl,
11
13
  NumberControl,
@@ -68,6 +70,36 @@ const VarControl = observer(function VarControl(p: {
68
70
  }
69
71
  })
70
72
 
73
+ /** a form row's reorder wiring: the row takes the drop, its label is the handle */
74
+ function rowDrag(p: { st: WebSt; module: string; names: readonly string[]; index: number }): {
75
+ row: Pick<HTMLAttributes<HTMLDivElement>, 'onDragOver' | 'onDrop'>
76
+ handle: Pick<HTMLAttributes<HTMLDivElement>, 'draggable' | 'onDragStart'>
77
+ } {
78
+ return {
79
+ row: {
80
+ onDragOver: (e) => {
81
+ // only a row drag: a file dropped on an image var must still reach its own handler
82
+ if (e.dataTransfer.types.includes('application/x-comfy-var')) e.preventDefault()
83
+ },
84
+ onDrop: (e) => {
85
+ const raw = e.dataTransfer.getData('application/x-comfy-var')
86
+ if (raw === '') return
87
+ e.preventDefault()
88
+ const from = Number(raw)
89
+ if (Number.isInteger(from) && from !== p.index)
90
+ p.st.moveVar({ module: p.module, names: p.names, from, to: p.index })
91
+ },
92
+ },
93
+ handle: {
94
+ draggable: true,
95
+ onDragStart: (e) => {
96
+ e.dataTransfer.effectAllowed = 'move'
97
+ e.dataTransfer.setData('application/x-comfy-var', String(p.index))
98
+ },
99
+ },
100
+ }
101
+ }
102
+
71
103
  const VarRow = observer(function VarRow(p: {
72
104
  v: VarSt
73
105
  host: string
@@ -83,8 +115,10 @@ const VarRow = observer(function VarRow(p: {
83
115
  const rowRef = useRef<HTMLDivElement>(null)
84
116
  const jump = p.st.jump
85
117
  const jumpKind = p.jumpKey == null ? null : p.v.desc.kind
118
+ const seenJump = useRef(jump?.seq ?? 0)
86
119
  useEffect(() => {
87
- if (jump == null || jumpKind !== 'prompt' || jump.kind !== 'prompt') return
120
+ if (jumpKind !== 'prompt' || !isNewJump(jump, 'prompt', seenJump.current)) return
121
+ seenJump.current = jump?.seq ?? 0
88
122
  const editor = rowRef.current?.querySelector<HTMLElement>('.cm-content')
89
123
  editor?.focus()
90
124
  editor?.scrollIntoView({ block: 'nearest' })
@@ -94,6 +128,7 @@ const VarRow = observer(function VarRow(p: {
94
128
  const ui = p.v.desc.ui
95
129
  const inactive = p.st.form?.inactiveReason(p.v) ?? null
96
130
  const wide = p.v.desc.kind === 'loras' || p.v.desc.kind === 'prompt'
131
+ const drag = rowDrag(p)
97
132
  return (
98
133
  <div
99
134
  ref={rowRef}
@@ -105,18 +140,7 @@ const VarRow = observer(function VarRow(p: {
105
140
  outline: ui?.border == null ? undefined : `1px solid ${ui.border}`,
106
141
  outlineOffset: ui?.border == null ? undefined : '-1px',
107
142
  }}
108
- onDragOver={(e) => {
109
- // only a row drag: a file dropped on an image var must still reach its own handler
110
- if (e.dataTransfer.types.includes('application/x-comfy-var')) e.preventDefault()
111
- }}
112
- onDrop={(e) => {
113
- const raw = e.dataTransfer.getData('application/x-comfy-var')
114
- if (raw === '') return
115
- e.preventDefault()
116
- const from = Number(raw)
117
- if (Number.isInteger(from) && from !== p.index)
118
- p.st.moveVar({ module: p.module, names: p.names, from, to: p.index })
119
- }}
143
+ {...drag.row}
120
144
  >
121
145
  {/* in the form's left gutter: back to the workflow's default. Always there (disabled at
122
146
  the default), so no row moves when a value changes */}
@@ -132,14 +156,7 @@ const VarRow = observer(function VarRow(p: {
132
156
  </button>
133
157
  {/* the LABEL is the handle: a separate grip was one more piece of permanent chrome
134
158
  for something the label itself can carry */}
135
- <div
136
- className={p.jumpKey == null ? 'var-label' : 'var-label has-kbd'}
137
- draggable
138
- onDragStart={(e) => {
139
- e.dataTransfer.effectAllowed = 'move'
140
- e.dataTransfer.setData('application/x-comfy-var', String(p.index))
141
- }}
142
- >
159
+ <div className={p.jumpKey == null ? 'var-label' : 'var-label has-kbd'} {...drag.handle}>
143
160
  {/* the kind is a TOOLTIP, not a second line: printed under every label it was a
144
161
  column of noise you read past, and it only ever answers a question you ask once */}
145
162
  {/* the (?) LEADS: labels are right-aligned against their control, so what trails a
@@ -280,12 +297,13 @@ export const GenerateButton = observer(function GenerateButton(p: { st: WebSt })
280
297
 
281
298
  /** where the generated images go: the same row shape as a var, because it is one more knob
282
299
  * of the run. The toggle and the folder are SERVER settings, so curl sees the same choice */
283
- const SaveRow = observer(function SaveRow(p: { st: WebSt; module: string }) {
300
+ const SaveRow = observer(function SaveRow(p: { st: WebSt; module: string; index: number; names: readonly string[] }) {
284
301
  const on = p.st.saveToDisk
302
+ const drag = rowDrag(p)
285
303
  return (
286
- <div className="var-row">
287
- <div className="var-label">
288
- <span data-tip="save — where this workflow's images go">output</span>
304
+ <div className="var-row" {...drag.row}>
305
+ <div className="var-label" {...drag.handle}>
306
+ <span data-tip={"save — where this workflow's images go\ndrag the label to reorder"}>output</span>
289
307
  </div>
290
308
  <div className="var-control">
291
309
  <div className="row-inline">
@@ -355,12 +373,10 @@ export const VarsForm = observer(function VarsForm(p: { st: WebSt }) {
355
373
  }, [p.st])
356
374
  if (form == null) return null
357
375
  // YOUR order (drag), falling back to the workflow's own declaration order
358
- const orderedNames = p.st.orderedVars(
359
- form.moduleKey,
360
- form.vars.map((v) => v.name),
361
- )
376
+ const orderedNames = p.st.orderedVars(form.moduleKey, formRowNames(form.vars.map((v) => v.name)))
362
377
  const orderedVars = orderedNames.map((n) => form.vars.find((v) => v.name === n)).filter((v) => v != null)
363
- const places = groupPlaces(orderedVars.map((v) => v.desc.ui ?? {}))
378
+ // over every ROW, the output slot included, so an index here is a row index
379
+ const places = groupPlaces(orderedNames.map((n) => form.vars.find((v) => v.name === n)?.desc.ui ?? {}))
364
380
  const targets = jumpTargets(
365
381
  orderedVars.map((v) => ({ name: v.name, kind: v.desc.kind, inactive: form.inactiveReason(v) != null })),
366
382
  )
@@ -380,37 +396,39 @@ export const VarsForm = observer(function VarsForm(p: { st: WebSt }) {
380
396
  drag it (kept in this browser): labels never wrap, a cut one shows whole on hover */}
381
397
  <div className="vars" style={{ gridTemplateColumns: `${p.st.labelWidth}px minmax(0, 1fr)` }}>
382
398
  <LabelResizer st={p.st} />
383
- {orderedVars.map((v, ix) => (
399
+ {orderedNames.map((name, ix) => {
400
+ // the OUTPUT is a knob like the others: a row, not a lone button in the header
401
+ if (name === OUTPUT_ROW)
402
+ return <SaveRow key={OUTPUT_ROW} st={p.st} module={form.moduleKey} index={ix} names={orderedNames} />
403
+ const v = form.vars.find((x) => x.name === name)
404
+ if (v == null) return null
384
405
  // keyed by MODULE and DRAFT: a switch must reset per-row ui state (lora filter,
385
406
  // remembered strengths, paused set), not carry the other selection's over.
386
407
  // module matters because every workflow has a `default` draft and a `prompt`
387
408
  // var, so draft+name alone matches across workflows and react reuses the row
388
- <VarRow
389
- key={`${form.moduleKey}/${form.draft}/${v.name}`}
390
- v={v}
391
- host={form.host}
392
- st={p.st}
393
- module={form.moduleKey}
394
- index={ix}
395
- names={orderedNames}
396
- place={places[ix] ?? null}
397
- jumpKey={jumpKeyOf(v.name)}
398
- />
399
- ))}
400
- {/* the OUTPUT is a knob like the others: a row, not a lone button in the header */}
401
- <SaveRow st={p.st} module={form.moduleKey} />
409
+ return (
410
+ <VarRow
411
+ key={`${form.moduleKey}/${form.draft}/${v.name}`}
412
+ v={v}
413
+ host={form.host}
414
+ st={p.st}
415
+ module={form.moduleKey}
416
+ index={ix}
417
+ names={orderedNames}
418
+ place={places[ix] ?? null}
419
+ jumpKey={jumpKeyOf(v.name)}
420
+ />
421
+ )
422
+ })}
402
423
  </div>
403
- {/* side and pinned put generate INSIDE the results panel, with its error slot; the
404
- form keeps both otherwise. The error is one reserved line either way, so a failed
405
- run never adds a bar or pushes anything down */}
424
+ {/* side and pinned put generate INSIDE the results panel; the form keeps it otherwise.
425
+ The error shows under the prompt preview, in the results panel, unless that is off */}
406
426
  {p.st.generateInResults ? null : (
407
427
  <div className="runbar">
408
428
  <GenerateButton st={p.st} />
409
- <span className="run-error" data-tip={p.st.run.error ?? undefined}>
410
- {p.st.run.error == null ? '' : `🔴 ${p.st.run.error}`}
411
- </span>
412
429
  </div>
413
430
  )}
431
+ {p.st.layout === 'off' ? <RunError st={p.st} /> : null}
414
432
  </div>
415
433
  )
416
434
  })
@@ -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
- style={{ flex: 1, minWidth: 120 }}
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={-1}
360
- max={2}
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 == null || jump.kind !== 'loras') return
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
 
@@ -224,8 +224,10 @@ const theme = EditorView.theme(
224
224
  '.cm-content': { padding: '6px 0', caretColor: 'var(--text)' },
225
225
  '.cm-line': { padding: '0 8px' },
226
226
  '.cm-cursor': { borderLeftColor: 'var(--text)' },
227
+ // opaque on purpose: webkit blends a translucent selection down to near the background
227
228
  '&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection': {
228
- background: 'var(--accent-dim) !important',
229
+ background: '#c3d1f4 !important',
230
+ color: '#000 !important',
229
231
  },
230
232
  '.cm-placeholder': { color: 'var(--dim)' },
231
233
  '.pe-comment': { color: 'var(--dim)', fontStyle: 'italic' },