From 624a3a6a547de11354e9da477e038ff54f7353e2 Mon Sep 17 00:00:00 2001 From: Yiling-J Date: Fri, 7 Aug 2026 22:40:06 +0800 Subject: [PATCH] feat(webui): remove original-file display fallbacks, use proxies only (#273) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(webui): remove original-file display fallbacks, use proxies only WebUI now never uses the raw original file for display. All viewers (image, video, compare, pdf) render exclusively from transcoded proxies; when no proxy exists the viewer shows an unavailable placeholder instead of falling back to media.original. - getBestTranscode: drop the isRaw fallback candidates - video-viewer / compare-video-pane: remove the synthetic 'Original' resolution entry and the original.downloadUrl hasMedia gate - image-viewer / compare-image-pane: remove original.downloadUrl default - pdf-viewer: require pdfTranscode.url (no original fallback) - download menus (video-control-bar, breadcrumb-nav): use media.original.key for the 'Original' download option instead of the isRaw transcode marker entry Backend: - transcode-video workflow no longer pushes the isRaw:true marker entry into videoTranscodes (it pointed at the original file key) - remove media.original.downloadUrl from the DTO, asset service mapping, MediaInfo DB type, and transcode workflows/activities (it was only consumed by the removed display fallbacks; downloads already use key via the download-url endpoints) Tests/fixtures updated; docs updated to state the proxy-only display policy. * refactor: remove isRaw field via data migration, clean legacy media JSON Add a Prisma data migration that cleans legacy media JSONB on both assets and watermark_files: - drop the raw-original marker entries (isRaw: true) from videoTranscodes / imageTranscodes — they pointed at the original file key and were only used by the removed display fallbacks / download menus, which now use media.original.key directly - strip the isRaw field from remaining transcode entries - drop original.downloadUrl (removed from the AssetInfo DTO) The migration is generated via prisma migrate dev --create-only and applied automatically by migrate deploy in production. It is guarded by a test (packages/db/src/clean-media-migration.test.ts) that seeds legacy media JSON, runs the migration SQL, and asserts the transform on both tables. With the data cleaned, remove the isRaw field entirely from the codebase: - DTO schemas + ImageTranscode/VideoTranscode interfaces - PrismaJson MediaInfo transcode types - watermark activity isRaw skip (and its test), watermark proxy mapping, agent-embedding transcode selection, webui transcode filters, and all test fixtures AGENTS.md: clarify that the no-manual-migration rule applies to DDL; data migrations (pure SQL transforms, no schema change) are allowed inside a --create-only generated migration and must be tested. --- AGENTS.md | 3 +- .../src/workflows/agent-embedding.test.ts | 4 +- .../agent/src/workflows/agent-embedding.ts | 10 +- packages/api/src/public-share.ts | 2 - packages/api/src/share.test.ts | 17 +-- packages/core/src/asset/asset.ts | 8 -- packages/core/src/watermark/watermark.test.ts | 2 +- .../migration.sql | 86 ++++++++++++ packages/db/src/prisma-json-types.ts | 3 - packages/dtos/src/asset.ts | 6 +- .../e2e/workflow/transcode-watermark.test.ts | 13 +- .../transcode/src/activities/transcode.ts | 1 - .../src/activities/watermark.test.ts | 62 --------- .../transcode/src/activities/watermark.ts | 5 - .../src/workflows/transcode-image.ts | 1 - .../transcode/src/workflows/transcode-pdf.ts | 1 - .../src/workflows/transcode-video.test.ts | 1 - .../src/workflows/transcode-video.ts | 8 -- packages/webui/components/breadcrumb-nav.tsx | 48 +++---- .../webui/components/public-share-manager.tsx | 1 - .../viewers/image/compare-image-pane.tsx | 6 +- .../components/viewers/image/image-viewer.tsx | 49 +++---- .../components/viewers/pdf/pdf-viewer.tsx | 2 +- .../viewers/video/compare-video-pane.tsx | 34 ++--- .../viewers/video/video-control-bar.tsx | 26 +++- .../components/viewers/video/video-viewer.tsx | 130 ++++++++---------- packages/webui/docs/file_viewer_registry.md | 11 +- packages/webui/e2e/harness/fixture.ts | 34 ++++- packages/webui/lib/media.ts | 16 +-- .../$projectId/files/$fileId.lazy.tsx | 1 - packages/webui/stores/top-nav.ts | 1 - 31 files changed, 277 insertions(+), 315 deletions(-) create mode 100644 packages/db/prisma/migrations/20260807140837_clean_media_remove_raw_transcodes_and_original_download_url/migration.sql diff --git a/AGENTS.md b/AGENTS.md index 72e8f894..84bb8b1b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -321,7 +321,8 @@ We use `prisma-json-types-generator` to enforce strict type-safety for Prisma `J - Development: Use `bun --bun run prisma migrate dev` to create and apply migrations during development. - Production: Use `bun --bun run prisma migrate deploy` to apply pending migrations in production environments. -- **No Manual Migration Creation**: Never create migration SQL files or directories manually by hand. Always use Prisma CLI commands (e.g. `bun --bun run prisma migrate dev --create-only` to generate a migration template, or `bun --bun run prisma migrate dev`) so Prisma correctly tracks migration metadata and checksums. +- **No Manual DDL Creation**: Never hand-write **schema (DDL) migration** files or directories. Always generate them with Prisma CLI (`bun --bun run prisma migrate dev --create-only` to create a template, then edit it if needed, or `bun --bun run prisma migrate dev` to apply) so Prisma correctly tracks migration metadata and checksums. +- **Data Migrations Are Allowed**: Pure **data migration** SQL (no schema change) may be written by hand, but it MUST live inside a migration generated via `bun --bun run prisma migrate dev --create-only` so it is tracked and applied automatically. - **No Automatic Dev DB Reset**: Do not run `prisma migrate reset --force` or commands that force-reset the database automatically. If migrations become out of sync or a reset is required, stop executing, report the situation to the user, and present suggested manual cleanup/reset steps for the user to execute. ### Commands diff --git a/packages/agent/src/workflows/agent-embedding.test.ts b/packages/agent/src/workflows/agent-embedding.test.ts index c409159b..375473ac 100644 --- a/packages/agent/src/workflows/agent-embedding.test.ts +++ b/packages/agent/src/workflows/agent-embedding.test.ts @@ -186,7 +186,7 @@ describe('Agent Embedding Workflow', () => { mediaType: 'image/png', storageKey: { key: 'test.png' }, media: { - imageTranscodes: [{ key: 'test-transcoded.webp', isRaw: false, format: 'webp' }], + imageTranscodes: [{ key: 'test-transcoded.webp', format: 'webp' }], }, }, chunkDuration: 60.0, @@ -220,7 +220,7 @@ describe('Agent Embedding Workflow', () => { storageKey: { key: 'test.mp4' }, media: { duration: 150.0, - videoTranscodes: [{ key: 'test-transcoded.mp4', isRaw: false }], + videoTranscodes: [{ key: 'test-transcoded.mp4' }], }, }, chunkDuration: 60.0, diff --git a/packages/agent/src/workflows/agent-embedding.ts b/packages/agent/src/workflows/agent-embedding.ts index 07f77f50..54739c25 100644 --- a/packages/agent/src/workflows/agent-embedding.ts +++ b/packages/agent/src/workflows/agent-embedding.ts @@ -91,20 +91,14 @@ export async function agentEmbeddingMedia(task: WorkflowTask): Promise { const media = asset.media as any if (isVideo) { if (media.videoTranscodes && media.videoTranscodes.length > 0) { - // Find first non-raw transcode or fallback to first transcode - const transcode = - media.videoTranscodes.find((t: PrismaJson.VideoTranscode) => !t.isRaw) || - media.videoTranscodes[0] + const transcode = media.videoTranscodes[0] as PrismaJson.VideoTranscode if (transcode?.key) { embeddingKey = transcode.key } } } else if (isImage) { if (media.imageTranscodes && media.imageTranscodes.length > 0) { - // Find first non-raw transcode or fallback to first transcode - const transcode = - media.imageTranscodes.find((t: PrismaJson.ImageTranscode) => !t.isRaw) || - media.imageTranscodes[0] + const transcode = media.imageTranscodes[0] as PrismaJson.ImageTranscode if (transcode?.key) { embeddingKey = transcode.key if (transcode.format) { diff --git a/packages/api/src/public-share.ts b/packages/api/src/public-share.ts index 119d5490..f57ff041 100644 --- a/packages/api/src/public-share.ts +++ b/packages/api/src/public-share.ts @@ -54,7 +54,6 @@ async function applyWatermarkToAssetMedia( width: vt.width ?? 0, height: vt.height ?? 0, size: 0, - isRaw: false, })), ) : [] @@ -69,7 +68,6 @@ async function applyWatermarkToAssetMedia( width: it.width ?? 0, height: it.height ?? 0, size: 0, - isRaw: false, })), ) : [] diff --git a/packages/api/src/share.test.ts b/packages/api/src/share.test.ts index 2f0918a1..f11d817b 100644 --- a/packages/api/src/share.test.ts +++ b/packages/api/src/share.test.ts @@ -71,7 +71,6 @@ function watermarkMediaInfo(overrides: Partial = {}): Pris }, original: { key: 'files/orig.mp4', - downloadUrl: 'u', filesizeInBytes: 100, codec: '', }, @@ -245,11 +244,10 @@ describe('Share API', () => { width: 640, height: 360, size: 1, - isRaw: false, }, ], imageTranscodes: [], - original: { downloadUrl: 'u', key: 'files/orig.mp4' }, + original: { key: 'files/orig.mp4' }, }, }, { @@ -270,11 +268,10 @@ describe('Share API', () => { width: 640, height: 360, size: 1, - isRaw: false, }, ], imageTranscodes: [], - original: { downloadUrl: 'u', key: 'files/orig.mp4' }, + original: { key: 'files/orig.mp4' }, }, }, { @@ -290,7 +287,7 @@ describe('Share API', () => { pdfTranscode: { url: 'u', key: 'files/doc.pdf' }, videoTranscodes: [], imageTranscodes: [], - original: { downloadUrl: 'u', key: 'files/doc.pdf' }, + original: { key: 'files/doc.pdf' }, }, }, // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -326,7 +323,6 @@ describe('Share API', () => { width: 640, height: 360, size: 0, - isRaw: false, }, ]) // Pending item → original transcodes emptied @@ -368,11 +364,10 @@ describe('Share API', () => { width: 640, height: 360, size: 100, - isRaw: false, }, ], imageTranscodes: [], - original: { downloadUrl: 'http://s3/original', key: 'files/original.mp4' }, + original: { key: 'files/original.mp4' }, }, // eslint-disable-next-line @typescript-eslint/no-explicit-any } as any @@ -411,7 +406,6 @@ describe('Share API', () => { width: 640, height: 360, size: 0, - isRaw: false, }, ]) expect(body.media.imageTranscodes).toEqual([]) @@ -447,7 +441,7 @@ describe('Share API', () => { pdfTranscode: { url: 'http://s3/doc', key: 'files/doc.pdf' }, videoTranscodes: [], imageTranscodes: [], - original: { downloadUrl: 'http://s3/doc-original', key: 'files/doc.pdf' }, + original: { key: 'files/doc.pdf' }, }, // eslint-disable-next-line @typescript-eslint/no-explicit-any } as any) @@ -495,7 +489,6 @@ describe('Share API', () => { width: 640, height: 360, size: 100, - isRaw: false, }, ]) expect(wfSpy).not.toHaveBeenCalled() diff --git a/packages/core/src/asset/asset.ts b/packages/core/src/asset/asset.ts index 79feb4b4..67ba9615 100644 --- a/packages/core/src/asset/asset.ts +++ b/packages/core/src/asset/asset.ts @@ -853,13 +853,6 @@ export class AssetService { t.url = await s3Service.presign(process.env.S3_BUCKET || 'shumai', t.key, 'GET') } } - if (info.media.original?.key) { - info.media.original.downloadUrl = await s3Service.presign( - process.env.S3_BUCKET || 'shumai', - info.media.original.key, - 'GET', - ) - } } return info @@ -1732,7 +1725,6 @@ export class AssetService { } media.original = { key, - downloadUrl: await s3Service.presign(process.env.S3_BUCKET || 'shumai', key, 'GET'), filesizeInBytes: Number(latestVersion.sizeByte), codec: '', } diff --git a/packages/core/src/watermark/watermark.test.ts b/packages/core/src/watermark/watermark.test.ts index 1395b2a9..d4f1c57a 100644 --- a/packages/core/src/watermark/watermark.test.ts +++ b/packages/core/src/watermark/watermark.test.ts @@ -290,7 +290,7 @@ describe('WatermarkService', () => { }, finishedAt: new Date().toISOString(), metadata: null, - original: { key: 'files/gc/original.mp4', downloadUrl: '', filesizeInBytes: 0, codec: '' }, + original: { key: 'files/gc/original.mp4', filesizeInBytes: 0, codec: '' }, } } diff --git a/packages/db/prisma/migrations/20260807140837_clean_media_remove_raw_transcodes_and_original_download_url/migration.sql b/packages/db/prisma/migrations/20260807140837_clean_media_remove_raw_transcodes_and_original_download_url/migration.sql new file mode 100644 index 00000000..4bb17f7d --- /dev/null +++ b/packages/db/prisma/migrations/20260807140837_clean_media_remove_raw_transcodes_and_original_download_url/migration.sql @@ -0,0 +1,86 @@ +-- Data cleanup: remove legacy media JSON fields that are no longer used. +-- +-- WebUI now displays transcoded proxies only and never falls back to the raw +-- original file: +-- 1. Drop the raw-original marker entries (`isRaw: true`) from +-- videoTranscodes / imageTranscodes. They pointed at the original file +-- key and were only consumed by the removed display fallbacks and the +-- download-menu entries, which now use media.original.key directly. +-- 2. Strip the now-removed `isRaw` field from remaining transcode entries. +-- 3. Drop `original.downloadUrl` (removed from the AssetInfo DTO; downloads +-- resolve a fresh presigned URL from `key` via the download-url APIs). + +UPDATE "assets" +SET "media" = jsonb_set( + jsonb_set( + CASE WHEN jsonb_typeof("media"->'original') = 'object' + THEN "media" #- '{original,downloadUrl}' + ELSE "media" END, + '{videoTranscodes}', + COALESCE( + (SELECT jsonb_agg(elem - 'isRaw') + FROM jsonb_array_elements("media"->'videoTranscodes') elem + WHERE jsonb_typeof(elem) = 'object' + AND NOT COALESCE((elem->>'isRaw')::boolean, false)), + '[]'::jsonb + ) + ), + '{imageTranscodes}', + COALESCE( + (SELECT jsonb_agg(elem - 'isRaw') + FROM jsonb_array_elements("media"->'imageTranscodes') elem + WHERE jsonb_typeof(elem) = 'object' + AND NOT COALESCE((elem->>'isRaw')::boolean, false)), + '[]'::jsonb + ) +) +WHERE "media" IS NOT NULL + AND ( + (jsonb_typeof("media"->'original') = 'object' AND "media"->'original' ? 'downloadUrl') + OR EXISTS ( + SELECT 1 FROM jsonb_array_elements(COALESCE("media"->'videoTranscodes', '[]'::jsonb)) e + WHERE jsonb_typeof(e) = 'object' AND e ? 'isRaw' + ) + OR EXISTS ( + SELECT 1 FROM jsonb_array_elements(COALESCE("media"->'imageTranscodes', '[]'::jsonb)) e + WHERE jsonb_typeof(e) = 'object' AND e ? 'isRaw' + ) + ); + +-- Same cleanup for watermarked proxy media. +UPDATE "watermark_files" +SET "media" = jsonb_set( + jsonb_set( + CASE WHEN jsonb_typeof("media"->'original') = 'object' + THEN "media" #- '{original,downloadUrl}' + ELSE "media" END, + '{videoTranscodes}', + COALESCE( + (SELECT jsonb_agg(elem - 'isRaw') + FROM jsonb_array_elements("media"->'videoTranscodes') elem + WHERE jsonb_typeof(elem) = 'object' + AND NOT COALESCE((elem->>'isRaw')::boolean, false)), + '[]'::jsonb + ) + ), + '{imageTranscodes}', + COALESCE( + (SELECT jsonb_agg(elem - 'isRaw') + FROM jsonb_array_elements("media"->'imageTranscodes') elem + WHERE jsonb_typeof(elem) = 'object' + AND NOT COALESCE((elem->>'isRaw')::boolean, false)), + '[]'::jsonb + ) +) +WHERE "media" IS NOT NULL + AND ( + (jsonb_typeof("media"->'original') = 'object' AND "media"->'original' ? 'downloadUrl') + OR EXISTS ( + SELECT 1 FROM jsonb_array_elements(COALESCE("media"->'videoTranscodes', '[]'::jsonb)) e + WHERE jsonb_typeof(e) = 'object' AND e ? 'isRaw' + ) + OR EXISTS ( + SELECT 1 FROM jsonb_array_elements(COALESCE("media"->'imageTranscodes', '[]'::jsonb)) e + WHERE jsonb_typeof(e) = 'object' AND e ? 'isRaw' + ) + ); diff --git a/packages/db/src/prisma-json-types.ts b/packages/db/src/prisma-json-types.ts index 439360ec..1b6af340 100644 --- a/packages/db/src/prisma-json-types.ts +++ b/packages/db/src/prisma-json-types.ts @@ -74,7 +74,6 @@ declare global { width: number height: number resolution?: string - isRaw?: boolean } export interface ImageTranscode { @@ -84,7 +83,6 @@ declare global { height: number quality: number format: string - isRaw?: boolean } export interface SpriteInfo { @@ -117,7 +115,6 @@ declare global { export interface OriginalInfo { key: string - downloadUrl: string filesizeInBytes: number codec: string } diff --git a/packages/dtos/src/asset.ts b/packages/dtos/src/asset.ts index 9200c750..e5cf3e9b 100644 --- a/packages/dtos/src/asset.ts +++ b/packages/dtos/src/asset.ts @@ -77,7 +77,7 @@ export const assetInfoSchema = z.object({ media: z .object({ - original: z.object({ downloadUrl: z.string(), key: z.string().optional() }).optional(), + original: z.object({ key: z.string().optional() }).optional(), videoTranscodes: z .array( z.object({ @@ -87,7 +87,6 @@ export const assetInfoSchema = z.object({ width: z.number(), height: z.number(), size: z.number(), - isRaw: z.boolean(), }), ) .optional(), @@ -100,7 +99,6 @@ export const assetInfoSchema = z.object({ width: z.number(), height: z.number(), size: z.number(), - isRaw: z.boolean(), }), ) .optional(), @@ -285,7 +283,6 @@ export interface ImageTranscode { width: number height: number size: number - isRaw: boolean } export interface VideoTranscode { @@ -295,7 +292,6 @@ export interface VideoTranscode { width: number height: number size: number - isRaw: boolean } export const postAttachmentRequestSchema = z.object({ diff --git a/packages/e2e/workflow/transcode-watermark.test.ts b/packages/e2e/workflow/transcode-watermark.test.ts index 47c35d4a..ebca4e77 100644 --- a/packages/e2e/workflow/transcode-watermark.test.ts +++ b/packages/e2e/workflow/transcode-watermark.test.ts @@ -123,7 +123,6 @@ describe.each(['local', 'temporal'] as const)( }, original: { key: storageKey.key, - downloadUrl: '', filesizeInBytes: sampleBuffer.length, codec: '', }, @@ -232,12 +231,7 @@ describe.each(['local', 'temporal'] as const)( frames: 30, proxyType: 'video', imageTranscodes: [], - videoTranscodes: [ - { key: storageKey.key, width: 640, height: 360, resolution: '360p' }, - // Raw marker entry (as produced by transcodeVideoWorkflow) — must - // not be watermarked. - { key: storageKey.key, width: 640, height: 360, isRaw: true }, - ], + videoTranscodes: [{ key: storageKey.key, width: 640, height: 360, resolution: '360p' }], videoPreview: { width: 640, height: 360 }, finishedAt: new Date().toISOString(), metadata: { @@ -253,7 +247,6 @@ describe.each(['local', 'temporal'] as const)( }, original: { key: storageKey.key, - downloadUrl: '', filesizeInBytes: videoBuffer.length, codec: '', }, @@ -313,8 +306,7 @@ describe.each(['local', 'temporal'] as const)( expect(watermarkFile).toBeDefined() expect(watermarkFile?.status).toBe(WatermarkFileStatus.completed) expect(watermarkFile?.media).toBeDefined() - // Only the transcoded proxy should be watermarked — the raw marker entry - // (isRaw: true) must be skipped, so exactly one watermark proxy is produced. + // The transcoded proxy should be watermarked, producing exactly one proxy. const mediaInfo = watermarkFile?.media as PrismaJson.MediaInfo | null expect(mediaInfo?.videoTranscodes?.length).toBe(1) expect(mediaInfo?.videoTranscodes?.[0].resolution).toBe('360p') @@ -384,7 +376,6 @@ describe.each(['local', 'temporal'] as const)( }, original: { key, - downloadUrl: '', filesizeInBytes: buffer.length, codec: '', }, diff --git a/packages/transcode/src/activities/transcode.ts b/packages/transcode/src/activities/transcode.ts index 52038865..6f4343bf 100644 --- a/packages/transcode/src/activities/transcode.ts +++ b/packages/transcode/src/activities/transcode.ts @@ -75,7 +75,6 @@ export async function getMediaInfoActivity(params: { metadata: null, original: { key: '', // Will be filled by caller or updated later - downloadUrl: '', filesizeInBytes: 0, codec: '', }, diff --git a/packages/transcode/src/activities/watermark.test.ts b/packages/transcode/src/activities/watermark.test.ts index c8533cdd..69a2adfb 100644 --- a/packages/transcode/src/activities/watermark.test.ts +++ b/packages/transcode/src/activities/watermark.test.ts @@ -213,7 +213,6 @@ describe('Watermark Activities', () => { }, original: { key, - downloadUrl: '', filesizeInBytes: 0, codec: '', }, @@ -295,66 +294,6 @@ describe('Watermark Activities', () => { fs.rmSync(outFilePath, { force: true }) }) - it('skips the raw (isRaw) video transcode when generating watermark proxies', async () => { - const assetKey = 'files/e2e-wm/raw-video.mp4' - const asset = await seedAsset('raw-video.mp4', 'video/mp4', assetKey, 'video') - const config = await seedConfig() - - // Simulate the media state produced by transcodeVideoWorkflow: a - // transcoded proxy plus a raw marker entry pointing at the original file. - await prisma.asset.update({ - where: { id: asset.id }, - data: { - media: { - ...(asset.media as PrismaJson.MediaInfo), - videoTranscodes: [ - { key: assetKey, width: 100, height: 100, resolution: '100p' }, - { key: assetKey, width: 1920, height: 1080, isRaw: true }, - ], - }, - }, - }) - - vi.mocked(transcodeService.getVideoInfo).mockResolvedValue({ - originalWidth: 1920, - originalHeight: 1080, - duration: 10, - bitRate: 1000, - frameRate: 30, - totalFrames: 300, - startTimecode: '00:00:00:00', - hasAudio: true, - mimeType: 'video/mp4', - }) - vi.mocked(s3Service.putObject).mockResolvedValue(undefined as never) - - // The ffmpeg execFile call is mocked, but the activity stats the output - // file afterwards, so pre-create both expected output paths. - const stem = 'raw-video' - const configId = config.id - const proxyOutFilePath = path.join('/tmp', `${stem}-watermark-${configId}-100p.mp4`) - const rawOutFilePath = path.join('/tmp', `${stem}-watermark-${configId}-1080p.mp4`) - fs.writeFileSync(proxyOutFilePath, Buffer.from('fake mp4')) - fs.writeFileSync(rawOutFilePath, Buffer.from('fake mp4')) - - try { - const media = await transcodeWatermarkMediaActivity({ - assetId: asset.id, - watermarkConfigId: config.id, - }) - - expect(media.proxyType).toBe('video') - // Only the transcoded proxy should be watermarked, never the raw original. - expect(transcodeService.transcodeVideo).toHaveBeenCalledTimes(1) - expect(media.videoTranscodes).toHaveLength(1) - expect(media.videoTranscodes?.[0].resolution).toBe('100p') - expect(media.videoTranscodes?.[0].key).toContain('watermark-') - } finally { - fs.rmSync(proxyOutFilePath, { force: true }) - fs.rmSync(rawOutFilePath, { force: true }) - } - }) - it('produces a watermarked mp4 proxy for a video asset (ffmpeg path)', async () => { const assetKey = 'files/e2e-wm/video.mp4' const asset = await seedAsset('video.mp4', 'video/mp4', assetKey, 'video') @@ -435,7 +374,6 @@ describe('Watermark Activities', () => { }, original: { key: 'files/x/original.png', - downloadUrl: '', filesizeInBytes: 0, codec: '', }, diff --git a/packages/transcode/src/activities/watermark.ts b/packages/transcode/src/activities/watermark.ts index 823cfb3a..76510657 100644 --- a/packages/transcode/src/activities/watermark.ts +++ b/packages/transcode/src/activities/watermark.ts @@ -246,7 +246,6 @@ export async function transcodeWatermarkMediaActivity( }, original: { key: assetKey, - downloadUrl: '', filesizeInBytes: 0, codec: '', }, @@ -302,10 +301,6 @@ export async function transcodeWatermarkMediaActivity( for (let i = 0; i < originalTranscodes.length; i++) { const vt = originalTranscodes[i] - // Skip the raw marker entry (points at the original file) — it is not a - // transcoded proxy, so there is nothing to watermark (and transcoding - // the original at full resolution would be needlessly expensive). - if (vt.isRaw) continue const targetWidth = vt.width || originalWidth const targetHeight = vt.height || originalHeight const resolution = vt.resolution || `${targetHeight}p` diff --git a/packages/transcode/src/workflows/transcode-image.ts b/packages/transcode/src/workflows/transcode-image.ts index ab662335..00b64287 100644 --- a/packages/transcode/src/workflows/transcode-image.ts +++ b/packages/transcode/src/workflows/transcode-image.ts @@ -49,7 +49,6 @@ export async function transcodeImageWorkflow(task: WorkflowTask): Promise mediaInfo.original = { key, - downloadUrl: '', filesizeInBytes: 0, codec: '', } diff --git a/packages/transcode/src/workflows/transcode-pdf.ts b/packages/transcode/src/workflows/transcode-pdf.ts index eaff5723..c45f4759 100644 --- a/packages/transcode/src/workflows/transcode-pdf.ts +++ b/packages/transcode/src/workflows/transcode-pdf.ts @@ -60,7 +60,6 @@ export async function transcodePdfWorkflow(task: WorkflowTask): Promise { mediaInfo.original = { key, - downloadUrl: '', filesizeInBytes: 0, codec: '', } diff --git a/packages/transcode/src/workflows/transcode-video.test.ts b/packages/transcode/src/workflows/transcode-video.test.ts index 2f7bb26a..b5da86f3 100644 --- a/packages/transcode/src/workflows/transcode-video.test.ts +++ b/packages/transcode/src/workflows/transcode-video.test.ts @@ -210,7 +210,6 @@ describe('transcodeVideoWorkflow', () => { }, original: { key: 'audio.wav', - downloadUrl: '', filesizeInBytes: 0, codec: '', }, diff --git a/packages/transcode/src/workflows/transcode-video.ts b/packages/transcode/src/workflows/transcode-video.ts index afbf56c3..01f58715 100644 --- a/packages/transcode/src/workflows/transcode-video.ts +++ b/packages/transcode/src/workflows/transcode-video.ts @@ -54,7 +54,6 @@ export async function transcodeVideoWorkflow(task: WorkflowTask): Promise mediaInfo.original = { key, - downloadUrl: '', filesizeInBytes: 0, codec: '', } @@ -94,13 +93,6 @@ export async function transcodeVideoWorkflow(task: WorkflowTask): Promise mediaInfo.videoTranscodes.push(videoTranscode) } } - - mediaInfo.videoTranscodes.push({ - key: mediaInfo.original?.key, - width: metadata.originalWidth, - height: metadata.originalHeight, - isRaw: true, - }) } const isAudio = mediaInfo.proxyType === 'audio' diff --git a/packages/webui/components/breadcrumb-nav.tsx b/packages/webui/components/breadcrumb-nav.tsx index 577869f6..c76e5560 100644 --- a/packages/webui/components/breadcrumb-nav.tsx +++ b/packages/webui/components/breadcrumb-nav.tsx @@ -71,7 +71,6 @@ interface BreadcrumbNavProps { key: string width: number height: number - isRaw?: boolean }> } versions?: Array<{ @@ -159,10 +158,7 @@ export function BreadcrumbNav({ } const isAudio = currentAsset.proxyType === 'audio' - const hasVideoTranscodes = - !isAudio && - downloadInfo?.videoTranscodes && - downloadInfo.videoTranscodes.filter((t) => !t.isRaw).length > 0 + const hasVideoTranscodes = !isAudio && (downloadInfo?.videoTranscodes?.length ?? 0) > 0 const breadcrumbs: { name: string; path?: string; id?: string; isMuted?: boolean }[] = isPublic ? [ @@ -244,28 +240,26 @@ export function BreadcrumbNav({ {m.download()} - {downloadInfo?.videoTranscodes - ?.filter((t) => !t.isRaw) - .map((t) => { - const longSide = Math.max(t.width, t.height) - let resolution = `${t.height}p` - if (longSide >= 3840) resolution = '2160p' - else if (longSide >= 1920) resolution = '1080p' - else if (longSide >= 1280) resolution = '720p' - else if (longSide >= 960) resolution = '540p' - else if (longSide >= 640) resolution = '360p' - else if (longSide >= 320) resolution = '180p' - return ( - handleDownload(t.key)} - className="flex items-center justify-between" - > - {resolution} - MP4 - - ) - })} + {downloadInfo?.videoTranscodes?.map((t) => { + const longSide = Math.max(t.width, t.height) + let resolution = `${t.height}p` + if (longSide >= 3840) resolution = '2160p' + else if (longSide >= 1920) resolution = '1080p' + else if (longSide >= 1280) resolution = '720p' + else if (longSide >= 960) resolution = '540p' + else if (longSide >= 640) resolution = '360p' + else if (longSide >= 320) resolution = '180p' + return ( + handleDownload(t.key)} + className="flex items-center justify-between" + > + {resolution} + MP4 + + ) + })} {downloadInfo?.originalKey && ( <> diff --git a/packages/webui/components/public-share-manager.tsx b/packages/webui/components/public-share-manager.tsx index ec27b9b1..236c71be 100644 --- a/packages/webui/components/public-share-manager.tsx +++ b/packages/webui/components/public-share-manager.tsx @@ -425,7 +425,6 @@ export function PublicShareManager({ key: t.key, width: t.width, height: t.height, - isRaw: t.isRaw, })), } : undefined, diff --git a/packages/webui/components/viewers/image/compare-image-pane.tsx b/packages/webui/components/viewers/image/compare-image-pane.tsx index 283432f6..9a07938d 100644 --- a/packages/webui/components/viewers/image/compare-image-pane.tsx +++ b/packages/webui/components/viewers/image/compare-image-pane.tsx @@ -111,11 +111,7 @@ export const CompareImagePane = forwardRef { const key = file.media?.original?.key diff --git a/packages/webui/components/viewers/image/image-viewer.tsx b/packages/webui/components/viewers/image/image-viewer.tsx index b7b3d923..c7556f30 100644 --- a/packages/webui/components/viewers/image/image-viewer.tsx +++ b/packages/webui/components/viewers/image/image-viewer.tsx @@ -96,12 +96,7 @@ export const ImageViewer = React.forwardRef( setPan({ x, y }) } - let bestUrl = file.media?.original?.downloadUrl - - const bestTranscode = getBestTranscode(file.media?.imageTranscodes, screenWidth) - if (bestTranscode?.url) { - bestUrl = bestTranscode.url - } + const bestUrl = getBestTranscode(file.media?.imageTranscodes, screenWidth)?.url ?? '' const handleDownload = async () => { const key = file.media?.original?.key @@ -184,24 +179,30 @@ export const ImageViewer = React.forwardRef(
{children}
- + {bestUrl ? ( + + ) : ( +
+

Preview unavailable

+
+ )}
( } }, []) - const fileUrl = file.media?.pdfTranscode?.url || file.media?.original?.downloadUrl + const fileUrl = file.media?.pdfTranscode?.url // Load PDF Document useEffect(() => { diff --git a/packages/webui/components/viewers/video/compare-video-pane.tsx b/packages/webui/components/viewers/video/compare-video-pane.tsx index a5376799..da6d5ddb 100644 --- a/packages/webui/components/viewers/video/compare-video-pane.tsx +++ b/packages/webui/components/viewers/video/compare-video-pane.tsx @@ -30,20 +30,9 @@ interface CompareVideoPaneProps { } function computeResolutions(file: AssetInfo): DisplayTranscode[] { - const original: DisplayTranscode | null = file.media?.original?.downloadUrl - ? { - id: 'original', - url: file.media.original.downloadUrl, - key: file.media.original.key ?? '', - width: file.media?.metadata?.originalWidth ?? 0, - height: file.media?.metadata?.originalHeight ?? 0, - size: 0, - isRaw: true, - resolution: 'Original', - } - : null - - const transcodes: DisplayTranscode[] = (file.media?.videoTranscodes ?? []).map((t) => { + // Only transcoded proxy versions are ever displayed; the raw original file + // is never used as a playback source. + return (file.media?.videoTranscodes ?? []).map((t) => { const longSide = Math.max(t.width, t.height) let resolution = `${t.height}p` if (longSide >= 3840) resolution = '2160p' @@ -52,14 +41,8 @@ function computeResolutions(file: AssetInfo): DisplayTranscode[] { else if (longSide >= 960) resolution = '540p' else if (longSide >= 640) resolution = '360p' else if (longSide >= 320) resolution = '180p' - return { ...t, resolution: t.isRaw ? 'Original' : resolution } + return { ...t, resolution } }) - - const hasOriginalTranscode = transcodes.some((t) => t.isRaw) - if (!hasOriginalTranscode && original) { - return [...transcodes, original] - } - return transcodes } export const CompareVideoPane = forwardRef( @@ -113,9 +96,8 @@ export const CompareVideoPane = forwardRef !r.isRaw) - const initialRes = previewResolutions[0] ?? resolutions[0] - const [currentResolution, setCurrentResolution] = useState(initialRes?.resolution ?? 'Original') + const initialRes = resolutions[0] + const [currentResolution, setCurrentResolution] = useState(initialRes?.resolution ?? '') const currentSrcRef = useRef(initialRes?.url) const isAudio = file.proxyType === 'audio' @@ -155,7 +137,7 @@ export const CompareVideoPane = forwardRef { - setCurrentResolution(initialRes?.resolution ?? 'Original') + setCurrentResolution(initialRes?.resolution ?? '') currentSrcRef.current = initialRes?.url }, [file.id]) @@ -421,7 +403,7 @@ export const CompareVideoPane = forwardRef

Media is not available.

diff --git a/packages/webui/components/viewers/video/video-control-bar.tsx b/packages/webui/components/viewers/video/video-control-bar.tsx index c2548221..7b08ea83 100644 --- a/packages/webui/components/viewers/video/video-control-bar.tsx +++ b/packages/webui/components/viewers/video/video-control-bar.tsx @@ -23,6 +23,7 @@ import { DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, + DropdownMenuSeparator, DropdownMenuTrigger, } from '../../ui/dropdown-menu' import { Slider } from '../../ui/slider' @@ -115,7 +116,6 @@ export const VideoControlBar: React.FC = ({ const overlay = state.isFullScreen && floatOverlayInFullScreen const isAudio = data.proxyType === 'audio' - const previewResolutions = resolutions.filter((r) => !r.isRaw) const startTimecode = data.media?.metadata?.startTimecode const displayTotalFrames = Math.max(0, totalFrames - 1) @@ -311,7 +311,7 @@ export const VideoControlBar: React.FC = ({ {/* Settings / Resolution */} - {!isAudio && previewResolutions.length > 0 && ( + {!isAudio && resolutions.length > 0 && (