Skip to content

armgit / fuobe

Public Imported from GitHub
0

The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.

Live edit: one prompt that keeps growing

Adarshe6e86929dbbc
diff --git a/docs/FEATURES.md b/docs/FEATURES.md
index 07bc6198..71d018d0 100644
--- a/docs/FEATURES.md
+++ b/docs/FEATURES.md
@@ -57,7 +57,7 @@ Fuobe is a complete creative studio you can run yourself: 108 camera motions, 25
## Create
- **Create:** Image · Video (text, image, start/end frame, **Frames**: up to 10 stills on a timeline, reference images and clips, multi-shot, draft mode) · Edit · **Layers** (split a flat image into editable layers, edit text with the lines found for you on either engine, Inpaint a painted area, an Enhancer (skin, soft glow, sharpen, detail), regional edits, save a layer as an element, cropped or positioned zips) · Inpaint & Draw to Edit · Color grading · Camera motions and Effects (on Fuobe DoP) · Storyboard (Popcorn: a board in one of Fuobe Soul's looks if you like, priced next to Generate, and turned into a film; cloud boards start on hosted open models, Z-Image Turbo or Qwen-Image-Edit, then Qwen-Image-Edit 2509 with a next-scene LoRA, and "Frames made on" switches them to Nano Banana Pro) · **Canvas** (wire prompts, files and models into node workflows; every template in a cloud and an open-source version, 10 Effects 2.0 chains among them (your photo, a "Set the scene" edit, then a 5 s Fuobe DoP clip); up to 20 pages per board, groups you can run as one, comment pins with replies, and drawing, shapes and text from a toolbar with keys; a Table node runs the node it feeds once per row; Change voice, Clone voice, Translate (text, or a dub of a video) and Video concatenator (cut, mute and join up to 50 clips) nodes) · Apps
-- **Live edit** (Create → Live edit, the Edit studio's Live switch, a Library picture's "Change it as you type") — the picture changes as you type, on your own GPU: Qwen-Image 2.1 with linoyts' 2-step DMD2 LoRA on Fuobe's live nodes (fuobe_live.py, which the Windows start file and the setup card add to ComfyUI). Live frames come at 384 to 768 px (Auto steps down on a slower GPU); a pause renders the text on screen at full quality, and Enter, Keep or a click on a Try keeps exactly that picture as a lossless full-size master. Typing never keeps anything by itself. Unchanged pixels are copied from the step before, so stacking edits doesn't wear the picture down. Undo and redo every step, hold C to compare (Shift+C with the original), paint a region to change only that. On "Use the ComfyUI on this computer" the tab talks to its ComfyUI directly. Guests see a recorded session. Non-commercial weights; none of it has rendered on a real GPU yet
+- **Live edit** (Create → Live edit, the Edit studio's Live switch, a Library picture's "Change it as you type") — the picture changes as you type, on your own GPU: Qwen-Image 2.1 with linoyts' 2-step DMD2 LoRA on Fuobe's live nodes (fuobe_live.py, which the Windows start file and the setup card add to ComfyUI). Live frames come at 384 to 768 px (Auto steps down on a slower GPU); a pause renders the text on screen at full quality. One prompt keeps growing: Enter ends a change and starts the next, and every frame renders all the words on the original with one seed for the session, so the picture stays steady while you type and nothing wears down, however many changes you make. Undo drops the newest change; Start fresh makes the picture on screen the new original (a lossless full-size master) and clears the words. Hold C to compare (Shift+C with the original), paint a region to change only that. On "Use the ComfyUI on this computer" the tab talks to its ComfyUI directly. Guests see a recorded session. Non-commercial weights; none of it has rendered on a real GPU yet
- **MOSS-Image** (Image studio → model menu → MOSS-Image) — OpenMOSS's picture model, made for Chinese and English text in pictures. In the cloud it runs on fal at $0.05 per megapixel, up to 4 images (fal's safety checker returns a black image when it flags an output). On your GPU it is free, on ComfyUI's built-in nodes, with about 15 GB of files and 16 GB of VRAM (a guess); **Options → Quality** picks Standard (25 steps), Best (50), Fast (8 steps, an extra 5.4 GB file) or Base model (MOSS-Image Base, 50 steps, an extra 5.4 GB file). Its text encoder is the int8 Qwen3.5-9B: the w4a8 build in ComfyUI's template crashed the graphics driver on a test PC. The Image studio's controls chip now reads **Options** (it read "Director"). Text placed in boxes comes later: the code that turns layout boxes into MOSS's prompt is in (`src/lib/layout-prompt.ts`), but the screen to draw them, Layout mode, is the next package in the queue
- **The newest open image models, first on your GPU** — Ideogram 4, Qwen-Image 2.1 and its Turbo, Krea 2 (Realism, Turbo, Edit, Identity Edit, Image to image, Inpaint) and FIBO 2 (Dev, Edit Turbo), from the owner's ComfyUI workflows. On the open engine the Image studio opens on Ideogram 4 (on Qwen-Image 2.1 for an account, a guest, or an install with no local LLM to write Ideogram's caption) and Edit and Inpaint on Qwen-Image 2.1; every model menu's "Best" list puts the new models first (text to image: Ideogram 4, Qwen-Image 2.1, Krea 2 Realism, MOSS-Image, then FIBO 2 Dev; edits: Qwen-Image 2.1, its Turbo, FIBO 2 Dev and Edit Turbo, then Krea 2 Edit), and so do apps, Layers, Canvas, Cinema stills, Photodump, Fashion Factory and Character swap's anchor. Apps and tools that run a LoRA trained on an older model keep it (Angles, Relight, Product shot, Try-On, Cinema's recompose). Ideogram 4 reads a JSON caption, which Fuobe writes from your words (with your local LLM, never a paid API; a plain caption without one) and keeps as the run's prompt. When Ideogram's safety filter sends its grey card instead of a picture, the run fails and says what to try. Soul Location doesn't offer Ideogram 4 (pictures of empty places hit that filter most), and a new Layers layer starts on Qwen-Image 2.1. Qwen-Image 2.1, FIBO 2 and Krea 2 Edit take up to 4 references (Krea 2 Edit 2) and leave out the ones you don't give; an edit keeps image 1's shape and size, so Edit and Inpaint show no aspect or size choice for them, and Qwen-Image 2.1's inpaint and expand take the picture alone. An app run made before an app moved to Qwen-Image 2.1 (a retry, Run again, Reuse) runs on Qwen-Image 2.1 and says so. About 92 GB of new files, 20–24 GB of VRAM (estimates), ComfyUI 0.42.0; Krea 2 runs Comfy-Org's fp8 Krea 2 Turbo, the file the owner's edit workflow loads. Krea 2 Inpaint also needs the ComfyUI-Krea2-Ostris-Edit node pack, so it isn't in Inpaint's "Best" list. Qwen-Image 2.1, Ideogram 4 and FIBO 2 weights are non-commercial. None of the 16 graphs has rendered through Fuobe yet
diff --git a/public/previews/live-edit/512/step-01.webp b/public/previews/live-edit/512/step-01.webp
index 34658c72..88eb846f 100644
Binary files a/public/previews/live-edit/512/step-01.webp and b/public/previews/live-edit/512/step-01.webp differ
diff --git a/public/previews/live-edit/512/step-02.webp b/public/previews/live-edit/512/step-02.webp
index f564927e..ec891791 100644
Binary files a/public/previews/live-edit/512/step-02.webp and b/public/previews/live-edit/512/step-02.webp differ
diff --git a/public/previews/live-edit/512/step-03.webp b/public/previews/live-edit/512/step-03.webp
index 1ac08776..affca844 100644
Binary files a/public/previews/live-edit/512/step-03.webp and b/public/previews/live-edit/512/step-03.webp differ
diff --git a/public/previews/live-edit/512/step-04.webp b/public/previews/live-edit/512/step-04.webp
index 8bb2d3e9..abe1b4be 100644
Binary files a/public/previews/live-edit/512/step-04.webp and b/public/previews/live-edit/512/step-04.webp differ
diff --git a/public/previews/live-edit/512/step-05.webp b/public/previews/live-edit/512/step-05.webp
index d52b60eb..2f16c888 100644
Binary files a/public/previews/live-edit/512/step-05.webp and b/public/previews/live-edit/512/step-05.webp differ
diff --git a/public/previews/live-edit/512/step-06.webp b/public/previews/live-edit/512/step-06.webp
index 95e36cf1..256edb6a 100644
Binary files a/public/previews/live-edit/512/step-06.webp and b/public/previews/live-edit/512/step-06.webp differ
diff --git a/public/previews/live-edit/512/step-07.webp b/public/previews/live-edit/512/step-07.webp
index 6d839b30..24bc4a93 100644
Binary files a/public/previews/live-edit/512/step-07.webp and b/public/previews/live-edit/512/step-07.webp differ
diff --git a/public/previews/live-edit/512/step-08.webp b/public/previews/live-edit/512/step-08.webp
index b45003b4..5cfa3200 100644
Binary files a/public/previews/live-edit/512/step-08.webp and b/public/previews/live-edit/512/step-08.webp differ
diff --git a/public/previews/live-edit/512/step-09.webp b/public/previews/live-edit/512/step-09.webp
index 234c86fc..6ba3bece 100644
Binary files a/public/previews/live-edit/512/step-09.webp and b/public/previews/live-edit/512/step-09.webp differ
diff --git a/public/previews/live-edit/512/step-10.webp b/public/previews/live-edit/512/step-10.webp
index f26614ba..fcfd4d12 100644
Binary files a/public/previews/live-edit/512/step-10.webp and b/public/previews/live-edit/512/step-10.webp differ
diff --git a/public/previews/live-edit/512/step-11.webp b/public/previews/live-edit/512/step-11.webp
index e78fd40e..631934f8 100644
Binary files a/public/previews/live-edit/512/step-11.webp and b/public/previews/live-edit/512/step-11.webp differ
diff --git a/public/previews/live-edit/960/step-01.webp b/public/previews/live-edit/960/step-01.webp
index 2a5e728a..10027892 100644
Binary files a/public/previews/live-edit/960/step-01.webp and b/public/previews/live-edit/960/step-01.webp differ
diff --git a/public/previews/live-edit/960/step-02.webp b/public/previews/live-edit/960/step-02.webp
index ac8f32db..4567e527 100644
Binary files a/public/previews/live-edit/960/step-02.webp and b/public/previews/live-edit/960/step-02.webp differ
diff --git a/public/previews/live-edit/960/step-03.webp b/public/previews/live-edit/960/step-03.webp
index 2318e16a..781b074f 100644
Binary files a/public/previews/live-edit/960/step-03.webp and b/public/previews/live-edit/960/step-03.webp differ
diff --git a/public/previews/live-edit/960/step-04.webp b/public/previews/live-edit/960/step-04.webp
index faaa5986..d495e432 100644
Binary files a/public/previews/live-edit/960/step-04.webp and b/public/previews/live-edit/960/step-04.webp differ
diff --git a/public/previews/live-edit/960/step-05.webp b/public/previews/live-edit/960/step-05.webp
index ed05c54d..c536834e 100644
Binary files a/public/previews/live-edit/960/step-05.webp and b/public/previews/live-edit/960/step-05.webp differ
diff --git a/public/previews/live-edit/960/step-06.webp b/public/previews/live-edit/960/step-06.webp
index 638e0a11..08065a9f 100644
Binary files a/public/previews/live-edit/960/step-06.webp and b/public/previews/live-edit/960/step-06.webp differ
diff --git a/public/previews/live-edit/960/step-07.webp b/public/previews/live-edit/960/step-07.webp
index bcc9a538..bd3392be 100644
Binary files a/public/previews/live-edit/960/step-07.webp and b/public/previews/live-edit/960/step-07.webp differ
diff --git a/public/previews/live-edit/960/step-08.webp b/public/previews/live-edit/960/step-08.webp
index e4dc997b..f7309fb9 100644
Binary files a/public/previews/live-edit/960/step-08.webp and b/public/previews/live-edit/960/step-08.webp differ
diff --git a/public/previews/live-edit/960/step-09.webp b/public/previews/live-edit/960/step-09.webp
index ecec8367..29d47c02 100644
Binary files a/public/previews/live-edit/960/step-09.webp and b/public/previews/live-edit/960/step-09.webp differ
diff --git a/public/previews/live-edit/960/step-10.webp b/public/previews/live-edit/960/step-10.webp
index f92f9734..341eee7b 100644
Binary files a/public/previews/live-edit/960/step-10.webp and b/public/previews/live-edit/960/step-10.webp differ
diff --git a/public/previews/live-edit/960/step-11.webp b/public/previews/live-edit/960/step-11.webp
index 70e12556..45611a74 100644
Binary files a/public/previews/live-edit/960/step-11.webp and b/public/previews/live-edit/960/step-11.webp differ
diff --git a/public/previews/live-edit/demo.json b/public/previews/live-edit/demo.json
index 1514cf28..7c587ac6 100644
--- a/public/previews/live-edit/demo.json
+++ b/public/previews/live-edit/demo.json
@@ -1,126 +1,130 @@
{
- "v": 2,
+ "v": 3,
"size": [960, 720],
"frames": {
"s0": {"src": "/previews/live-edit/960/step-00.webp?v=9d4a860e", "small": "/previews/live-edit/512/step-00.webp?v=c47f82ab"},
- "s1a": {"src": "/previews/live-edit/live/step-01-1.webp?v=95f2d54d"},
- "s1b": {"src": "/previews/live-edit/live/step-01-2.webp?v=32e1b3e9"},
- "s1c": {"src": "/previews/live-edit/live/step-01-3.webp?v=841a6980"},
- "s1": {"src": "/previews/live-edit/960/step-01.webp?v=541106bb", "small": "/previews/live-edit/512/step-01.webp?v=dba8a40c"},
- "s2a": {"src": "/previews/live-edit/live/step-02-1.webp?v=5bb58562"},
- "s2b": {"src": "/previews/live-edit/live/step-02-2.webp?v=33be604d"},
- "s2c": {"src": "/previews/live-edit/live/step-02-3.webp?v=9ef90659"},
- "s2": {"src": "/previews/live-edit/960/step-02.webp?v=66d43685", "small": "/previews/live-edit/512/step-02.webp?v=76a29afa"},
- "s3a": {"src": "/previews/live-edit/live/step-03-1.webp?v=c800d544"},
- "s3b": {"src": "/previews/live-edit/live/step-03-2.webp?v=c3be087b"},
- "s3": {"src": "/previews/live-edit/960/step-03.webp?v=c6674bcc", "small": "/previews/live-edit/512/step-03.webp?v=ef5b6616"},
- "s4a": {"src": "/previews/live-edit/live/step-04-1.webp?v=0c1a6657"},
- "s4": {"src": "/previews/live-edit/960/step-04.webp?v=7ac28830", "small": "/previews/live-edit/512/step-04.webp?v=3232ef5d"},
- "s5a": {"src": "/previews/live-edit/live/step-05-1.webp?v=ade78628"},
- "s5b": {"src": "/previews/live-edit/live/step-05-2.webp?v=5e4aa500"},
- "s5": {"src": "/previews/live-edit/960/step-05.webp?v=8eb781f9", "small": "/previews/live-edit/512/step-05.webp?v=2eb522e9"},
- "s6a": {"src": "/previews/live-edit/live/step-06-1.webp?v=09c74831"},
- "s6b": {"src": "/previews/live-edit/live/step-06-2.webp?v=ee1062c1"},
- "s6": {"src": "/previews/live-edit/960/step-06.webp?v=a4c2f7f0", "small": "/previews/live-edit/512/step-06.webp?v=7c905df8"},
- "s7a": {"src": "/previews/live-edit/live/step-07-1.webp?v=3402d883"},
- "s7b": {"src": "/previews/live-edit/live/step-07-2.webp?v=78c2d107"},
- "s7": {"src": "/previews/live-edit/960/step-07.webp?v=4be10fc9", "small": "/previews/live-edit/512/step-07.webp?v=80192a89"},
- "s8a": {"src": "/previews/live-edit/live/step-08-1.webp?v=62ed261f"},
- "s8b": {"src": "/previews/live-edit/live/step-08-2.webp?v=4377c72d"},
- "s8": {"src": "/previews/live-edit/960/step-08.webp?v=4457e3e6", "small": "/previews/live-edit/512/step-08.webp?v=9c570756"},
- "s9a": {"src": "/previews/live-edit/live/step-09-1.webp?v=af96200f"},
- "s9b": {"src": "/previews/live-edit/live/step-09-2.webp?v=5be1d9b2"},
- "s9": {"src": "/previews/live-edit/960/step-09.webp?v=b9d1302c", "small": "/previews/live-edit/512/step-09.webp?v=b7bc4937"},
- "s10a": {"src": "/previews/live-edit/live/step-10-1.webp?v=2ced9938"},
- "s10b": {"src": "/previews/live-edit/live/step-10-2.webp?v=edf847f6"},
- "s10": {"src": "/previews/live-edit/960/step-10.webp?v=c0c1411a", "small": "/previews/live-edit/512/step-10.webp?v=231d06ef"},
- "s11a": {"src": "/previews/live-edit/live/step-11-1.webp?v=39d640d9"},
- "s11b": {"src": "/previews/live-edit/live/step-11-2.webp?v=669b291b"},
- "s11": {"src": "/previews/live-edit/960/step-11.webp?v=c15dc572", "small": "/previews/live-edit/512/step-11.webp?v=4d25f666"}
+ "s1a": {"src": "/previews/live-edit/live/step-01-1.webp?v=84ed2404"},
+ "s1b": {"src": "/previews/live-edit/live/step-01-2.webp?v=70afa1a2"},
+ "s1": {"src": "/previews/live-edit/960/step-01.webp?v=04fbd2a2", "small": "/previews/live-edit/512/step-01.webp?v=19a3ade1"},
+ "s2a": {"src": "/previews/live-edit/live/step-02-1.webp?v=30891ecf"},
+ "s2b": {"src": "/previews/live-edit/live/step-02-2.webp?v=92e73db3"},
+ "s2c": {"src": "/previews/live-edit/live/step-02-3.webp?v=516a0eed"},
+ "s2": {"src": "/previews/live-edit/960/step-02.webp?v=f9d3957b", "small": "/previews/live-edit/512/step-02.webp?v=a57c6e4d"},
+ "s3a": {"src": "/previews/live-edit/live/step-03-1.webp?v=fff855f9"},
+ "s3b": {"src": "/previews/live-edit/live/step-03-2.webp?v=61cb325b"},
+ "s3": {"src": "/previews/live-edit/960/step-03.webp?v=fdc0c41f", "small": "/previews/live-edit/512/step-03.webp?v=1e2adc3f"},
+ "s4a": {"src": "/previews/live-edit/live/step-04-1.webp?v=998fef14"},
+ "s4b": {"src": "/previews/live-edit/live/step-04-2.webp?v=b89005d8"},
+ "s4": {"src": "/previews/live-edit/960/step-04.webp?v=29aaa3ac", "small": "/previews/live-edit/512/step-04.webp?v=9cdec4c0"},
+ "s5a": {"src": "/previews/live-edit/live/step-05-1.webp?v=96941b26"},
+ "s5b": {"src": "/previews/live-edit/live/step-05-2.webp?v=230813bc"},
+ "s5": {"src": "/previews/live-edit/960/step-05.webp?v=aab1b774", "small": "/previews/live-edit/512/step-05.webp?v=75e4427f"},
+ "s6a": {"src": "/previews/live-edit/live/step-06-1.webp?v=03cdf060"},
+ "s6b": {"src": "/previews/live-edit/live/step-06-2.webp?v=f5efa037"},
+ "s6": {"src": "/previews/live-edit/960/step-06.webp?v=8b7bc1e7", "small": "/previews/live-edit/512/step-06.webp?v=f712bf4c"},
+ "s7a": {"src": "/previews/live-edit/live/step-07-1.webp?v=e7abfac0"},
+ "s7b": {"src": "/previews/live-edit/live/step-07-2.webp?v=35a636ab"},
+ "s7": {"src": "/previews/live-edit/960/step-07.webp?v=b47bdd99", "small": "/previews/live-edit/512/step-07.webp?v=f31ca351"},
+ "s8a": {"src": "/previews/live-edit/live/step-08-1.webp?v=466d8815"},
+ "s8b": {"src": "/previews/live-edit/live/step-08-2.webp?v=f319b508"},
+ "s8c": {"src": "/previews/live-edit/live/step-08-3.webp?v=5118d810"},
+ "s8": {"src": "/previews/live-edit/960/step-08.webp?v=caa8bdbe", "small": "/previews/live-edit/512/step-08.webp?v=056243a3"},
+ "s9a": {"src": "/previews/live-edit/live/step-09-1.webp?v=35954674"},
+ "s9b": {"src": "/previews/live-edit/live/step-09-2.webp?v=3a18e101"},
+ "s9": {"src": "/previews/live-edit/960/step-09.webp?v=00791b3e", "small": "/previews/live-edit/512/step-09.webp?v=2c50c9dc"},
+ "s10a": {"src": "/previews/live-edit/live/step-10-1.webp?v=4070bc5b"},
+ "s10b": {"src": "/previews/live-edit/live/step-10-2.webp?v=6bbcd231"},
+ "s10": {"src": "/previews/live-edit/960/step-10.webp?v=b96fcc4d", "small": "/previews/live-edit/512/step-10.webp?v=00db63dd"},
+ "s11a": {"src": "/previews/live-edit/live/step-11-1.webp?v=fe53f9eb"},
+ "s11b": {"src": "/previews/live-edit/live/step-11-2.webp?v=20900715"},
+ "s11": {"src": "/previews/live-edit/960/step-11.webp?v=c811f0d7", "small": "/previews/live-edit/512/step-11.webp?v=0934584d"}
},
"script": [
{"type": "frame", "frame": "s0", "ms": 800},
{"type": "zoom", "box": [0.42, 0.267, 0.577, 0.528], "ms": 150},
- {"type": "type", "text": "evening makeup", "ms": 628},
+ {"type": "type", "text": "evening makeup, deep red", "ms": 1080},
{"type": "frame", "frame": "s1a", "live": true, "ms": 600},
- {"type": "type", "text": ", deep red", "ms": 500},
+ {"type": "type", "text": " lips", "ms": 240},
{"type": "frame", "frame": "s1b", "live": true, "ms": 600},
- {"type": "type", "text": " lips", "ms": 250},
- {"type": "frame", "frame": "s1c", "live": true, "ms": 600},
{"type": "zoom", "box": null, "ms": 0},
{"type": "frame", "frame": "s1", "ms": 680},
- {"type": "keep", "label": "Evening makeup", "ms": 820},
- {"type": "type", "text": "hair down", "ms": 418},
+ {"type": "change", "ms": 640},
+ {"type": "type", "text": ", hair down", "ms": 520},
{"type": "frame", "frame": "s2a", "live": true, "ms": 600},
- {"type": "type", "text": ", side-swept", "ms": 544},
+ {"type": "type", "text": ", side-swept", "ms": 520},
{"type": "frame", "frame": "s2b", "live": true, "ms": 600},
- {"type": "type", "text": " waves", "ms": 292},
+ {"type": "type", "text": " waves", "ms": 280},
{"type": "frame", "frame": "s2c", "live": true, "ms": 600},
{"type": "frame", "frame": "s2", "ms": 680},
- {"type": "keep", "label": "Side-swept waves", "ms": 820},
- {"type": "zoom", "box": [0.376, 0.422, 0.619, 0.538], "ms": 230},
- {"type": "type", "text": "big gold hoop", "ms": 470},
+ {"type": "change", "ms": 640},
+ {"type": "zoom", "box": [0.376, 0.422, 0.619, 0.538], "ms": 160},
+ {"type": "type", "text": ", big gold hoop", "ms": 540},
{"type": "frame", "frame": "s3a", "live": true, "ms": 540},
- {"type": "type", "text": " earrings", "ms": 310},
+ {"type": "type", "text": " earrings", "ms": 292},
{"type": "frame", "frame": "s3b", "live": true, "ms": 540},
{"type": "zoom", "box": null, "ms": 0},
{"type": "frame", "frame": "s3", "ms": 600},
- {"type": "keep", "label": "Gold hoops", "ms": 700},
+ {"type": "change", "ms": 520},
{"type": "zoom", "box": [0.312, 0.626, 0.61, 0.997], "ms": 150},
- {"type": "type", "text": "jet black velvet gown", "ms": 750},
+ {"type": "type", "text": ", jet black velvet", "ms": 624},
{"type": "frame", "frame": "s4a", "live": true, "ms": 540},
+ {"type": "type", "text": " gown", "ms": 180},
+ {"type": "frame", "frame": "s4b", "live": true, "ms": 540},
{"type": "zoom", "box": null, "ms": 0},
{"type": "frame", "frame": "s4", "ms": 600},
- {"type": "keep", "label": "Black velvet gown", "ms": 700},
- {"type": "zoom", "box": [0.4, 0.3, 0.64, 0.7], "ms": 240},
- {"type": "type", "text": "diamond choker", "ms": 460},
+ {"type": "change", "ms": 520},
+ {"type": "zoom", "box": [0.4, 0.3, 0.64, 0.7], "ms": 172},
+ {"type": "type", "text": ", diamond choker", "ms": 528},
{"type": "frame", "frame": "s5a", "live": true, "ms": 540},
- {"type": "type", "text": " necklace", "ms": 310},
+ {"type": "type", "text": " necklace", "ms": 292},
{"type": "frame", "frame": "s5b", "live": true, "ms": 540},
{"type": "zoom", "box": null, "ms": 0},
{"type": "frame", "frame": "s5", "ms": 600},
- {"type": "keep", "label": "Diamond choker", "ms": 700},
- {"type": "zoom", "box": [0.586, 0.164, 0.682, 0.366], "ms": 420},
- {"type": "type", "text": "red rose", "ms": 280},
+ {"type": "change", "ms": 520},
+ {"type": "zoom", "box": [0.586, 0.164, 0.682, 0.366], "ms": 340},
+ {"type": "type", "text": ", red rose", "ms": 360},
{"type": "frame", "frame": "s6a", "live": true, "ms": 540},
- {"type": "type", "text": " in her hair", "ms": 480},
+ {"type": "type", "text": " in her hair", "ms": 456},
{"type": "frame", "frame": "s6b", "live": true, "ms": 540},
{"type": "zoom", "box": null, "ms": 0},
{"type": "frame", "frame": "s6", "ms": 600},
- {"type": "keep", "label": "Red rose", "ms": 700},
+ {"type": "change", "ms": 520},
{"type": "zoom", "box": [0.28, 0.626, 0.722, 0.996], "ms": 150},
- {"type": "type", "text": "sheer black lace", "ms": 560},
+ {"type": "type", "text": ", sheer black lace", "ms": 624},
{"type": "frame", "frame": "s7a", "live": true, "ms": 540},
- {"type": "type", "text": " sleeves", "ms": 280},
+ {"type": "type", "text": " sleeves", "ms": 264},
{"type": "frame", "frame": "s7b", "live": true, "ms": 540},
{"type": "zoom", "box": null, "ms": 0},
{"type": "frame", "frame": "s7", "ms": 600},
- {"type": "keep", "label": "Black lace sleeves", "ms": 700},
- {"type": "type", "text": "candlelit", "ms": 270},
+ {"type": "change", "ms": 520},
+ {"type": "type", "text": ", candlelit", "ms": 348},
{"type": "frame", "frame": "s8a", "live": true, "ms": 540},
- {"type": "type", "text": " ballroom background", "ms": 680},
+ {"type": "type", "text": " ballroom", "ms": 292},
{"type": "frame", "frame": "s8b", "live": true, "ms": 540},
+ {"type": "type", "text": " background", "ms": 348},
+ {"type": "frame", "frame": "s8c", "live": true, "ms": 540},
{"type": "frame", "frame": "s8", "ms": 600},
- {"type": "keep", "label": "Candlelit ballroom", "ms": 700},
- {"type": "type", "text": "soft golden", "ms": 370},
+ {"type": "change", "ms": 520},
+ {"type": "type", "text": ", soft golden", "ms": 444},
{"type": "frame", "frame": "s9a", "live": true, "ms": 540},
- {"type": "type", "text": " backlight", "ms": 340},
+ {"type": "type", "text": " backlight", "ms": 320},
{"type": "frame", "frame": "s9b", "live": true, "ms": 540},
{"type": "frame", "frame": "s9", "ms": 600},
- {"type": "keep", "label": "Golden backlight", "ms": 700},
- {"type": "type", "text": "diamond tiara", "ms": 430},
+ {"type": "change", "ms": 520},
+ {"type": "zoom", "box": [0.36, 0.02, 0.62, 0.3], "ms": 200},
+ {"type": "type", "text": ", diamond tiara", "ms": 500},
{"type": "frame", "frame": "s10a", "live": true, "ms": 540},
- {"type": "type", "text": " on top", "ms": 290},
+ {"type": "type", "text": " on top", "ms": 276},
{"type": "frame", "frame": "s10b", "live": true, "ms": 540},
+ {"type": "zoom", "box": null, "ms": 0},
{"type": "frame", "frame": "s10", "ms": 600},
- {"type": "keep", "label": "Diamond tiara", "ms": 700},
- {"type": "type", "text": "black and white photo", "ms": 666},
+ {"type": "change", "ms": 520},
+ {"type": "type", "text": ", gold confetti", "ms": 500},
{"type": "frame", "frame": "s11a", "live": true, "ms": 540},
- {"type": "type", "text": ", only the rose stays", "ms": 706},
+ {"type": "type", "text": " in the air", "ms": 428},
{"type": "frame", "frame": "s11b", "live": true, "ms": 540},
- {"type": "type", "text": " red", "ms": 144},
{"type": "frame", "frame": "s11", "ms": 600},
- {"type": "keep", "label": "Black and white", "ms": 700},
+ {"type": "change", "ms": 520},
{"type": "compare", "ms": 2400},
{"type": "pause", "ms": 900}
]
diff --git a/public/previews/live-edit/live/step-01-1.webp b/public/previews/live-edit/live/step-01-1.webp
index eddf73d4..febf5c9b 100644
Binary files a/public/previews/live-edit/live/step-01-1.webp and b/public/previews/live-edit/live/step-01-1.webp differ
diff --git a/public/previews/live-edit/live/step-01-2.webp b/public/previews/live-edit/live/step-01-2.webp
index e37201ce..bda5e541 100644
Binary files a/public/previews/live-edit/live/step-01-2.webp and b/public/previews/live-edit/live/step-01-2.webp differ
diff --git a/public/previews/live-edit/live/step-01-3.webp b/public/previews/live-edit/live/step-01-3.webp
deleted file mode 100644
index 9374a5d7..00000000
Binary files a/public/previews/live-edit/live/step-01-3.webp and /dev/null differ
diff --git a/public/previews/live-edit/live/step-02-1.webp b/public/previews/live-edit/live/step-02-1.webp
index 335b2873..88a46c68 100644
Binary files a/public/previews/live-edit/live/step-02-1.webp and b/public/previews/live-edit/live/step-02-1.webp differ
diff --git a/public/previews/live-edit/live/step-02-2.webp b/public/previews/live-edit/live/step-02-2.webp
index c5608769..fe57925e 100644
Binary files a/public/previews/live-edit/live/step-02-2.webp and b/public/previews/live-edit/live/step-02-2.webp differ
diff --git a/public/previews/live-edit/live/step-02-3.webp b/public/previews/live-edit/live/step-02-3.webp
index 46e5ae5e..1862b94c 100644
Binary files a/public/previews/live-edit/live/step-02-3.webp and b/public/previews/live-edit/live/step-02-3.webp differ
diff --git a/public/previews/live-edit/live/step-03-1.webp b/public/previews/live-edit/live/step-03-1.webp
index 241d4bda..8152b4e4 100644
Binary files a/public/previews/live-edit/live/step-03-1.webp and b/public/previews/live-edit/live/step-03-1.webp differ
diff --git a/public/previews/live-edit/live/step-03-2.webp b/public/previews/live-edit/live/step-03-2.webp
index f0baf9b1..b902de8b 100644
Binary files a/public/previews/live-edit/live/step-03-2.webp and b/public/previews/live-edit/live/step-03-2.webp differ
diff --git a/public/previews/live-edit/live/step-04-1.webp b/public/previews/live-edit/live/step-04-1.webp
index ce2b28bf..90ec1d78 100644
Binary files a/public/previews/live-edit/live/step-04-1.webp and b/public/previews/live-edit/live/step-04-1.webp differ
diff --git a/public/previews/live-edit/live/step-04-2.webp b/public/previews/live-edit/live/step-04-2.webp
new file mode 100644
index 00000000..58ef06c4
Binary files /dev/null and b/public/previews/live-edit/live/step-04-2.webp differ
diff --git a/public/previews/live-edit/live/step-05-1.webp b/public/previews/live-edit/live/step-05-1.webp
index 6669291c..9dd150e4 100644
Binary files a/public/previews/live-edit/live/step-05-1.webp and b/public/previews/live-edit/live/step-05-1.webp differ
diff --git a/public/previews/live-edit/live/step-05-2.webp b/public/previews/live-edit/live/step-05-2.webp
index 0089e29a..6e7953fa 100644
Binary files a/public/previews/live-edit/live/step-05-2.webp and b/public/previews/live-edit/live/step-05-2.webp differ
diff --git a/public/previews/live-edit/live/step-06-1.webp b/public/previews/live-edit/live/step-06-1.webp
index 54b16fa1..af3a309f 100644
Binary files a/public/previews/live-edit/live/step-06-1.webp and b/public/previews/live-edit/live/step-06-1.webp differ
diff --git a/public/previews/live-edit/live/step-06-2.webp b/public/previews/live-edit/live/step-06-2.webp
index 7266eea4..1bffcbc8 100644
Binary files a/public/previews/live-edit/live/step-06-2.webp and b/public/previews/live-edit/live/step-06-2.webp differ
diff --git a/public/previews/live-edit/live/step-07-1.webp b/public/previews/live-edit/live/step-07-1.webp
index 37806a96..af8d38c7 100644
Binary files a/public/previews/live-edit/live/step-07-1.webp and b/public/previews/live-edit/live/step-07-1.webp differ
diff --git a/public/previews/live-edit/live/step-07-2.webp b/public/previews/live-edit/live/step-07-2.webp
index a222254e..ae2f3271 100644
Binary files a/public/previews/live-edit/live/step-07-2.webp and b/public/previews/live-edit/live/step-07-2.webp differ
diff --git a/public/previews/live-edit/live/step-08-1.webp b/public/previews/live-edit/live/step-08-1.webp
index f0d85914..59b05978 100644
Binary files a/public/previews/live-edit/live/step-08-1.webp and b/public/previews/live-edit/live/step-08-1.webp differ
diff --git a/public/previews/live-edit/live/step-08-2.webp b/public/previews/live-edit/live/step-08-2.webp
index ed865904..c370c451 100644
Binary files a/public/previews/live-edit/live/step-08-2.webp and b/public/previews/live-edit/live/step-08-2.webp differ
diff --git a/public/previews/live-edit/live/step-08-3.webp b/public/previews/live-edit/live/step-08-3.webp
new file mode 100644
index 00000000..a08ea717
Binary files /dev/null and b/public/previews/live-edit/live/step-08-3.webp differ
diff --git a/public/previews/live-edit/live/step-09-1.webp b/public/previews/live-edit/live/step-09-1.webp
index 3fe4f200..6a6a846f 100644
Binary files a/public/previews/live-edit/live/step-09-1.webp and b/public/previews/live-edit/live/step-09-1.webp differ
diff --git a/public/previews/live-edit/live/step-09-2.webp b/public/previews/live-edit/live/step-09-2.webp
index 134924db..e7606977 100644
Binary files a/public/previews/live-edit/live/step-09-2.webp and b/public/previews/live-edit/live/step-09-2.webp differ
diff --git a/public/previews/live-edit/live/step-10-1.webp b/public/previews/live-edit/live/step-10-1.webp
index 26b51c32..100aa6a5 100644
Binary files a/public/previews/live-edit/live/step-10-1.webp and b/public/previews/live-edit/live/step-10-1.webp differ
diff --git a/public/previews/live-edit/live/step-10-2.webp b/public/previews/live-edit/live/step-10-2.webp
index d75bd3be..90130375 100644
Binary files a/public/previews/live-edit/live/step-10-2.webp and b/public/previews/live-edit/live/step-10-2.webp differ
diff --git a/public/previews/live-edit/live/step-11-1.webp b/public/previews/live-edit/live/step-11-1.webp
index 23ae060c..5da2a62c 100644
Binary files a/public/previews/live-edit/live/step-11-1.webp and b/public/previews/live-edit/live/step-11-1.webp differ
diff --git a/public/previews/live-edit/live/step-11-2.webp b/public/previews/live-edit/live/step-11-2.webp
index 1face86c..ce2ab775 100644
Binary files a/public/previews/live-edit/live/step-11-2.webp and b/public/previews/live-edit/live/step-11-2.webp differ
diff --git a/src/app/api/live/render/route.ts b/src/app/api/live/render/route.ts
index a98dad1e..d0f01c8f 100644
--- a/src/app/api/live/render/route.ts
+++ b/src/app/api/live/render/route.ts
@@ -1,9 +1,9 @@
import { connection } from "next/server";
import { eventFrame, imageFrame, LIVE_STREAM_TYPE, type LiveEvent } from "@/lib/live/frames";
-import { MAX_GRAPH_PROMPT, slotBindings, type LiveGraphParams } from "@/lib/live/graph";
+import { slotBindings, type LiveGraphParams } from "@/lib/live/graph";
import { LIVE_INPUT, pictureExt, pngSize } from "@/lib/live/names";
import { isAspect, isKeepRes, isLiveSize, editSize, MAX_MASTER_SIDE } from "@/lib/live/sizes";
-import { METHODS, type Method } from "@/lib/live/steps";
+import { DEFAULT_METHOD, METHODS, type Method } from "@/lib/live/steps";
import { MAX_LIVE_TEXT, normalize, renderKey } from "@/lib/live/text";
import { ACCOUNT_MESSAGES, accountTotalBytes, accountUsage, diskHasRoom, filesFullMessage } from "@/server/account-files";
import { asWho, liveWho } from "@/server/live/access";
@@ -20,8 +20,6 @@ interface Body {
slot?: unknown;
urgent?: unknown;
text?: unknown;
- /** compose (an owner's lab method): the kept texts and the live text as one instruction. */
- compose?: unknown;
seed?: unknown;
size?: unknown;
keepRes?: unknown;
@@ -58,10 +56,9 @@ export async function POST(request: Request) {
// What to render: every value checked against the session and the size tables.
if (b.method !== undefined && !METHODS.includes(b.method as Method)) return Response.json({ error: "Bad method" }, { status: 400 });
- const method: Method = (b.method as Method | undefined) ?? "hybrid";
+ const method: Method = (b.method as Method | undefined) ?? DEFAULT_METHOD;
const text = typeof b.text === "string" ? b.text : "";
- const compose = who.kind === "owner" && method === "compose" && typeof b.compose === "string" ? b.compose : null;
- const prompt = compose !== null ? compose.slice(0, MAX_GRAPH_PROMPT) : normalize(text.slice(0, MAX_LIVE_TEXT * 2));
+ const prompt = normalize(text.slice(0, MAX_LIVE_TEXT * 2));
const seed = Number(b.seed);
if (!Number.isSafeInteger(seed) || seed < 0) return Response.json({ error: "Bad seed" }, { status: 400 });
const base = b.base === undefined || b.base === null ? undefined : b.base;
diff --git a/src/components/home/home-sections.tsx b/src/components/home/home-sections.tsx
index 786fe482..f2a31729 100644
--- a/src/components/home/home-sections.tsx
+++ b/src/components/home/home-sections.tsx
@@ -1,6 +1,6 @@
import Link from "next/link";
import { Fragment } from "react";
-import { ArrowRight, AudioLines, Box, CalendarClock, CornerDownLeft, ImageIcon, ListChecks, Plug, ScanEye, Sparkles, Undo2, Video, Zap, type LucideIcon } from "lucide-react";
+import { ArrowRight, AudioLines, Box, CalendarClock, ImageIcon, ListChecks, Plug, ScanEye, Sparkles, TextCursorInput, Undo2, Video, Zap, type LucideIcon } from "lucide-react";
import { GitHubMark } from "@/components/github-mark";
import { BeforeAfter } from "@/components/home/before-after";
import {
@@ -169,8 +169,8 @@ export function AppsSection({ facts, beforeAfter, reveals }: Pick<HomeShowcase,
export function LiveEditSection() {
const points: [LucideIcon, string][] = [
[Zap, "Live frames as you type, on your own GPU"],
- [CornerDownLeft, "Enter keeps a change; typing never does"],
- [Undo2, "Undo, redo and compare every step"],
+ [TextCursorInput, "One prompt that keeps growing, always on your original"],
+ [Undo2, "Undo a change, or start fresh from the picture"],
];
return (
<section aria-labelledby="home-live" className={cn(SECTION, "[--cv:720px] sm:[--cv:860px] md:[--cv:820px] lg:[--cv:470px] xl:[--cv:500px]")}>
diff --git a/src/components/live/live-demo.tsx b/src/components/live/live-demo.tsx
index 047805cd..4136b4a9 100644
--- a/src/components/live/live-demo.tsx
+++ b/src/components/live/live-demo.tsx
@@ -1,23 +1,22 @@
"use client";
-import { Check, CornerDownLeft, Zap } from "lucide-react";
+import { Zap } from "lucide-react";
import { type CSSProperties, useEffect, useLayoutEffect, useRef, useState } from "react";
import {
cameraFor,
+ changesWord,
+ countChanges,
type Demo,
type DemoView,
demoEnds,
FADE_MS,
frameOrder,
- KEEP_PULSE_MS,
LIVE_DEMO,
LIVE_DEMO_V,
pillText,
startView,
- stepsWord,
SWEEP_MS,
sweepPath,
- trailWindow,
typeDelays,
viewBefore,
ZOOM_MAX,
@@ -26,12 +25,12 @@ import {
import { cn } from "@/lib/utils";
/**
- * A recorded live edit session, played back: the camera moves in on the area the step changes, the text types itself
- * into the dock, each live frame is drawn across the picture as it arrives, the full-quality picture settles, the
- * camera pulls back out, Keep pulses, a step joins the trail, and a compare sweep shows the original against the last
- * step. It loops, pauses off screen and
- * in a hidden tab and picks up where it stopped, and under reduced motion it is a still before/after. Frames load
- * only once the player is in view. No GPU, no requests beyond the files: guests, Home and the Apps card see it.
+ * A recorded live edit session, played back: one prompt that keeps growing. The camera moves in on the area a change
+ * touches, the words type themselves onto the end of the prompt in the dock, each live frame is drawn across the
+ * picture as it arrives, the full-quality picture settles, the camera pulls back out and the change count goes up;
+ * at the end a compare sweep shows the original against the last picture. It loops, pauses off screen and in a hidden
+ * tab and picks up where it stopped, and under reduced motion it is a still before/after. Frames load only once the
+ * player is in view. No GPU, no requests beyond the files: guests, Home and the Apps card see it.
*/
export { LIVE_DEMO };
@@ -174,7 +173,6 @@ export function LiveDemo({ compact, className, onTypeAttempt }: { compact?: bool
frame: s.frame,
fade: v.frame === s.frame ? v.fade : FADE_MS,
sweep: !!s.live,
- ...(s.live ? { pill: "Live" as const } : {}),
},
);
await wait(s.ms);
@@ -191,12 +189,9 @@ export function LiveDemo({ compact, className, onTypeAttempt }: { compact?: bool
await wait(delays[c]);
}
typed = base + s.text;
- } else if (s.type === "keep") {
- setView((v) => v && { ...v, keepPulse: true });
- await wait(KEEP_PULSE_MS);
- typed = "";
- setView((v) => v && { ...v, keepPulse: false, typed: "", steps: [...v.steps, s.label], pill: "Kept ✓" });
- await wait(s.ms - KEEP_PULSE_MS);
+ } else if (s.type === "change") {
+ setView((v) => v && { ...v, changes: v.changes + 1 });
+ await wait(s.ms);
} else if (s.type === "compare") {
const t0 = performance.now();
while (alive && performance.now() - t0 < s.ms) {
@@ -226,7 +221,7 @@ export function LiveDemo({ compact, className, onTypeAttempt }: { compact?: bool
const v = ends && (reduced || !view) ? startView(ends.before) : view;
const ratio = demo ? `${demo.size[0]} / ${demo.size[1]}` : "4 / 3";
const pill = v ? pillText(v, compact) : { main: "Live", count: null };
- const kept = v?.steps.length ?? 0;
+ const changes = v?.changes ?? 0;
const showImages = visible || view !== null;
// The small card keeps the whole picture: zoomed in, the typing bar would cover the change.
const cam = cameraFor(v?.zoom ?? null, compact ? 1 : ZOOM_MAX);
@@ -245,7 +240,7 @@ export function LiveDemo({ compact, className, onTypeAttempt }: { compact?: bool
return (
<div ref={box} className={cn("@container relative isolate overflow-hidden rounded-2xl bg-media text-white", className)} style={{ aspectRatio: compact ? ratio : undefined }} data-live-demo>
{demo && ends && v && showImages && (reduced ? (
- <StillCompare before={src(ends.before)} after={src(ends.after)} steps={countKeeps(demo)} />
+ <StillCompare before={src(ends.before)} after={src(ends.after)} changes={countChanges(demo)} />
) : (
// The camera: it glides in on the area a step changes while the live frames arrive, and back out to keep.
<div
@@ -308,12 +303,12 @@ export function LiveDemo({ compact, className, onTypeAttempt }: { compact?: bool
{pill.main}
{pill.count && <span className="text-white/75">· {pill.count}</span>}
</span>
- {/* The compare sweep has its own labels; the trail steps aside while it plays. */}
- {!compact && v && <DemoTrail steps={v.steps} hidden={v.compare !== null} />}
+ {/* The compare sweep has its own labels; the count steps aside while it plays. */}
+ {!compact && v && <ChangeCount changes={v.changes} hidden={v.compare !== null} />}
{v && v.compare !== null && (
<div className={cn("pointer-events-none absolute inset-x-3 flex justify-between text-[11px] font-medium", compact ? "inset-x-2 bottom-12" : "bottom-16")} data-live-compare>
<span className="rounded-full bg-black/45 px-2 py-0.5 backdrop-blur">Original</span>
- <span className="rounded-full bg-white/90 px-2 py-0.5 text-black">{stepsWord(kept)}</span>
+ <span className="rounded-full bg-white/90 px-2 py-0.5 text-black">{changesWord(changes)}</span>
</div>
)}
<div className={cn("absolute inset-x-3 bottom-3 flex items-center gap-2", compact && "inset-x-2 bottom-2")}>
@@ -336,82 +331,33 @@ export function LiveDemo({ compact, className, onTypeAttempt }: { compact?: bool
{v.typed}
</span>
) : (
- <span className="truncate text-white/55">Type a change…</span>
+ <span className="truncate text-white/55">Type a change, then keep adding…</span>
)}
</span>
<span className="-ml-1.5 h-4 w-px shrink-0 bg-white/80 motion-safe:animate-[live-caret_1s_steps(1)_infinite]" />
</button>
- <span className={cn("inline-flex shrink-0 items-center justify-center gap-1 rounded-xl bg-white font-medium text-black transition-transform", compact ? "size-8" : "h-11 px-3.5 text-[13px]", v?.keepPulse && "scale-95 ring-4 ring-primary/60")} aria-label={compact ? "Keep" : undefined}>
- {kept && !v?.typed ? <Check className="size-3.5" /> : <CornerDownLeft className="size-3.5" />}
- {!compact && "Keep"}
- </span>
</div>
</div>
);
}
-const countKeeps = (d: Demo) => d.script.filter((s) => s.type === "keep").length;
-
/**
- * The kept steps, as the editor shows them: Original › +N › the newest step(s), the newest one whole and lit. One step
- * fits a phone-width player; three from a wider one. The player's own width decides (a container query), not the
- * window's, so Home's half-width player and a full-width phone each get the right count.
+ * How many changes the one prompt holds so far: "One prompt" and the count, which pops each time a change settles. The
+ * words themselves are in the dock.
*/
-export function DemoTrail({ steps, hidden }: { steps: readonly string[]; hidden?: boolean }) {
- if (!steps.length) return null;
- const wide = trailWindow(steps, 3);
- const narrow = trailWindow(steps, 1);
- const sep = <span className="shrink-0 text-white/70">›</span>;
+export function ChangeCount({ changes, hidden }: { changes: number; hidden?: boolean }) {
+ if (!changes) return null;
return (
- <div
- className={cn("pointer-events-none absolute top-3 right-3 flex max-w-[calc(100%-6.5rem)] min-w-0 items-center gap-1 text-[11px] transition-opacity duration-300", hidden && "opacity-0")}
- aria-hidden={hidden || undefined}
- data-live-trail
- >
- {/* On a narrow player, once earlier steps fold into a count, Original steps aside to keep the picture clear. */}
- <span className={cn("shrink-0 rounded-full bg-black/45 px-2 py-0.5 backdrop-blur", narrow.hidden > 0 && "@max-md:hidden")} data-live-original>
- Original
+ <div className={cn("pointer-events-none absolute top-3 right-3 flex items-center gap-1 text-[11px] transition-opacity duration-300", hidden && "opacity-0")} aria-hidden={hidden || undefined} data-live-count={changes}>
+ <span className="shrink-0 rounded-full bg-black/45 px-2 py-0.5 backdrop-blur max-[420px]:hidden">One prompt</span>
+ <span key={changes} className="shrink-0 rounded-full bg-white/95 px-2 py-0.5 font-medium text-black tabular-nums ring-2 ring-primary/60 animate-[live-chip_260ms_ease-out]">
+ {changesWord(changes)}
</span>
- {narrow.hidden > 0 && (
- <span className="contents @md:hidden">
- <span className="shrink-0 rounded-full bg-black/45 px-1.5 py-0.5 tabular-nums backdrop-blur" title={`${stepsWord(narrow.hidden)} before`} data-live-more={narrow.hidden}>
- +{narrow.hidden}
- </span>
- </span>
- )}
- {wide.hidden > 0 && (
- <span className="contents @max-md:hidden">
- {sep}
- <span className="shrink-0 rounded-full bg-black/45 px-1.5 py-0.5 tabular-nums backdrop-blur" title={`${stepsWord(wide.hidden)} before`} data-live-more={wide.hidden}>
- +{wide.hidden}
- </span>
- </span>
- )}
- {wide.shown.map(({ n, label }) => {
- const newest = n === steps.length;
- return (
- <span key={n} className={cn("contents", !newest && "@max-md:hidden")}>
- {sep}
- <span
- className={cn(
- "min-w-0 truncate rounded-full px-2 py-0.5",
- newest ? "max-w-[12rem] bg-white/95 font-medium text-black ring-2 ring-primary/60 animate-[live-chip_260ms_ease-out]" : "max-w-[8rem] shrink-[3] bg-white/70 text-black/80",
- )}
- title={label}
- data-live-chip={n}
- data-newest={newest || undefined}
- aria-current={newest ? "step" : undefined}
- >
- {n} · {label}
- </span>
- </span>
- );
- })}
</div>
);
}
-function StillCompare({ before, after, steps }: { before: string; after: string; steps: number }) {
+function StillCompare({ before, after, changes }: { before: string; after: string; changes: number }) {
const [pos, setPos] = useState(50);
return (
<div className="absolute inset-0">
@@ -421,10 +367,10 @@ function StillCompare({ before, after, steps }: { before: string; after: string;
<img src={before} alt="Before" className="absolute inset-0 size-full object-cover" style={{ clipPath: `inset(0 ${100 - pos}% 0 0)` }} />
<input type="range" min={0} max={100} value={pos} onChange={(e) => setPos(Number(e.target.value))} aria-label="Compare before and after" className="absolute inset-x-6 top-1/2 opacity-0" />
<span className="pointer-events-none absolute inset-y-0 w-0.5 bg-white" style={{ left: `${pos}%` }} />
- {steps > 0 && (
+ {changes > 0 && (
<div className="pointer-events-none absolute inset-x-3 top-12 flex justify-between text-[11px] font-medium">
<span className="rounded-full bg-black/45 px-2 py-0.5 backdrop-blur">Original</span>
- <span className="rounded-full bg-white/90 px-2 py-0.5 text-black">{stepsWord(steps)}</span>
+ <span className="rounded-full bg-white/90 px-2 py-0.5 text-black">{changesWord(changes)}</span>
</div>
)}
</div>
diff --git a/src/components/live/live-edit-app.tsx b/src/components/live/live-edit-app.tsx
index e9d4a708..454cdb2b 100644
--- a/src/components/live/live-edit-app.tsx
+++ b/src/components/live/live-edit-app.tsx
@@ -71,7 +71,7 @@ export function useLiveTransport(): LiveAccess {
/**
* Live edit inside the Edit studio (its Live switch): the same editor, seeded with the composer's picture. "Use in
- * Edit" hands the kept picture back to the composer, so the full model can finish the job.
+ * Edit" hands the picture on screen (full quality) back to the composer, so the full model can finish the job.
*/
export function LiveEditPanel({ image, text, onUse, onClose }: { image?: string; text?: string; onUse: (url: string) => void; onClose: () => void }) {
const live = useLiveTransport();
@@ -142,10 +142,10 @@ function LiveShowcase({ kind }: { kind: "guest" | "connect" | "unsupported" }) {
<div className="max-w-md">
<p className="font-heading text-[34px] leading-[1.08] text-balance sm:text-[40px]">Change a picture as you type</p>
<p className="mt-3 text-[15px] leading-relaxed text-muted-foreground text-pretty">
- Type a change and watch the picture follow. Press Enter to keep it, then type the next. Every kept step is a lossless full-size master, so nothing blurs, however many changes you stack.
+ Type a change and watch the picture follow, then keep adding to the same words. Every frame renders all of them on your original, so nothing blurs, however many changes you make.
</p>
<ul className="mt-4 space-y-1.5 text-[13.5px]">
- {["Live frames as you type, on your own GPU", "Keep, undo and redo every step", "Paint a region to change only that", "Compare with the step before or the original"].map((t) => (
+ {["Live frames as you type, on your own GPU", "One prompt that keeps growing", "Undo a change, or start fresh from the picture", "Paint a region to change only that"].map((t) => (
<li key={t} className="flex items-center gap-2">
<Sparkles className="size-3.5 shrink-0 text-primary" />
{t}
diff --git a/src/components/live/live-editor.tsx b/src/components/live/live-editor.tsx
index 0f8ad780..d9bddcbd 100644
--- a/src/components/live/live-editor.tsx
+++ b/src/components/live/live-editor.tsx
@@ -10,6 +10,7 @@ import {
Expand,
ImagePlus,
Keyboard,
+ Layers,
Loader2,
MoreHorizontal,
Redo2,
@@ -35,19 +36,21 @@ import { postFile } from "@/lib/upload";
import type { LiveEvent } from "@/lib/live/frames";
import { aspectOf, AutoSize, isAspect, keepAuto, KEEP_LADDER, LIVE_LADDER, type Aspect, type KeepRes, type LiveSize } from "@/lib/live/sizes";
import { pictureExt, pngSize } from "@/lib/live/names";
-import { restoreStack, StepStack, type Method, type Step } from "@/lib/live/steps";
-import { completedWords, endsWord, MAX_LIVE_TEXT, normalize } from "@/lib/live/text";
+import { DEFAULT_METHOD, restoreStack, StepStack, type Method, type Step } from "@/lib/live/steps";
+import { changeCount, completedWords, dropLastChange, endsWord, MAX_LIVE_TEXT, nextChange, normalize } from "@/lib/live/text";
import { cn } from "@/lib/utils";
import { keyOf, type LiveFacts, type LiveTransport, type RenderOut, type RenderReq, type TransportStatus } from "./live-transport";
import { idbDel, idbGet, idbPrune, idbPut } from "./live-store";
/**
- * Live edit: change a picture as you type. The text box drives throwaway live frames (small WebP, a few hundred
- * milliseconds each); a pause renders the text on screen at full quality (the settled frame); Keep (Enter, the Keep
- * button, or a click on a Try) stores that exact picture as a lossless master and the next change builds on it. Typing
- * never keeps anything by itself. Undo and redo move through the kept steps; hold C to compare with the step before
- * (Shift+C: the original); B paints a region to change. Two shells: the full-screen app (/live-edit) and a panel in
- * the Edit studio.
+ * Live edit: change a picture as you type. One prompt keeps growing, and every frame renders the whole of it on the
+ * same picture (the original, or the picture the person started fresh from), with one seed for the session, so the
+ * picture stays steady while the words change. The text box drives throwaway live frames (small WebP); a pause renders
+ * the text on screen at full quality (the settled frame). Enter ends a change (", ") and Undo drops the newest one.
+ * Start fresh stores the picture on screen as a lossless master, makes it the new start and clears the words (Undo
+ * brings them back). Hold C to compare with the picture before the words (Shift+C: the original); B paints a region
+ * to change. The owner's lab switch (?lab=1) brings back stacking, where Enter keeps each change as a step. Two
+ * shells: the full-screen app (/live-edit) and a panel in the Edit studio.
*/
export interface LiveEditorProps {
@@ -61,7 +64,7 @@ export interface LiveEditorProps {
from?: string;
/** The owner may save to the Library; an account downloads instead. */
canSave: boolean;
- /** The owner's lab: the stacking method can be switched (hybrid, chain, compose). */
+ /** The owner's lab: the method can be switched (compose, or stacking: hybrid, chain). */
lab?: boolean;
/** Embedded: hand the kept picture to the Edit studio. */
onUse?: (url: string) => void;
@@ -74,6 +77,8 @@ const IDLE_MS = 250;
const SETTLE_MS = 1200;
const CACHE_SIZE = 120;
const MAX_TRIES = 6;
+/** Compose: from this many changes in one prompt, the editor suggests a fresh start. */
+const LONG_PROMPT_CHANGES = 12;
interface Shown {
url: string;
@@ -196,7 +201,11 @@ export function LiveEditor(props: LiveEditorProps) {
const [liveChoice, setLiveChoice] = useState<"auto" | LiveSize>("auto");
const [keepChoice, setKeepChoice] = useState<"auto" | KeepRes>("auto");
const [aspect, setAspect] = useState<Aspect>("3:4");
- const [method, setMethod] = useState<Method>("hybrid");
+ const [method, setMethod] = useState<Method>(DEFAULT_METHOD);
+ /** One growing prompt on the start picture (everyone); the others stack kept steps (the owner's lab). */
+ const compose = method === "compose";
+ /** What Undo took off the end of the words, for Redo (while the words are still what Undo left). */
+ const [textRedo, setTextRedo] = useState<{ text: string; was: string }[]>([]);
const auto = useRef(new AutoSize(512));
const [liveSize, setLiveSize] = useState<LiveSize>(512);
const sizeShown: LiveSize = liveChoice === "auto" ? liveSize : liveChoice;
@@ -209,7 +218,7 @@ export function LiveEditor(props: LiveEditorProps) {
const anySize = useRef(new Map<string, string>());
const idle = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
const settle = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
- const [busy, setBusy] = useState<{ what: "rendering" | "warming" | "keeping" | "adding"; since: number; progress?: number } | null>(null);
+ const [busy, setBusy] = useState<{ what: "rendering" | "warming" | "keeping" | "saving" | "adding"; since: number; progress?: number } | null>(null);
const [lastMs, setLastMs] = useState<number | null>(null);
const [keptFlash, setKeptFlash] = useState(false);
const [hidden, setHidden] = useState(false);
@@ -240,7 +249,7 @@ export function LiveEditor(props: LiveEditorProps) {
const urlOf = (s: Step | null): string | null => (s ? (urls[s.master.name] ?? s.master.url ?? null) : null);
const persist = useCallback(() => {
- save(persistKey, { v: 1, stack: stack.current.toJSON(), seed: seedRef.current, keepChoice, liveChoice, aspect });
+ save(persistKey, { v: 1, stack: stack.current.toJSON(), seed: seedRef.current, keepChoice, liveChoice, aspect, text: textRef.current });
}, [persistKey, keepChoice, liveChoice, aspect]);
const showMaster = useCallback(
@@ -286,7 +295,7 @@ export function LiveEditor(props: LiveEditorProps) {
void transport.render(req, onEvent).then(() => setBusy((b) => (b?.what === "warming" ? null : b)));
};
/** The newest handlers, for effects and timers. */
- const latest = useRef({ warm, render: (() => {}) as (slot: "live" | "settle", t: string, o?: { urgent?: boolean }) => void, schedule: (() => {}) as (t: string, typed?: string) => void, addFile: (async () => {}) as (f: File) => Promise<void> });
+ const latest = useRef({ warm, render: (() => {}) as (slot: "live" | "settle", t: string, o?: { urgent?: boolean }) => void, schedule: (() => {}) as (t: string, typed?: string, whole?: boolean) => void, addFile: (async () => {}) as (f: File) => Promise<void> });
useEffect(() => {
let alive = true;
@@ -303,13 +312,18 @@ export function LiveEditor(props: LiveEditorProps) {
// Masters this browser kept for steps no saved session refers to any more go.
void idbPrune(idbInUse());
// A stored session for this picture comes back as it was.
- const stored = load<{ stack: unknown; seed: number; keepChoice?: "auto" | KeepRes; liveChoice?: "auto" | LiveSize; aspect?: string }>(storageKey(props.image));
+ const stored = load<{ stack: unknown; seed: number; keepChoice?: "auto" | KeepRes; liveChoice?: "auto" | LiveSize; aspect?: string; text?: unknown }>(storageKey(props.image));
const restored = stored ? restoreStack(stored.stack) : new StepStack();
seedRef.current = stored?.seed ?? r.seed;
setSeed(seedRef.current);
if (stored?.keepChoice) setKeepChoice(stored.keepChoice);
if (stored?.liveChoice) setLiveChoice(stored.liveChoice);
if (stored?.aspect && isAspect(stored.aspect)) setAspect(stored.aspect);
+ // The words come back with the picture (a link's own text wins).
+ if (!props.text && typeof stored?.text === "string" && stored.text) {
+ textRef.current = stored.text.slice(0, MAX_LIVE_TEXT);
+ setText(textRef.current);
+ }
try {
if (!restored.empty) {
stack.current = restored;
@@ -342,7 +356,7 @@ export function LiveEditor(props: LiveEditorProps) {
useEffect(() => {
if (phase.s === "ready") persist();
- }, [view, phase.s, persist]);
+ }, [view, text, phase.s, persist]);
// The tab in view: renders pause while it is hidden.
useEffect(() => {
@@ -364,13 +378,12 @@ export function LiveEditor(props: LiveEditorProps) {
const reqFor = (slot: RenderReq["slot"], t: string, o: { urgent?: boolean; seed?: number } = {}): RenderReq => {
const s = stack.current;
- const base = s.base(method)?.name;
+ const base = s.base()?.name;
return {
seq: ++seq.current,
slot,
urgent: o.urgent,
text: t,
- ...(method === "compose" && { compose: s.composePrompt(normalize(t)) }),
seed: o.seed ?? seedRef.current,
size: sizeNow(),
keepRes,
@@ -471,7 +484,7 @@ export function LiveEditor(props: LiveEditorProps) {
}
setLastMs(out.ms);
// A frame for a base that is no longer the head doesn't show.
- if (baseAtStart !== stack.current.base(method)?.name) return;
+ if (baseAtStart !== stack.current.base()?.name) return;
present(c, req.seq, key);
});
};
@@ -484,21 +497,24 @@ export function LiveEditor(props: LiveEditorProps) {
else if (wasOther.current && status.online && phase.s === "ready") {
wasOther.current = false;
latest.current.warm(stack.current.head?.master.name);
- latest.current.render("live", textRef.current, { urgent: true });
+ // The words render again, settle included (a settle the pause dropped would never come back otherwise).
+ if (normalize(textRef.current)) latest.current.schedule(textRef.current, undefined, true);
}
}, [status.running, status.online, phase.s]);
- // Coming back from a pause (live switched on, the tab in view again, the connection back): the newest text renders.
+ // Coming back from a pause (live switched on, the tab in view again, the connection back): the newest text renders,
+ // and settles.
useEffect(() => {
- if (!paused && phase.s === "ready" && normalize(textRef.current)) latest.current.render("live", textRef.current, { urgent: true });
+ if (!paused && phase.s === "ready" && normalize(textRef.current)) latest.current.schedule(textRef.current, undefined, true);
}, [paused, phase.s]);
- const schedule = (t: string, typed?: string) => {
+ const schedule = (t: string, typed?: string, whole = false) => {
clearTimeout(idle.current);
clearTimeout(settle.current);
- // A word boundary, a line break or a paste: the words so far render at once.
- if (typed === undefined || (typed.length === 1 && endsWord(typed)) || typed.length > 1) {
- const words = typed && typed.length > 1 ? t : completedWords(t);
+ // A word boundary, a line break or a paste: the words so far render at once (all of them, for a paste, an undo
+ // or a redo).
+ if (whole || typed === undefined || (typed.length === 1 && endsWord(typed)) || typed.length > 1) {
+ const words = whole || (typed && typed.length > 1) ? t : completedWords(t);
if (normalize(words)) render("live", words);
}
// A pause: the exact text, urgently.
@@ -507,7 +523,8 @@ export function LiveEditor(props: LiveEditorProps) {
settle.current = setTimeout(() => normalize(t) && latest.current.render("settle", t), SETTLE_MS);
};
- const onType = (next: string, typed?: string) => {
+ /** New words in the box: they render (whole: all of them at once). */
+ const applyText = (next: string, typed?: string, whole = false) => {
const t = next.slice(0, MAX_LIVE_TEXT);
setText(t);
textRef.current = t;
@@ -518,7 +535,12 @@ export function LiveEditor(props: LiveEditorProps) {
showMaster(stack.current.head);
return;
}
- schedule(t, typed);
+ schedule(t, typed, whole);
+ };
+
+ const onType = (next: string, typed?: string) => {
+ if (textRedo.length) setTextRedo([]);
+ applyText(next, typed);
};
// A starting text from the link renders once ready.
@@ -557,24 +579,14 @@ export function LiveEditor(props: LiveEditorProps) {
/** A keep is running (a ref: two Enters in one tick must not both start one). */
const keepingRef = useRef(false);
- const keep = async (choice?: { text: string; seed: number }, download = false) => {
- if (keepingRef.current || phase.s !== "ready") return;
- const t = choice?.text ?? textRef.current;
- if (!normalize(t)) return;
- const keepSeed = choice?.seed ?? seedRef.current;
- keepingRef.current = true;
- // The step joins the head it started from (undo, redo and a new picture wait until the keep is done).
- const parent = stack.current.head?.id ?? null;
- setKeeping(true);
- clearTimeout(idle.current);
- clearTimeout(settle.current);
- setBusy({ what: "keeping", since: performance.now() });
- try {
+ /**
+ * The full-quality picture of this text as a lossless master: the server's file (or this browser's copy, when the
+ * account's space is full), staged in ComfyUI under its name. Null when the render didn't come back.
+ */
+ const makeMaster = async (t: string, keepSeed: number) => {
const req = reqFor("keep", t, { seed: keepSeed });
const settledKey = keyOf({ ...req, slot: "settle" });
const held = cache.current.get(settledKey);
- // Stale live renders of the old base stop now.
- transport.cancel((_, slot) => slot === "live" || slot === "settle");
let out: RenderOut;
if (held && transport.kind === "computer") {
// What you saw is what you keep: the settled picture, as it is.
@@ -583,7 +595,7 @@ export function LiveEditor(props: LiveEditorProps) {
const res = await transport.render(req, onEvent);
if (!res.ok) {
if ("error" in res) failed(res.error, res.code);
- return;
+ return null;
}
out = res.out;
}
@@ -614,32 +626,57 @@ export function LiveEditor(props: LiveEditorProps) {
}
where.url = url;
where.idb = idb;
+ return { req, out, size, name, url, idb, local, blobUrl };
+ };
+
+ /**
+ * Keep the picture of this text. Compose: a fresh start (the picture on screen becomes the new start). The lab's
+ * stacking: a new step. The words clear either way; Undo brings them back.
+ */
+ const keep = async (choice?: { text: string; seed: number }, download = false) => {
+ if (keepingRef.current || phase.s !== "ready") return;
+ const t = choice?.text ?? textRef.current;
+ if (!normalize(t)) return;
+ const keepSeed = choice?.seed ?? seedRef.current;
+ keepingRef.current = true;
+ // The step joins the head it started from (undo, redo and a new picture wait until the keep is done).
+ const parent = stack.current.head?.id ?? null;
+ setKeeping(true);
+ clearTimeout(idle.current);
+ clearTimeout(settle.current);
+ setBusy({ what: "keeping", since: performance.now() });
+ try {
+ // Stale live renders of the old base stop now.
+ transport.cancel((_, slot) => slot === "live" || slot === "settle");
+ const m = await makeMaster(t, keepSeed);
+ if (!m) return;
const step = stack.current.keep({
text: t,
norm: normalize(t),
seed: keepSeed,
method,
- keepRes: req.keepRes,
+ keepRes: m.req.keepRes,
...(mask && { mask: { name: mask.name } }),
- master: { name, w: size.w, h: size.h, sha256: out.sha256, format: "png", ...(url && { url }), ...(idb && { idb }) },
- ms: out.ms,
- ...(local && { local: true }),
+ master: { name: m.name, w: m.size.w, h: m.size.h, sha256: m.out.sha256, format: "png", ...(m.url && { url: m.url }), ...(m.idb && { idb: m.idb }) },
+ ms: m.out.ms,
+ ...(m.local && { local: true }),
}, parent);
bump();
releaseBlobs();
setText("");
textRef.current = "";
+ setTextRedo([]);
setTries([]);
setMask(null);
showMaster(step);
setKeptFlash(true);
setTimeout(() => setKeptFlash(false), 1000);
- if (download) downloadUrl(blobUrl, `live-edit-${step.id}.png`);
- if (local) toast.message("Kept in this browser only", { description: "Your files are full, so this step stays here. Download it to keep it." });
+ if (download) downloadUrl(m.blobUrl, `live-edit-${step.id}.png`);
+ if (m.local) toast.message("Kept in this browser only", { description: "Your files are full, so this picture stays here. Download it to keep it." });
// Once, on a touch screen: how to compare.
if (load<boolean>(HOLD_HINT) === null && window.matchMedia?.("(pointer: coarse)").matches) {
save(HOLD_HINT, true);
- toast.message("Press and hold the picture to see the step before", { description: "The … menu compares with the original too." });
+ toast.message(compose ? "Press and hold the picture to see it before the words" : "Press and hold the picture to see the step before", { description: "The … menu compares with the original too." });
}
} catch (e) {
toast.error((e as Error).message);
@@ -653,16 +690,65 @@ export function LiveEditor(props: LiveEditorProps) {
const move = async (to: "undo" | "redo" | string) => {
if (keepingRef.current) return;
const s = stack.current;
+ const from = s.path();
const step = to === "undo" ? s.undo() : to === "redo" ? s.redo() : s.jump(to);
if (!step) return;
transport.cancel((_, slot) => slot === "live" || slot === "settle");
setTries([]);
+ setTextRedo([]);
bump();
+ if (compose) {
+ // Back to an earlier start: the words that led on from it come back, with their seed. Forward: a clean box.
+ const at = from.findIndex((x) => x.id === step.id);
+ const next = at >= 0 && at < from.length - 1 ? from[at + 1] : null;
+ textRef.current = next?.text ?? "";
+ setText(textRef.current);
+ if (next) {
+ seedRef.current = next.seed;
+ setSeed(next.seed);
+ }
+ }
showMaster(step);
try {
await ensureStaged(step);
} catch {}
- if (normalize(textRef.current)) render("live", textRef.current, { urgent: true });
+ if (normalize(textRef.current)) {
+ if (compose) schedule(textRef.current, undefined, true);
+ else render("live", textRef.current, { urgent: true });
+ }
+ };
+
+ /** Undo: compose takes the newest change off the words first, then goes back past a fresh start. */
+ const undo = () => {
+ const t = textRef.current;
+ if (compose && normalize(t)) {
+ const left = dropLastChange(t);
+ setTextRedo((r) => [...r, { text: left, was: t }]);
+ applyText(left, undefined, true);
+ return;
+ }
+ void move("undo");
+ };
+ const textRedoTop = textRedo.at(-1);
+ const canTextRedo = compose && !!textRedoTop && textRedoTop.text === text;
+ const redo = () => {
+ if (canTextRedo && textRedoTop) {
+ setTextRedo((r) => r.slice(0, -1));
+ applyText(textRedoTop.was, undefined, true);
+ return;
+ }
+ void move("redo");
+ };
+
+ /** A click on a try. Compose: a try is a moment of the session, and the click goes back to its words (and seed). The lab: keep it. */
+ const onTry = (e: React.MouseEvent<HTMLButtonElement>) => {
+ const t = tries.find((x) => x.key === e.currentTarget.dataset.try);
+ if (!t) return;
+ if (!compose) return void keep({ text: t.text, seed: t.seed });
+ seedRef.current = t.seed;
+ setSeed(t.seed);
+ if (textRedo.length) setTextRedo([]);
+ applyText(t.text, undefined, true);
};
/** Live off stops what is rendering for the text; on again, the newest text renders. */
@@ -750,20 +836,80 @@ export function LiveEditor(props: LiveEditorProps) {
// Saving and downloading
const current = shown?.url ?? urlOf(head);
- const download = () => current && downloadUrl(current, `live-edit-${head?.id ?? "frame"}.${shown?.kind === "live" ? "webp" : "png"}`);
+
+ /** Compose: the full-quality picture of the words on screen (the settled frame, rendered now if it isn't there yet). */
+ const settledNow = async (): Promise<Cached | null> => {
+ const t = textRef.current;
+ const req = reqFor("settle", t);
+ const key = keyOf(req);
+ const had = cache.current.get(key);
+ if (had) return had;
+ setBusy((b) => b ?? { what: "rendering", since: performance.now() });
+ const res = await transport.render(req, onEvent);
+ setBusy((b) => (b?.what === "rendering" && !inflight.current.size ? null : b));
+ if (!res.ok) {
+ if ("error" in res) failed(res.error, res.code);
+ return null;
+ }
+ const c: Cached = { url: URL.createObjectURL(new Blob([res.out.data as BlobPart], { type: res.out.type })), out: res.out, kind: "settled", seed: req.seed, text: t };
+ remember(key, c);
+ present(c, req.seq, key);
+ return c;
+ };
+
+ const download = async () => {
+ if (compose && normalize(textRef.current)) {
+ const c = await settledNow();
+ if (c) downloadUrl(c.url, `live-edit-${head?.id ?? "frame"}.png`);
+ return;
+ }
+ if (current) downloadUrl(current, `live-edit-${head?.id ?? "frame"}.${shown?.kind === "live" ? "webp" : "png"}`);
+ };
+
+ /** What Save and Use hand on: compose with words, the picture on screen as a new master (the words stay); else the kept head. */
+ const canHandOn = compose ? !!normalize(text) || view.path.length > 1 : !!head?.master.url && view.path.length > 1;
+ const handOn = async (): Promise<string | null> => {
+ const h = stack.current.head;
+ if (!(compose && normalize(textRef.current))) return h?.master.url ?? null;
+ if (keepingRef.current || phase.s !== "ready") return null;
+ keepingRef.current = true;
+ setKeeping(true);
+ setBusy({ what: "saving", since: performance.now() });
+ try {
+ const m = await makeMaster(textRef.current, seedRef.current);
+ if (m && !m.url) toast.error("Your files are full, so this picture can't be handed on. Download it instead.");
+ return m?.url ?? null;
+ } catch (e) {
+ toast.error((e as Error).message);
+ return null;
+ } finally {
+ keepingRef.current = false;
+ setKeeping(false);
+ setBusy(null);
+ }
+ };
+ const sendToEdit = async () => {
+ const url = await handOn();
+ if (url) props.onUse?.(url);
+ };
const saveToLibrary = async () => {
const s = stack.current;
- const h = s.head;
- if (!h?.master.url) return toast.error("Keep a change first");
+ const open = compose && normalize(textRef.current) ? textRef.current : "";
+ const seedNow = seedRef.current;
+ const url = await handOn();
+ if (!url) return open ? undefined : toast.error("Make a change first");
+ const steps = [...s.path().filter((x) => x.text).map((x) => ({ text: x.text, seed: x.seed })), ...(open ? [{ text: open, seed: seedNow }] : [])];
const res = await fetch("/api/live/save", {
method: "POST",
headers: { "content-type": "application/json" },
- body: JSON.stringify({ master: h.master.url, ...(s.original?.master.url && s.original.parent === null && s.original.text === "" && { original: s.original.master.url }), steps: s.path().filter((x) => x.text).map((x) => ({ text: x.text, seed: x.seed })), ...(props.from && { from: props.from }) }),
+ body: JSON.stringify({ master: url, ...(s.original?.master.url && s.original.parent === null && s.original.text === "" && { original: s.original.master.url }), steps, ...(props.from && { from: props.from }) }),
});
if (res.ok) toast.success("Saved to your Library");
else toast.error(((await res.json().catch(() => ({}))) as { error?: string }).error ?? "Couldn't save");
};
+ const canKeep = !!normalize(text) && phase.s === "ready" && !keeping;
+
// ---------------------------------------------------------------------------
// Keys
@@ -776,10 +922,10 @@ export function LiveEditor(props: LiveEditorProps) {
const mod = e.metaKey || e.ctrlKey;
if (mod && (e.key === "z" || e.key === "Z") && !e.shiftKey && (!inBox || !textRef.current)) {
e.preventDefault();
- void move("undo");
+ undo();
} else if (mod && (((e.key === "z" || e.key === "Z") && e.shiftKey) || e.key === "y") && (!inBox || !textRef.current)) {
e.preventDefault();
- void move("redo");
+ redo();
}
if (inBox || mod || e.altKey) return;
const k = e.key;
@@ -790,7 +936,8 @@ export function LiveEditor(props: LiveEditorProps) {
else if (k === "l" || k === "L") toggleLive();
else if (k === "c" || k === "C") setHold(e.shiftKey ? "orig" : "prev");
else if ((k === "b" || k === "B") && hasPicture) setBrushOpen(true);
- else if (k === "d" || k === "D") download();
+ else if (k === "d" || k === "D") void download();
+ else if ((k === "f" || k === "F") && compose && canKeep) void keep();
else if ((k === "s" || k === "S") && props.canSave) void saveToLibrary();
else if (k === "?") setKeysOpen(true);
else if (k === "ArrowLeft" || k === "ArrowRight") {
@@ -819,9 +966,12 @@ export function LiveEditor(props: LiveEditorProps) {
const path = view.path;
const previous = view.previous;
const original = view.original;
- const heldUrl = hold === "orig" ? urlOf(original) : hold === "prev" ? urlOf(previous ?? original) : null;
+ /** "Before": with words in the box (compose), the picture they change; otherwise the step before. */
+ const before = compose && normalize(text) ? head : (previous ?? original);
+ const heldUrl = hold === "orig" ? urlOf(original) : hold === "prev" ? urlOf(before) : null;
const stageUrl = heldUrl ?? current;
- const canKeep = !!normalize(text) && phase.s === "ready" && !keeping;
+ /** A very long prompt: a late change can lose out to the earlier ones, and the box nears its limit. */
+ const longPrompt = changeCount(text) >= LONG_PROMPT_CHANGES || text.length > MAX_LIVE_TEXT - 60;
const link = transport.kind === "link";
const pill = (() => {
@@ -830,11 +980,12 @@ export function LiveEditor(props: LiveEditorProps) {
if (phase.s === "error") return { tone: "warn", text: "Not available" };
if (!status.online) return { tone: "wait", text: "Reconnecting…" };
if (status.running === "other") return { tone: "warn", text: "Paused: GPU busy" };
- if (busy?.what === "keeping") return { tone: "busy", text: "Keeping…" };
+ if (busy?.what === "keeping") return { tone: "busy", text: compose ? "Starting fresh…" : "Keeping…" };
+ if (busy?.what === "saving") return { tone: "busy", text: "Getting it ready…" };
if (busy?.what === "warming") return { tone: "busy", text: "Warming up (about 20 s)" };
if (busy?.what === "adding") return { tone: "busy", text: "Adding the picture…" };
if (!liveOn) return { tone: "off", text: "Live off" };
- if (keptFlash) return { tone: "ok", text: "Kept ✓" };
+ if (keptFlash) return { tone: "ok", text: compose ? "Fresh start ✓" : "Kept ✓" };
const label = link ? "Live (slower over a link)" : "Live";
// A kept picture's size is on its badge; the pill tells the live size and time only for live and settled frames.
if (!shown || shown.kind === "master") return { tone: busy ? "busy" : "ok", text: label };
@@ -878,10 +1029,10 @@ export function LiveEditor(props: LiveEditorProps) {
</h1>
<StatusPill tone={pill.tone} text={pill.text} detail={pill.detail} progress={busy?.progress} />
<div className="ml-auto flex shrink-0 items-center gap-0.5">
- <ToolButton label="Undo" keys="Ctrl+Z" onClick={() => void move("undo")} disabled={!view.canUndo}>
+ <ToolButton label={compose && normalize(text) ? "Undo the last change" : "Undo"} keys="Ctrl+Z" onClick={() => undo()} disabled={!(compose && normalize(text)) && !view.canUndo}>
<Undo2 />
</ToolButton>
- <ToolButton label="Redo" keys="Ctrl+Shift+Z" onClick={() => void move("redo")} disabled={!view.canRedo}>
+ <ToolButton label="Redo" keys="Ctrl+Shift+Z" onClick={() => redo()} disabled={!canTextRedo && !view.canRedo}>
<Redo2 />
</ToolButton>
<ToolButton label="Compare" keys="hold C" onClick={() => setCompareOpen(true)} disabled={!previous && !original} className="max-sm:hidden">
@@ -906,6 +1057,7 @@ export function LiveEditor(props: LiveEditorProps) {
hasPicture={hasPicture}
seed={seed}
lab={props.lab}
+ compose={compose}
method={method}
setMethod={setMethod}
onKeys={() => setKeysOpen(true)}
@@ -916,12 +1068,12 @@ export function LiveEditor(props: LiveEditorProps) {
compare: previous || original ? () => setCompareOpen(true) : undefined,
liveOn,
toggleLive,
- download: current ? download : undefined,
- save: !embedded && props.canSave && head?.master.url && path.length > 1 ? () => void saveToLibrary() : undefined,
+ download: current ? () => void download() : undefined,
+ save: !embedded && props.canSave && canHandOn ? () => void saveToLibrary() : undefined,
fullScreen: embedded ? `/live-edit${image ? `?image=${encodeURIComponent(image)}&from=edit` : "?from=edit"}` : undefined,
}}
/>
- <ToolButton label="Download" keys="D" onClick={download} disabled={!current} className="max-sm:hidden">
+ <ToolButton label="Download" keys="D" onClick={() => void download()} disabled={!current} className="max-sm:hidden">
<Download />
</ToolButton>
{embedded ? (
@@ -936,7 +1088,7 @@ export function LiveEditor(props: LiveEditorProps) {
</TooltipTrigger>
<TooltipContent>Full screen</TooltipContent>
</Tooltip>
- <Button size="sm" onClick={() => head?.master.url && props.onUse?.(head.master.url)} disabled={!head?.master.url || path.length < 2} className="ml-1 max-sm:px-2.5">
+ <Button size="sm" onClick={() => void sendToEdit()} disabled={!canHandOn || keeping} className="ml-1 max-sm:px-2.5">
<span className="max-sm:hidden">Use in Edit</span>
<span className="sm:hidden">Use</span>
</Button>
@@ -947,7 +1099,7 @@ export function LiveEditor(props: LiveEditorProps) {
)}
</>
) : props.canSave ? (
- <Button size="sm" variant="secondary" onClick={() => void saveToLibrary()} disabled={!head?.master.url || path.length < 2} className="ml-1 max-sm:hidden">
+ <Button size="sm" variant="secondary" onClick={() => void saveToLibrary()} disabled={!canHandOn || keeping} className="ml-1 max-sm:hidden">
<Save className="size-4" />
Save
</Button>
@@ -957,21 +1109,30 @@ export function LiveEditor(props: LiveEditorProps) {
{/* Stage */}
<div className={cn("relative mx-3 min-h-0 flex-1 overflow-hidden rounded-2xl bg-media sm:mx-4", dragging && "ring-2 ring-primary")} data-live-stage onPointerDown={(e) => e.pointerType !== "mouse" && setHold("prev")} onPointerUp={() => setHold(null)} onPointerLeave={() => setHold(null)}>
- {setupPanel ?? errorPanel ?? (stageUrl ? <StageImage src={stageUrl} alt={hold ? "The picture before this change" : "Your picture"} /> : <EmptyStage busy={busy?.what === "adding"} onBrowse={() => fileInput.current?.click()} />)}
+ {setupPanel ?? errorPanel ?? (stageUrl ? <StageImage src={stageUrl} alt={hold ? "The picture before this change" : "Your picture"} /> : <EmptyStage busy={busy?.what === "adding"} compose={compose} onBrowse={() => fileInput.current?.click()} />)}
{mask && !hold && (
// eslint-disable-next-line @next/next/no-img-element
<img src={mask.preview} alt="" className="pointer-events-none absolute inset-0 size-full object-contain opacity-35 mix-blend-screen" />
)}
{stageUrl && phase.s === "ready" && (
<span className="pointer-events-none absolute bottom-3 left-3 rounded-full bg-black/55 px-2.5 py-1 text-[11px] font-medium text-white tabular-nums backdrop-blur" data-live-badge>
- {hold ? (hold === "orig" ? "Original" : "Before") : shown?.kind === "master" ? `${shown.w}×${shown.h} · kept ✓` : shown?.kind === "settled" ? `${shown.w}×${shown.h} · ready to keep` : `${sizeShown} · live`}
+ {hold
+ ? hold === "orig"
+ ? "Original"
+ : "Before"
+ : shown?.kind === "master"
+ ? `${shown.w}×${shown.h} · ${compose ? (head?.parent ? "fresh start" : "original") : "kept ✓"}`
+ : shown?.kind === "settled"
+ ? `${shown.w}×${shown.h} · ${compose ? "full quality" : "ready to keep"}`
+ : `${sizeShown} · live`}
</span>
)}
</div>
{/* Steps, the box, tries */}
<div className={cn("shrink-0 px-3 pt-2 sm:px-4", embedded ? "pb-3" : "pb-[max(12px,env(safe-area-inset-bottom))]")}>
- <StepTrail path={path} all={view.all} headId={head?.id} onJump={(id) => void move(id)} urlOf={urlOf} />
+ {/* Compose shows its starts only once there is a fresh start to go back to. */}
+ {(!compose || path.length > 1) && <StepTrail path={path} all={view.all} headId={head?.id} onJump={(id) => void move(id)} urlOf={urlOf} />}
<div className="mt-2 flex items-end gap-2">
<div className="relative min-w-0 flex-1 rounded-2xl border bg-card shadow-soft focus-within:border-primary/60 focus-within:ring-3 focus-within:ring-ring/25">
<textarea
@@ -979,7 +1140,7 @@ export function LiveEditor(props: LiveEditorProps) {
value={text}
rows={1}
maxLength={MAX_LIVE_TEXT}
- placeholder={hasPicture ? (head?.parent ? "Type the next change…" : "Type a change…") : "Describe a picture, or drop one here…"}
+ placeholder={hasPicture ? (compose ? "Type a change, then keep adding…" : head?.parent ? "Type the next change…" : "Type a change…") : "Describe a picture, or drop one here…"}
aria-label="Type a change"
className="block max-h-28 min-h-11 w-full resize-none bg-transparent px-3.5 py-3 text-[15px] leading-5 outline-none placeholder:text-muted-foreground [field-sizing:content]"
onChange={(e) => {
@@ -987,7 +1148,13 @@ export function LiveEditor(props: LiveEditorProps) {
onType(e.target.value, native.data ?? (native.inputType === "insertLineBreak" ? "\n" : native.inputType === "insertFromPaste" ? e.target.value : undefined));
}}
onKeyDown={(e) => {
- if (e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing) {
+ if (e.key === "Enter" && compose && !e.nativeEvent.isComposing) {
+ // Enter ends this change and starts the next (Ctrl+Enter: download the picture).
+ e.preventDefault();
+ if (e.metaKey || e.ctrlKey) return void download();
+ const next = nextChange(textRef.current);
+ if (next !== textRef.current) onType(next, ", ");
+ } else if (e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing) {
e.preventDefault();
void keep(undefined, e.metaKey || e.ctrlKey);
} else if (e.key === "Escape") box.current?.blur();
@@ -995,25 +1162,45 @@ export function LiveEditor(props: LiveEditorProps) {
disabled={phase.s !== "ready"}
/>
</div>
- <Button size="lg" className={cn("h-11 shrink-0 rounded-2xl px-4", keptFlash && "bg-success hover:bg-success")} onClick={() => void keep()} disabled={!canKeep} data-live-keep>
- {keeping ? <Loader2 className="size-4 animate-spin" /> : keptFlash ? <Check className="size-4" /> : <CornerDownLeft className="size-4" />}
- {keptFlash ? "Kept" : "Keep"}
- </Button>
+ {compose ? (
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button size="lg" variant="secondary" className={cn("h-11 shrink-0 rounded-2xl px-4 max-sm:w-11 max-sm:px-0", keptFlash && "bg-success text-white hover:bg-success")} onClick={() => void keep()} disabled={!canKeep} aria-label="Start fresh from this picture" data-live-keep>
+ {keeping ? <Loader2 className="size-4 animate-spin" /> : keptFlash ? <Check className="size-4" /> : <Layers className="size-4" />}
+ <span className="max-sm:hidden">Start fresh</span>
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent className="max-w-64">Start fresh from this picture: it becomes the new original and the words clear. Undo brings them back.</TooltipContent>
+ </Tooltip>
+ ) : (
+ <Button size="lg" className={cn("h-11 shrink-0 rounded-2xl px-4", keptFlash && "bg-success hover:bg-success")} onClick={() => void keep()} disabled={!canKeep} data-live-keep>
+ {keeping ? <Loader2 className="size-4 animate-spin" /> : keptFlash ? <Check className="size-4" /> : <CornerDownLeft className="size-4" />}
+ {keptFlash ? "Kept" : "Keep"}
+ </Button>
+ )}
</div>
{(tries.length > 0 || hasPicture) && (
// The row keeps its height from the start, so the picture doesn't move when the first try comes in.
<div className="mt-2 flex h-[46px] items-center gap-1.5 overflow-x-auto pb-0.5" data-live-tries={tries.length > 0 ? "" : undefined}>
- <span className="shrink-0 text-[11.5px] font-medium text-muted-foreground">Tries</span>
- {tries.length === 0 && <span className="truncate text-[11.5px] text-subtle-foreground">Pause while typing and each take lands here. Click one to keep it.</span>}
+ <span className="shrink-0 text-[11.5px] font-medium text-muted-foreground">{compose ? "Takes" : "Tries"}</span>
+ {tries.length === 0 && (
+ <span className="truncate text-[11.5px] text-subtle-foreground">{compose ? "Each pause lands here. Tap one to go back to it." : "Pause while typing and each take lands here. Click one to keep it."}</span>
+ )}
{tries.map((t) => (
<Tooltip key={t.key}>
<TooltipTrigger asChild>
- <button type="button" onClick={() => void keep({ text: t.text, seed: t.seed })} className={cn("relative size-11 shrink-0 overflow-hidden rounded-lg ring-1 ring-border hover:ring-2 hover:ring-primary", shown?.key === t.key && "ring-2 ring-primary")} aria-label={`Keep this try (seed ${t.seed})`}>
+ <button
+ type="button"
+ onClick={onTry}
+ data-try={t.key}
+ className={cn("relative size-11 shrink-0 overflow-hidden rounded-lg ring-1 ring-border hover:ring-2 hover:ring-primary", shown?.key === t.key && "ring-2 ring-primary")}
+ aria-label={compose ? `Go back to: ${t.text}` : `Keep this try (seed ${t.seed})`}
+ >
{/* eslint-disable-next-line @next/next/no-img-element */}
<img src={t.url} alt="" className="size-full object-cover" />
</button>
</TooltipTrigger>
- <TooltipContent>Keep this one</TooltipContent>
+ <TooltipContent className="max-w-64">{compose ? t.text : "Keep this one"}</TooltipContent>
</Tooltip>
))}
{tries.length > 0 && (
@@ -1023,6 +1210,14 @@ export function LiveEditor(props: LiveEditorProps) {
)}
</div>
)}
+ {compose && longPrompt && phase.s === "ready" && (
+ <p className="mt-1.5 flex items-center gap-1.5 text-[12px] text-muted-foreground" data-live-long>
+ <span className="min-w-0 flex-1 truncate">A long prompt: a new change may not show.</span>
+ <button type="button" onClick={() => void keep()} disabled={!canKeep} className="shrink-0 font-medium text-brand-text hover:underline disabled:opacity-50">
+ Start fresh from this picture
+ </button>
+ </p>
+ )}
{facts?.highvram === false && highvramHint && phase.s === "ready" && (
<p className="mt-1.5 flex items-center gap-1.5 text-[12px] text-muted-foreground" data-live-highvram>
<span className="min-w-0 flex-1 truncate">Faster: start ComfyUI with --highvram (live frames take about twice as long without it).</span>
@@ -1051,8 +1246,17 @@ export function LiveEditor(props: LiveEditorProps) {
{current && (head || shown) && (
<SketchEditor open={brushOpen} onOpenChange={setBrushOpen} image={urlOf(head) ?? current} mode="mask" onDone={(r) => void onBrushDone(r)} />
)}
- <CompareDialog open={compareOpen} onOpenChange={setCompareOpen} after={current} before={compareWith === "prev" ? urlOf(previous ?? original) : urlOf(original)} which={compareWith} setWhich={setCompareWith} />
- <KeysDialog open={keysOpen} onOpenChange={setKeysOpen} canSave={props.canSave} />
+ <CompareDialog
+ open={compareOpen}
+ onOpenChange={setCompareOpen}
+ after={current}
+ before={compareWith === "prev" ? urlOf(before) : urlOf(original)}
+ which={compareWith}
+ setWhich={setCompareWith}
+ prevLabel={compose && normalize(text) ? "Before the words" : "With the step before"}
+ same={before?.id === original?.id}
+ />
+ <KeysDialog open={keysOpen} onOpenChange={setKeysOpen} canSave={props.canSave} compose={compose} />
</div>
);
}
@@ -1135,13 +1339,13 @@ function StageImage({ src, alt }: { src: string; alt: string }) {
);
}
-function EmptyStage({ busy, onBrowse }: { busy: boolean; onBrowse: () => void }) {
+function EmptyStage({ busy, compose, onBrowse }: { busy: boolean; compose: boolean; onBrowse: () => void }) {
return (
<div className="absolute inset-0 grid place-items-center p-6 text-center text-white">
<div className="max-w-sm">
<span className="mx-auto grid size-12 place-items-center rounded-2xl bg-white/10">{busy ? <Loader2 className="size-5 animate-spin" /> : <ImagePlus className="size-5" />}</span>
<p className="mt-4 font-heading text-[24px] leading-tight">Drop a picture, paste one, or start typing to make one</p>
- <p className="mt-2 text-[13px] text-white/65">Each change shows up as you type. Press Enter to keep it, then type the next.</p>
+ <p className="mt-2 text-[13px] text-white/65">{compose ? "The picture follows as you type. Keep adding to the words: every change lands on your picture." : "Each change shows up as you type. Press Enter to keep it, then type the next."}</p>
<Button variant="secondary" className="mt-5" onClick={onBrowse}>
<Upload className="size-4" />
Add a picture
@@ -1192,6 +1396,7 @@ function Settings(p: {
hasPicture: boolean;
seed: number;
lab?: boolean;
+ compose: boolean;
method: Method;
setMethod: (m: Method) => void;
onKeys: () => void;
@@ -1297,11 +1502,13 @@ function Settings(p: {
{p.lab && (
<div className={row}>
<span>Method</span>
- {seg<Method>(p.method, [{ v: "hybrid", label: "Hybrid" }, { v: "chain", label: "Chain" }, { v: "compose", label: "Compose" }], p.setMethod)}
+ {seg<Method>(p.method, [{ v: "compose", label: "Compose" }, { v: "hybrid", label: "Hybrid" }, { v: "chain", label: "Chain" }], p.setMethod)}
</div>
)}
<p className="mt-2 border-t pt-2 text-[12px] text-muted-foreground">
- Kept steps are lossless masters at full size: unchanged parts of the picture stay exactly as they were, however many changes you stack.
+ {p.compose
+ ? "Every frame renders all your words on the same picture, so nothing blurs however long they get. Start fresh makes the picture on screen the new original."
+ : "Kept steps are lossless masters at full size: unchanged parts of the picture stay exactly as they were, however many changes you stack."}
</p>
<button type="button" onClick={p.onKeys} className="mt-2 inline-flex items-center gap-1.5 text-[12px] font-medium text-brand-text hover:underline">
<Keyboard className="size-3.5" />
@@ -1312,7 +1519,26 @@ function Settings(p: {
);
}
-function CompareDialog({ open, onOpenChange, before, after, which, setWhich }: { open: boolean; onOpenChange: (o: boolean) => void; before: string | null; after: string | null; which: "prev" | "orig"; setWhich: (w: "prev" | "orig") => void }) {
+function CompareDialog({
+ open,
+ onOpenChange,
+ before,
+ after,
+ which,
+ setWhich,
+ prevLabel,
+ same,
+}: {
+ open: boolean;
+ onOpenChange: (o: boolean) => void;
+ before: string | null;
+ after: string | null;
+ which: "prev" | "orig";
+ setWhich: (w: "prev" | "orig") => void;
+ prevLabel: string;
+ /** "Before" is the original: one choice, so no switch. */
+ same: boolean;
+}) {
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="w-[min(96vw,1100px)] max-w-none sm:max-w-none">
@@ -1320,19 +1546,39 @@ function CompareDialog({ open, onOpenChange, before, after, which, setWhich }: {
<DialogTitle>Compare</DialogTitle>
<DialogDescription>Drag across the picture, or use the arrow keys.</DialogDescription>
</DialogHeader>
- <div className="flex gap-1 self-start rounded-lg bg-muted p-0.5 text-[12.5px]">
- {(["prev", "orig"] as const).map((w) => (
- <button key={w} type="button" onClick={() => setWhich(w)} className={cn("h-7 rounded-md px-2.5", which === w ? "bg-background font-medium shadow-soft" : "text-muted-foreground")}>
- {w === "prev" ? "With the step before" : "With the original"}
- </button>
- ))}
- </div>
+ {!same && (
+ <div className="flex gap-1 self-start rounded-lg bg-muted p-0.5 text-[12.5px]">
+ {(["prev", "orig"] as const).map((w) => (
+ <button key={w} type="button" onClick={() => setWhich(w)} className={cn("h-7 rounded-md px-2.5", which === w ? "bg-background font-medium shadow-soft" : "text-muted-foreground")}>
+ {w === "prev" ? prevLabel : "With the original"}
+ </button>
+ ))}
+ </div>
+ )}
<div className="grid max-h-[72vh] place-items-center overflow-hidden rounded-xl bg-media">{before && after ? <CompareSlider before={before} after={after} /> : <p className="p-10 text-white/70">Keep a change to compare.</p>}</div>
</DialogContent>
</Dialog>
);
}
+const COMPOSE_KEYS: [string, string][] = [
+ ["/", "Type a change (Esc leaves the box)"],
+ ["Enter", "End this change and type the next"],
+ ["Ctrl+Enter", "Download the picture"],
+ ["Ctrl+Z", "Undo the last change (in the box: when it is empty)"],
+ ["Ctrl+Shift+Z", "Redo"],
+ ["F", "Start fresh from this picture"],
+ ["R", "Shuffle: another take of the words"],
+ ["L", "Live on or off"],
+ ["C (hold)", "Compare with the picture before the words"],
+ ["Shift+C (hold)", "Compare with the original"],
+ ["B", "Paint a region to change"],
+ ["D", "Download"],
+ ["S", "Save to your Library"],
+ ["← →", "Step through your fresh starts"],
+ ["?", "These shortcuts"],
+];
+
const KEYS: [string, string][] = [
["/", "Type a change (Esc leaves the box)"],
["Enter", "Keep the change (Shift+Enter: a new line)"],
@@ -1350,7 +1596,7 @@ const KEYS: [string, string][] = [
["?", "These shortcuts"],
];
-function KeysDialog({ open, onOpenChange, canSave }: { open: boolean; onOpenChange: (o: boolean) => void; canSave: boolean }) {
+function KeysDialog({ open, onOpenChange, canSave, compose }: { open: boolean; onOpenChange: (o: boolean) => void; canSave: boolean; compose: boolean }) {
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="max-w-md">
@@ -1359,7 +1605,7 @@ function KeysDialog({ open, onOpenChange, canSave }: { open: boolean; onOpenChan
<DialogDescription>Outside the text box, unless it says otherwise.</DialogDescription>
</DialogHeader>
<dl className="grid grid-cols-[auto_1fr] gap-x-4 gap-y-2 text-[13px]">
- {KEYS.filter(([k]) => canSave || k !== "S").map(([k, v]) => (
+ {(compose ? COMPOSE_KEYS : KEYS).filter(([k]) => canSave || k !== "S").map(([k, v]) => (
<div key={k} className="contents">
<dt>
<Kbd>{k}</Kbd>
diff --git a/src/components/live/live-transport.ts b/src/components/live/live-transport.ts
index 9e4c8224..38123f46 100644
--- a/src/components/live/live-transport.ts
+++ b/src/components/live/live-transport.ts
@@ -34,8 +34,6 @@ export interface RenderReq {
slot: Slot;
urgent?: boolean;
text: string;
- /** compose (lab): the kept texts and the live text as one instruction. */
- compose?: string;
seed: number;
size: number;
keepRes: number;
@@ -108,15 +106,34 @@ export interface LiveTransport {
}
/** The key a render is cached by (the server computes the same). */
-export function keyOf(r: Pick<RenderReq, "base" | "refs" | "mask" | "text" | "compose" | "seed" | "size" | "keepRes" | "aspect" | "method" | "slot">): string {
+export function keyOf(r: Pick<RenderReq, "base" | "refs" | "mask" | "text" | "seed" | "size" | "keepRes" | "aspect" | "method" | "slot">): string {
const keep = r.slot === "keep" || r.slot === "settle";
- const prompt = r.method === "compose" && r.compose !== undefined ? r.compose : normalize(r.text);
+ const prompt = normalize(r.text);
return renderKey({ base: r.base ?? "", refs: r.refs, mask: r.mask, text: prompt, seed: r.seed, size: keep ? r.keepRes : r.size, aspect: r.aspect, method: r.method, quality: keep ? "keep" : "live" });
}
// ---------------------------------------------------------------------------
// Through Fuobe's server
+/** How many times a render asks again after "too many renders" (about half a minute at the server's pace). */
+const RETRY_429 = 30;
+
+/** Wait, unless the request is let go first (then it throws, like the aborted fetch would). */
+function abortableWait(ms: number, signal: AbortSignal): Promise<void> {
+ return new Promise((resolve, reject) => {
+ if (signal.aborted) return reject(new Error("aborted"));
+ const t = setTimeout(() => {
+ signal.removeEventListener("abort", stop);
+ resolve();
+ }, ms);
+ const stop = () => {
+ clearTimeout(t);
+ reject(new Error("aborted"));
+ };
+ signal.addEventListener("abort", stop, { once: true });
+ });
+}
+
export class ServerTransport implements LiveTransport {
kind: "server" | "link" = "server";
private sessionId = "";
@@ -187,7 +204,14 @@ export class ServerTransport implements LiveTransport {
this.inflight.set(req.seq, { ctl, slot: req.slot });
const key = keyOf(req);
try {
- const res = await fetch("/api/live/render", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ sessionId: this.sessionId, ...req }), signal: ctl.signal });
+ const body = JSON.stringify({ sessionId: this.sessionId, ...req });
+ let res = await fetch("/api/live/render", { method: "POST", headers: { "content-type": "application/json" }, body, signal: ctl.signal });
+ // Too many at once (a cold GPU's first frames are slow and the next ones queue up): ask again when the server
+ // says, until the render is answered or no longer wanted.
+ for (let tries = 0; res.status === 429 && tries < RETRY_429; tries++) {
+ await abortableWait(Math.min(5, Number(res.headers.get("Retry-After")) || 1) * 1000, ctl.signal);
+ res = await fetch("/api/live/render", { method: "POST", headers: { "content-type": "application/json" }, body, signal: ctl.signal });
+ }
if (!res.ok || !res.body) {
const j = (await res.json().catch(() => ({}))) as { error?: string; code?: string };
return { ok: false, error: j.error ?? `The render failed (${res.status})`, code: j.code ?? (res.status === 410 ? "session" : undefined) };
@@ -465,7 +489,7 @@ export class ChannelTransport implements LiveTransport {
const base = req.base ? this.names.get(req.base) : undefined;
const liveLong = base?.w ? Math.max(...editSize(req.size, base.w, base.h)) : req.size;
const bind = slotBindings(req.slot, { liveSize: req.size, keepRes: req.keepRes, hasMask: !!req.mask, to: "socket", liveLongSide: liveLong });
- const prompt = req.method === "compose" && req.compose !== undefined ? req.compose : normalize(req.text);
+ const prompt = normalize(req.text);
const params: LiveGraphParams = {
prompt: req.slot === "warm" ? "warm-up" : prompt,
seed: req.slot === "warm" ? 0 : req.seed,
diff --git a/src/lib/home-showcase.ts b/src/lib/home-showcase.ts
index cfe3b507..bad315da 100644
--- a/src/lib/home-showcase.ts
+++ b/src/lib/home-showcase.ts
@@ -114,7 +114,7 @@ export const HOME_OWN_SECTIONS = ["/assist", "/motions", "/effects", "/apps", "/
export const HOME_LIVE = {
href: "/live-edit?from=home",
title: "Change it as you type",
- line: "Type a change and watch the picture follow. Keep what you like; nothing blurs, however many changes you stack.",
+ line: "Type a change and watch the picture follow, then keep adding to the words. Nothing blurs, however many changes you make.",
};
/** Assist's starter skills, as its empty chat lists them first (assist-view.tsx). */
diff --git a/src/lib/live/demo.ts b/src/lib/live/demo.ts
index b6495517..891c325b 100644
--- a/src/lib/live/demo.ts
+++ b/src/lib/live/demo.ts
@@ -1,8 +1,9 @@
/**
* The recorded live edit session that guests, Home and the Apps card see (public/previews/live-edit/demo.json), and
* the pure parts of its player: how long each step takes, where a paused loop picks up again, which frames are the
- * before and after, where the camera sits when it zooms in on a change, and which kept steps the trail shows. The
- * player itself is src/components/live/live-demo.tsx.
+ * before and after, and where the camera sits when it zooms in on a change. The session is one prompt that keeps
+ * growing: every frame renders all the words so far on the original. The player itself is
+ * src/components/live/live-demo.tsx.
*/
export const LIVE_DEMO = "/previews/live-edit/demo.json";
@@ -10,12 +11,8 @@ export const LIVE_DEMO = "/previews/live-edit/demo.json";
* The file's content version: the first 8 hex digits of the SHA-256 of demo.json (line endings as \n). The player
* fetches the file with it (?v=), so a new session reaches returning visitors at once; a test keeps it in step.
*/
-export const LIVE_DEMO_V = "61b6e096";
+export const LIVE_DEMO_V = "78c8fd0c";
-/** A trail chip's label stays readable on a phone: the longer instruction is the typed text. */
-export const CHIP_MAX = 18;
-/** The Keep button's pulse, before the step joins the trail. */
-export const KEEP_PULSE_MS = 380;
/** A typed character never goes faster than this. */
export const TYPE_MIN_CHAR_MS = 28;
/** A space waits a little longer, the way people type. */
@@ -48,7 +45,8 @@ export type DemoStep =
/** live: a live frame (the pill says Live); it is drawn across the picture rather than faded in. */
| { type: "frame"; frame: string; live?: boolean; ms: number }
| { type: "type"; text: string; ms: number }
- | { type: "keep"; label: string; ms: number }
+ /** The words so far are one more change (its settled picture is on screen): the count goes up, the words stay. */
+ | { type: "change"; ms: number }
/** from/to: the frames to compare (the script's first and last frames when left out). */
| { type: "compare"; ms: number; from?: string; to?: string }
| { type: "pause"; ms: number }
@@ -76,7 +74,6 @@ export function typeDelays(text: string, ms: number): number[] {
export function stepMs(s: DemoStep): number {
if (s.type === "type") return typeDelays(s.text, s.ms).reduce((a, b) => a + b, 0);
- if (s.type === "keep") return Math.max(KEEP_PULSE_MS, s.ms);
return s.ms;
}
@@ -106,10 +103,9 @@ export interface DemoView {
/** The frame on top is drawn across the picture (a live frame) rather than faded in. */
sweep: boolean;
typed: string;
- steps: string[];
- keepPulse: boolean;
+ /** How many changes the words hold so far. */
+ changes: number;
compare: number | null;
- pill: "Live" | "Kept ✓";
/** The area the camera is on; null is the whole picture. */
zoom: Box | null;
}
@@ -120,10 +116,8 @@ export const startView = (frame: string, under: string | null = null): DemoView
fade: under ? REWIND_MS : FADE_MS,
sweep: false,
typed: "",
- steps: [],
- keepPulse: false,
+ changes: 0,
compare: null,
- pill: "Live",
zoom: null,
});
@@ -134,9 +128,9 @@ export const startView = (frame: string, under: string | null = null): DemoView
export function viewBefore(d: Demo, at: number): DemoView {
const v = { ...startView(demoEnds(d).before), fade: 0 };
for (const s of d.script.slice(0, at)) {
- if (s.type === "frame") Object.assign(v, { frame: s.frame, sweep: false, ...(s.live ? { pill: "Live" } : {}) });
+ if (s.type === "frame") Object.assign(v, { frame: s.frame, sweep: false });
else if (s.type === "type") v.typed += s.text;
- else if (s.type === "keep") Object.assign(v, { typed: "", steps: [...v.steps, s.label], pill: "Kept ✓" });
+ else if (s.type === "change") v.changes++;
else if (s.type === "zoom") v.zoom = s.box;
}
return v;
@@ -180,22 +174,18 @@ export function sweepPath(cam: { s: number; x: number }) {
const isBox = (b: unknown): b is Box =>
Array.isArray(b) && b.length === 4 && b.every((n) => typeof n === "number" && n >= 0 && n <= 1) && b[0] < b[2] && b[1] < b[3];
-/** The pill's words: compact cards add the step count after a keep. */
-export function pillText(v: Pick<DemoView, "pill" | "steps">, compact = false) {
- const count = compact && v.pill === "Kept ✓" && v.steps.length > 1 ? String(v.steps.length) : null;
- return { main: v.pill, count };
+/** The pill's words: compact cards add the change count once there are two. */
+export function pillText(v: Pick<DemoView, "changes">, compact = false) {
+ return { main: "Live", count: compact && v.changes > 1 ? String(v.changes) : null };
}
/** A frame's file, without the ?v= content version. */
export const framePath = (src: string) => src.split("?")[0];
-/** The trail: Original, how many earlier steps are folded away, then the newest `keep` steps (numbered from 1). */
-export function trailWindow(steps: readonly string[], keep: number) {
- const from = Math.max(0, steps.length - keep);
- return { hidden: from, shown: steps.slice(from).map((label, i) => ({ n: from + i + 1, label })) };
-}
+export const changesWord = (n: number) => `${n} ${n === 1 ? "change" : "changes"}`;
-export const stepsWord = (n: number) => `${n} ${n === 1 ? "step" : "steps"}`;
+/** How many changes a session makes. */
+export const countChanges = (d: Pick<Demo, "script">) => d.script.filter((s) => s.type === "change").length;
/** What is wrong with a demo file, in words; empty when it plays. `exists` checks that a frame's file is there. */
export function demoProblems(d: Demo, exists?: (src: string) => boolean): string[] {
@@ -225,12 +215,9 @@ export function demoProblems(d: Demo, exists?: (src: string) => boolean): string
if (!d.frames[s.frame]) out.push(`step ${i}: no frame ${s.frame}`);
} else if (s.type === "type") {
if (!s.text) out.push(`step ${i}: nothing to type`);
- } else if (s.type === "keep") {
- if (!s.label || s.label.length > CHIP_MAX) out.push(`step ${i}: a keep label is 1 to ${CHIP_MAX} characters`);
- if (s.ms < KEEP_PULSE_MS) out.push(`step ${i}: a keep lasts at least ${KEEP_PULSE_MS} ms`);
} else if (s.type === "compare") {
for (const f of [s.from, s.to]) if (f && !d.frames[f]) out.push(`step ${i}: no frame ${f}`);
- } else if (s.type !== "pause") out.push(`step ${i}: unknown step`);
+ } else if (s.type !== "pause" && s.type !== "change") out.push(`step ${i}: unknown step`);
});
for (const id of ids) if (!used.has(id)) out.push(`frame ${id} is never shown`);
if (loopMs(d) > LOOP_MAX_MS) out.push(`one round takes ${loopMs(d)} ms, over ${LOOP_MAX_MS}`);
diff --git a/src/lib/live/graph.ts b/src/lib/live/graph.ts
index c4a91aab..0b276110 100644
--- a/src/lib/live/graph.ts
+++ b/src/lib/live/graph.ts
@@ -31,7 +31,7 @@ export const LIVE_SIGMAS = "1.0, 0.5, 0.0";
/** The node that sends the picture. */
export const LIVE_OUTPUT = "90";
-/** The longest prompt a graph may carry (compose joins the kept texts). */
+/** The longest prompt a graph may carry. */
export const MAX_GRAPH_PROMPT = 2000;
export const PACK_LIVE_CLASSES = ["LoadImageFuobeLive", "CropFuobeLive", "Qwen21ReferenceFuobeLive", "Qwen21EncodeFuobeLive", "PasteBackFuobeLive", "SaveImageFuobeLive"] as const;
diff --git a/src/lib/live/steps.ts b/src/lib/live/steps.ts
index 0c3bf3ca..e20eb38f 100644
--- a/src/lib/live/steps.ts
+++ b/src/lib/live/steps.ts
@@ -1,16 +1,22 @@
/**
- * Live edit's kept steps (pure). A step is one change the person chose to keep, with its own lossless master. The
+ * Live edit's kept steps (pure). A step is a picture the person chose to keep, with its own lossless master. The
* stack is a tree: Undo moves to the parent, Redo to the newest child, and a Keep after an Undo starts a new branch
- * (the old one stays). Every render's base is a master or the original, never a live frame:
+ * (the old one stays). Every render's base is a master or the original, never a live frame.
*
- * 1. the base of a render is the head's master (hybrid, chain) or the original (compose);
+ * Methods: "compose" (everyone) renders the whole text box on the head's picture, so one prompt keeps growing and
+ * every frame comes from the same picture; a keep is a fresh start (the picture on screen becomes the new start and
+ * the box clears). "hybrid" and "chain" (an owner's lab switch) keep each change as a step and clear the box after it.
+ *
+ * 1. the base of a render is the head's master;
* 2. every kept master is a PNG at least as large as its base (for text to image, 1024 or more on the long side);
* 3. no name used as a base was ever a live frame's bytes;
* 4. a kept master is the settled picture that was on screen, byte for byte, when Keep came after the settle.
*/
-export type Method = "hybrid" | "chain" | "compose";
-export const METHODS: readonly Method[] = ["hybrid", "chain", "compose"];
+export type Method = "compose" | "hybrid" | "chain";
+export const METHODS: readonly Method[] = ["compose", "hybrid", "chain"];
+/** What everyone gets. */
+export const DEFAULT_METHOD: Method = "compose";
export interface Master {
/** A Fuobe file URL (/api/files/…), when the server keeps it. */
@@ -65,7 +71,7 @@ export class StepStack {
/** Start from a picture (step 0, the original: its bytes as they came, JPEG allowed). */
static from(original: Master, at = Date.now()): StepStack {
- return new StepStack({ steps: [{ id: "s0", parent: null, text: "", norm: "", seed: 0, method: "hybrid", keepRes: 0, master: original, ms: 0, at }], head: "s0" });
+ return new StepStack({ steps: [{ id: "s0", parent: null, text: "", norm: "", seed: 0, method: DEFAULT_METHOD, keepRes: 0, master: original, ms: 0, at }], head: "s0" });
}
get empty(): boolean {
@@ -102,17 +108,12 @@ export class StepStack {
}
/** What the next render edits (invariant 1): null for text to image. */
- base(method: Method): Master | null {
- const m = method === "compose" ? this.original?.master : this.head?.master;
+ base(): Master | null {
+ const m = this.head?.master;
if (m && this.liveShas.has(m.sha256)) throw new StepError("A live frame can't be a base");
return m ?? null;
}
- /** compose: the kept texts on the path, then the live text, as one instruction. */
- composePrompt(live: string): string {
- return [...this.path().map((s) => s.norm).filter(Boolean), live].filter(Boolean).join(". ");
- }
-
/** A live frame was shown: its bytes may never become a base (invariant 3). */
sawLive(sha256: string): void {
this.liveShas.add(sha256);
@@ -132,7 +133,7 @@ export class StepStack {
if (parent !== undefined && (base?.id ?? null) !== parent) throw new StepError("The picture changed while keeping. Keep again.");
if (base && s.master.format !== "png") throw new StepError("A kept master must be a PNG");
if (this.liveShas.has(s.master.sha256)) throw new StepError("A live frame can't be kept as a master");
- if (base && s.method !== "compose" && s.master.w * s.master.h < base.master.w * base.master.h) throw new StepError("A kept master can't be smaller than its base");
+ if (base && s.master.w * s.master.h < base.master.w * base.master.h) throw new StepError("A kept master can't be smaller than its base");
if (!base && Math.max(s.master.w, s.master.h) < 1024) throw new StepError("A first picture is kept at 1024 or more");
const step: Step = { ...s, id: `s${++this.n}`, parent: base?.id ?? null, at: s.at ?? Date.now(), master: { ...s.master } };
this.steps.push(step);
diff --git a/src/lib/live/text.ts b/src/lib/live/text.ts
index 2eaa6aac..95094993 100644
--- a/src/lib/live/text.ts
+++ b/src/lib/live/text.ts
@@ -45,3 +45,26 @@ export interface KeyParts {
export function renderKey(p: KeyParts): string {
return JSON.stringify([p.base, p.refs ?? [], p.mask ?? "", normalize(p.text), p.seed >>> 0, p.size, p.base ? "" : (p.aspect ?? "1:1"), p.method ?? "hybrid", p.quality ?? "live"]);
}
+
+/**
+ * One prompt that keeps growing: each change is a part of it, ended by a comma (or ; . or a line break). Enter ends
+ * the change being typed; Undo drops the newest one.
+ */
+const PART_END = /[,;.\n]/u;
+
+/** The text with the change being typed ended, ready for the next one (unchanged when there is nothing to end). */
+export function nextChange(s: string): string {
+ const t = s.replace(/\s+$/u, "");
+ if (!normalize(t)) return s;
+ return PART_END.test(t.slice(-1)) ? `${t} ` : `${t}, `;
+}
+
+/** The text without its newest change, ready for the next one ("" when it had only one). */
+export function dropLastChange(s: string): string {
+ const t = s.replace(/[\s,;.]+$/u, "");
+ const at = Math.max(...[",", ";", ".", "\n"].map((c) => t.lastIndexOf(c)));
+ return at < 0 ? "" : `${t.slice(0, at + 1)} `;
+}
+
+/** How many changes the text holds. */
+export const changeCount = (s: string) => normalize(s.replace(/\n/g, ",")).split(/[,;.]/u).filter((p) => p.trim()).length;
diff --git a/tests/live-core.test.ts b/tests/live-core.test.ts
index 2269f0f0..1e962df0 100644
--- a/tests/live-core.test.ts
+++ b/tests/live-core.test.ts
@@ -3,7 +3,7 @@
* step stack with its no-degradation invariants (src/lib/live).
*/
import { describe, expect, it } from "vitest";
-import { completedWords, normalize, renderKey } from "@/lib/live/text";
+import { changeCount, completedWords, dropLastChange, nextChange, normalize, renderKey } from "@/lib/live/text";
import { aspectOf, AutoSize, editSize, keepAuto, sizeFor, ASPECT_NAMES } from "@/lib/live/sizes";
import { inputName, LIVE_INPUT, pictureExt, pngSize } from "@/lib/live/names";
import { eventFrame, FrameError, FrameReader, imageFrame } from "@/lib/live/frames";
@@ -25,6 +25,21 @@ describe("text", () => {
expect(completedWords("add")).toBe("");
expect(completedWords("add gold,")).toBe("add gold,");
});
+ it("one growing prompt: Enter ends a change, Undo drops the newest, and the changes are counted", () => {
+ expect(nextChange("evening makeup")).toBe("evening makeup, ");
+ expect(nextChange("evening makeup,")).toBe("evening makeup, ");
+ expect(nextChange("evening makeup. ")).toBe("evening makeup. ");
+ expect(nextChange(" ")).toBe(" ");
+ expect(dropLastChange("evening makeup, deep red lips, hair down")).toBe("evening makeup, deep red lips, ");
+ expect(dropLastChange("evening makeup, deep red lips, ")).toBe("evening makeup, ");
+ expect(dropLastChange("evening makeup. hair down")).toBe("evening makeup. ");
+ expect(dropLastChange("evening makeup")).toBe("");
+ // What Undo leaves renders as the words before it: the trailing ", " changes nothing.
+ expect(normalize(dropLastChange("a, b, c"))).toBe("a, b");
+ expect(changeCount("a, b; c. d\ne")).toBe(5);
+ expect(changeCount("a, , b,")).toBe(2);
+ expect(changeCount("")).toBe(0);
+ });
it("render keys are stable over no-op changes and differ on real ones", () => {
const k = (text: string, o: Partial<Parameters<typeof renderKey>[0]> = {}) => renderKey({ base: "b", text, seed: 7, size: 512, ...o });
expect(k("add gold hoop earrings.")).toBe(k("add gold hoop earrings"));
@@ -126,18 +141,17 @@ describe("frames", () => {
describe("steps", () => {
const master = (n: number, o: Partial<Master> = {}): Master => ({ name: `fuobe_lv${String(n).padStart(20, "0")}.png`, w: 1536, h: 2048, sha256: `sha${n}`, format: "png", ...o });
- const keep = (s: StepStack, n: number, text = `edit ${n}`, o: Partial<Master> = {}) => s.keep({ text, norm: text, seed: n, method: "hybrid", keepRes: 1536, master: master(n, o), ms: 900 });
+ const keep = (s: StepStack, n: number, text = `edit ${n}`, o: Partial<Master> = {}) => s.keep({ text, norm: text, seed: n, method: "compose", keepRes: 1536, master: master(n, o), ms: 900 });
- it("keeps, undoes, redoes and branches, and picks the base per method", () => {
+ it("keeps, undoes, redoes and branches; every render's base is the head's picture", () => {
const s = StepStack.from(master(0, { format: "jpg" }));
+ expect(s.base()?.sha256).toBe("sha0");
keep(s, 1);
keep(s, 2);
expect(s.path().map((x) => x.text)).toEqual(["", "edit 1", "edit 2"]);
- expect(s.base("hybrid")?.sha256).toBe("sha2");
- expect(s.base("chain")?.sha256).toBe("sha2");
- expect(s.base("compose")?.sha256).toBe("sha0");
- expect(s.composePrompt("live")).toBe("edit 1. edit 2. live");
+ expect(s.base()?.sha256).toBe("sha2");
expect(s.undo()?.text).toBe("edit 1");
+ expect(s.base()?.sha256).toBe("sha1");
expect(s.canRedo()).toBe(true);
expect(s.redo()?.text).toBe("edit 2");
s.undo();
@@ -176,7 +190,7 @@ describe("steps", () => {
it("text to image starts empty and keeps a first picture of 1024 or more", () => {
const s = new StepStack();
- expect(s.base("hybrid")).toBeNull();
+ expect(s.base()).toBeNull();
expect(() => keep(s, 1, "x", { w: 512, h: 512 })).toThrow(/1024/);
keep(s, 1, "a portrait", { w: 1024, h: 1024 });
expect(s.original?.text).toBe("a portrait");
diff --git a/tests/live-demo.test.ts b/tests/live-demo.test.ts
index d0bc4b00..faff5127 100644
--- a/tests/live-demo.test.ts
+++ b/tests/live-demo.test.ts
@@ -4,18 +4,18 @@ import path from "node:path";
import { createElement } from "react";
import { renderToStaticMarkup } from "react-dom/server";
import { describe, expect, it } from "vitest";
-import { DemoTrail } from "@/components/live/live-demo";
+import { ChangeCount } from "@/components/live/live-demo";
import {
type Box,
cameraFor,
- CHIP_MAX,
+ changesWord,
+ countChanges,
type Demo,
type DemoStep,
demoEnds,
demoProblems,
frameOrder,
framePath,
- KEEP_PULSE_MS,
LIVE_DEMO,
LIVE_DEMO_V,
LOOP_MAX_MS,
@@ -24,7 +24,6 @@ import {
stepMs,
SWEEP_MS,
sweepPath,
- trailWindow,
typeDelays,
viewBefore,
ZOOM_MAX,
@@ -33,8 +32,8 @@ import {
/*
* The recorded live edit session (public/previews/live-edit/demo.json) and its player (src/lib/live/demo.ts,
- * src/components/live/live-demo.tsx): the file plays, every frame is there, one round stays short, and a long session
- * keeps its trail readable.
+ * src/components/live/live-demo.tsx): the file plays, every frame is there, one round stays short, and the session is
+ * one prompt that keeps growing.
*/
const PUBLIC = path.join(__dirname, "..", "public");
@@ -43,9 +42,9 @@ const shippedText = fs.readFileSync(path.join(PUBLIC, LIVE_DEMO), "utf8").replac
const shipped = JSON.parse(shippedText) as Demo;
/**
- * An eleven-step session in the shape of the shipped one: the camera moves in on the changed area, partial live frames
- * arrive while typing, the camera pulls back out as the settled one arrives, then the keep. The two big changes keep
- * the whole picture.
+ * An eleven-change session in the shape of the shipped one: the camera moves in on the changed area, the words go on
+ * the end of the one prompt, partial live frames arrive while typing, the camera pulls back out as the settled one
+ * arrives, then the count goes up. The two big changes keep the whole picture.
*/
const LABELS = ["Red lips", "Hair down", "Gold hoops", "Velvet gown", "Diamond choker", "Red rose", "Fur stole", "Ballroom", "Spotlight", "Soft smile", "Cinematic grade"];
function longSession(): Demo {
@@ -59,12 +58,12 @@ function longSession(): Demo {
const box: Box | null = label === "Ballroom" || label === "Spotlight" ? null : [0.4, 0.3, 0.6, 0.6];
if (box) script.push({ type: "zoom", box, ms: 200 });
script.push(
- { type: "type", text: label.toLowerCase(), ms: early ? 700 : 450 },
+ { type: "type", text: `${i ? ", " : ""}${label.toLowerCase()}`, ms: early ? 700 : 450 },
{ type: "frame", frame: `s${i + 1}a`, live: true, ms: early ? 600 : 540 },
- { type: "type", text: " please", ms: early ? 500 : 300 },
+ { type: "type", text: " now", ms: early ? 500 : 300 },
);
if (box) script.push({ type: "zoom", box: null, ms: 0 });
- script.push({ type: "frame", frame: `s${i + 1}`, ms: early ? 700 : 560 }, { type: "keep", label, ms: early ? 900 : 700 });
+ script.push({ type: "frame", frame: `s${i + 1}`, ms: early ? 700 : 560 }, { type: "change", ms: early ? 900 : 700 });
});
script.push({ type: "compare", ms: 3400 }, { type: "pause", ms: 1200 });
return { v: 2, size: [960, 720], frames, script };
@@ -76,14 +75,20 @@ describe("the shipped demo", () => {
expect(loopMs(shipped)).toBeLessThanOrEqual(LOOP_MAX_MS);
});
- it("is one session of eleven kept steps, each settled picture shown before its keep", () => {
- const keeps = shipped.script.flatMap((s, i) => (s.type === "keep" ? [i] : []));
- expect(keeps).toHaveLength(11);
- for (const [k, i] of keeps.entries()) {
+ it("is one prompt of eleven changes, each settled picture shown before the count goes up", () => {
+ const changes = shipped.script.flatMap((s, i) => (s.type === "change" ? [i] : []));
+ expect(changes).toHaveLength(11);
+ expect(countChanges(shipped)).toBe(11);
+ for (const [k, i] of changes.entries()) {
const prev = shipped.script[i - 1];
expect(prev).toMatchObject({ type: "frame", frame: `s${k + 1}` });
expect(prev.type === "frame" && prev.live).toBeFalsy();
+ // Every change after the first goes on the end of the same words.
+ const next = shipped.script.slice(i + 1).find((s) => s.type === "type");
+ if (next?.type === "type") expect(next.text.startsWith(", ")).toBe(true);
}
+ // The words at the end are the whole prompt: every change is still in it (a change may hold a comma of its own).
+ expect(viewBefore(shipped, shipped.script.length).typed.split(", ").length).toBeGreaterThanOrEqual(11);
expect(shipped.script.at(-2)?.type).toBe("compare");
expect(Object.keys(shipped.frames)[0]).toBe("s0");
for (const id of Object.keys(shipped.frames)) expect(id).not.toMatch(/^\d+$/);
@@ -118,7 +123,7 @@ describe("the shipped demo", () => {
if (s.box) expect(cameraFor(s.box).s).toBeGreaterThan(1);
if (s.box) zoomed++;
}
- if (s.type === "keep" || s.type === "compare" || (s.type === "frame" && !s.live)) expect(zoom).toBeNull();
+ if (s.type === "change" || s.type === "compare" || (s.type === "frame" && !s.live)) expect(zoom).toBeNull();
}
expect(zoomed).toBeGreaterThanOrEqual(4);
});
@@ -139,7 +144,7 @@ describe("the shipped demo", () => {
for (const s of shipped.script) if (s.type === "frame" && s.live) expect(s.ms).toBeGreaterThanOrEqual(SWEEP_MS);
});
- it("shows no timings: the pill says Live or Kept, nothing more", () => {
+ it("shows no timings: the pill says Live, nothing more", () => {
expect(shippedText).not.toMatch(/Ms"\s*:/);
});
});
@@ -155,10 +160,6 @@ describe("timing", () => {
it("never types faster than a person can read", () => {
expect(Math.min(...typeDelays("a very long instruction typed in no time at all", 100))).toBeGreaterThanOrEqual(28);
});
-
- it("holds a keep for at least its pulse", () => {
- expect(stepMs({ type: "keep", label: "x", ms: 100 })).toBe(KEEP_PULSE_MS);
- });
});
describe("an eleven-step session", () => {
@@ -176,34 +177,32 @@ describe("an eleven-step session", () => {
expect(demoEnds(d)).toEqual({ before: "s0", after: "s11" });
});
- it("picks up where it paused, with the kept steps and the typed text", () => {
- const keep7 = d.script.findIndex((s) => s.type === "keep" && s.label === LABELS[6]);
- const v = viewBefore(d, keep7 + 2);
- expect(v.steps).toEqual(LABELS.slice(0, 7));
+ it("picks up where it paused, with the count and the words so far", () => {
+ const change7 = d.script.flatMap((s, i) => (s.type === "change" ? [i] : []))[6];
+ const v = viewBefore(d, change7 + 2);
+ expect(v.changes).toBe(7);
expect(v.frame).toBe("s7");
- expect(v.typed).toBe(LABELS[7].toLowerCase());
- expect(v.pill).toBe("Kept ✓");
+ // The words are never cleared: all seven changes, then the eighth being typed.
+ expect(v.typed).toBe(`${LABELS.slice(0, 7).map((l) => `${l.toLowerCase()} now`).join(", ")}, ${LABELS[7].toLowerCase()}`);
expect(v.zoom).toBeNull();
// The picture is there at once, not faded in from the dark behind it.
expect(v).toMatchObject({ fade: 0, sweep: false, under: null });
- const mid = viewBefore(d, keep7 + 3);
- expect(mid).toMatchObject({ frame: "s8a", pill: "Live" });
- const keep2 = d.script.findIndex((s) => s.type === "keep" && s.label === LABELS[1]);
- expect(viewBefore(d, keep2 + 4)).toMatchObject({ frame: "s3a", zoom: [0.4, 0.3, 0.6, 0.6] });
- expect(viewBefore(d, keep2).zoom).toBeNull();
+ expect(viewBefore(d, change7 + 3)).toMatchObject({ frame: "s8a", changes: 7 });
+ const change2 = d.script.flatMap((s, i) => (s.type === "change" ? [i] : []))[1];
+ expect(viewBefore(d, change2 + 4)).toMatchObject({ frame: "s3a", zoom: [0.4, 0.3, 0.6, 0.6] });
+ expect(viewBefore(d, change2).zoom).toBeNull();
});
- it("shows the count on the small card after a keep", () => {
- expect(pillText({ pill: "Live", steps: [] })).toEqual({ main: "Live", count: null });
- expect(pillText({ pill: "Kept ✓", steps: LABELS.slice(0, 7) }, true).count).toBe("7");
- expect(pillText({ pill: "Kept ✓", steps: LABELS.slice(0, 7) }).count).toBeNull();
+ it("shows the count on the small card once there are two changes", () => {
+ expect(pillText({ changes: 0 })).toEqual({ main: "Live", count: null });
+ expect(pillText({ changes: 1 }, true).count).toBeNull();
+ expect(pillText({ changes: 7 }, true).count).toBe("7");
+ expect(pillText({ changes: 7 }).count).toBeNull();
});
- it("refuses chip labels too long for a phone, keeps too short for the pulse, and a round over the limit", () => {
- const bad: Demo = { ...d, script: d.script.map((s) => (s.type === "keep" ? { ...s, label: "x".repeat(CHIP_MAX + 1), ms: 200 } : s)) };
- const p = demoProblems(bad);
- expect(p.some((x) => x.includes("label"))).toBe(true);
- expect(p.some((x) => x.includes(`${KEEP_PULSE_MS} ms`))).toBe(true);
+ it("refuses an unknown step and a round over the limit", () => {
+ const odd = { ...d, script: [...d.script, { type: "keep", label: "x", ms: 800 }] } as unknown as Demo;
+ expect(demoProblems(odd).some((x) => x.includes("unknown step"))).toBe(true);
const slow: Demo = { ...d, script: [...d.script, { type: "pause", ms: LOOP_MAX_MS }] };
expect(demoProblems(slow).some((x) => x.startsWith("one round"))).toBe(true);
});
@@ -272,47 +271,17 @@ describe("the camera", () => {
});
});
-describe("the trail", () => {
- it("folds older steps into a count and keeps the newest", () => {
- expect(trailWindow(LABELS.slice(0, 7), 1)).toEqual({ hidden: 6, shown: [{ n: 7, label: "Fur stole" }] });
- expect(trailWindow(LABELS.slice(0, 7), 3).hidden).toBe(4);
- expect(trailWindow(LABELS.slice(0, 2), 3)).toEqual({ hidden: 0, shown: [{ n: 1, label: "Red lips" }, { n: 2, label: "Hair down" }] });
- });
-
- it("renders Original, the folded count for each width, and at most three chips, the newest lit", () => {
- const html = renderToStaticMarkup(createElement(DemoTrail, { steps: LABELS }));
- expect(html).toContain(">Original<");
- expect(html.match(/data-live-chip="/g)).toHaveLength(3);
- expect(html).toContain('data-live-chip="11"');
- expect(html).not.toContain('data-live-chip="8"');
- expect(html).toContain('data-live-more="10"');
- expect(html).toContain('data-live-more="8"');
- expect(html.match(/data-newest="true"/g)).toHaveLength(1);
- expect(html).toMatch(/data-live-chip="11"[^>]*aria-current="step"|aria-current="step"[^>]*data-live-chip="11"/);
- // Phones see only the newest chip and the count of the rest.
- expect(html).toMatch(/class="contents @max-md:hidden"><span[^>]*>›<\/span><span[^>]*data-live-chip="10"/);
- });
-
- it("lets Original step aside on narrow players once earlier steps fold into a count", () => {
- const folded = renderToStaticMarkup(createElement(DemoTrail, { steps: LABELS }));
- expect(folded).toMatch(/<span class="[^"]*@max-md:hidden[^"]*"[^>]*data-live-original/);
- // The narrow count then leads the trail, with no separator before it.
- expect(folded).toMatch(/class="contents @md:hidden"><span[^>]*data-live-more="10"/);
- const first = renderToStaticMarkup(createElement(DemoTrail, { steps: LABELS.slice(0, 1) }));
- expect(first).toMatch(/data-live-original/);
- expect(first).not.toMatch(/<span class="[^"]*@max-md:hidden[^"]*"[^>]*data-live-original/);
- });
-
- it("has no wide count before a fourth step while the narrow one folds the earlier ones; nothing before the first keep", () => {
- const html = renderToStaticMarkup(createElement(DemoTrail, { steps: LABELS.slice(0, 3) }));
- expect(html).toContain('data-live-more="2"');
- expect(html).not.toContain('data-live-more="0"');
- expect(html.match(/data-live-chip="/g)).toHaveLength(3);
- expect(renderToStaticMarkup(createElement(DemoTrail, { steps: [] }))).toBe("");
+describe("the change count", () => {
+ it("says how many changes the one prompt holds, and nothing before the first", () => {
+ expect(changesWord(1)).toBe("1 change");
+ const html = renderToStaticMarkup(createElement(ChangeCount, { changes: 7 }));
+ expect(html).toContain(">7 changes<");
+ expect(html).toContain(">One prompt<");
+ expect(html).toContain('data-live-count="7"');
+ expect(renderToStaticMarkup(createElement(ChangeCount, { changes: 0 }))).toBe("");
});
- it("keeps every chip on one line, cut short rather than wrapped", () => {
- const html = renderToStaticMarkup(createElement(DemoTrail, { steps: LABELS }));
- for (const chip of html.match(/<span class="[^"]*"[^>]*data-live-chip="\d+"/g) ?? []) expect(chip).toMatch(/truncate/);
+ it("steps aside while the compare plays", () => {
+ expect(renderToStaticMarkup(createElement(ChangeCount, { changes: 3, hidden: true }))).toMatch(/opacity-0/);
});
});
diff --git a/tests/live-drift.test.ts b/tests/live-drift.test.ts
index 8b13d3df..886f0816 100644
--- a/tests/live-drift.test.ts
+++ b/tests/live-drift.test.ts
@@ -97,7 +97,7 @@ async function session(method: Method | "preview") {
let previewBase: { name: string; bytes: Buffer } | null = null;
for (const [k, text] of EDITS.entries()) {
const seed = 1000 + k;
- const baseName = method === "preview" && previewBase ? previewBase.name : stack.base(method === "preview" ? "hybrid" : method)!.name;
+ const baseName = method === "preview" && previewBase ? previewBase.name : stack.base()!.name;
const paste = method === "chain" ? ("off" as const) : ("auto" as const);
// Two live frames while typing: small WebP, never a base.
let lastLive: Buffer | null = null;
diff --git a/tests/live-transport.test.ts b/tests/live-transport.test.ts
new file mode 100644
index 00000000..404f4cdb
--- /dev/null
+++ b/tests/live-transport.test.ts
@@ -0,0 +1,35 @@
+import { afterEach, describe, expect, it, vi } from "vitest";
+import { ServerTransport, type RenderReq } from "@/components/live/live-transport";
+import { imageFrame } from "@/lib/live/frames";
+
+/*
+ * The server transport asks again when the server says "too many renders" (a cold GPU's first frames are slow and the
+ * next ones queue up), and lets go of a render that is no longer wanted while it waits.
+ */
+
+const req: RenderReq = { seq: 1, slot: "live", text: "evening makeup", seed: 7, size: 512, keepRes: 1024, aspect: "1:1", method: "compose" };
+const busy = () => new Response(JSON.stringify({ error: "Too many renders at once" }), { status: 429, headers: { "Retry-After": "0.01" } });
+const picture = () => new Response(imageFrame({ seq: 1, slot: "live", key: "k", w: 2, h: 2, type: "image/webp", ms: 900, sha256: "ab" }, new Uint8Array([1, 2, 3])) as BodyInit, { status: 200 });
+
+afterEach(() => vi.unstubAllGlobals());
+
+describe("the server transport", () => {
+ it("asks again after 429 until the picture comes", async () => {
+ const fetch = vi.fn().mockResolvedValueOnce(busy()).mockResolvedValueOnce(busy()).mockResolvedValueOnce(picture());
+ vi.stubGlobal("fetch", fetch);
+ const r = await new ServerTransport().render(req, () => {});
+ expect(fetch).toHaveBeenCalledTimes(3);
+ expect(r.ok && r.out.ms).toBe(900);
+ });
+
+ it("drops a render cancelled while it waits to ask again", async () => {
+ const fetch = vi.fn().mockResolvedValue(new Response("{}", { status: 429, headers: { "Retry-After": "1" } }));
+ vi.stubGlobal("fetch", fetch);
+ const t = new ServerTransport();
+ const p = t.render(req, () => {});
+ await new Promise((r) => setTimeout(r, 30));
+ t.cancel(() => true);
+ expect(await p).toEqual({ ok: false, dropped: "cancelled" });
+ expect(fetch.mock.calls.filter((c) => String(c[0]).includes("/api/live/render"))).toHaveLength(1);
+ });
+});