Orkas is an open-source (MIT), local-first AI team for your desktop: a Commander turns your goal into to-dos and coordinates 16 built-in specialist agents plus Claude Code, Codex, OpenCode, OpenClaw and Hermes, with projects, scheduled automations and connectors. Free app for macOS & Windows; built-in models or your own keys.
JavaScript agent-collaborationagent-harnessagent-orchestrationagent-teamagent-workflowai-assistantai-automationai-employeeai-productivityai-teamai-workflowautonomous-agentsclaude-code-guiclaude-coworkdesktop-agentlocal-firstmulti-agentmulti-agent-systemself-evolving-agentstask-automation
import { composerText, expectComposerText } from './fixtures/composer';
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
import { createHash } from 'node:crypto';
import path from 'node:path';
import { expect, test } from './fixtures/orkas';
// Host-owned video review panel (P2): the drawer renders scenes, preview
// evidence, narration audio, and takes straight from production state, and
// its action buttons only prefill the composer. This spec runs the real
// pipeline end to end: a conversation created through the actual composer and
// model, production state seeded on disk exactly where the tool would write
// it, the probe resolving it through the real IPC + workspace mapping, frames
// served over chat-media://local, and the prefill landing in the composer.
const TINY_PNG = Buffer.from(
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==',
'base64',
);
test.describe('video review panel', () => {
test.describe.configure({ timeout: process.platform === 'win32' ? 120_000 : 60_000 });
test('surfaces production state with scenes, takes, and composer prefill', async ({ modelOrkas }, testInfo) => {
if (!modelOrkas.page) throw new Error('Orkas renderer is unavailable');
const page = modelOrkas.page;
// 1. A real conversation through the composer + local model.
await page.locator('#new-chat-btn').click();
await page.locator('#new-chat-input').fill('Prepare the video review e2e conversation.');
await page.locator('#new-chat-send-btn').click();
await expect(page.locator('#panel-conversation')).toHaveClass(/\bactive\b/);
await expect(page.locator('#chat-history .chat-message.assistant [data-role="final"]'))
.toBeVisible({ timeout: 30_000 });
const cid = String(await page.evaluate('currentCid'));
expect(cid).toMatch(/\w/);
// The video review toggle stays hidden while no production state exists.
await expect(page.locator('#video-review-toggle')).toBeHidden();
// 2. Freeze the conversation workspace slug so the seeded production
// lands inside the workspace the panel resolves for this cid.
const uid = 'account-e2e';
const convStateFile = path.join(
modelOrkas.workspaceRoot, uid, 'cloud', 'chats', cid, 'state.json',
);
const convState = JSON.parse(readFileSync(convStateFile, 'utf8')) as Record<string, unknown>;
convState.workspace_dir = 'e2e-video-review';
writeFileSync(convStateFile, JSON.stringify(convState), 'utf8');
// 3. Seed the production exactly where the tool would write it.
const compositionDir = path.join(
modelOrkas.workspaceRoot, '..', 'userWorkSpace', 'e2e-video-review', 'project', 'composition',
);
const previewDir = path.join(compositionDir, 'preview');
const draftPath = path.join(path.dirname(compositionDir), 'render', 'draft.mp4');
mkdirSync(previewDir, { recursive: true });
mkdirSync(path.join(compositionDir, 'assets'), { recursive: true });
mkdirSync(path.dirname(draftPath), { recursive: true });
writeFileSync(path.join(compositionDir, 'composition-manifest.json'), JSON.stringify({
schema_version: 1,
composition: { id: 'main', width: 1920, height: 1080, duration: 5, fps: 30 },
scenes: [{
id: 'cover',
start: 0,
duration: 5,
approved_copy: ['E2E Approved'],
narration_text: 'Speak once.',
narration_refs: [],
source_shots: ['cover'],
roles: ['title'],
}],
audio: { owner: 'none', tracks: [] },
}), 'utf8');
const contactSheet = path.join(previewDir, 'contact-sheet.png');
const coverFrame = path.join(previewDir, '02-cover-mid.png');
const frozenSheet = path.join(previewDir, 'frozen-take.png');
writeFileSync(contactSheet, TINY_PNG);
writeFileSync(coverFrame, TINY_PNG);
writeFileSync(frozenSheet, TINY_PNG);
// The real preview decodes these files, so fixture bytes must be playable.
await modelOrkas.electronApp!.evaluate(async (_electron, args) => {
const require = (process as any).mainModule.require.bind((process as any).mainModule);
const { ffmpeg } = require(args.module).bundledFfmpegPaths();
if (!ffmpeg) throw new Error('Bundled FFmpeg is required for the review fixture');
const encode = (argv: string[]) => new Promise<void>((resolve, reject) => {
require('node:child_process').execFile(ffmpeg, ['-hide_banner', '-loglevel', 'error', '-y', ...argv],
{ windowsHide: true, timeout: 30000 }, (error: Error | null) => error ? reject(error) : resolve());
});
await encode(['-f', 'lavfi', '-i', 'color=c=blue:s=160x90:r=10:d=4.2',
'-c:v', 'libx264', '-pix_fmt', 'yuv420p', '-threads', '1', args.video]);
await encode(['-f', 'lavfi', '-i', 'sine=frequency=440:duration=4.2', '-c:a', 'libmp3lame', args.audio]);
}, { module: path.resolve(__dirname, '../../src/main/util/bundled-runtime.ts'),
video: draftPath, audio: path.join(compositionDir, 'assets', 'narration.mp3') });
const stateKey = createHash('sha256')
.update(`${uid}\0${path.resolve(compositionDir)}`)
.digest('hex')
.slice(0, 32);
const gatesDir = path.join(modelOrkas.workspaceRoot, uid, 'local', 'video_studio', 'gates');
mkdirSync(gatesDir, { recursive: true });
writeFileSync(path.join(gatesDir, `${stateKey}.json`), JSON.stringify({
schema_version: 1,
revision: 3,
composition_dir: compositionDir,
task_title: 'A 60-second Orkas product film',
stage: 'draft_ready',
plan_approval: { gate: 'B', signature: 'sig', turn_id: 't1', approved_at: 'now' },
preview: {
signature: 'full-sig',
status: 'approved',
path: contactSheet,
frame_paths: [coverFrame],
validation_version: 5,
turn_id: 't1',
created_at: 'now',
},
narration: {
status: 'materialized',
path: path.join(compositionDir, 'assets', 'narration.mp3'),
measured_duration_sec: 4.2,
language: 'en',
speed: 1,
},
draft: {
signature: 'draft-sig',
status: 'ready',
path: draftPath,
validation_version: 5,
turn_id: 't2',
created_at: 'now',
},
current_candidate: {
revision_id: 'candidate-e2e-current',
content_hash: 'hash-current',
artifacts: {},
locators: { preview_path: contactSheet },
runtime_fingerprint: 'fp',
created_at: '2026-08-03T01:00:00Z',
last_observed_at: '2026-08-03T02:00:00Z',
last_observed_op: 'composition.snapshot',
last_quality_result: { ok: true, observed_at: '2026-08-03T02:00:00Z' },
},
candidate_history: [{
revision_id: 'candidate-e2e-older',
content_hash: 'hash-older',
artifacts: {},
locators: {},
snapshot: { locators: { preview_path: frozenSheet } },
runtime_fingerprint: 'fp',
created_at: '2026-08-03T00:00:00Z',
last_observed_at: '2026-08-03T00:30:00Z',
last_observed_op: 'composition.snapshot',
last_quality_result: { ok: false, error_code: 'E_PREVIEW_QA_BLOCKED', observed_at: '2026-08-03T00:30:00Z' },
}],
}), 'utf8');
// 4. Re-probe (same call the conversation-detail-open hook makes).
await page.evaluate('VideoReviewPanel.probe(currentCid)');
// 5. The toggle appears only now, and the drawer renders the production:
// what the user asked for, how far it got, then the evidence. The
// composition path is an instruction identifier, never a heading.
await expect(page.locator('#video-review-toggle')).toBeVisible();
await page.locator('#video-review-toggle').click();
await expect(page.locator('#video-review-panel')).toBeVisible();
await expect(page.locator('#video-review-toggle')).toHaveClass(/\bis-active\b/);
await expect(page.locator('#video-review-toggle')).toHaveAttribute('aria-expanded', 'true');
const videoPanel = page.locator('#video-review-panel');
const details = page.locator('#conversation-info-panel');
await expect(details).toBeHidden();
await page.setViewportSize({ width: 1800, height: 900 });
await expect.poll(async () => (await videoPanel.boundingBox())!.width).toBe(540);
await page.setViewportSize({ width: 1280, height: 800 });
await expect.poll(async () => (await videoPanel.boundingBox())!.width).toBe(400);
// Mount actual markdown media in the real reply bubble to exercise its
// intrinsic width while the user changes the adjacent panel width.
const audioPath = path.join(compositionDir, 'assets', 'narration.mp3');
const replyBody = page.locator('#chat-history .chat-message.assistant .markdown-body').last();
await replyBody.evaluate((el, file) => {
el.innerHTML = (window as any).renderMarkdownFull(`[Narration](<${file}>)`);
}, audioPath);
const audioCard = replyBody.locator('.chat-md-audio-card');
const audio = audioCard.locator('audio');
await expect(audio).toBeVisible();
const fits = () => audioCard.evaluate(el => {
const card = el.getBoundingClientRect();
const body = el.closest('.markdown-body')!.getBoundingClientRect();
const audio = el.querySelector('audio')!.getBoundingClientRect();
return card.right <= body.right + 1 && card.width <= body.width + 1 && audio.right <= card.right;
});
await expect.poll(fits).toBe(true);
const beforeWidth = (await audioCard.boundingBox())!.width;
const grip = (await page.locator('#video-review-resize').boundingBox())!;
await page.mouse.move(grip.x + grip.width / 2, grip.y + 100);
await page.mouse.down();
await page.mouse.move(grip.x - 150, grip.y + 100);
await page.mouse.up();
const draggedWidth = (await videoPanel.boundingBox())!.width;
expect(draggedWidth).toBeGreaterThan(500);
await expect.poll(fits).toBe(true);
expect((await audioCard.boundingBox())!.width).toBeLessThan(beforeWidth);
await audio.evaluate(async (element: HTMLAudioElement) => { element.muted = true; await element.play(); });
await expect.poll(() => audio.evaluate((element: HTMLAudioElement) => element.currentTime)).toBeGreaterThan(0);
await audio.evaluate((element: HTMLAudioElement) => element.pause());
await page.locator('#conversation-info-toggle').click();
await expect(details).toBeVisible();
await expect(videoPanel).toBeHidden();
await expect(page.locator('#video-review-toggle')).not.toHaveClass(/\bis-active\b/);
await expect(page.locator('#video-review-toggle')).toHaveAttribute('aria-expanded', 'false');
expect((await details.boundingBox())!.width).toBe(draggedWidth);
await page.locator('#video-review-toggle').click();
await expect(videoPanel).toBeVisible();
await expect(details).toBeHidden();
expect((await videoPanel.boundingBox())!.width).toBe(draggedWidth);
await expect(page.locator('#video-review-toggle')).toHaveClass(/\bis-active\b/);
await expect(page.locator('#conversation-info-toggle')).not.toHaveClass(/\bis-active\b/);
await page.screenshot({ path: testInfo.outputPath('audio-and-resizable-video-panel.png') });
await expect(page.locator('.video-review-comp-name')).toHaveText('A 60-second Orkas product film');
await expect(page.locator('.video-review-comp-name')).not.toContainText('project/composition');
await expect(page.locator('.video-review-step')).toHaveCount(4);
await expect(page.locator('.video-review-step').nth(1)).toHaveClass(/\bis-done\b/);
await expect(page.locator('.video-review-step').nth(3)).toHaveClass(/\bis-wait\b/);
// A standalone final-confirmation stop stores its playable artifact in
// draft.path; final.path only exists for assembled delivery. Exercise the
// real IPC + renderer path so a panel cannot say "waiting" while omitting
// the video the user is meant to review.
const draftVideo = page.locator('.video-review-final-video');
await expect(draftVideo).toHaveCount(1);
await expect(draftVideo).toHaveAttribute('src', /^chat-media:\/\/local\//);
await expect(draftVideo).toHaveAttribute('src', /draft\.mp4/);
const videoPreview = await modelOrkas.openPreview(() => draftVideo.click());
await expect(videoPreview.locator('.chat-file-viewer')).toHaveClass(/\bis-open\b/);
await expect(videoPreview.locator('.chat-file-viewer-video')).toHaveAttribute('src', /draft\.mp4/);
const player = videoPreview.locator('.chat-file-viewer-video');
await player.evaluate(async (element: HTMLVideoElement) => { element.muted = true; await element.play(); });
await expect.poll(() => player.evaluate((element: HTMLVideoElement) => element.currentTime)).toBeGreaterThan(0);
expect(await player.evaluate((element: HTMLVideoElement) => element.error)).toBeNull();
await modelOrkas.closePreview(videoPreview);
// Scenes are labelled by position, never by the authoring id (2026-08-06):
// `cover` / `s2_body` mean nothing to the person watching the video.
await expect(page.locator('.video-review-scene-id')).toHaveText(/^(Scene|场景|シーン|Cena)\s*1$/);
await expect(page.locator('.video-review-scene-id')).not.toHaveText('cover');
await expect(page.locator('.video-review-scene-narration')).toHaveText('Speak once.');
await expect(page.locator('.video-review-narration audio')).toHaveCount(1);
await expect(page.locator('.video-review-take')).toHaveCount(0);
// Scene frames stream over chat-media://local — a broken URL would leave
// naturalWidth at 0 even though the <img> is "visible".
await expect.poll(async () => page.locator('.video-review-scene-frame')
.evaluate((el) => (el as HTMLImageElement).naturalWidth)).toBeGreaterThan(0);
// There is no whole-production frames overview (removed 2026-08-06 by
// product decision — too many frames); the scene image itself is the
// entry: clicking expands it into the shared lightbox, and closing
// returns to the panel untouched.
await expect(page.locator('.video-review-sheet-img')).toHaveCount(0);
await expect(page.locator('.video-review-scene-frame')).toHaveClass(/\bis-expandable\b/);
const imagePreview = await modelOrkas.openPreview(() => page.locator('.video-review-scene-frame').click());
await expect(imagePreview.locator('.chat-lightbox .chat-lightbox-img')).toBeVisible();
await expect.poll(async () => imagePreview.locator('.chat-lightbox .chat-lightbox-img')
.evaluate((el) => (el as HTMLImageElement).naturalWidth)).toBeGreaterThan(0);
// Escape destroys this native renderer during keydown, before Playwright
// can acknowledge keyup. Only the expected page closure may end the input.
await imagePreview.keyboard.press('Escape').catch(error => {
if (!imagePreview.isClosed()) throw error;
});
await expect.poll(() => imagePreview.isClosed()).toBe(true);
await expect(page.locator('#video-review-panel')).toBeVisible();
// 6. Modification entries prefill the composer and never auto-send.
const messagesBefore = await page.locator('#chat-history .chat-message').count();
await page.locator('.video-review-scene-actions button').nth(1).click();
const composer = page.locator('#chat-input');
// The instruction leads with the position the user just clicked and keeps
// the authoring id as the handle that binds the edit to the right scene
// even if positions shift before it is sent.
await expectComposerText(composer, /(scene|场景|シーン|cena)[^\n]*1/i);
await expectComposerText(composer, /cover/);
// The instruction names the video the way the panel titles it, so the user
// can check what they are about to send against what they clicked.
await expectComposerText(composer, /A 60-second Orkas product film/);
await expect.poll(() => composerText(composer)).not.toMatch(/project\/composition/);
expect(await page.locator('#chat-history .chat-message').count()).toBe(messagesBefore);
// 7. A second entry accumulates instead of replacing the first, so one
// message can carry several changes. The production is already named, so
// the follow-up line drops the identifier rather than repeating it.
await page.locator('.video-review-scene-actions button').nth(0).click();
const merged = await composerText(composer);
expect(merged.split('\n').filter((line) => line.trim())).toHaveLength(2);
expect(merged.match(/A 60-second Orkas product film/g)).toHaveLength(1);
expect(await page.locator('#chat-history .chat-message').count()).toBe(messagesBefore);
// No version history and no restore entry point in the panel.
await expect(page.locator('#video-review-panel')).not.toContainText('candidate-e2e-older');
await page.screenshot({ path: testInfo.outputPath('video-review-panel.png'), fullPage: false });
await page.locator('#video-review-panel-close').click();
await expect(videoPanel).toBeHidden();
await expect(page.locator('#video-review-toggle')).not.toHaveClass(/\bis-active\b/);
await page.locator('#video-review-toggle').click();
await expect(page.locator('#video-review-toggle')).toHaveClass(/\bis-active\b/);
const nextTask = await modelOrkas.invoke<{ conversation: { conversation_id: string } }>('conversations.create', { title: 'Another task' });
await page.evaluate(id => (window as any).setView('conversation', id), nextTask.conversation.conversation_id);
await expect(videoPanel).toBeHidden();
await expect(page.locator('#video-review-toggle')).not.toHaveClass(/\bis-active\b/);
await expect(page.locator('#video-review-toggle')).toHaveAttribute('aria-expanded', 'false');
});
});