comfy-ts 2.5.0 → 2.6.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 (61) hide show
  1. package/README.md +12 -1
  2. package/dist/{DefinedWorkflow-CnzmQrBh.js → DefinedWorkflow-BJgt5t0x.js} +14 -3
  3. package/dist/DefinedWorkflow-BJgt5t0x.js.map +1 -0
  4. package/dist/{DraftsSt-C1MbWnEp.js → DraftsSt-dizp3VcC.js} +2 -2
  5. package/dist/{DraftsSt-C1MbWnEp.js.map → DraftsSt-dizp3VcC.js.map} +1 -1
  6. package/dist/cli.js +4 -4
  7. package/dist/index.cjs +3 -2
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.d.cts +21 -18
  10. package/dist/index.d.ts +21 -18
  11. package/dist/index.js +3 -2
  12. package/dist/index.js.map +1 -1
  13. package/dist/{run-serve-D47Zas-a.js → run-serve-CVu39RNd.js} +330 -16
  14. package/dist/run-serve-CVu39RNd.js.map +1 -0
  15. package/dist/{run-tui-t2TRBN0H.js → run-tui-idFhdO4f.js} +704 -524
  16. package/dist/run-tui-idFhdO4f.js.map +1 -0
  17. package/dist/serve-web.js +280 -0
  18. package/dist/{state-DY3Mp9Cl.js → state-C90kdjtB.js} +3 -13
  19. package/dist/state-C90kdjtB.js.map +1 -0
  20. package/dist/web.d.ts +21 -18
  21. package/dist/web.js +3 -2
  22. package/dist/web.js.map +1 -1
  23. package/package.json +7 -5
  24. package/src/cli/serve/ServeApp.ts +314 -13
  25. package/src/cli/serve/describeVar.ts +6 -1
  26. package/src/cli/serve/run-serve.ts +4 -2
  27. package/src/cli/serve/web/api.ts +105 -0
  28. package/src/cli/serve/web/clipboard.ts +25 -0
  29. package/src/cli/serve/web/components/App.tsx +53 -0
  30. package/src/cli/serve/web/components/Gallery.tsx +186 -0
  31. package/src/cli/serve/web/components/PromptEnhancer.tsx +210 -0
  32. package/src/cli/serve/web/components/Sidebar.tsx +42 -0
  33. package/src/cli/serve/web/components/VarsForm.tsx +173 -0
  34. package/src/cli/serve/web/components/controls/BasicControls.tsx +95 -0
  35. package/src/cli/serve/web/components/controls/ImageControl.tsx +71 -0
  36. package/src/cli/serve/web/components/controls/LorasControl.tsx +340 -0
  37. package/src/cli/serve/web/components/controls/SeedControl.tsx +43 -0
  38. package/src/cli/serve/web/components/controls/SizeControl.tsx +49 -0
  39. package/src/cli/serve/web/main.tsx +18 -0
  40. package/src/cli/serve/web/openrouter.ts +142 -0
  41. package/src/cli/serve/web/state/EnhancerSt.ts +370 -0
  42. package/src/cli/serve/web/state/FormSt.ts +177 -0
  43. package/src/cli/serve/web/state/RunSt.ts +136 -0
  44. package/src/cli/serve/web/state/WebSt.ts +210 -0
  45. package/src/cli/serve/web/state/payload.ts +110 -0
  46. package/src/cli/serve/web/styles.ts +259 -0
  47. package/src/cli/serve/web/tsconfig.json +15 -0
  48. package/src/cli/serve/webBundle.ts +66 -0
  49. package/src/cli/tui/imageEscapes.ts +105 -0
  50. package/src/cli/tui/imagePicker/ImagePickerSt.ts +21 -8
  51. package/src/cli/tui/protocolImage.ts +39 -0
  52. package/src/cli/tui/protocolImagePainter.ts +56 -23
  53. package/src/cli/tui/run-tui.tsx +3 -2
  54. package/src/cli/tui/state/LorasSt.ts +22 -9
  55. package/src/cli/tui/state/PreviewSt.ts +31 -13
  56. package/src/cli/tui/state/SettingsSt.ts +1 -1
  57. package/src/vars/ComfyVars.ts +4 -1
  58. package/dist/DefinedWorkflow-CnzmQrBh.js.map +0 -1
  59. package/dist/run-serve-D47Zas-a.js.map +0 -1
  60. package/dist/run-tui-t2TRBN0H.js.map +0 -1
  61. package/dist/state-DY3Mp9Cl.js.map +0 -1
