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.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
Handoff: Layout mode's report keeps its implement and review stages
Claude54e3340a186b
diff --git a/docs/handoff/reports/n7-2-layout-mode.json b/docs/handoff/reports/n7-2-layout-mode.jsonindex e912b716..04225ed8 100644--- a/docs/handoff/reports/n7-2-layout-mode.json+++ b/docs/handoff/reports/n7-2-layout-mode.json@@ -1,5 +1,162 @@{"key": "n7-2-layout-mode",+ "impl": {+ "branch": "o/n7-2-layout-mode",+ "summary": "The Layout mode package is built, verified in demo mode and committed on o/n7-2-layout-mode, in /home/user/wt/o-n7-2-layout-mode. The tree is clean, all 5 commits are signed, and nothing was pushed then (the branch was later pushed to origin/o/n7-2-layout-mode at 492643b). I didn't verify real MOSS / FLUX.3 / Ideogram renders because there is no GPU and no fal key here.\n\nResuming the earlier attempt: its 3 commits were sound. But the working tree and index had the package's own changes to 15 files under src/ reverted and staged, dated 12:27, after the last commit. This looks like a check that was cut off mid-way. I restored those files from HEAD and kept the attempt's uncommitted test additions (a Reuse round trip in the unit tests and in the e2e script).\n\nThe base claude/fuobe-parity-4 had moved on since the branch was cut (cd9e5ff to f7c6d8e, which brings in acc-2 accounts and n7-6). I rebased the 3 commits onto it. The rebase had no conflicts and the commits were signed again. No pnpm-lock changes came with the new base.\n\nNew work in this session:\n- **Closing keeps your boxes:** the editor now keeps what was drawn when it is closed with Escape or by clicking outside it. Before, those boxes were lost, because the editor has no Cancel button.\n- **Shift (or Alt) drag draws over a box:** you can now draw a new box on top of another, such as a headline on a product. Before, any press on a box moved it, so you couldn't start a drag there.\n- **Nudges can be undone:** arrow-key nudges go into Undo; holding a key down counts as one step.\n- **Steady phone sheet:** the rows sheet at 390 px has a fixed height, so the canvas no longer shrinks under your finger when the first box is added.\n\nAlready on the base (from N7-1, reused, not rebuilt): src/lib/layout-prompt.ts (the neutral draft, the MOSS / FLUX.3 / Ideogram / VGL / plain-words compilers, decodeMoss, the Import parser, validateLayout, readsBoxes, carriesLayout). Also from N7-1: `options.layout` on the models and the `promptExpansion` setting. That setting switches the API's own prompt expansion off for moss-image, flux-3 and ideogram-4-5 whenever a request carries a layout.\n\nBuilt by the earlier attempt and checked now: everything the plan lists for N7-2.\n- **Composer:** `layout: true` in the Image studio and the StudioConfig flag; enterLayout / layoutRequest / leaveLayout plus withoutLayout for Reuse; the Layout chip, the strip and the Reuse path in the composer.\n- **Plan:** it compiles the draft at the size the model renders. On your GPU that is computeDimensions on a 16 px grid fitted to 2048, sent as width and height. On fal it is sizeValue clamped to 512-2048, sent as image_size. The browser's catalog keeps each route's size field so the composer prices the same canvas as the server.\n- **Server:** generations.ts never runs the prompt enhancer on a layout request.\n- **Edit layout:** fal outputs keep actual_prompt, seed and size, and ComfyUI pictures keep the seed they were drawn with. The Edit layout action and `/image?layout=<generation>` open the boxes with the same seed.\n- **Editor and picker:** the new layout-editor.tsx and its box maths in layout-edit.ts (built on layers.ts). The model list puts box-reading models first with a \"Reads boxes\" badge. Feed tiles say \"Layout · N boxes\".\n\nAccounts: the accounts core is on the base, but this package adds no routes, tables, jobs or paid calls. Edit layout reads results through the existing GET /api/generations/[id], which already goes through the accounts route handler. No migration was needed.",+ "built": [+ {+ "feature": "Layout chip in the Image studio composer (StudioConfig.layout, IMAGE_STUDIO layout: true), strip above the prompt with box preview, Experimental badge, compiled-size line, Edit / Layout off with Undo; prompt becomes the summary caption; Enhance hidden",+ "status": "done (earlier attempt), re-verified",+ "verifiedHow": "tests/layout-mode.test.ts composer helper tests; tests/e2e/composer-flows.mjs section 7; my browser check at 1440/390, light and dark (screenshots)"+ },+ {+ "feature": "Composer helpers enterLayout / layoutRequest / leaveLayout / withoutLayout, layoutShape, layoutModelNote, layoutSizeWarning, the 'Reads your boxes' group in groupModels",+ "status": "done (earlier attempt)",+ "verifiedHow": "vitest tests/layout-mode.test.ts"+ },+ {+ "feature": "Plan compiles params.extra.layout at the exact render size: oss-moss-image on the 16 px grid with extra.width/height (fitted to 2048 as the ComfyUI provider fits it); fal moss-image image_size clamped to 512-2048 with the minimum respected; FLUX.3 / Ideogram 4.5 with their own compilers; other models get compileWords; a Text box without words is refused; enhancePrompt off",+ "status": "done (earlier attempt)",+ "verifiedHow": "vitest tests/layout-mode.test.ts (open 1360x768 and 2048x880; fal clamp 3000x300 -> 2048x512 and 300x300 -> 512x512; payload has enable_prompt_expansion false; the browser's catalog compiles the same)"+ },+ {+ "feature": "Server never runs the prompt enhancer on a layout request (generations.ts submit)",+ "status": "done (earlier attempt)",+ "verifiedHow": "vitest tests/layout-mode-server.test.ts (demo mode, mock provider; enhancer mocked and never called for a layout, still called for a plain prompt)"+ },+ {+ "feature": "Edit layout: an output action shown only when it can work (the request's own layout, or a fal MOSS actual_prompt decoded at the picture's own width and height); /image?layout=<id>[.<index>] opens Layout mode with the draft, caption, model and same seed; ComfyUI pictures keep the seed they were drawn with",+ "status": "done (earlier attempt)",+ "verifiedHow": "vitest tests/layout-mode.test.ts using the stored actual_prompt fixture tests/fixtures/moss-actual-prompt.json; e2e: Edit layout from a feed tile reopens the boxes (demo mode)"+ },+ {+ "feature": "Reuse round trip (layout run comes back in Layout mode with boxes and caption, plans to the same prompt, size and seed)",+ "status": "done; test changes committed this session",+ "verifiedHow": "vitest Reuse test; e2e check 'Reuse brings the boxes and the caption back'"+ },+ {+ "feature": "Layout editor (layout-editor.tsx): canvas in the chosen aspect ratio, drag to draw, numbered tabs, select / move / 8-handle resize, Delete, arrow-key nudge (Shift x10), the same spot cycles stacked boxes, Add box, Undo; rows with Object/Character/Text, what it looks like, exact words (inline error), optional colour; caption, canvas type Single/Panels/Collage, style tags; desktop rows beside the canvas, phone rows in a bottom sheet",+ "status": "done (earlier attempt) plus fixes this session: closing keeps the boxes, Shift/Alt-drag draws over a box, nudges go into Undo, fixed-height phone sheet",+ "verifiedHow": "My Playwright check (<the old session's scratch folder, gone>/layout-check.mjs): all checks pass at 1440 and 390 px, light and dark. Covered: drawing, moving and resizing by mouse and by touch; Shift-draw plus Undo; overlap cycling; nudge, Delete, Ctrl+Z; keyboard focus reaches every new control; the sheet folds; nothing scrolls sideways; labels fit; Escape keeps the boxes"+ },+ {+ "feature": "Import / Export (browser only): import a Fuobe or LinXce draft, a compiled MOSS prompt read on the current canvas, a legacy scene prompt or CreateBoundingBoxes elements (paste or file); copy the compiled prompt, copy the draft JSON, download .json",+ "status": "done (earlier attempt)",+ "verifiedHow": "Browser check: CreateBoundingBoxes import (3 boxes), round trip through the copied compiled MOSS prompt (2 boxes, words kept), clipboard contents checked"+ },+ {+ "feature": "Model list: box readers first with a 'Reads boxes' badge (cloud: FLUX.3, Ideogram 4.5, MOSS-Image; open: MOSS-Image); other models show 'This model reads the layout as words, not exact positions.' with a 'Use MOSS-Image' fix",+ "status": "done (earlier attempt)",+ "verifiedHow": "Browser: picker group contents on cloud and open; the words-model line on Nano Banana Pro"+ },+ {+ "feature": "Warning past 2048 px a side or 4 MP, with the size the model renders instead; Experimental noted in the mode's hint, badge and strip; 'Free' price on the open engine",+ "status": "done (earlier attempt)",+ "verifiedHow": "Browser: oss-moss-image at 21:9 and 1.5K shows '2352 × 1008 is past 2048 px a side, so MOSS-Image renders 2048 × 880'; Generate shows Free"+ },+ {+ "feature": "Feed tiles say 'Layout · N boxes'",+ "status": "done (earlier attempt)",+ "verifiedHow": "e2e 'the feed says it's a layout'"+ }+ ],+ "tests": "- **Unit tests:** 64 test files that touch the changed modules (composer, plan, outputs, cloud catalog, comfy provider, moss-image, image studios, layout-mode and its server test, and others). 63 files and 1166 tests passed. The other file, tests/comfy-dbs.test.ts, failed to load: it imports scripts/comfy/build-library.mjs, which needs playwright-core, and scripts/comfy/node_modules is not installed in this worktree. That is a setup gap; this package doesn't touch that file.\n- **Typecheck:** `tsc --noEmit` is clean.\n- **Lint:** eslint is clean on every file the package changed.\n- **E2E:** `node tests/e2e/composer-flows.mjs` against `pnpm dev -p 3427` (FUOBE_DATA_DIR=/tmp/fuobe-o-n7-2-layout-mode-data, demo mode) passed fully, twice: all composer checks, including the 11 layout checks (draw, Text error, compiled-size strip, Generate sends the draft, feed label, compiled MOSS prompt, Reuse, Edit layout from a tile, touch draw at 390 px, sheet under the canvas, no sideways scroll).\n- **Browser check:** an extra Playwright check at 1440 and 390 px, light and dark, passed every check (about 70 checks and screenshots in <the old session's scratch folder, gone>/shots/: editor-*, strip-*, picker-*).\n- **Cleanup:** the dev server is stopped and .next is deleted.\n\nNo full suite and no pnpm build, as the stage rules say.",+ "left": [+ "Real MOSS-Image, FLUX.3 and Ideogram 4.5 renders, and how well they follow the boxes, are not verified: that needs a GPU (oss-moss-image on ComfyUI) or a fal key. Everything here was checked in demo mode with the mock provider.",+ "Touch has no Shift key, so on phones a box can't be drawn starting on top of another one; the way round is 'Add box', then move and resize it. A long-press-to-draw gesture could be added later.",+ "The size warning shows in the composer strip; the editor shows the canvas size but not the warning sentence itself.",+ "On your GPU the canvas grid (16 px) and the 2048 limit come from constants in layout-prompt.ts that mirror the moss-image-t2i manifest limits; a test pins them to the manifest. A later change to the manifest limits would need those constants updated too.",+ "Layouts in Canvas, Marketing, Ads and Assist (Plan layout) are package N7-8, not this one.",+ "tests/comfy-dbs.test.ts can't load in this worktree until scripts/comfy dependencies (playwright-core 1.56.1) are installed. This is not about N7-2."+ ],+ "docsNotes": "For STATUS / ARCHITECTURE:\n- **The mode:** the Image studio has a Layout mode (chip next to Frames' place). Its draft rides as params.extra.layout. planGeneration compiles it once the render size is known: layoutCanvas, then the model's compiler (planLayout in src/lib/catalog/plan.ts).\n- **Sizes by engine:** on your GPU, exact width and height in extra on a 16 px grid, up to 2048 a side. On fal MOSS-Image, image_size equal to the canvas (512-2048) and enable_prompt_expansion false. FLUX.3 and Ideogram 4.5 use their own forms with expansion off; every other model gets plain sentences.\n- **No enhancer:** the server never runs Fuobe's prompt enhancer on a layout.\n- **Browser catalog:** slimModel now keeps a route's size field as route.preview.size, so the browser prices and compiles the same canvas as the server.\n- **Edit layout:** an output action, plus the /image?layout=<generation>[.<index>] hand-off. Its source is the request's own draft, or fal's actual_prompt decoded at the picture's size. fal MOSS outputs keep meta.actualPrompt, seed, width and height; ComfyUI image outputs keep meta.seed.\n- **Editor:** src/components/studio/layout-editor.tsx, with box maths in src/lib/layout-edit.ts (on layers.ts' rectFrom / resizeBox). Shift or Alt and drag draws over a box. Closing the editor keeps the boxes.\n- **No storage or route changes:** no migration, no new route, no new ComfyUI graph, no LoRA.\n- **Research:** no research corrections were needed."+ },+ "review": {+ "findings": [+ {+ "file": "src/lib/catalog/payload.ts",+ "line": 1003,+ "severity": "major",+ "summary": "Edit layout reopens cloud layout runs without the seed they were drawn with. extractOutputs records fal's `seed` only inside the `if (actualPrompt)` block. A layout run sends enable_prompt_expansion:false, and the research says fal returns actual_prompt only \"when expansion ran\". FLUX.3 and Ideogram 4.5 never return it. So no meta.seed is stored, and editableLayout falls back to the request's seed, which is normally unset. The plan says Edit layout opens \"with the draft and the same seed\". Separately, the fal provider sends seed+index per job, but the fallback hands every output the base seed.",+ "failureScenario": "Image studio on the cloud (the default engine), MOSS-Image or FLUX.3, Layout mode, random seed, Generate, then Edit layout on the result. The toast says \"Layout opened\" with no seed, and the re-render uses a new random seed, so the whole picture changes instead of only the moved box. Verified with a scratch vitest probe: extractOutputs({images:[{url,width:1360,height:768}],seed:918273}) gives meta undefined, and editableLayout(...).seed is undefined. The repo's own test at tests/layout-mode.test.ts:239 asserts the same no-meta result.",+ "verified": true+ },+ {+ "file": "src/components/studio/studio-page.tsx",+ "line": 473,+ "severity": "major",+ "summary": "Using Edit layout a second time on the same picture does nothing. LayoutHandoff keeps `opened.current = value` and never resets it, and it returns early when `opened.current === value`. `layout` is not in HANDOFF_PARAMS, so navigating to /image?layout=X does not bump the StudioProvider epoch, and the same LayoutHandoff instance (with its ref) survives. The early return also skips the `finally` cleanup, so ?layout=X stays in the address bar.",+ "failureScenario": "In the Image studio: Edit layout on picture X, move boxes, Generate (result Y), then Edit layout on X again to try another variation from the original (or after turning Layout off). No fetch, no toast, nothing reopens until the page is reloaded. Opening a different picture in between makes X work again. Traced: handoffKey only keeps image/ref/video/audio/prompt/preset/model/format (composer.ts L720), and StudioProvider is keyed by start.epoch (studio-page.tsx L556).",+ "verified": true+ },+ {+ "file": "tests/e2e/composer-flows.mjs",+ "line": 285,+ "severity": "minor",+ "summary": "The e2e check \"Edit layout reopens the boxes\" cannot fail. It runs right after the Reuse step, which already put the same 1-box layout in the strip. The `waitForFunction(() => !location.search.includes(\"layout=\"))` is already true before the menu click navigates, so it resolves at once. The check passes even if Edit layout does nothing, so it misses the second-click bug and does not check the seed. The ComfyUI change that copies meta.seed onto image outputs (comfyui.ts L1281 / L1495) has no test either.",+ "failureScenario": "Break LayoutHandoff (for example, make it return early always). Section 7 still prints a pass for \"layout: Edit layout reopens the boxes\", because the strip shows \"1 box\" from Reuse. Verified by reading the sequence (Reuse check at L272-275, Edit layout check at L276-285). A grep of tests/ finds no test of comfyProvider.poll seed meta.",+ "verified": true+ },+ {+ "file": "src/components/studio/composer.tsx",+ "line": 690,+ "severity": "minor",+ "summary": "The strip's \"Use MOSS-Image\" fix ignores Settings → Models & licences. boxModel comes from catalog.getModel(BOX_MODELS[engine]). getModel deliberately also finds models the admin switched off (catalog.tsx L85-L94), and the composer never checks catalog.offered() for it.",+ "failureScenario": "An admin switches moss-image off. A user in Layout mode on Nano Banana Pro sees \"This model reads the layout as words… Use MOSS-Image\". Tapping it picks a model that is off, and the composer's offModel fallback (L331-332) moves straight back to the studio default. The suggested fix is a dead end. Traced in code.",+ "verified": true+ },+ {+ "file": "src/components/studio/layout-editor.tsx",+ "line": 296,+ "severity": "minor",+ "summary": "Keyboard users cannot resize boxes. The 8 handles are aria-hidden spans driven only by pointer events, and onKeyDown handles only Ctrl+Z, Delete/Backspace and arrow-key nudges (nudgedBox). Add box always makes a box a third of each side, so a keyboard-only user is stuck at that size. Also, Delete on a focused box tab unmounts that tab and focus falls out of the canvas, so further arrow or Delete keys do nothing until the user tabs back in.",+ "failureScenario": "Keyboard only: Tab to Add box and press Enter (a 1/3 × 1/3 box), Tab to its number tab, then try to make it a wide headline strip. There is no key that changes width or height. Verified by reading onKeyDown and the HANDLES markup (aria-hidden, no tabIndex).",+ "verified": true+ },+ {+ "file": "src/components/studio/layout-editor.tsx",+ "line": 452,+ "severity": "minor",+ "summary": "Box number tabs (11 px) and row number chips (12 px) put white text on the kind colours: Text #ff9f0a about 2.1:1 and Character #34c759 about 2.2:1. Both fail WCAG AA in light and dark themes. Any colour the user picks (for example white or yellow) can make the number unreadable.",+ "failureScenario": "Draw a box and set it to Text: its \"1\" tab is white on orange at 2.06:1 contrast. Computed from the sRGB relative luminance of the hex values in KIND_COLOR.",+ "verified": true+ },+ {+ "file": "src/lib/output-actions.ts",+ "line": 250,+ "severity": "nit",+ "summary": "editableLayout returns the request's own layout even when it has zero boxes. A run made with Layout on but nothing drawn gets an Edit layout action that opens an empty canvas, while its feed tile has no \"Layout\" label.",+ "failureScenario": "Turn Layout on, close the editor without drawing, type a prompt and Generate. The result menu offers Edit layout, which opens a blank layout. readLayout accepts items: [] and editableLayout has no items.length check on the `own` path.",+ "verified": true+ },+ {+ "file": "src/lib/catalog/plan.ts",+ "line": 472,+ "severity": "nit",+ "summary": "The size line and warning for cloud models without a size field come from computeDimensions' tier table. FLUX.3's \"512sq\" and \"768sq\" are unknown tiers there and show as \"about 1360 × 768\". Words models also get the 2048/4 MP warning (\"Nano Banana Pro may place the boxes less exactly\") although they never place boxes by position.",+ "failureScenario": "Probe: layoutCanvas(flux-3, 16:9, \"512sq\") returns 1360×768. With Nano Banana Pro at 2K the strip shows both the \"reads the layout as words\" line and the warning that it \"may place the boxes less exactly\".",+ "verified": true+ },+ {+ "file": "src/lib/layout-edit.ts",+ "line": 14,+ "severity": "nit",+ "summary": "MIN_BOX_PX is measured in render pixels, not screen pixels. On a phone the canvas is drawn about 358 px wide, so for a 2048-wide render 16 px is about 2.8 screen px. A tap meant to deselect that drifts about 3 px in both directions draws a tiny box.",+ "failureScenario": "390 px, oss-moss-image at 16:9 1.5K (2048×1152): tap empty canvas with slight finger drift, and a roughly 17×17 px box appears and is selected. rectFrom only rejects a side under `min` in render pixels.",+ "verified": true+ },+ {+ "file": "src/components/studio/layout-editor.tsx",+ "line": 366,+ "severity": "nit",+ "summary": "The editor's aspect select drops \"auto\" from its options but keeps value=\"auto\". With Nano Banana Pro set to Auto, the select shows its first option (21:9) while the canvas is square (ratioOf(\"auto\") = 1).",+ "failureScenario": "Nano Banana Pro, aspect Auto, Layout on: the header select reads 21:9 over a 1:1 canvas, and picking 21:9 fires no change because it already looks selected.",+ "verified": true+ }+ ],+ "checks": "Ran: vitest on tests/layout-mode.test.ts, tests/layout-mode-server.test.ts, tests/layout-prompt.test.ts and tests/moss-image.test.ts (4 files, 68 tests, all passed). `tsc --noEmit` reported no errors in package files. The only errors were Next's generated RouteContext/LayoutProps/PageProps globals, which are missing because .next was deleted, an environment gap. ESLint on every changed file: clean. Scratch vitest probes are in <the old session's scratch folder, gone>/n72review; nothing was written to the worktree. The probes covered: layout canvases for flux-3, ideogram-4-5, moss-image, oss-moss-image, nano-banana-pro and bria-fibo-2 at each tier; the Bria payload, which carries `vgl` as the research says; cloud MOSS with LoRAs keeping image_size; num_images=4 with expansion off; FLUX.3 and Ideogram edit routes with a layout; an empty caption with boxes; the Soul words path; and seed capture for fal responses without actual_prompt. Traced by reading: StudioProvider epoch and HANDOFF_PARAMS against LayoutHandoff; the engine-switch effect against the Edit layout engine change; the catalog access filter; ComfyUI seed meta; the server enhancer skip; stored request vs prompt column; and readLayout HEX colour sanitising (no CSS injection). No Higgsfield references, binaries, LoRA files or new models in the diff, so no licence data was needed. No new routes, tables or jobs, so nothing for the accounts core. All 5 commits carry gpgsig and the tree is clean.",+ "verdict": "Most of the package is sound and does what the plan asks: the composer helpers, the plan compiling at the exact render size on both engines (16 px grid up to 2048 on the GPU, fal image_size kept within 512-2048), prompt expansion off and the server enhancer skipped for layouts, the browser catalog keeping the size field, Import / Export, the model list with box readers first, the feed label and the 390 px sheet. Fix two major Edit layout problems before merging. First, cloud layout runs (MOSS with expansion off, FLUX.3, Ideogram) never store fal's seed, so \"Edit layout with the same seed\" fails on the default engine whenever the seed was random. Second, reopening the same picture with Edit layout a second time in one Image studio session silently does nothing. The e2e check for Edit layout cannot fail as written, so it should be rewritten to start from a state with no layout. The rest are minor accessibility and polish items: no keyboard resize, low-contrast box numbers, and \"Use MOSS-Image\" offered when an admin has switched it off."+ },"fix": {"applied": ["MAJOR payload.ts extractOutputs: fal's seed now stored on t2i/edit image outputs without actual_prompt; tests in tests/layout-mode.test.ts",