import type { StudioFileAttachment, StudioRun, StudioSession, StudioTask, StudioWork, StudioWorkResult } from '../protocol/studio-agent-types'
import { formatStudioTime, studioStatusBadge, truncateStudioText } from '../theme'
interface StudioWorkListItem {
work: StudioWork
latestTask: StudioTask | null
result: StudioWorkResult | null
}
interface StudioAssetsPanelProps {
session: StudioSession | null
works: StudioWorkListItem[]
selectedWorkId: string | null
work: StudioWork | null
result: StudioWorkResult | null
latestRun: StudioRun | null
onSelectWork: (workId: string) => void
}
export function StudioAssetsPanel({
session,
works,
selectedWorkId,
work,
result,
latestRun,
onSelectWork,
}: StudioAssetsPanelProps) {
const previewAttachment = result?.attachments?.find(isPreviewAttachment) ?? result?.attachments?.[0] ?? null
return (
)
}
function PreviewSurface({
attachment,
result,
}: {
attachment: StudioFileAttachment | null | undefined
result: StudioWorkResult | null
}) {
if (attachment?.mimeType?.startsWith('video/') || isVideoPath(attachment?.path)) {
return
}
if (attachment?.mimeType?.startsWith('image/') || isImagePath(attachment?.path)) {
return
}
if (result?.kind === 'failure-report') {
return (
)
}
// 无产出时保持空白
return null
}
function isPreviewAttachment(attachment: { path: string; mimeType?: string } | undefined) {
if (!attachment) {
return false
}
return (
attachment.mimeType?.startsWith('video/') ||
attachment.mimeType?.startsWith('image/') ||
isVideoPath(attachment.path) ||
isImagePath(attachment.path)
)
}
function isVideoPath(path?: string) {
return Boolean(path && /\.(mp4|webm|mov|m4v)$/i.test(path))
}
function isImagePath(path?: string) {
return Boolean(path && /\.(png|jpg|jpeg|gif|webp|svg)$/i.test(path))
}
function translateRunStatus(status: string) {
switch (status) {
case 'running':
return '运行中'
case 'completed':
return '已完成'
case 'failed':
return '失败'
case 'cancelled':
return '已取消'
case 'pending':
return '排队中'
default:
return status
}
}
function translateWorkStatus(status: string) {
switch (status) {
case 'running':
return '进行中'
case 'completed':
return '完成'
case 'failed':
return '失败'
case 'cancelled':
return '取消'
case 'proposed':
return '提议'
default:
return status
}
}
function translateWorkType(type: string) {
switch (type) {
case 'video':
return '视频'
case 'review':
return '审查'
case 'design':
return '设计'
case 'edit':
return '编辑'
case 'render-fix':
return '渲染修复'
default:
return type
}
}
function translateResultKind(kind: string) {
switch (kind) {
case 'render-output':
return '渲染产物'
case 'review-report':
return '审查报告'
case 'design-plan':
return '设计方案'
case 'edit-result':
return '编辑结果'
case 'failure-report':
return '失败报告'
default:
return kind
}
}