From ebf20db35e81e499cefb6774e4ce09dd37521aa6 Mon Sep 17 00:00:00 2001 From: benjcooley Date: Tue, 29 Sep 2026 11:52:18 -0700 Subject: [PATCH 1/9] feat(website): run Re-shoot through comfy-api's app proxy Re-shoot's two calls go to comfy-api's /app-proxy/{id} routes: the analyze job is free and rate limited, the generate job is charged on success. Each Workshop family carries its own public proxy id, so no build variable is needed. Also bound-checks CrossView geometry reads, ignores quote answers from a previous workspace, and stops the dev proxy writing twice when a stream fails. --- apps/website/package.json | 1 + .../scripts/crossview-dev-proxy.test.ts | 138 +++ apps/website/scripts/crossview-dev-proxy.ts | 165 +++ .../reshoot/ReshootMoveControls.vue | 4 +- .../cinematic-studio/reshoot/ReshootSide.vue | 47 +- .../cinematic-studio/reshoot/ReshootStage.vue | 18 +- .../reshoot/ReshootStudio.test.ts | 52 + .../reshoot/ReshootStudio.vue | 55 +- .../reshoot/ReshootTakeView.vue | 30 +- .../cinematic-studio/reshoot/ReshootTakes.vue | 2 +- .../reshoot/ReshootViewport.vue | 20 +- .../cinematic-studio/reshoot/take-label.ts | 2 +- .../src/composables/useReshoot.test.ts | 272 +++++ apps/website/src/composables/useReshoot.ts | 447 +++++++ .../src/composables/useReshootDemo.test.ts | 24 - .../website/src/composables/useReshootDemo.ts | 217 ---- apps/website/src/config/workshop-env.ts | 13 + apps/website/src/env.d.ts | 6 + .../workshop/cinematic-studio/reshoot-copy.ts | 47 + .../__fixtures__/reshootFakes.ts | 85 ++ .../reshoot-engine/analyze.api.json | 62 + .../reshoot-engine/camera.fixtures.json | 1079 +++++++++++++++++ .../reshoot-engine/camera.test.ts | 61 + .../cinematic-studio/reshoot-engine/camera.ts | 242 ++++ .../reshoot-engine/cvgeo.test.ts | 105 ++ .../cinematic-studio/reshoot-engine/cvgeo.ts | 145 +++ .../reshoot-engine/generate.api.json | 303 +++++ .../reshoot-engine/notes.test.ts | 128 ++ .../cinematic-studio/reshoot-engine/notes.ts | 108 ++ .../reshoot-engine/run.test.ts | 189 +++ .../cinematic-studio/reshoot-engine/run.ts | 119 ++ .../reshoot-engine/transport-config.ts | 20 + .../reshoot-engine/transport.test.ts | 292 +++++ .../reshoot-engine/transport.ts | 250 ++++ .../reshoot-engine/workflow.test.ts | 75 ++ .../reshoot-engine/workflow.ts | 98 ++ 36 files changed, 4645 insertions(+), 276 deletions(-) create mode 100644 apps/website/scripts/crossview-dev-proxy.test.ts create mode 100644 apps/website/scripts/crossview-dev-proxy.ts create mode 100644 apps/website/src/composables/useReshoot.test.ts create mode 100644 apps/website/src/composables/useReshoot.ts delete mode 100644 apps/website/src/composables/useReshootDemo.test.ts delete mode 100644 apps/website/src/composables/useReshootDemo.ts create mode 100644 apps/website/src/lib/workshop/cinematic-studio/reshoot-engine/__fixtures__/reshootFakes.ts create mode 100644 apps/website/src/lib/workshop/cinematic-studio/reshoot-engine/analyze.api.json create mode 100644 apps/website/src/lib/workshop/cinematic-studio/reshoot-engine/camera.fixtures.json create mode 100644 apps/website/src/lib/workshop/cinematic-studio/reshoot-engine/camera.test.ts create mode 100644 apps/website/src/lib/workshop/cinematic-studio/reshoot-engine/camera.ts create mode 100644 apps/website/src/lib/workshop/cinematic-studio/reshoot-engine/cvgeo.test.ts create mode 100644 apps/website/src/lib/workshop/cinematic-studio/reshoot-engine/cvgeo.ts create mode 100644 apps/website/src/lib/workshop/cinematic-studio/reshoot-engine/generate.api.json create mode 100644 apps/website/src/lib/workshop/cinematic-studio/reshoot-engine/notes.test.ts create mode 100644 apps/website/src/lib/workshop/cinematic-studio/reshoot-engine/notes.ts create mode 100644 apps/website/src/lib/workshop/cinematic-studio/reshoot-engine/run.test.ts create mode 100644 apps/website/src/lib/workshop/cinematic-studio/reshoot-engine/run.ts create mode 100644 apps/website/src/lib/workshop/cinematic-studio/reshoot-engine/transport-config.ts create mode 100644 apps/website/src/lib/workshop/cinematic-studio/reshoot-engine/transport.test.ts create mode 100644 apps/website/src/lib/workshop/cinematic-studio/reshoot-engine/transport.ts create mode 100644 apps/website/src/lib/workshop/cinematic-studio/reshoot-engine/workflow.test.ts create mode 100644 apps/website/src/lib/workshop/cinematic-studio/reshoot-engine/workflow.ts diff --git a/apps/website/package.json b/apps/website/package.json index 2c67717ac86..499c56a56f3 100644 --- a/apps/website/package.json +++ b/apps/website/package.json @@ -6,6 +6,7 @@ "scripts": { "dev": "astro dev", "dev:no-toolbar": "cross-env NO_TOOLBAR=1 astro dev", + "dev:crossview-proxy": "tsx scripts/crossview-dev-proxy.ts", "build": "astro build", "format": "prettier --write \"src/**/*.astro\"", "format:check": "prettier --check \"src/**/*.astro\"", diff --git a/apps/website/scripts/crossview-dev-proxy.test.ts b/apps/website/scripts/crossview-dev-proxy.test.ts new file mode 100644 index 00000000000..5c1dfea3e90 --- /dev/null +++ b/apps/website/scripts/crossview-dev-proxy.test.ts @@ -0,0 +1,138 @@ +import { once } from 'node:events' +import { createServer, request } from 'node:http' +import { describe, expect, it, vi } from 'vitest' + +import { + corsHeaders, + handler, + parseEnvFile, + proxyConfig, + route, + upstreamHeaders +} from './crossview-dev-proxy' + +describe('crossview dev proxy', () => { + it('reads plain and exported assignments, unquoting values', () => { + expect( + parseEnvFile( + [ + '# comment', + 'export CROSSVIEW_DEPLOYMENT_URL="https://dep.run.comfy.app/"', + " COMFY_API_KEY='k' ", + 'not an assignment' + ].join('\n') + ) + ).toEqual({ + CROSSVIEW_DEPLOYMENT_URL: 'https://dep.run.comfy.app/', + COMFY_API_KEY: 'k' + }) + }) + + it.for<{ + env: Record + files: Record + config?: { target: string; key: string } + }>([ + { + env: { CROSSVIEW_DEPLOYMENT_URL: 'https://a/', COMFY_API_KEY: 'env' }, + files: { COMFY_API_KEY: 'file' }, + config: { target: 'https://a', key: 'env' } + }, + { + env: {}, + files: { CROSSVIEW_DEPLOYMENT_URL: 'https://b', COMFY_API_KEY: 'file' }, + config: { target: 'https://b', key: 'file' } + }, + { env: { CROSSVIEW_DEPLOYMENT_URL: 'https://a' }, files: {} }, + { env: { COMFY_API_KEY: 'k' }, files: {} } + ])('configures $config.target', ({ env, files, config }) => { + expect(proxyConfig(env, files)).toEqual(config) + }) + + it.for<[string | undefined, boolean]>([ + ['http://localhost:4321', true], + ['http://127.0.0.1:4321', true], + ['https://comfy.org', false], + [undefined, false] + ])('allows %s from the browser: %s', ([origin, allowed]) => { + const headers = corsHeaders(origin) + expect(headers['Access-Control-Allow-Origin']).toBe( + allowed ? origin : undefined + ) + }) + + it('adds the key and passes on only the headers a job needs', () => { + expect( + upstreamHeaders( + { + 'content-type': 'application/json', + 'idempotency-key': 'k-1', + cookie: 'session=1' + }, + 'secret' + ) + ).toEqual({ + authorization: 'Bearer secret', + 'content-type': 'application/json', + 'idempotency-key': 'k-1' + }) + }) + + it.for<[string, string, string]>([ + ['OPTIONS', '/api/v2/jobs', 'preflight'], + ['POST', '/api/v2/jobs', 'forward'], + ['GET', '/api/v2/jobs/1', 'forward'], + ['GET', '/admin', 'notFound'] + ])('routes %s %s to %s', ([method, url, next]) => { + expect(route(method, url)).toBe(next) + }) + + it('handles an upstream response-stream failure after sending headers', async () => { + const failure = new Error('upstream failed') + vi.stubGlobal( + 'fetch', + vi.fn(async () => + Promise.resolve( + new Response( + new ReadableStream({ + start(controller) { + controller.enqueue(new TextEncoder().encode('partial')) + queueMicrotask(() => controller.error(failure)) + } + }) + ) + ) + ) + ) + const logged = vi.spyOn(console, 'error').mockImplementation(() => {}) + const server = createServer( + handler({ target: 'https://deployment.example', key: 'key' }) + ) + server.listen(0, '127.0.0.1') + await once(server, 'listening') + const address = server.address() + if (!address || typeof address === 'string') throw new Error('no port') + + try { + await new Promise((resolve) => { + const outgoing = request( + { host: '127.0.0.1', port: address.port, path: '/api/v2/jobs' }, + (response) => { + const finish = () => resolve() + response.resume() + response.once('aborted', finish) + response.once('end', finish) + response.once('error', finish) + } + ) + outgoing.once('error', () => resolve()) + outgoing.end() + }) + expect(logged).toHaveBeenCalledWith(failure) + } finally { + server.closeAllConnections() + server.close() + await once(server, 'close') + } + }) +}) diff --git a/apps/website/scripts/crossview-dev-proxy.ts b/apps/website/scripts/crossview-dev-proxy.ts new file mode 100644 index 00000000000..bbddbec2a8f --- /dev/null +++ b/apps/website/scripts/crossview-dev-proxy.ts @@ -0,0 +1,165 @@ +/** + * Local stand-in for the app proxy, for developing Re-shoot only. + * + * A Comfy API deployment takes an API key, and a static site has nowhere to + * keep one, so this forwards /api/v2/* to the deployment and adds the key on + * the way. It runs on the developer's machine and nowhere else; the site + * reaches it only under `astro dev` (PUBLIC_CROSSVIEW_PROXY). + * + * CROSSVIEW_DEPLOYMENT_URL=https://dep-….run.comfy.app \ + * COMFY_API_KEY=… pnpm --filter @comfyorg/website dev:crossview-proxy + * + * Both values may instead live as `export NAME=value` lines in + * ~/.config/comfy-workshop/crossview.env or deployment.env. + */ +import { readFileSync } from 'node:fs' +import type { + IncomingHttpHeaders, + IncomingMessage, + ServerResponse +} from 'node:http' +import { createServer } from 'node:http' +import { homedir } from 'node:os' +import { join } from 'node:path' +import { Readable } from 'node:stream' +import { pipeline } from 'node:stream/promises' +import type { ReadableStream as NodeReadableStream } from 'node:stream/web' + +import { isDirectExecution } from './script-entry-point' + +const ENV_FILES = ['deployment.env', 'crossview.env'] +const FORWARDED = ['content-type', 'idempotency-key'] +const LOCAL = /^https?:\/\/(localhost|127\.0\.0\.1)(:\d+)?$/ + +/** `NAME=value` and `export NAME="value"` lines; anything else is ignored. */ +export function parseEnvFile(text: string): Record { + const entries = text + .split('\n') + .map((line) => line.trim().match(/^(?:export\s+)?(\w+)=(.*)$/)) + .flatMap((m) => (m ? [[m[1], m[2].replace(/^["']|["']$/g, '')]] : [])) + return Object.fromEntries(entries) +} + +function readEnvFile(name: string): string { + try { + return readFileSync(join(homedir(), '.config/comfy-workshop', name), 'utf8') + } catch { + return '' + } +} + +export interface ProxyConfig { + readonly target: string + readonly key: string +} + +/** The process environment wins over the files; undefined if either is missing. */ +export function proxyConfig( + env: Partial>, + files: Partial> +): ProxyConfig | undefined { + const target = ( + env.CROSSVIEW_DEPLOYMENT_URL ?? + files.CROSSVIEW_DEPLOYMENT_URL ?? + '' + ).replace(/\/$/, '') + const key = env.COMFY_API_KEY ?? files.COMFY_API_KEY + return target && key ? { target, key } : undefined +} + +export function corsHeaders( + origin: string | undefined +): Record { + if (!origin || !LOCAL.test(origin)) return {} + return { + 'Access-Control-Allow-Origin': origin, + 'Access-Control-Allow-Methods': 'GET, POST, OPTIONS', + 'Access-Control-Allow-Headers': FORWARDED.join(', ') + } +} + +export function upstreamHeaders( + incoming: IncomingHttpHeaders, + key: string +): Record { + const passed = FORWARDED.flatMap((name) => { + const value = incoming[name] + return typeof value === 'string' ? [[name, value]] : [] + }) + return { authorization: `Bearer ${key}`, ...Object.fromEntries(passed) } +} + +/** What to do with a request before it reaches the deployment. */ +export function route( + method: string | undefined, + url: string +): 'preflight' | 'forward' | 'notFound' { + if (method === 'OPTIONS') return 'preflight' + return url.startsWith('/api/v2/') ? 'forward' : 'notFound' +} + +async function forward( + req: IncomingMessage, + res: ServerResponse, + { target, key }: ProxyConfig +) { + const hasBody = req.method !== 'GET' && req.method !== 'HEAD' + // Redirects to signed storage are followed here; fetch drops the key on + // the way to another origin. + const upstream = await fetch(target + String(req.url), { + method: req.method, + headers: upstreamHeaders(req.headers, key), + body: hasBody ? (Readable.toWeb(req) as ReadableStream) : undefined, + // required by Node for a streamed request body + ...(hasBody ? { duplex: 'half' } : {}) + }) + const type = upstream.headers.get('content-type') + res.writeHead(upstream.status, type ? { 'content-type': type } : {}) + if (upstream.body) + await pipeline(Readable.fromWeb(upstream.body as NodeReadableStream), res) + else res.end() + process.stdout.write(`${req.method} ${req.url} -> ${upstream.status}\n`) +} + +export function handler(config: ProxyConfig) { + return async (req: IncomingMessage, res: ServerResponse) => { + for (const [name, value] of Object.entries(corsHeaders(req.headers.origin))) + res.setHeader(name, value) + const next = route(req.method, String(req.url)) + if (next !== 'forward') { + res.writeHead(next === 'preflight' ? 204 : 404).end() + return + } + try { + await forward(req, res, config) + } catch (error) { + console.error(error) + if (!res.headersSent) { + res.writeHead(502, { 'content-type': 'application/json' }) + res.end(JSON.stringify({ error: String(error) })) + } + } + } +} + +function main() { + const files = Object.assign( + {}, + ...ENV_FILES.map((name) => parseEnvFile(readEnvFile(name))) + ) + const config = proxyConfig(process.env, files) + if (!config) { + console.error( + 'crossview-dev-proxy: set CROSSVIEW_DEPLOYMENT_URL and COMFY_API_KEY' + ) + process.exit(1) + } + const port = Number(process.env.CROSSVIEW_PROXY_PORT ?? 4329) + createServer(handler(config)).listen(port, '127.0.0.1', () => + process.stdout.write( + `crossview-dev-proxy: http://127.0.0.1:${port} -> ${config.target}\n` + ) + ) +} + +if (isDirectExecution(process.argv[1], import.meta.filename)) main() diff --git a/apps/website/src/components/workshop/cinematic-studio/reshoot/ReshootMoveControls.vue b/apps/website/src/components/workshop/cinematic-studio/reshoot/ReshootMoveControls.vue index 8292dd74084..360e6ae7e3c 100644 --- a/apps/website/src/components/workshop/cinematic-studio/reshoot/ReshootMoveControls.vue +++ b/apps/website/src/components/workshop/cinematic-studio/reshoot/ReshootMoveControls.vue @@ -18,10 +18,12 @@ import ReshootSlider from './ReshootSlider.vue' const { keys, + frames = RESHOOT_FRAMES, disabled = false, locale = 'en' } = defineProps<{ keys: readonly CameraKey[] + frames?: number disabled?: boolean locale?: Locale }>() @@ -62,7 +64,7 @@ const motionValue = computed({ :label="rc('reshoot.move.frame', locale)" :display="frameTime(frame)" :min="0" - :max="RESHOOT_FRAMES - 1" + :max="frames - 1" :step="1" :disabled class="flex-1" diff --git a/apps/website/src/components/workshop/cinematic-studio/reshoot/ReshootSide.vue b/apps/website/src/components/workshop/cinematic-studio/reshoot/ReshootSide.vue index 93dbc10e2d0..b925ba6958a 100644 --- a/apps/website/src/components/workshop/cinematic-studio/reshoot/ReshootSide.vue +++ b/apps/website/src/components/workshop/cinematic-studio/reshoot/ReshootSide.vue @@ -2,8 +2,8 @@ import { computed } from 'vue' import Button from '@/components/ui/button/Button.vue' -import type { DepthState } from '../../../../composables/useReshootDemo' -import { RESHOOT_FRAMES } from '../../../../lib/workshop/cinematic-studio/reshoot' +import type { DepthState } from '../../../../composables/useReshoot' +import type { StudioGate } from '../../../../lib/workshop/cinematic-studio/gate' import type { CameraKey, ReshootAspect, @@ -13,6 +13,7 @@ import type { } from '../../../../lib/workshop/cinematic-studio/reshoot' import { rc } from '../../../../lib/workshop/cinematic-studio/reshoot-copy' import type { Locale } from '../../../../i18n/translations' +import CinematicGenerateAction from '../CinematicGenerateAction.vue' import ReshootAimRig from './ReshootAimRig.vue' import ReshootDisclosure from './ReshootDisclosure.vue' import ReshootFormat from './ReshootFormat.vue' @@ -25,6 +26,11 @@ const { camera, keys, depth, + frames, + gate, + canGenerate, + priceNote, + workspaceName, locale = 'en' } = defineProps<{ clip: string @@ -33,6 +39,11 @@ const { camera: Readonly keys: readonly CameraKey[] depth: DepthState + frames: number + gate: StudioGate + canGenerate: boolean + priceNote?: string + workspaceName?: string locale?: Locale }>() @@ -54,10 +65,12 @@ const motion = defineModel('motion', { required: true }) const prompt = defineModel('prompt', { required: true }) const ready = computed(() => depth === 'ready') -const frames = rc('reshoot.frames', locale, { - frames: RESHOOT_FRAMES, - seconds: (RESHOOT_FRAMES / 24).toFixed(1) -}) +const framesLabel = computed(() => + rc('reshoot.frames', locale, { + frames, + seconds: (frames / 24).toFixed(1) + }) +) function choose(event: Event) { const input = event.target @@ -90,7 +103,7 @@ function choose(event: Event) { {{ ready - ? `${rc('reshoot.clip.ready', locale)} · ${frames}` + ? `${rc('reshoot.clip.ready', locale)} · ${framesLabel}` : rc('reshoot.aim.reading', locale) }} @@ -120,6 +133,7 @@ function choose(event: Event) { v-model:frame="frame" v-model:motion="motion" :keys + :frames :disabled="!ready" :locale @key="emit('key')" @@ -181,15 +195,32 @@ function choose(event: Event) { rc(ready ? 'reshoot.generate.note' : 'reshoot.generate.wait', locale) }}

