Skip to content

Canvix — Free & open-source graphic design tool. A community-built Canva alternative with a drag-and-drop editor, templates, shapes, text, images & one-click export. Works on desktop, tablet & mobile.

10.2 KB
Raw Blame

AI Power-Up — Wave 4 (v0.19.0)

Date: 2026-11-09 · Wave 4 of the consolidation programme (roadmap: docs/COMPETITIVE-ANALYSIS.md)

Eight features across three gradients of intelligence: local (no provider, works offline on any image), text-slot (one chat completion each, behind an editable review gate), and the video slot (async generation). Every provider-backed feature has an admin kill switch; every AI draft is reviewed before it lands.

The design principle: local first, reviewed always

Wave 4 was scoped right after a live verification of the VibesAI worker (vibesai-openai.ashiqzback.workers.dev):

Test Result
Generate → edit the exact generated bytes ✅ 200 (chain works)
Edit an arbitrary uploaded image ❌ 422 source_image_not_editable
Edit a vibes image after re-encoding (same pixels) ❌ 422 — strict sha256 byte-hash registry

vibes.ai (and therefore the worker proxying it) only edits images it generated itself, matched by exact bytes or its internal image_ent_id. The response is a first-class contract now:

  • /api/ai/image-edit returns a structured 422 SOURCE_NOT_EDITABLE with a pointer to the local tools that work on any image.
  • Generation/edit responses forward image_ent_id; the editor stores it on the element (ImageElement.aiEntId) and sends it back as sourceEntId, so AI-edit chains survive re-encoding (the byte hash does not).

Engine preference — provider or this device (v0.22)

The one-click image tools — BG remover and Upscale — carry a small engine toggle in their popovers, persisted per browser (canvix.image-tools.engine, lib/image-tools-engine.ts):

Engine BG remover Upscale
Provider (default) the configured image-edit provider cuts the background out server-side — no local compute, no model download the provider re-renders the image with restored detail at its supported sizes (only attempted when it adds pixels), then the deterministic Lanczos pass finishes to the advertised target
This device the local ONNX segmentation model (first use downloads ~40 MB, then cached) pure Lanczos-3, exactly as before

Failure behaviour is honest and structured:

  • No provider configured / feature disabled (NO_PROVIDER, FEATURE_DISABLED) — Upscale silently degrades to the deterministic on-device pass and the toast says so; BG remover (whose device engine downloads a 40 MB model) instead explains and asks you to flip the toggle — no surprise downloads.
  • SOURCE_NOT_EDITABLE (VibesAI-class providers that only edit their own generations) — both popovers point at the This device engine, which works on any image.
  • Any other provider error surfaces with its reason, inline in the popover.

The text-driven Magic eraser and Enhance stay provider-only (their local counterpart is the brush eraser); the brush eraser stays device-only (its provider counterpart is the Magic eraser).

Local image power tools (any image, offline)

Upscaler — Lanczos-3 (lib/upscale.ts)

The "Upscale" button on a selected image offers 2× / 4× with a live target-size preview. Pure-TypeScript separable Lanczos-3 resampling with premultiplied alpha (cut-outs keep clean edges — straight RGBA filtering bleeds transparent-pixel colors). Output capped at 8192px per side; the factor auto-reduces when the cap would be exceeded. Deterministic and unit-pinned (lib/upscale.test.ts). v0.22 adds lanczosResize() — the same kernel to exact target dimensions — as the deterministic finish of the provider engine's upscale path.

Brush magic eraser — pyramid diffusion (lib/inpaint.ts)

Paint over anything — people, objects, watermarks — with an adjustable brush; the region is reconstructed from its surroundings. Clean-room "LaMa-style" pipeline, zero model download:

  1. Pull-push pyramid — downsample known pixels only until the hole has context at a coarse scale, then fill back up level by level.
  2. Boundary-constrained Jacobi diffusion at full resolution (the brush edge is a fixed boundary, so the reconstruction matches the image by construction).
  3. One feather pass over the seam.

Honest scope: this reconstructs backgrounds (sky, walls, gradients, texture) very well; it does not hallucinate new complex content the way a generative model might — that is what the provider-backed Magic Eraser (text-described) is for, on images the provider generated.

Agentic planning with an editable review gate

