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.
TypeScript canva-alternativecanvasdesigndesign-tooldrag-and-dropeditorgraphic-designkonvanextjsopen-sourcereactself-hostedtemplatestypescript
feat(v0.11.4): canonical design URLs — /design/<id> (#3)
Ashiq Hussain Mir9f28c253a8f5
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex e015e43..882d4d1 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -3,6 +3,39 @@All notable changes to Canvix will be documented in this file.The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).+## [0.11.4] — 2026-11-01++Share links looked like query strings. Every design URL a user ever+copied — `/?design=cmvxd70oo…` — carried the app's SPA implementation+detail in the one place users actually look at it. Deep links worked,+but they didn't look like they would.++### Added+- **Canonical design URLs — `/design/<id>`** (new `src/app/design/[id]`+ route rendering the same app shell). The address bar now follows the+ app: opening a design (from the dashboard, the Projects panel, or a+ link) lands on `/design/<id>`; going home resets to `/`. Refresh on a+ design URL reopens the design. An unknown id falls back to the landing+ page with the URL reset — a dead path renders the app, not a blank page.+- `src/lib/design-url.ts` — one home for URL concerns: `designPath`,+ `designShareUrl`, `readDesignIdFromLocation` (path → `?design=` → `?d=`,+ in that order) and a `replaceUrl` helper. `AppShell` is the extracted+ single-page shell shared by `/` and `/design/[id]`.+- Playwright suite `design-urls.spec.ts` (5 tests): address-bar sync on+ create/back, cold-open of a canonical link, legacy query link+ resolution into the canonical path, Share-dialog link format, and the+ unknown-id fallback.++### Changed+- **Share dialog now generates `/design/<id>` links.** `/?design=<id>`+ and `/?d=<id>` remain first-class — old links, QR codes and printed+ URLs keep resolving (the legacy query resolves into the canonical+ path once the editor opens, so the address bar self-heals).+- The app store (`openEditor` / `goLanding` / `goDashboard`) keeps the+ URL in sync via `history.replaceState` — deliberately not `pushState`:+ popstate is not routed in this shell, and replace keeps the history+ stack honest while giving refresh/share the URL they need.+## [0.11.3] — 2026-10-30One mobile UI bug with two loud symptoms and a quiet third one hiding indiff --git a/README.md b/README.mdindex b23362a..bfb5306 100644--- a/README.md+++ b/README.md@@ -736,7 +736,20 @@ tool descriptions so agents pick the right format.- [x] Audio/video elements & Beat Sync — chunked media store (bytea +Range streaming), in-browser tempo/beat analysis, per-element beatpulses in preview/present/export *(v0.11.0)*-- [ ] Plugin system (external, installable apps)+- [x] Production hardening sweep — presence P2002 storm + 30s function+ hangs, v0.11.0 smoke (preview playback, export audio, offline+ detection), editor Projects panel crash, Elements panel tab strip+ *(v0.11.1–v0.11.3)*+- [x] Canonical design URLs — `/design/<id>` share links, address-bar+ sync, legacy `/?design=` links self-heal to the canonical path *(v0.11.4)*+- [ ] Plugin system (external, installable apps) — sandboxed-iframe MVP+ per `research/PLUGIN-SYSTEM.md`: manifest + permission model, iframe+ sandbox with postMessage bridge, an “Apps” panel store, and 2–3+ reference plugins (stock icons, charts, QR codes) to prove the+ surface — then a community plugin registry+- [ ] Mobile editor polish — touch-first selection handles, gesture+ zoom/pan without modifier keys, bottom-sheet property panels+ (the responsive groundwork from v0.11.3 makes this tractable)## 🤝 Contributingdiff --git a/package.json b/package.jsonindex 9bcce9d..8d25db7 100644--- a/package.json+++ b/package.json@@ -1,8 +1,8 @@{"name": "canvix",- "version": "0.11.3",+ "version": "0.11.4","private": false,- "description": "Canvix — free & open-source graphic design tool. A community-built Canva alternative.",+ "description": "Canvix \u2014 free & open-source graphic design tool. A community-built Canva alternative.","scripts": {"dev": "next dev -p 3000 2>&1 | tee dev.log","build": "node scripts/build.mjs",diff --git a/research/V0114-QA-PASS.md b/research/V0114-QA-PASS.mdnew file mode 100644index 0000000..6cf99e6--- /dev/null+++ b/research/V0114-QA-PASS.md@@ -0,0 +1,84 @@+# v0.11.4 QA pass — full-app human walkthrough++Date: 2026-11-01 · Environment: local dev (Next.js 16.4.3 / Turbopack),+PostgreSQL 17 (embedded), seeded 110 templates, Chromium 156 headless at+1440×900 and 390×844, two parallel browser sessions for collaboration.++Scope: every user-facing surface exercised like a normal human —+landing → dashboard → editor (text, shapes, images, draw) → export →+share → auth → collaboration → comments → versions → mobile.++## Result matrix++| Area | Case | Result |+| --- | --- | --- |+| Landing | hero, CTAs, template showcase, open-source section, GitHub links | ✅ |+| Dashboard | quick-create presets, template browsing, categories, search, Projects | ✅ |+| Editor · text | add box, double-click edit overlay, commit on Escape, font size, bold | ✅ |+| Editor · history | undo/redo granular (bold → size → text), disabled states honest | ✅ |+| Editor · shapes | add circle/square, drag, resize 320→506px, rotate to 81°, z-order (To front) | ✅ |+| Editor · colour | Fill menu: brand palette, gradients picker opens, fill applied (#7630D7) | ✅ |+| Photos | 42 bundled photos render, add to canvas (756×432) | ✅ |+| Photos | web search without an AI provider key | ⚠️ see F2 |+| Uploads | file input → data-URL image lands on canvas | ✅ |+| Draw | brush colour + stroke created (12-pt line) | ✅ |+| Export | PNG 2160×2160 RGBA, SVG true vector (clipPaths), PDF 1 page 1440×1440pt | ✅ |+| Preview | fullscreen overlay, reduced-motion toggle, Close | ✅ |+| Autosave | design persisted to Postgres without explicit save | ✅ |+| Versions | labelled snapshot (“QA test v1”), Restore + Delete actions, DB row | ✅ |+| Auth | register (scrypt, DB row), adopt-all claim, sign out, sign in, wrong-password inline error | ✅ |+| Ownership | adopted design attributed to the account; dashboard scopes to owned | ✅ |+| Share | dialog generates canonical `/design/<id>` link | ✅ |+| Deep links | `/?design=`, `/?d=`, `/design/<id>` all open the editor | ✅ |+| Collab · stream | SSE replay from `?since=0` (21 events, HLC-stamped), keepalives, presence snapshot | ✅ |+| Collab · presence | second session joins, both eventually see 2 | ⚠️ see F4 |+| Comments | canvas pin drop, post with author identity, DB row, cross-session sync | ✅ |+| MCP | disabled without `CANVIX_MCP_TOKEN` — clear JSON-RPC error, no auth bypass | ✅ |+| Health | `/api/health` → ok, db kind/host, template count | ✅ |+| Mobile | editor + dashboard at 390px: no horizontal overflow, panels adapt | ✅ |+| Tests | vitest 285/285, Playwright 19/19 (incl. 5 new design-URL tests) | ✅ |++## Findings (fix candidates)++- **F1 — no deselect on empty-canvas click.** Clicking empty canvas keeps+ the current selection; only Escape deselects. Canva deselects on empty+ click. One-line fix in `CanvasStage.handleStageMouseDown` (stage-level+ click that hits no element → clear `selectedIds`).+- **F2 — Photos panel search state sticks.** After a web search returns+ “Web results (0)”, the “All photos” tab shows only the last category’s+ photos (6 of 42) instead of the full grid; the panel must be closed and+ reopened to recover. The category switch after a search doesn’t reset+ the results-mode flag. Also: no hint that web results need an AI+ provider key — a one-line “configure an AI provider to search the web”+ note would prevent the “search is broken” impression.+- **F3 — editing-mode toggles can disagree.** The top-bar “Editing mode”+ control and the Tools-panel Select/Draw toggle are separate states:+ the top bar can read “Draw” while the canvas behaves as Select. Only+ the Tools-panel toggle reliably activates drawing. Either drive both+ from one store field or make the top-bar control the single source.+- **F4 — presence latency for idle clients (most impactful).** The+ stream pump sends a frame only when events exist or every 20th tick;+ with the quiet-mode backoff (800ms → 3.2s) a newly joined participant+ takes ~60–90s to appear for clients that aren’t editing. Measured: join+ visible to the idle session only after ~90s. Fix: diff the presence+ list per tick and send a presence-only frame when it changes (or cap+ the presence cadence at ~5s). Cursor moves already ride heartbeats —+ it’s joins/leaves that stall.+- **F5 — React anti-pattern warning.** Console: “Cannot update a+ component (`MagicLayersDialog`) while rendering a different component+ (`CanvasStage`)”. A setState-during-render in the MagicLayers flow —+ harmless today but a future-interaction landmine.+- **F6 — share of signed-out ownerless designs.** The share URL works+ for anyone (by design, v0.5 note in README §collab). The editor shows+ an honest view-only banner for other accounts’ designs — correct; just+ worth documenting on the Share dialog for self-hosters.++## Enhancement candidates (beyond fixes)++- Browser Back/Forward: the shell uses `replaceState` (popstate unrouted);+ wiring popstate → view store would give natural history navigation now+ that URLs are canonical.+- Photos search: fall back to filtering the bundled library when no AI+ provider is configured (search “mountain” → nature pack).+- Presence avatar tooltips could show the “last seen” age for stale+ collaborators before the 30s GC window drops them.diff --git a/src/app/design/[id]/page.tsx b/src/app/design/[id]/page.tsxnew file mode 100644index 0000000..213aae4--- /dev/null+++ b/src/app/design/[id]/page.tsx@@ -0,0 +1,14 @@+'use client'++import { AppShell } from '@/components/AppShell'++/**+ * v0.11.4: canonical design URLs — /design/<id>.+ *+ * The shell is the same single-page app as /; the DeepLinkHandler inside+ * AppShell resolves the id from the path, fetches the design and opens the+ * editor. Unknown ids fall back to the landing page with the URL reset.+ */+export default function DesignPage() {+ return <AppShell />+}diff --git a/src/app/page.tsx b/src/app/page.tsxindex 394705d..311e511 100644--- a/src/app/page.tsx+++ b/src/app/page.tsx@@ -1,61 +1,7 @@'use client'-import dynamic from 'next/dynamic'-import { useEffect } from 'react'-import { useAppStore } from '@/store/app-store'-import { Landing } from '@/components/landing/Landing'-import { Dashboard } from '@/components/dashboard/Dashboard'--const Editor = dynamic(() => import('@/components/editor/Editor'), {- ssr: false,- loading: () => (- <div className="h-screen w-full flex items-center justify bg-[#E9EAF0]">- <div className="flex flex-col items-center gap-4">- <div className="h-10 w-10 rounded-full border-4 border-[#00C4CC] border-t-transparent animate-spin" />- <p className="text-sm text-muted-foreground font-medium">Loading editor…</p>- </div>- </div>- ),-})--/** v0.5: collaboration deep links — /?design=<id> or /?d=<id> opens the editor directly. */-function DeepLinkHandler() {- useEffect(() => {- try {- const params = new URLSearchParams(window.location.search)- const designId = params.get('design') ?? params.get('d')- if (!designId || !/^[a-zA-Z0-9_-]{5,40}$/.test(designId)) return- const openEditor = useAppStore.getState().openEditor- void fetch(`/api/designs/${encodeURIComponent(designId)}`)- .then((r) => (r.ok ? r.json() : null))- .then((design) => {- if (design && Array.isArray(design.pages)) {- openEditor(design)- }- })- .catch(() => {- /* bad link — stay on landing */- })- } catch {- /* SSR guard */- }- }, [])- return null-}+import { AppShell } from '@/components/AppShell'export default function Page() {- const view = useAppStore((s) => s.view)-- if (view === 'editor') {- return <Editor />- }- if (view === 'dashboard') {- return <Dashboard />- }- return (- <>- <DeepLinkHandler />- <Landing />- </>- )+ return <AppShell />}diff --git a/src/components/AppShell.tsx b/src/components/AppShell.tsxnew file mode 100644index 0000000..9cf19fb--- /dev/null+++ b/src/components/AppShell.tsx@@ -0,0 +1,74 @@+'use client'++import dynamic from 'next/dynamic'+import { useEffect } from 'react'+import { useAppStore } from '@/store/app-store'+import { Landing } from '@/components/landing/Landing'+import { Dashboard } from '@/components/dashboard/Dashboard'+import { readDesignIdFromLocation, isDesignPath, replaceUrl } from '@/lib/design-url'++const Editor = dynamic(() => import('@/components/editor/Editor'), {+ ssr: false,+ loading: () => (+ <div className="h-screen w-full flex items-center justify bg-[#E9EAF0]">+ <div className="flex flex-col items-center gap-4">+ <div className="h-10 w-10 rounded-full border-4 border-[#00C4CC] border-t-transparent animate-spin" />+ <p className="text-sm text-muted-foreground font-medium">Loading editor…</p>+ </div>+ </div>+ ),+})++/**+ * v0.5: collaboration deep links — /design/<id> (canonical, v0.11.4) or the+ * legacy /?design=<id> / /?d=<id> query forms open the editor directly.+ */+function DeepLinkHandler() {+ useEffect(() => {+ try {+ const designId = readDesignIdFromLocation()+ if (!designId) return+ const openEditor = useAppStore.getState().openEditor+ void fetch(`/api/designs/${encodeURIComponent(designId)}`)+ .then((r) => (r.ok ? r.json() : null))+ .then((design) => {+ if (design && Array.isArray(design.pages)) {+ openEditor(design)+ } else if (isDesignPath()) {+ // /design/<unknown-id> — an honest reset to the landing page+ // instead of a dead URL that renders nothing.+ replaceUrl('/')+ useAppStore.getState().goLanding()+ }+ })+ .catch(() => {+ /* bad link — stay on landing */+ })+ } catch {+ /* SSR guard */+ }+ }, [])+ return null+}++/**+ * The single-page Canvix shell — shared by / (landing + dashboard) and+ * /design/<id> (deep link). The view switch is client-side; the URL is+ * kept in sync by the app store (see src/store/app-store.ts).+ */+export function AppShell() {+ const view = useAppStore((s) => s.view)++ if (view === 'editor') {+ return <Editor />+ }+ if (view === 'dashboard') {+ return <Dashboard />+ }+ return (+ <>+ <DeepLinkHandler />+ <Landing />+ </>+ )+}diff --git a/src/components/editor/ShareDialog.tsx b/src/components/editor/ShareDialog.tsxindex 412101a..dfaa3ab 100644--- a/src/components/editor/ShareDialog.tsx+++ b/src/components/editor/ShareDialog.tsx@@ -3,6 +3,7 @@import { Link2, Check, Copy, Globe, Lock, QrCode } from 'lucide-react'import { useState } from 'react'import { useEditorStore } from '@/store/editor-store'+import { designShareUrl } from '@/lib/design-url'import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '@/components/ui/dialog'import { Button } from '@/components/ui/button'import { cn } from '@/lib/utils'@@ -28,7 +29,8 @@ export function ShareDialog({ open, onOpenChange }: { open: boolean; onOpenChangconst designName = useEditorStore((s) => s.designName)const [copied, setCopied] = useState(false)- const link = designId ? `${typeof window !== 'undefined' ? window.location.origin : ''}/?design=${designId}` : ''+ // v0.11.4: canonical share URLs — /design/<id> (legacy /?design=<id> links keep working)+ const link = designId ? designShareUrl(designId) : ''const copy = async () => {try {diff --git a/src/lib/design-url.ts b/src/lib/design-url.tsnew file mode 100644index 0000000..3db4089--- /dev/null+++ b/src/lib/design-url.ts@@ -0,0 +1,63 @@+'use client'++/**+ * v0.11.4: clean, shareable design URLs.+ *+ * /design/<id> → canonical design URL (new)+ * /?design=<id> → legacy query-param deep link (still works)+ * /?d=<id> → legacy short form (still works)+ *+ * The app is a single-page shell (the editor mounts client-side), so these+ * helpers resolve a design id from ANY of the shapes above and keep the+ * address bar in sync via history.replaceState — refresh keeps the design,+ * share links look like real URLs, and old links keep working.+ */++export const DESIGN_ID_RE = /^[a-zA-Z0-9_-]{5,40}$/++/** Canonical path for a design id. */+export function designPath(id: string): string {+ return `/design/${id}`+}++/** Absolute share URL for a design id (origin + canonical path). */+export function designShareUrl(id: string): string {+ const origin = typeof window !== 'undefined' ? window.location.origin : ''+ return `${origin}${designPath(id)}`+}++/** Replace the address bar without touching history (SPA — popstate is not routed). */+export function replaceUrl(path: string): void {+ if (typeof window === 'undefined') return+ try {+ if (window.location.pathname !== path || window.location.search) {+ window.history.replaceState(null, '', path)+ }+ } catch {+ /* SSR / security-context guard */+ }+}++/**+ * Read the design id the URL points at, whichever shape it takes.+ * Path form wins over query form; returns null when no design is referenced.+ */+export function readDesignIdFromLocation(): string | null {+ if (typeof window === 'undefined') return null+ try {+ const m = window.location.pathname.match(/^\/design\/([a-zA-Z0-9_-]{5,40})\/?$/)+ if (m) return m[1]+ const params = new URLSearchParams(window.location.search)+ const q = params.get('design') ?? params.get('d')+ if (q && DESIGN_ID_RE.test(q)) return q+ } catch {+ /* SSR guard */+ }+ return null+}++/** True when the URL is a /design/<id> path (vs. a legacy query link). */+export function isDesignPath(): boolean {+ if (typeof window === 'undefined') return false+ return /^\/design\/[a-zA-Z0-9_-]{5,40}\/?$/.test(window.location.pathname)+}diff --git a/src/store/app-store.ts b/src/store/app-store.tsindex 6507d07..70c1cd7 100644--- a/src/store/app-store.ts+++ b/src/store/app-store.ts@@ -2,6 +2,7 @@import { create } from 'zustand'import type { DesignRecord } from '@/lib/types'+import { designPath, replaceUrl } from '@/lib/design-url'export type AppView = 'landing' | 'dashboard' | 'editor'@@ -17,7 +18,19 @@ interface AppStore {export const useAppStore = create<AppStore>((set) => ({view: 'landing',pendingDesign: null,- goLanding: () => set({ view: 'landing' }),- goDashboard: () => set({ view: 'dashboard' }),- openEditor: (design) => set({ view: 'editor', pendingDesign: design }),+ // v0.11.4: the address bar follows the view — the editor lives at+ // /design/<id>, everything else resets to /. replaceState (not push)+ // because popstate is not routed in this SPA shell.+ goLanding: () => {+ set({ view: 'landing' })+ replaceUrl('/')+ },+ goDashboard: () => {+ set({ view: 'dashboard' })+ replaceUrl('/')+ },+ openEditor: (design) => {+ set({ view: 'editor', pendingDesign: design })+ if (design?.id) replaceUrl(designPath(design.id))+ },}))diff --git a/tests/e2e/design-urls.spec.ts b/tests/e2e/design-urls.spec.tsnew file mode 100644index 0000000..067ecf3--- /dev/null+++ b/tests/e2e/design-urls.spec.ts@@ -0,0 +1,92 @@+import { test, expect } from '@playwright/test'++/**+ * v0.11.4: clean design URLs.+ * /design/<id> — canonical, opens the editor directly+ * /?design=<id> — legacy deep link, still works+ * Share dialog — generates the canonical /design/<id> link+ * Needs a database (template/design API calls) — see playwright.config.ts.+ */+test.describe('Canvix design URLs', () => {+ test('opening a design puts the canonical path in the address bar', async ({ page }) => {+ await page.goto('/')+ await page.getByRole('button', { name: /start designing/i }).first().click()+ await expect(page.getByLabel('Create a design')).toBeVisible()++ await page+ .locator('section:has(h2:text("Start a new design")) [aria-label^="Create "]')+ .first()+ .click()+ await expect(page.getByLabel('Design canvas')).toBeVisible({ timeout: 30_000 })++ // v0.11.4: the address bar follows the open design+ await expect(page).toHaveURL(/\/design\/[a-zA-Z0-9_-]{5,40}$/)++ // going back home resets the URL+ await page.getByLabel('Back to home').click()+ await expect(page.getByLabel('Create a design')).toBeVisible()+ await expect(page).toHaveURL(/\/$/)+ })++ test('a canonical /design/<id> link opens the editor directly', async ({ page }) => {+ // create a design first, then re-open it from a cold navigation+ await page.goto('/')+ await page.getByRole('button', { name: /start designing/i }).first().click()+ await page+ .locator('section:has(h2:text("Start a new design")) [aria-label^="Create "]')+ .first()+ .click()+ await expect(page.getByLabel('Design canvas')).toBeVisible({ timeout: 30_000 })+ const url = page.url()++ await page.goto('/') // leave the editor — a cold load starts on the landing+ await expect(page.getByRole('button', { name: 'Canvix home' })).toBeVisible()++ await page.goto(url) // cold-open the canonical link+ await expect(page.getByLabel('Design canvas')).toBeVisible({ timeout: 30_000 })+ await expect(page).toHaveURL(/\/design\/[a-zA-Z0-9_-]{5,40}$/)+ })++ test('legacy /?design=<id> links keep working', async ({ page }) => {+ await page.goto('/')+ await page.getByRole('button', { name: /start designing/i }).first().click()+ await page+ .locator('section:has(h2:text("Start a new design")) [aria-label^="Create "]')+ .first()+ .click()+ await expect(page.getByLabel('Design canvas')).toBeVisible({ timeout: 30_000 })+ const match = page.url().match(/\/design\/([a-zA-Z0-9_-]{5,40})$/)+ expect(match).not.toBeNull()+ const designId = match![1]++ await page.goto(`/?design=${designId}`)+ await expect(page.getByLabel('Design canvas')).toBeVisible({ timeout: 30_000 })+ // the legacy query resolves into the canonical path+ await expect(page).toHaveURL(new RegExp(`/design/${designId}$`))+ })++ test('Share dialog generates the canonical link', async ({ page }) => {+ await page.goto('/')+ await page.getByRole('button', { name: /start designing/i }).first().click()+ await page+ .locator('section:has(h2:text("Start a new design")) [aria-label^="Create "]')+ .first()+ .click()+ await expect(page.getByLabel('Design canvas')).toBeVisible({ timeout: 30_000 })+ const match = page.url().match(/\/design\/([a-zA-Z0-9_-]{5,40})$/)+ const designId = match![1]++ // Share is a text button (icon + "Share"), not aria-labelled+ await page.getByRole('button', { name: 'Share' }).click()+ await expect(page.getByLabel('Share link')).toHaveValue(+ new RegExp(`/design/${designId}$`),+ )+ })++ test('an unknown /design/<id> falls back to the landing page', async ({ page }) => {+ await page.goto('/design/unknown-design-id-99')+ // dead path — the shell resets to the landing page instead of rendering nothing+ await expect(page.getByRole('button', { name: 'Canvix home' })).toBeVisible({ timeout: 15_000 })+ await expect(page).toHaveURL(/\/$/)+ })+})