Skip to content

Show it a video you love. Get a new video in the same style. An AI crew (Claude Code or Codex) plans, builds and reviews it with you.

Web: encode file URLs and quote CSS url()

revaldianggara383a58f096b8
diff --git a/app/web/src/App.tsx b/app/web/src/App.tsx
index 6611a44..a753e4e 100644
--- a/app/web/src/App.tsx
+++ b/app/web/src/App.tsx
@@ -77,7 +77,7 @@ function Home({ agents }: { agents?: Partial<AgentStatus> }) {
<div className="section-title"><h2>專案</h2><span className="small faint">{list.length}</span></div>
<div className="plist">{list.map((p, i) => (
<a key={p.id} className="pcard fade-in" onMouseEnter={(e) => { const v = e.currentTarget.querySelector('video'); if (v) { v.currentTime = 3; v.play().catch(() => {}); } }} onMouseLeave={(e) => e.currentTarget.querySelector('video')?.pause()} style={{ animationDelay: `${Math.min(i, 8) * 40}ms` }} href={`#/p/${p.id}`}>
- <div className="th" style={{ backgroundImage: p.thumb ? `url(${api.file(p.id, p.thumb)})` : undefined }}>{p.stage === 'done' && <video muted loop playsInline preload="none" src={api.file(p.id, 'out/video.mp4')} onError={(e) => e.currentTarget.remove()} />}<Status stage={p.stage} /></div>
+ <div className="th" style={{ backgroundImage: p.thumb ? `url("${api.file(p.id, p.thumb)}")` : undefined }}>{p.stage === 'done' && <video muted loop playsInline preload="none" src={api.file(p.id, 'out/video.mp4')} onError={(e) => e.currentTarget.remove()} />}<Status stage={p.stage} /></div>
<div className="meta"><b>{p.title}</b><div className="small faint" style={{ marginTop: 2 }}>{p.agent === 'codex' ? 'Codex' : 'Claude Code'} · {ago(p.updatedAt)}{p.needs ? ` · ${p.needs} 項待你提供` : ''}</div></div>
</a>))}</div>
</section>}
diff --git a/app/web/src/Project.tsx b/app/web/src/Project.tsx
index 4c1d65d..fac12c9 100644
--- a/app/web/src/Project.tsx
+++ b/app/web/src/Project.tsx
@@ -225,7 +225,7 @@ function Asset({ a, file }: { a: PlanAsset; file: FileUrl }) {
const src = a.file ? file(a.file) : undefined, isImg = src && /\.(jpe?g|png|webp|gif|svg)$/i.test(a.file!), isAud = src && /\.(mp3|m4a|wav|ogg)$/i.test(a.file!);
return (
<div className="asset">
- <div className="pv" style={isImg ? { backgroundImage: `url(${src})` } : undefined}>{isAud ? <audio controls src={src} /> : !isImg && <I n={a.kind === 'music' || a.kind === 'sfx' ? 'music' : a.kind === 'font' ? 'doc' : 'image'} />}</div>
+ <div className="pv" style={isImg ? { backgroundImage: `url("${src}")` } : undefined}>{isAud ? <audio controls src={src} /> : !isImg && <I n={a.kind === 'music' || a.kind === 'sfx' ? 'music' : a.kind === 'font' ? 'doc' : 'image'} />}</div>
<div className="b"><b>{a.id} · {a.purpose}</b><span className="faint">{ASTATUS[a.status ?? ''] || a.status}{a.source && ` · ${a.source}`}</span>
<span className={`cap ${a.license ? 'ok' : a.status === 'drawn_in_code' ? '' : 'warn'}`} style={{ justifySelf: 'start', height: 20, fontSize: 11 }}>{a.license || (a.status === 'drawn_in_code' ? '原創' : '授權未填')}</span></div>
</div>
diff --git a/app/web/src/api.ts b/app/web/src/api.ts
index 7bcf0b0..ad756ab 100644
--- a/app/web/src/api.ts
+++ b/app/web/src/api.ts
@@ -21,5 +21,6 @@ export const api = {
resume: (id: string) => fetch(`/api/projects/${id}/resume`, { method: 'POST' }).then(j<Ok>),
cancel: (id: string) => fetch(`/api/projects/${id}/cancel`, { method: 'POST' }).then(j<Ok>),
events: (id: string, fn: (ev: ServerEvent) => void) => { const es = new EventSource(`/api/projects/${id}/events`); es.onmessage = (m: MessageEvent<string>) => fn(JSON.parse(m.data) as ServerEvent); return () => es.close(); },
- file: (id: string, p: string, bust?: number) => `/files/${id}/${p}${bust ? `?v=${bust}` : ''}`,
+ // encode each path segment ('#' would start the fragment, '%' makes a malformed URI); agents on Windows may write '\' as separator
+ file: (id: string, p: string, bust?: number) => `/files/${id}/${p.split(/[\\/]/).map(encodeURIComponent).join('/')}${bust ? `?v=${bust}` : ''}`,
};