Apps → AI design plan. Describe the design ("4-page launch deck for a coffee subscription, warm and earthy"), pick the page count, and the text-slot model returns a structured multi-page plan — nothing is applied yet. The review gate shows each page as a card with a scaled wireframe preview; every page and element can be toggled off, and every text is inline-editable. Apply builds real editor elements via the same factories the MCP server uses (lib/design-plan.ts → planToPages), appends the pages through one history push, and a single Ctrl+Z removes everything.

  • Route: POST /api/ai/plan (slot text, flag agenticPlanning)
  • The plan JSON is normalized against a hostile-input-safe coercion (clamped geometry, validated fonts/colors, ≤6 pages × ≤30 elements).
  • The normalizer is shared logic with the MCP generate_design tool's semantics — one notion of "what a generated design looks like".

Speaker-notes generation

The page bar's notes popover gained "Generate with AI". The page outline (titles from the largest text, bullets from the rest, media summaries — lib/notes-outline.ts; the model sees content, never geometry) goes to POST /api/ai/notes (slot text, flag notesGeneration). The reply renders as one editable textarea per page; Apply writes each page's notes via setPageNotes. Notes ride autosave/versions/collab and appear in presenter view — never on the canvas or in exports.

AI theme generation

Apps → AI theme. Describe a mood; the model returns a role-tagged palette (background / surface / ink / inkSoft / accent / accentSoft) plus a font pairing from the installed catalog. The preview shows all six roles; Apply maps them design-wide (lib/theme.ts → applyTheme, pure):

  • page backgrounds → background (gradients → accent→accentSoft)
  • headline text → ink + heading font; body text → inkSoft + body font
  • grayscale shapes → surface; colored shapes → accent; lines → accent
  • images, charts, stickers are never touched (recoloring media is a lie)

Two WCAG contrast guards run automatically: unreadable ink gets swapped at normalize time, and any text that would strand below 3:1 on the new background flips to ink at apply time. One history push — one Ctrl+Z reverts.

Alt-text generation (accessibility)

The image toolbar's Alt button opens an editor with Generate: one vision-slot call (POST /api/ai/alt-text, flag altText) returns a single plain sentence (≤ 200 chars after normalization, decorative for decorative images). The user reviews/edits before Save stores it on ImageElement.alt — which rides autosave, versions and collab, and feeds screen-reader landmarks. Never burned into visual exports.

Video generation slot

The fifth capability slot. Videos panel → "Generate with AI" (the card hides itself when the slot has no provider): prompt → POST /api/ai/video starts an async generation → the card polls GET /api/ai/video?id=… with a progress bar → preview → Add to design downloads the MP4 through the same-origin proxy (…&content=1), probes real dimensions and first-frame poster, and inserts a native video element through the chunked media store.

The slot speaks the emerging OpenAI "Sora-style" async shape — the exact surface the VibesAI worker exposes:

POST {baseUrl}/videos/generations        → { id, status: "queued" }
GET  {baseUrl}/videos/generations/:id    → { status, progress, videos[] }
GET  {baseUrl}/videos/generations/:id/content?index=N → MP4 bytes

Admin: flag videoGeneration, slot row "Video generation" in the console. The route rate-limits starts (3/min/IP) and polls (60/min/IP) separately so watching a generation cannot exhaust the start budget.

MCP: canvas-screenshot vision grounding

New tool vision_ground (21 tools total): feed it a screenshot of a canvas page (dataURL) plus the page's pixel size, and the vision slot returns a grounded inventory — what is visible, where (normalized 0..1 bounds and page-pixel boxes), in what colors, plus a reading-order description. Agents use it to reason about layout before acting with update_element / add_text, or to answer "what does this design look like". Pure normalizer: lib/mcp/vision-ground.ts (unit-tested); no-provider path fails with a pointer to get_design_content.

Capability surface

GET /api/ai/capabilities (booleans only, never secrets) now reports:

Capability Provider Kill switch
agenticPlanning text slot agenticPlanning
notesGeneration text slot notesGeneration
themeGeneration text slot themeGeneration
altText vision slot altText
videoGeneration video slot videoGeneration
upscale — local engine always available; provider engine via image-edit slot when configured —
brushEraser — local, always on —

Acceptance

  • Unit: 1309 tests pass (+54 for Wave 4: upscale, inpaint, design-plan, notes-outline, theme, vision-ground, video status, config slot table).
  • e2e: tests/e2e/wave4-ai-powerup.spec.ts — plan gate (edit + toggle + apply), notes review, theme apply, real local upscale (8→16px verified through the designs API), brush-eraser surface, alt text round-trip, capabilities shape. AI routes are mocked at the network layer.
  • No migration: aiEntId / alt ride as additive nullable element fields; slots/features ride the existing AppConfig JSON. Pre-v0.19 documents open byte-identically; stored admin tables merge over the new feature defaults (on).
  • Export parity: nothing new is burned into exports — alt text and notes are metadata; upscale/eraser swap the element src like any edit.