@@ -0,0 +1,25 @@
1
+ // copy a served image to the clipboard. ClipboardItem accepts image/png and
2
+ // nothing else that matters, so non-png outputs re-encode through a canvas
3
+ export async function copyImageToClipboard(url: string): Promise<void> {
4
+ const res = await fetch(url)
5
+ if (!res.ok) throw new Error(`fetch failed (http ${res.status})`)
6
+ const blob = await res.blob()
7
+ const png = blob.type === 'image/png' ? blob : await reencodeToPng(blob)
8
+ await navigator.clipboard.write([new ClipboardItem({ 'image/png': png })])
9
+ }
10
+
11
+ async function reencodeToPng(blob: Blob): Promise<Blob> {
12
+ const bitmap = await createImageBitmap(blob)
13
+ const canvas = document.createElement('canvas')
14
+ canvas.width = bitmap.width
15
+ canvas.height = bitmap.height
16
+ const ctx = canvas.getContext('2d')
17
+ if (ctx == null) throw new Error('canvas 2d context unavailable')
18
+ ctx.drawImage(bitmap, 0, 0)
19
+ return await new Promise<Blob>((resolve, reject) => {
20
+ canvas.toBlob((out) => {
21
+ if (out == null) reject(new Error('png encode failed'))
22
+ else resolve(out)
23
+ }, 'image/png')
24
+ })
25
+ }
@@ -0,0 +1,53 @@
1
+ // layout root: topbar (burger toggles the sidebar), sidebar drawer, form
2
+ // column + results column (right on wide screens, below on narrow ones)
3
+ import { observer } from 'mobx-react-lite'
4
+ import { Gallery } from 'src/cli/serve/web/components/Gallery.tsx'
5
+ import { Sidebar } from 'src/cli/serve/web/components/Sidebar.tsx'
6
+ import { VarsForm } from 'src/cli/serve/web/components/VarsForm.tsx'
7
+ import type { WebSt } from 'src/cli/serve/web/state/WebSt.ts'
8
+
9
+ export const App = observer(function App(p: { st: WebSt }) {
10
+ if (p.st.phase === 'loading') return <div className="center">loading…</div>
11
+ if (p.st.phase === 'error')
12
+ return (
13
+ <div className="center">
14
+ <div className="error">🔴 {p.st.bootError}</div>
15
+ </div>
16
+ )
17
+ return (
18
+ <div className="app">
19
+ <div className="topbar">
20
+ <button
21
+ type="button"
22
+ className="burger"
23
+ title="toggle the workflow menu"
24
+ onClick={() => p.st.toggleSidebar()}
25
+ >
26
+ ☰
27
+ </button>
28
+ <h1>comfy-ts serve</h1>
29
+ <span className="dim">
30
+ {p.st.modules.length} workflow{p.st.modules.length === 1 ? '' : 's'} · drafts are the base, edits
31
+ override per run
32
+ </span>
33
+ </div>
34
+ <div className="cols">
35
+ {p.st.sidebarOpen ? <div className="backdrop" onClick={() => p.st.toggleSidebar()} /> : null}
36
+ {p.st.sidebarOpen ? <Sidebar st={p.st} /> : null}
37
+ <div className="main">
38
+ {p.st.formError != null ? <div className="center error">🔴 {p.st.formError}</div> : null}
39
+ {p.st.formLoading && p.st.form == null ? <div className="center">loading draft…</div> : null}
40
+ {p.st.modules.length === 0 ? <div className="center">no workflow modules loaded</div> : null}
41
+ <div className="work">
42
+ <div className="form-col">
43
+ <VarsForm st={p.st} />
44
+ </div>
45
+ <div className="results-col">
46
+ <Gallery st={p.st} />
47
+ </div>
48
+ </div>
49
+ </div>
50
+ </div>
51
+ </div>
52
+ )
53
+ })
@@ -0,0 +1,186 @@
1
+ // results, newest first: per-run delete + clear all; clicking any image (latent
2
+ // included) opens the LIGHTBOX (esc/backdrop closes; copy / open / delete
3
+ // inside). copy needs a secure context (localhost is one, LAN http is not) —
4
+ // the button hides where the clipboard api is absent
5
+ import { observer, useLocalObservable } from 'mobx-react-lite'
6
+ import { useEffect } from 'react'
7
+ import { runPreviewSrc } from 'src/cli/serve/web/api.ts'
8
+ import { copyImageToClipboard } from 'src/cli/serve/web/clipboard.ts'
9
+ import type { WebSt } from 'src/cli/serve/web/state/WebSt.ts'
10
+
11
+ const canCopy = typeof navigator !== 'undefined' && navigator.clipboard != null
12
+
13
+ type LightboxTarget = { url: string; title: string; promptId: string | null }
14
+
15
+ type GalleryLocal = {
16
+ copyNote: { url: string; text: string } | null
17
+ lightbox: LightboxTarget | null
18
+ setCopyNote(url: string, text: string): void
19
+ openLightbox(target: LightboxTarget): void
20
+ closeLightbox(): void
21
+ }
22
+
23
+ function useGalleryLocal(): GalleryLocal {
24
+ return useLocalObservable<GalleryLocal>(() => ({
25
+ copyNote: null,
26
+ lightbox: null,
27
+ setCopyNote(url: string, text: string) {
28
+ this.copyNote = { url, text }
29
+ },
30
+ openLightbox(target: LightboxTarget) {
31
+ this.lightbox = target
32
+ },
33
+ closeLightbox() {
34
+ this.lightbox = null
35
+ },
36
+ }))
37
+ }
38
+
39
+ const Lightbox = observer(function Lightbox(p: { st: WebSt; local: GalleryLocal }) {
40
+ const box = p.local.lightbox
41
+ useEffect(() => {
42
+ if (box == null) return
43
+ const onKey = (e: KeyboardEvent): void => {
44
+ if (e.key === 'Escape') p.local.closeLightbox()
45
+ }
46
+ window.addEventListener('keydown', onKey)
47
+ return () => window.removeEventListener('keydown', onKey)
48
+ }, [box, p.local])
49
+ if (box == null) return null
50
+ const copy = (): void => {
51
+ copyImageToClipboard(box.url)
52
+ .then(() => p.local.setCopyNote(box.url, 'copied ✓'))
53
+ .catch((e: unknown) =>
54
+ p.local.setCopyNote(box.url, `copy failed: ${e instanceof Error ? e.message : String(e)}`),
55
+ )
56
+ }
57
+ return (
58
+ <div className="modal-overlay" onClick={() => p.local.closeLightbox()}>
59
+ <div className="lightbox" onClick={(e) => e.stopPropagation()}>
60
+ <img src={box.url} alt={box.title} />
61
+ <div className="lightbox-bar">
62
+ <span className="hint" title={box.title}>
63
+ {box.title}
64
+ </span>
65
+ {canCopy ? (
66
+ <button type="button" onClick={copy}>
67
+ copy
68
+ </button>
69
+ ) : null}
70
+ <a href={box.url} target="_blank" rel="noreferrer">
71
+ open ↗
72
+ </a>
73
+ {box.promptId != null ? (
74
+ <button
75
+ type="button"
76
+ title="remove this result"
77
+ onClick={() => {
78
+ if (box.promptId != null) p.st.run.remove(box.promptId)
79
+ p.local.closeLightbox()
80
+ }}
81
+ >
82
+ delete
83
+ </button>
84
+ ) : null}
85
+ {p.local.copyNote?.url === box.url ? <span className="hint">{p.local.copyNote.text}</span> : null}
86
+ <button type="button" title="close (esc)" onClick={() => p.local.closeLightbox()}>
87
+ ✕
88
+ </button>
89
+ </div>
90
+ </div>
91
+ </div>
92
+ )
93
+ })
94
+
95
+ /** live card while a run is in flight: progress bar + the latest latent frame */
96
+ const RunningCard = observer(function RunningCard(p: { st: WebSt; local: GalleryLocal }) {
97
+ // the RUNNING module, never the selection: switching modules mid-run must not retarget the card
98
+ const moduleKey = p.st.run.runningModule
99
+ if (!p.st.run.isRunning || moduleKey == null) return null
100
+ const percent = p.st.run.progressPercent
101
+ const previewUrl = runPreviewSrc({ module: moduleKey, tick: p.st.run.previewTick })
102
+ return (
103
+ <div className="run-card running">
104
+ <div className="meta">
105
+ <span>generating {moduleKey}…</span>
106
+ <span>{percent != null ? `${Math.round(percent)}%` : ''}</span>
107
+ </div>
108
+ <div className="progress-track">
109
+ <div className="progress-fill" style={{ width: `${percent ?? 0}%` }} />
110
+ </div>
111
+ {p.st.run.hasPreview ? (
112
+ <div className="imgs">
113
+ <button
114
+ type="button"
115
+ className="img-button"
116
+ onClick={() => p.local.openLightbox({ url: previewUrl, title: 'latent preview', promptId: null })}
117
+ >
118
+ <img src={previewUrl} alt="latent preview" />
119
+ </button>
120
+ </div>
121
+ ) : null}
122
+ </div>
123
+ )
124
+ })
125
+
126
+ export const Gallery = observer(function Gallery(p: { st: WebSt }) {
127
+ const local = useGalleryLocal()
128
+ if (p.st.run.results.length === 0 && !p.st.run.isRunning) return null
129
+ return (
130
+ <div className="gallery">
131
+ <RunningCard st={p.st} local={local} />
132
+ {p.st.run.results.length > 0 ? (
133
+ <div className="gallery-head">
134
+ <span>
135
+ {p.st.run.results.length} result{p.st.run.results.length === 1 ? '' : 's'}
136
+ </span>
137
+ <button type="button" className="link" onClick={() => p.st.run.clear()}>
138
+ clear all
139
+ </button>
140
+ </div>
141
+ ) : null}
142
+ {p.st.run.results.map((r) => (
143
+ <div key={r.promptId} className="run-card">
144
+ <div className="meta">
145
+ <span>
146
+ {r.at} · {r.module}/{r.draft} · {(r.durationMs / 1000).toFixed(1)}s
147
+ {Object.entries(r.seeds).map(([k, seed]) => ` · ${k}: ${seed}`)}
148
+ </span>
149
+ <button
150
+ type="button"
151
+ className="link"
152
+ title="remove this result"
153
+ onClick={() => p.st.run.remove(r.promptId)}
154
+ >
155
+ ✕
156
+ </button>
157
+ </div>
158
+ <div className="imgs">
159
+ {r.images.map((img) =>
160
+ img.url != null ? (
161
+ <button
162
+ key={img.filename}
163
+ type="button"
164
+ className="img-button"
165
+ title={img.filename}
166
+ onClick={() => {
167
+ if (img.url != null)
168
+ local.openLightbox({ url: img.url, title: img.filename, promptId: r.promptId })
169
+ }}
170
+ >
171
+ <img src={img.url} alt={img.filename} />
172
+ </button>
173
+ ) : (
174
+ <div key={img.filename} className="noimg">
175
+ {img.filename} (not saved locally — no preview)
176
+ </div>
177
+ ),
178
+ )}
179
+ {r.images.length === 0 ? <div className="noimg">no image outputs</div> : null}
180
+ </div>
181
+ </div>
182
+ ))}
183
+ <Lightbox st={p.st} local={local} />
184
+ </div>
185
+ )
186
+ })
@@ -0,0 +1,210 @@
1
+ // ✨ on a prompt row → the refine modal: openrouter key + thinking model +
2
+ // a library of named master prompts. Nothing touches the var until APPLY.
3
+ import { observer } from 'mobx-react-lite'
4
+ import { useEffect } from 'react'
5
+ import type { ReasoningEffort } from 'src/cli/serve/web/openrouter.ts'
6
+ import type { EnhancerSt } from 'src/cli/serve/web/state/EnhancerSt.ts'
7
+ import type { VarSt } from 'src/cli/serve/web/state/FormSt.ts'
8
+ import type { WebSt } from 'src/cli/serve/web/state/WebSt.ts'
9
+
10
+ const EFFORTS: ReasoningEffort[] = ['off', 'low', 'medium', 'high']
11
+
12
+ const Settings = observer(function Settings(p: { e: EnhancerSt }) {
13
+ const models = p.e.visibleModels
14
+ return (
15
+ <div>
16
+ <div className="section-title">openrouter · the key stays in this browser</div>
17
+ <div className="enh-row">
18
+ <input
19
+ type="password"
20
+ placeholder="sk-or-v1-… (localStorage only)"
21
+ value={p.e.apiKey}
22
+ onChange={(ev) => p.e.setApiKey(ev.target.value)}
23
+ style={{ flex: 1, minWidth: 200 }}
24
+ />
25
+ <button type="button" onClick={() => void p.e.loadModels()} disabled={p.e.modelsState === 'loading'}>
26
+ {p.e.modelsState === 'loading' ? 'loading…' : 'load models'}
27
+ </button>
28
+ </div>
29
+ <div className="enh-row">
30
+ {models.length > 0 ? (
31
+ <select value={p.e.model} onChange={(ev) => p.e.setModel(ev.target.value)} style={{ flex: 1 }}>
32
+ {/* honest display for an id outside the loaded list (free text, or a filtered-out model) */}
33
+ {models.some((m) => m.id === p.e.model) ? null : (
34
+ <option value={p.e.model}>{p.e.model} (not in the list)</option>
35
+ )}
36
+ {models.map((m) => (
37
+ <option key={m.id} value={m.id}>
38
+ {m.id}
39
+ </option>
40
+ ))}
41
+ </select>
42
+ ) : (
43
+ <input
44
+ type="text"
45
+ placeholder="model id, e.g. anthropic/claude-sonnet-5"
46
+ value={p.e.model}
47
+ onChange={(ev) => p.e.setModel(ev.target.value)}
48
+ style={{ flex: 1 }}
49
+ />
50
+ )}
51
+ <label className="row-inline" title="only models that support reasoning">
52
+ <input type="checkbox" checked={p.e.thinkingOnly} onChange={() => p.e.toggleThinkingOnly()} />
53
+ <span className="hint">thinking only</span>
54
+ </label>
55
+ <label className="row-inline" title="reasoning effort sent to the model">
56
+ <span className="hint">effort</span>
57
+ <select value={p.e.effort} onChange={(ev) => p.e.setEffort(ev.target.value)}>
58
+ {EFFORTS.map((x) => (
59
+ <option key={x} value={x}>
60
+ {x}
61
+ </option>
62
+ ))}
63
+ </select>
64
+ </label>
65
+ </div>
66
+ {p.e.modelsError !== '' ? <div className="error">🔴 {p.e.modelsError}</div> : null}
67
+ </div>
68
+ )
69
+ })
70
+
71
+ const MasterPrompt = observer(function MasterPrompt(p: { e: EnhancerSt }) {
72
+ const preset = p.e.preset
73
+ if (preset == null) return null
74
+ const rename = (): void => {
75
+ const name = window.prompt('rename this master prompt', preset.name)
76
+ if (name != null) p.e.renamePreset(name)
77
+ }
78
+ const create = (): void => {
79
+ const name = window.prompt('name the new master prompt', 'refine-<model>-prompt')
80
+ if (name != null) p.e.addPreset(name)
81
+ }
82
+ return (
83
+ <div>
84
+ <div className="section-title">master prompt · one per image model</div>
85
+ <div className="enh-row">
86
+ <select value={preset.id} onChange={(ev) => p.e.selectPreset(ev.target.value)} style={{ flex: 1 }}>
87
+ {p.e.presets.map((m) => (
88
+ <option key={m.id} value={m.id}>
89
+ {m.name}
90
+ </option>
91
+ ))}
92
+ </select>
93
+ <button type="button" onClick={create}>
94
+ new
95
+ </button>
96
+ <button type="button" onClick={() => p.e.duplicatePreset()}>
97
+ duplicate
98
+ </button>
99
+ <button type="button" onClick={rename}>
100
+ rename
101
+ </button>
102
+ <button type="button" onClick={() => p.e.deletePreset()} title="delete this master prompt">
103
+ ✕
104
+ </button>
105
+ <button
106
+ type="button"
107
+ className="link"
108
+ onClick={() => p.e.restoreDefaults()}
109
+ title="re-add the shipped ones"
110
+ >
111
+ restore defaults
112
+ </button>
113
+ </div>
114
+ <textarea rows={8} value={preset.text} onChange={(ev) => p.e.setPresetText(ev.target.value)} />
115
+ </div>
116
+ )
117
+ })
118
+
119
+ const Modal = observer(function Modal(p: { e: EnhancerSt }) {
120
+ const e = p.e
121
+ useEffect(() => {
122
+ const onKey = (ev: KeyboardEvent): void => {
123
+ if (ev.key === 'Escape') e.close()
124
+ if (ev.key === 'Enter' && (ev.metaKey || ev.ctrlKey)) {
125
+ // inside the modal ⌘⏎ refines; VarsForm's generate shortcut stands down while it is open
126
+ ev.preventDefault()
127
+ e.run()
128
+ }
129
+ }
130
+ window.addEventListener('keydown', onKey)
131
+ return () => window.removeEventListener('keydown', onKey)
132
+ }, [e])
133
+ const running = e.phase === 'running'
134
+ return (
135
+ <div className="modal-overlay" onClick={() => e.close()}>
136
+ <div className="modal" onClick={(ev) => ev.stopPropagation()}>
137
+ <div className="modal-head">
138
+ <b style={{ flex: 1 }}>✨ enhance prompt</b>
139
+ <button type="button" onClick={() => e.close()}>
140
+ ✕
141
+ </button>
142
+ </div>
143
+ <div className="modal-body">
144
+ <Settings e={e} />
145
+ <MasterPrompt e={e} />
146
+ <div className="section-title">prompt</div>
147
+ <div className="enh-cols">
148
+ <div>
149
+ <div className="hint">yours (edit before refining, the var is untouched)</div>
150
+ <textarea rows={8} value={e.original} onChange={(ev) => e.setOriginal(ev.target.value)} />
151
+ </div>
152
+ <div>
153
+ <div className="hint">{running ? 'rewriting…' : 'rewritten (editable before apply)'}</div>
154
+ <textarea
155
+ rows={8}
156
+ value={e.result}
157
+ placeholder="hit enhance"
158
+ onChange={(ev) => e.setResult(ev.target.value)}
159
+ />
160
+ </div>
161
+ </div>
162
+ {e.thinking !== '' ? (
163
+ <div>
164
+ <div className="section-title">thinking</div>
165
+ <div className="enh-think">{e.thinking}</div>
166
+ </div>
167
+ ) : null}
168
+ {e.error !== '' ? <div className="error">🔴 {e.error}</div> : null}
169
+ </div>
170
+ <div className="modal-foot">
171
+ {running ? (
172
+ <button type="button" onClick={() => e.cancel()}>
173
+ stop
174
+ </button>
175
+ ) : (
176
+ <button type="button" className="primary" onClick={() => e.run()} title="⌘⏎ / ctrl+⏎">
177
+ enhance
178
+ </button>
179
+ )}
180
+ <button type="button" onClick={() => e.apply()} disabled={e.result.trim() === ''}>
181
+ apply to prompt
182
+ </button>
183
+ <span className="hint" style={{ flex: 1 }}>
184
+ {running ? `${e.result.length} chars streamed` : 'nothing is written until you apply'}
185
+ </span>
186
+ <button type="button" className="link" onClick={() => e.close()}>
187
+ cancel
188
+ </button>
189
+ </div>
190
+ </div>
191
+ </div>
192
+ )
193
+ })
194
+
195
+ export const PromptEnhancer = observer(function PromptEnhancer(p: { v: VarSt; st: WebSt; module: string }) {
196
+ const e = p.st.enhancer
197
+ return (
198
+ <>
199
+ <button
200
+ type="button"
201
+ className="link"
202
+ title="rewrite this prompt with an llm"
203
+ onClick={() => e.openFor({ v: p.v, module: p.module })}
204
+ >
205
+ ✨ enhance
206
+ </button>
207
+ {e.target === p.v ? <Modal e={e} /> : null}
208
+ </>
209
+ )
210
+ })
@@ -0,0 +1,42 @@
1
+ // module → drafts navigation + module load errors, mirrors the TUI tree's job
2
+ import { observer } from 'mobx-react-lite'
3
+ import type { WebSt } from 'src/cli/serve/web/state/WebSt.ts'
4
+
5
+ export const Sidebar = observer(function Sidebar(p: { st: WebSt }) {
6
+ return (
7
+ <div className="sidebar">
8
+ {p.st.modules.map((mod) => (
9
+ <div key={mod.module}>
10
+ <div className="side-module">
11
+ <span className="name">{mod.module}</span>
12
+ <span className="host">{mod.host}</span>
13
+ </div>
14
+ {mod.drafts.map((draft) => {
15
+ const sel = p.st.form?.moduleKey === mod.module && p.st.form?.draft === draft
16
+ return (
17
+ <button
18
+ key={draft}
19
+ type="button"
20
+ className={sel ? 'side-draft sel' : 'side-draft'}
21
+ onClick={() => void p.st.select({ module: mod.module, draft })}
22
+ >
23
+ {draft}
24
+ </button>
25
+ )
26
+ })}
27
+ </div>
28
+ ))}
29
+ {Object.keys(p.st.loadErrors).length > 0 ? (
30
+ <div className="side-errors">
31
+ <div>failed to load:</div>
32
+ {Object.entries(p.st.loadErrors).map(([file, msg]) => (
33
+ <div key={file}>
34
+ <div className="file">{file}</div>
35
+ <div className="msg">{msg}</div>
36
+ </div>
37
+ ))}
38
+ </div>
39
+ ) : null}
40
+ </div>
41
+ )
42
+ })