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.

fix(v0.23.2): 'Test video generation' answered 'Unknown slot' — the v0.16-era slot lists never learned the v0.19 video slot

Ashiq Hussain Mirbe75f39c0303
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ad2ead2..068e4f5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,52 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
## [Unreleased]
+## [0.23.2] — 2026-11-13
+
+### Fixed
+
+- **"Test video generation" answered "Unknown slot"** — the video
+ slot joined `SLOT_ENDPOINT` and the probe set. The admin console's
+ per-slot Test buttons (v0.16.3 A3) guard against a slot map that
+ predates the video slot (v0.19 Wave 4): clicking *Test video
+ generation* on a provider pinned to `video` (e.g. VibesAI ·
+ vibes-video) answered 400 "Unknown slot — use text, vision, image
+ or imageEdit" — the slot saved and resolved fine (v0.23.1), the
+ Videos panel generated fine, but the one button that exists to
+ verify the provider before trusting it refused to run. The fix
+ teaches the whole admin surface the fifth slot, which shipped in
+ v0.19 and was never added to any v0.16-era list:
+ - `src/lib/ai/probe.ts` — `video: 'POST {base}/videos/generations'`
+ joins `SLOT_ENDPOINT`; `probeSlot` gains a video branch that
+ mirrors the feature route's exact transport (`src/app/api/ai/
+ video/route.ts`): raw `fetch` (the SDK has no video surface),
+ the Sora-style `POST /videos/generations` tried first, the z-ai
+ internal `POST /video/generation` only when that 404s, companion
+ auth headers (`ResolvedSlot.headers` — the z-ai X-Token dialect)
+ riding along. Zero-cost posture (the imageEdit philosophy): a
+ 4xx validation rejection PROVES the endpoint exists without
+ spending a generation; a 2xx is the full-path verdict; both-404
+ is a not-served verdict that names the fix.
+ - `src/app/api/admin/config/ai-test/route.ts` — the guard message
+ lists video; the `resolveSlot` cast types against `AI_SLOTS`
+ (the one source of truth) instead of a hand-rolled four-literal
+ union; the probe target carries the companion headers.
+ - **The admin Logs view learned the slot too** (the sibling gap
+ found while fixing the first): the video feature route has
+ written `recordUsage('video', …)` rows since v0.19, but they
+ were invisible — `LOG_FEATURES` (filter validation + per-feature
+ counters) and the route's `SLOT_ORDER` (the slot cards) predated
+ the slot, so video rows rendered but could not be filtered and
+ the video slot had no card. Both lists, and the Logs UI's label
+ maps + feature chips, now include video.
+ - 9 regression tests: the seven video-probe verdicts (200 w/ task
+ id, 4xx-proves-reachable, Sora-404 → z-ai fallthrough, both-404,
+ 401, companion headers, network failure) and the logs pair
+ (video filterable, video counted). Full suite 1411/1411,
+ `tsc --noEmit` + `eslint` clean.
+
+## [0.23.1] — 2026-11-13
+
### Added
- **Profile page + bring your own key** (v0.23): every signed-in user
diff --git a/package-lock.json b/package-lock.json
index 467d49a..1a074ef 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "canvix",
- "version": "0.23.1",
+ "version": "0.23.2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "canvix",
- "version": "0.23.1",
+ "version": "0.23.2",
"hasInstallScript": true,
"dependencies": {
"@imgly/background-removal": "^1.7.0",
diff --git a/package.json b/package.json
index c97c906..e5b3c70 100644
--- a/package.json
+++ b/package.json
@@ -1,8 +1,8 @@
{
"name": "canvix",
- "version": "0.23.1",
+ "version": "0.23.2",
"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/src/app/api/admin/config/ai-test/route.ts b/src/app/api/admin/config/ai-test/route.ts
index 3327ccf..e89e217 100644
--- a/src/app/api/admin/config/ai-test/route.ts
+++ b/src/app/api/admin/config/ai-test/route.ts
@@ -126,9 +126,12 @@ async function __canvix_post(req: NextRequest) {
const slotProbe = typeof body.slot === 'string' ? body.slot.trim() : null
if (slotProbe) {
if (!(slotProbe in SLOT_ENDPOINT)) {
- return NextResponse.json({ ok: false, error: 'Unknown slot — use text, vision, image or imageEdit.' }, { status: 400 })
+ return NextResponse.json({ ok: false, error: 'Unknown slot — use text, vision, image, imageEdit or video.' }, { status: 400 })
}
- const resolved = await resolveSlot(slotProbe as 'text' | 'vision' | 'image' | 'imageEdit')
+ // v0.23.2: the video slot joins the probe set — SLOT_ENDPOINT (and
+ // probeSlot) learned it; until now this guard answered "Unknown
+ // slot" for the console's "Test video generation" button.
+ const resolved = await resolveSlot(slotProbe as (typeof AI_SLOTS)[number])
if (!resolved) {
return NextResponse.json(
{ ok: false, error: `The ${slotProbe} slot has no provider — pin one on the AI & models page.` },
@@ -142,6 +145,9 @@ async function __canvix_post(req: NextRequest) {
model: modelOverride ?? resolved.model,
label: resolved.label ?? resolved.source,
source: resolved.source,
+ // v0.23.2: companion auth headers ride the video probe (the z-ai
+ // dialect authenticates with X-Token, not just the bearer)
+ ...(resolved.headers ? { headers: resolved.headers } : {}),
}
try {
const out = await probeSlot(slotProbe, target)
diff --git a/src/app/api/admin/logs/route.ts b/src/app/api/admin/logs/route.ts
index 025d987..ebd9caf 100644
--- a/src/app/api/admin/logs/route.ts
+++ b/src/app/api/admin/logs/route.ts
@@ -27,7 +27,10 @@ export const dynamic = 'force-dynamic'
// v0.16.4 (A4): imageSearch is retired — photo search runs on the
// stock-provider keys, not on an AI slot (its searches are not AIUsage
// rows; historical 'search' rows keep rendering in the log below)
-const SLOT_ORDER = ['text', 'vision', 'image', 'imageEdit'] as const
+// v0.23.2: 'video' joins the slot cards — the feature route has written
+// recordUsage('video', …) rows since v0.19, but the slot card never
+// showed here because this list predated the slot.
+const SLOT_ORDER = ['text', 'vision', 'image', 'imageEdit', 'video'] as const
async function __canvix_get(req: NextRequest) {
const guard = await requireAdmin(req)
diff --git a/src/components/admin/logs.tsx b/src/components/admin/logs.tsx
index 384e48d..98edf25 100644
--- a/src/components/admin/logs.tsx
+++ b/src/components/admin/logs.tsx
@@ -58,12 +58,14 @@ const SLOT_LABEL: Record<string, string> = {
vision: 'Vision',
image: 'Image generation',
imageEdit: 'Image editing',
+ video: 'Video generation',
}
const SLOT_FEATURES: Record<string, string> = {
text: 'Magic Write · Translate · Assistant',
vision: 'Magic Layers',
image: 'Photos panel → Generate',
imageEdit: 'Magic Eraser · Enhance · BG remove',
+ video: 'Videos panel → AI video card',
}
const SOURCE_LABEL: Record<string, string> = {
multi: 'providers table',
@@ -74,7 +76,8 @@ const SOURCE_LABEL: Record<string, string> = {
const WINDOWS = ['15m', '1h', '6h', '24h', '7d'] as const
// 'search' stays for HISTORICAL rows (the retired imageSearch slot,
// v0.16.4 A4 — stock-photo searches are not AIUsage rows)
-const FEATURES = ['assistant', 'write', 'translate', 'image', 'image-edit', 'magic-layers', 'search'] as const
+// v0.23.2: 'video' joins (filterable rows + per-feature counters)
+const FEATURES = ['assistant', 'write', 'translate', 'image', 'image-edit', 'magic-layers', 'search', 'video'] as const
function fmtTime(iso: string): string {
const d = new Date(iso)
diff --git a/src/lib/admin/logs.test.ts b/src/lib/admin/logs.test.ts
index f790711..1094ff6 100644
--- a/src/lib/admin/logs.test.ts
+++ b/src/lib/admin/logs.test.ts
@@ -110,6 +110,22 @@ describe('queryAiLogs (A3)', () => {
rand.mockRestore()
})
+ // v0.23.2: 'video' joins LOG_FEATURES — the feature route has written
+ // recordUsage('video', …) rows since v0.19, but they were unfilterable
+ // and absent from the counters because this list predated the slot.
+ it('filters and counts video rows (the v0.19 slot is a first-class log feature)', async () => {
+ const rand = vi.spyOn(Math, 'random').mockReturnValue(0.5)
+ await queryAiLogs({ window: '24h', feature: 'video', outcome: 'all', limit: 150 })
+ expect(dbMock.aIUsage.findMany.mock.calls[0][0].where.feature).toBe('video')
+ dbMock.aIUsage.groupBy.mockResolvedValue([
+ { feature: 'video', ok: true, _count: { _all: 2 } },
+ { feature: 'video', ok: false, _count: { _all: 1 } },
+ ])
+ const out = await queryAiLogs({ window: '24h', outcome: 'all', limit: 150 })
+ expect(out.counts.byFeature.video).toEqual({ calls: 3, errors: 1 })
+ rand.mockRestore()
+ })
+
it('sweeps rows past retention when the 1% dice come up', async () => {
const rand = vi.spyOn(Math, 'random').mockReturnValue(0)
dbMock.aIUsage.deleteMany.mockResolvedValue({ count: 12 })
diff --git a/src/lib/admin/logs.ts b/src/lib/admin/logs.ts
index eb6a092..d75b6b9 100644
--- a/src/lib/admin/logs.ts
+++ b/src/lib/admin/logs.ts
@@ -44,7 +44,11 @@ export function parseLimit(value: string | null): number {
return Math.min(400, Math.max(20, Math.round(n)))
}
-/** Feature names the log can filter by (kept in a stable order for UIs). */
+/** Feature names the log can filter by (kept in a stable order for UIs).
+ * 'search' stays for HISTORICAL rows (the retired imageSearch slot,
+ * v0.16.4 A4). v0.23.2: 'video' joins — the feature route has written
+ * those rows since v0.19 but they were unfilterable (and missing from
+ * the per-feature counters) until now. */
export const LOG_FEATURES = [
'assistant',
'write',
@@ -53,6 +57,7 @@ export const LOG_FEATURES = [
'image-edit',
'magic-layers',
'search',
+ 'video',
] as const
export interface AiLogRow {
diff --git a/src/lib/ai/probe.test.ts b/src/lib/ai/probe.test.ts
index a9ebb76..200774f 100644
--- a/src/lib/ai/probe.test.ts
+++ b/src/lib/ai/probe.test.ts
@@ -3,6 +3,12 @@
// admin acts on. The production incident this encodes: NVIDIA NIM
// (chat-only) pinned to every slot — text tests passed while image
// generation 404'd with no explanation anywhere the admin could see.
+//
+// v0.23.2: the video slot's regression suite — the console's "Test
+// video generation" button answered "Unknown slot" because
+// SLOT_ENDPOINT (a v0.16.3 map) predated the v0.19 slot. The video
+// probe speaks raw fetch (the SDK has no video surface), so these
+// cases mock global fetch, not the SDK.
import { describe, it, expect, vi, beforeEach } from 'vitest'
@@ -29,6 +35,11 @@ import { classifyProbeError, probeSlot, SLOT_ENDPOINT } from './probe'
const TARGET = { baseUrl: 'https://provider.test/v1', apiKey: 'k', label: 'Test Provider', source: 'multi' }
+/** fetch-mock helper — a Response with the minimum surface the probe reads. */
+function fetchOk(body: unknown, status = 200): Promise<Response> {
+ return Promise.resolve(new Response(JSON.stringify(body), { status }))
+}
+
beforeEach(() => {
vi.clearAllMocks()
chatCreate.mockResolvedValue({ choices: [{ message: { content: 'ok' } }] })
@@ -108,3 +119,90 @@ describe('probeSlot (A3)', () => {
expect(chatCreate).toHaveBeenCalled()
})
})
+
+describe('probeSlot — video (v0.23.2: the "Unknown slot" regression)', () => {
+ it('the video slot is in the endpoint map — the guard no longer rejects it', () => {
+ expect(SLOT_ENDPOINT.video).toBe('POST {base}/videos/generations')
+ })
+
+ it('a Sora-style 200 with a task id is a full-path verdict', async () => {
+ const fetchMock = vi.spyOn(globalThis, 'fetch').mockImplementation(() => fetchOk({ id: 'task-1' }))
+ const out = await probeSlot('video', TARGET)
+ expect(out.verdict.ok).toBe(true)
+ expect(out.verdict.httpStatus).toBe(200)
+ expect(out.verdict.message).toContain('full path works')
+ expect(fetchMock).toHaveBeenCalledWith(
+ 'https://provider.test/v1/videos/generations',
+ expect.objectContaining({ method: 'POST' })
+ )
+ fetchMock.mockRestore()
+ })
+
+ it('a 4xx validation rejection PROVES the endpoint exists (zero-cost posture)', async () => {
+ const fetchMock = vi
+ .spyOn(globalThis, 'fetch')
+ .mockImplementation(() => fetchOk({ error: 'prompt violates policy' }, 400))
+ const out = await probeSlot('video', TARGET)
+ expect(out.verdict.ok).toBe(true) // reachable — that is the signal
+ expect(out.verdict.httpStatus).toBe(400)
+ expect(out.verdict.message).toContain('reachable')
+ fetchMock.mockRestore()
+ })
+
+ it('Sora 404 falls through to the z-ai dialect, which answers 200', async () => {
+ const fetchMock = vi
+ .spyOn(globalThis, 'fetch')
+ .mockImplementationOnce(() => fetchOk('404 page not found', 404))
+ .mockImplementationOnce(() => fetchOk({ id: 'ztask-1', task_status: 'PROCESSING' }))
+ const out = await probeSlot('video', TARGET)
+ expect(fetchMock).toHaveBeenNthCalledWith(
+ 2,
+ 'https://provider.test/v1/video/generation',
+ expect.objectContaining({ method: 'POST' })
+ )
+ expect(out.verdict.ok).toBe(true)
+ expect(out.verdict.message).toContain('z-ai dialect')
+ fetchMock.mockRestore()
+ })
+
+ it('both dialects 404 is a NOT-SERVED verdict that names the fix', async () => {
+ const fetchMock = vi
+ .spyOn(globalThis, 'fetch')
+ .mockImplementation(() => fetchOk('404 page not found', 404))
+ const out = await probeSlot('video', TARGET)
+ expect(out.verdict.ok).toBe(false)
+ expect(out.verdict.httpStatus).toBe(404)
+ expect(out.verdict.message).toContain('does not serve video')
+ expect(fetchMock).toHaveBeenCalledTimes(2) // tried both dialects
+ fetchMock.mockRestore()
+ })
+
+ it('a 401 is a credentials verdict (bearer rejected)', async () => {
+ const fetchMock = vi.spyOn(globalThis, 'fetch').mockImplementation(() => fetchOk('unauthorized', 401))
+ const out = await probeSlot('video', TARGET)
+ expect(out.verdict.ok).toBe(false)
+ expect(out.verdict.message).toContain('credentials')
+ fetchMock.mockRestore()
+ })
+
+ it('companion headers ride the request (the z-ai X-Token auth)', async () => {
+ const fetchMock = vi.spyOn(globalThis, 'fetch').mockImplementation(() => fetchOk({ id: 't' }))
+ await probeSlot('video', { ...TARGET, headers: { 'X-Token': 'tok', 'X-User-Id': 'u1' } })
+ const [, init] = fetchMock.mock.calls[0] as [string, RequestInit]
+ const headers = init.headers as Record<string, string>
+ expect(headers['X-Token']).toBe('tok')
+ expect(headers['X-User-Id']).toBe('u1')
+ expect(headers['Authorization']).toBe('Bearer k')
+ fetchMock.mockRestore()
+ })
+
+ it('a network failure is a failed verdict, never a thrown error', async () => {
+ const fetchMock = vi
+ .spyOn(globalThis, 'fetch')
+ .mockImplementation(() => Promise.reject(new Error('fetch failed: ECONNREFUSED')))
+ const out = await probeSlot('video', TARGET)
+ expect(out.verdict.ok).toBe(false)
+ expect(out.verdict.message).toContain('ECONNREFUSED')
+ fetchMock.mockRestore()
+ })
+})
diff --git a/src/lib/ai/probe.ts b/src/lib/ai/probe.ts
index 50f105b..3a37674 100644
--- a/src/lib/ai/probe.ts
+++ b/src/lib/ai/probe.ts
@@ -25,6 +25,10 @@ export const SLOT_ENDPOINT: Record<string, string> = {
vision: 'POST {base}/chat/completions',
image: 'POST {base}/images/generations',
imageEdit: 'POST {base}/images/generations/edit',
+ // v0.19 shipped the video slot; this map (v0.16.3) only caught up in
+ // v0.23.2 — until then the console's "Test video generation" button
+ // answered "Unknown slot" because the guard keys off this map.
+ video: 'POST {base}/videos/generations',
}
export interface ProbeVerdict {
@@ -96,6 +100,9 @@ export interface ProbeTarget {
model?: string
label: string
source: string
+ /** v0.23.2: companion auth headers for the video dialects (the z-ai
+ * internal API's X-Token/X-User-Id/X-Chat-Id) — mirrors ResolvedSlot. */
+ headers?: Record<string, string>
}
/** Probe ONE capability slot through its real endpoint (A3). Provider
@@ -164,6 +171,106 @@ export async function probeSlot(slot: string, target: ProbeTarget): Promise<{ ve
return { verdict: classifyProbeError(slot, err) }
}
}
+ if (slot === 'video') {
+ // v0.23.2: the video slot's zero-cost probe — the same transport and
+ // dialects the feature route uses (src/app/api/ai/video/route.ts):
+ // raw fetch (the SDK has no video surface), Sora-style
+ // POST /videos/generations first, the z-ai internal
+ // POST /video/generation only when that 404s. Companion headers
+ // (ResolvedSlot.headers) ride along so env/file-configured z-ai
+ // providers answer with their X-Token auth instead of 401-ing.
+ //
+ // Zero-cost posture (the imageEdit philosophy): we send a minimal
+ // prompt and treat a 4xx VALIDATION rejection as proof the endpoint
+ // exists — we never poll a task to completion, so a probe can never
+ // spend a generation. A 200 with a task id is an accepted probe (it
+ // starts a real provider-side task; video tasks are typically free
+ // to START and bill on completion/preview — still, the console's
+ // one-probe-per-10s rate limit is the guardrail).
+ const base = target.baseUrl.replace(/\/+$/, '')
+ const headers: Record<string, string> = {
+ Authorization: `Bearer ${target.apiKey}`,
+ 'X-Z-AI-From': 'Z',
+ 'Content-Type': 'application/json',
+ ...(target.headers ?? {}),
+ }
+ const body = JSON.stringify({
+ prompt: 'a one-second clip of a solid red circle',
+ size: '1024x576',
+ ...(model ? { model } : {}),
+ })
+ const verdictFrom = (status: number, text: string, endpoint: string, dialect: string): ProbeVerdict => {
+ const clean = text
+ .replace(/[\r\n\t]+/g, ' ')
+ .trim()
+ .slice(0, 220)
+ if (status === 404 || status === 405) {
+ return {
+ ok: false,
+ slot,
+ endpoint,
+ httpStatus: status,
+ message:
+ `The provider answered ${status} for ${endpoint.replace('{base}', 'its base URL')} — it does not serve video ` +
+ `generation${dialect === 'z-ai' ? ' in either dialect' : ''}. The video slot needs a provider with ` +
+ `POST /videos/generations (Sora-style) or the z-ai /video/generation route — pin one on this page.`,
+ }
+ }
+ if (status === 401 || status === 403) {
+ return {
+ ok: false,
+ slot,
+ endpoint,
+ httpStatus: status,
+ message: `The provider rejected the credentials (HTTP ${status}) — check the API key for this provider.`,
+ }
+ }
+ if (status >= 200 && status < 300) {
+ return {
+ ok: true,
+ slot,
+ endpoint,
+ httpStatus: status,
+ message: `The video endpoint accepted the probe${dialect === 'z-ai' ? ' (z-ai dialect)' : ''} — ` +
+ `the full path works. The probe task is discarded; nothing is billed for the test itself.`,
+ }
+ }
+ // 4xx validation rejection — endpoint exists, request shape refused
+ if (status >= 400 && status < 500) {
+ return {
+ ok: true,
+ slot,
+ endpoint,
+ httpStatus: status,
+ message: `Endpoint is reachable (HTTP ${status} rejecting the minimal probe — expected for this test shape). ` +
+ `The provider serves ${endpoint.replace('{base}', 'this route')}${dialect === 'z-ai' ? ' (z-ai dialect)' : ''}; ${clean}`,
+ }
+ }
+ return { ok: false, slot, endpoint, httpStatus: status, message: clean || 'The provider did not answer in time.' }
+ }
+ try {
+ // dialect 1 — Sora-style (the deployed shape), tried first so
+ // configured providers keep answering exactly as the feature does
+ const sora = await withTimeout(fetch(`${base}/videos/generations`, { method: 'POST', headers, body }))
+ const soraText = await sora.text()
+ if (sora.status !== 404) {
+ return { verdict: verdictFrom(sora.status, soraText, SLOT_ENDPOINT.video, 'sora') }
+ }
+ // dialect 2 — z-ai internal API, only when the Sora route is absent
+ const zai = await withTimeout(fetch(`${base}/video/generation`, { method: 'POST', headers, body }))
+ const zaiText = await zai.text()
+ return { verdict: verdictFrom(zai.status, zaiText, 'POST {base}/video/generation', 'z-ai') }
+ } catch (err) {
+ // fetch rejections (network, DNS, timeout) classify through the
+ // shared scrubber; a "status NNN" message re-routes to the map above
+ const raw = err instanceof Error ? err.message : String(err)
+ if (/status \d{3}/i.test(raw)) {
+ const m = raw.match(/status (\d{3})/i)
+ return { verdict: verdictFrom(Number(m![1]), raw, SLOT_ENDPOINT.video, 'sora') }
+ }
+ return { verdict: classifyProbeError(slot, err) }
+ }
+ }
// text / vision — the existing minimal chat completion
// (v0.16.4 A4: the imageSearch probe is gone with the slot — photo
// search runs on the stock-provider keys, probed by its own rail)