+

+ {{ priceNote }} +

+ diff --git a/apps/website/src/components/workshop/cinematic-studio/reshoot/ReshootStage.vue b/apps/website/src/components/workshop/cinematic-studio/reshoot/ReshootStage.vue index 28362909441..f361e181a46 100644 --- a/apps/website/src/components/workshop/cinematic-studio/reshoot/ReshootStage.vue +++ b/apps/website/src/components/workshop/cinematic-studio/reshoot/ReshootStage.vue @@ -6,8 +6,9 @@ import { computed, ref, useTemplateRef } from 'vue' import type { DepthState, ReshootTake -} from '../../../../composables/useReshootDemo' +} from '../../../../composables/useReshoot' import type { ReshootCamera } from '../../../../lib/workshop/cinematic-studio/reshoot' +import type { ReshootRunPhase } from '../../../../lib/workshop/cinematic-studio/reshoot-engine/run' import { rc } from '../../../../lib/workshop/cinematic-studio/reshoot-copy' import type { Locale } from '../../../../i18n/translations' import type { ReshootSound, ReshootView } from './output' @@ -21,6 +22,8 @@ const { clip, camera, depth, + stage, + notice, step, takes, selected, @@ -31,6 +34,8 @@ const { clip: string camera: Readonly depth: DepthState + stage?: ReshootRunPhase + notice?: string step: 1 | 2 takes: readonly ReshootTake[] selected: string @@ -54,6 +59,11 @@ const sound = ref('generated') const finished = computed(() => current?.status === 'done' && current.url ? current : undefined ) +const href = computed(() => + sound.value === 'original' + ? (finished.value?.originalUrl ?? finished.value?.url) + : finished.value?.url +) const fileName = computed( () => `crossview-take-${current?.n ?? 0}${sound.value === 'original' ? '-original-audio' : ''}.mp4` @@ -69,11 +79,11 @@ const fileName = computed( class="flex w-[min(100%,calc(52svh*16/9))] flex-col gap-3 max-lg:contents" > ({ reshootTransport: vi.fn() }) +) +vi.mock( + import('../../../../lib/workshop/cinematic-studio/reshoot-engine/cvgeo'), + () => ({ readGeometry: vi.fn() }) +) + function setup() { render(ReshootStudio) return userEvent.setup({ advanceTimers: vi.advanceTimersByTime }) @@ -11,6 +30,13 @@ function setup() { beforeEach(() => { vi.useFakeTimers({ shouldAdvanceTime: true }) + vi.mocked(reshootTransport).mockReturnValue(fakeTransport()) + vi.mocked(readGeometry).mockResolvedValue(fakeGeometry()) + vi.stubGlobal( + 'fetch', + vi.fn(async () => new Response(new Blob(['clip'], { type: 'video/mp4' }))) + ) + signIn() }) describe('Re-shoot on one screen', () => { @@ -38,6 +64,15 @@ describe('Re-shoot on one screen', () => { expect(screen.getByTestId('reshoot-action')).toBeEnabled() }) + it('shows what the next take costs above Generate', async () => { + const user = setup() + await pickExample(user) + + expect(screen.getByTestId('reshoot-price')).toHaveTextContent( + 'Free · 3 of 5 left this week' + ) + }) + it('lets only the latest scene reading finish', async () => { const user = setup() const example = () => screen.getByRole('button', { name: /Sci-fi pilot/ }) @@ -96,6 +131,23 @@ describe('Re-shoot on one screen', () => { expect(screen.getByRole('status')).toHaveTextContent('Cancelled') }) + it('asks before the page is left while a take renders', async () => { + const user = setup() + await pickExample(user) + const leave = () => { + const event = new Event('beforeunload', { cancelable: true }) + window.dispatchEvent(event) + return event.defaultPrevented + } + expect(leave()).toBe(false) + + await user.click(screen.getByTestId('reshoot-action')) + + expect(leave()).toBe(true) + await user.click(screen.getByRole('button', { name: 'Cancel' })) + expect(leave()).toBe(false) + }) + it("aims again from a finished take's angle", async () => { const user = setup() await pickExample(user) diff --git a/apps/website/src/components/workshop/cinematic-studio/reshoot/ReshootStudio.vue b/apps/website/src/components/workshop/cinematic-studio/reshoot/ReshootStudio.vue index 9987ec3c0c4..6c5b53c4bf0 100644 --- a/apps/website/src/components/workshop/cinematic-studio/reshoot/ReshootStudio.vue +++ b/apps/website/src/components/workshop/cinematic-studio/reshoot/ReshootStudio.vue @@ -1,9 +1,12 @@ diff --git a/apps/website/src/components/workshop/cinematic-studio/reshoot/ReshootTakeView.vue b/apps/website/src/components/workshop/cinematic-studio/reshoot/ReshootTakeView.vue index 8d69cbfb36c..f3f93e6798e 100644 --- a/apps/website/src/components/workshop/cinematic-studio/reshoot/ReshootTakeView.vue +++ b/apps/website/src/components/workshop/cinematic-studio/reshoot/ReshootTakeView.vue @@ -3,7 +3,7 @@ import { CircleStop, LoaderCircle } from '@lucide/vue' import { useTimestamp } from '@vueuse/core' import { computed } from 'vue' -import type { ReshootTake } from '../../../../composables/useReshootDemo' +import type { ReshootTake } from '../../../../composables/useReshoot' import { formatElapsed } from '../../../../config/workshop-run' import { rc } from '../../../../lib/workshop/cinematic-studio/reshoot-copy' import type { Locale } from '../../../../i18n/translations' @@ -29,7 +29,11 @@ const emit = defineEmits<{ cancel: [] }>() const now = useTimestamp({ interval: 1000 }) const elapsed = computed(() => Math.max(0, now.value - take.startedAt)) -const shown = computed(() => (view === 'result' ? take.url : clip)) +const shown = computed(() => { + if (view === 'source') return clip + if (view === 'warp') return take.warpUrl ?? clip + return sound === 'original' ? (take.originalUrl ?? take.url) : take.url +})