From f5a67e608f178237e79a2c061e9ea192e1b93650 Mon Sep 17 00:00:00 2001 From: dolphin Date: Mon, 24 Aug 2026 18:38:37 +0800 Subject: [PATCH] Revert "chore(chat): trace the composer video poster lifecycle" This reverts commit bda6633465b72734c1a143bff6c973dbea57ebc1. --- .../Chat/attachments/MediaAttachmentChip.tsx | 16 +------- .../pages/appChat/components/InputFiles.tsx | 16 +------- .../client/src/utils/mediaAttachmentUtils.ts | 37 ++++--------------- 3 files changed, 9 insertions(+), 60 deletions(-) diff --git a/src/frontend/client/src/components/Chat/attachments/MediaAttachmentChip.tsx b/src/frontend/client/src/components/Chat/attachments/MediaAttachmentChip.tsx index 95b9cb8cd..4cad895b1 100644 --- a/src/frontend/client/src/components/Chat/attachments/MediaAttachmentChip.tsx +++ b/src/frontend/client/src/components/Chat/attachments/MediaAttachmentChip.tsx @@ -12,7 +12,6 @@ import { getMediaKind, isMediaAttachmentFile, resolveMediaCoverUrl, - tracePoster, resolveMediaPlaybackUrl, type MediaParsingState, } from '~/utils/mediaAttachmentUtils'; @@ -79,16 +78,6 @@ export function MediaAttachmentChip({ setCoverFailed(false); }, [resolvedCoverUrl]); const coverUrl = coverFailed ? undefined : resolvedCoverUrl; - if (kind === 'video') { - tracePoster('chip:render', { - name: fileName, - variant, - raw: rawCoverUrl?.slice(0, 24), - cover: coverUrl?.slice(0, 24), - coverFilepath: (file.cover_filepath ?? '').slice(0, 40), - failed: coverFailed, - }); - } const mediaFilepath = extractMediaFilepath(file); const canPlay = !!playbackUrl && !isUploading; const parsingLabel = localize('com_chat.media_parsing'); @@ -147,10 +136,7 @@ export function MediaAttachmentChip({ src={coverUrl} alt="" className="size-full object-cover" - onError={() => { - tracePoster('img:error', { name: fileName, cover: coverUrl?.slice(0, 60) }); - setCoverFailed(true); - }} + onError={() => setCoverFailed(true)} /> ) : ( <> diff --git a/src/frontend/client/src/pages/appChat/components/InputFiles.tsx b/src/frontend/client/src/pages/appChat/components/InputFiles.tsx index 49e11de3e..a92b99291 100644 --- a/src/frontend/client/src/pages/appChat/components/InputFiles.tsx +++ b/src/frontend/client/src/pages/appChat/components/InputFiles.tsx @@ -28,7 +28,6 @@ import { import { captureVideoPosterFromFile, getMediaKind, - tracePoster, readMediaDurationFromFile, isMediaAttachmentFile, } from "~/utils/mediaAttachmentUtils"; @@ -85,7 +84,6 @@ const applyParseStatusToFile = (file: any, entry: { parsing_status?: string; cov ...(coverFilepath ? { cover_filepath: coverFilepath } : {}), }; if (coverFilepath && file.mediaCoverUrl?.startsWith('blob:')) { - tracePoster('revoke:parse-status', { id: file.id, coverFilepath }); URL.revokeObjectURL(file.mediaCoverUrl); next.mediaCoverUrl = undefined; } @@ -311,15 +309,9 @@ const InputFiles = forwardRef(({ v, showVoice, accepts, disabled = false, size, const target = filesRef.current.find((f) => f.id === id); // Removed while decoding, or the server poster won the race. if (!target || target.cover_filepath) { - tracePoster('apply:dropped', { - id, - reason: target ? 'server-cover' : 'file-gone', - ids: filesRef.current.map((f) => f.id), - }); URL.revokeObjectURL(mediaCoverUrl); return; } - tracePoster('apply:ok', { id, name: target.name }); const updated = filesRef.current.map((f) => f.id === id ? { ...f, mediaCoverUrl } : f, ); @@ -400,7 +392,6 @@ const InputFiles = forwardRef(({ v, showVoice, accepts, disabled = false, size, ...(coverFilepath ? { cover_filepath: coverFilepath } : {}), }; if (coverFilepath && f.mediaCoverUrl?.startsWith('blob:')) { - tracePoster('revoke:upload-response', { id, coverFilepath }); URL.revokeObjectURL(f.mediaCoverUrl); next.mediaCoverUrl = undefined; } @@ -544,7 +535,6 @@ const InputFiles = forwardRef(({ v, showVoice, accepts, disabled = false, size, }, supportsFolderUpload, clear: () => { - tracePoster('clear', { ids: filesRef.current.map((f) => f.id) }); filesRef.current.forEach(f => { if (f.previewUrl) URL.revokeObjectURL(f.previewUrl); if (f.mediaPreviewUrl) URL.revokeObjectURL(f.mediaPreviewUrl); @@ -560,7 +550,6 @@ const InputFiles = forwardRef(({ v, showVoice, accepts, disabled = false, size, // Release any live object URLs when the component unmounts so pinned image // previews don't leak blobs. useEffect(() => () => { - tracePoster('unmount', { ids: filesRef.current.map((f) => f.id) }); filesRef.current.forEach(f => { if (f.previewUrl) URL.revokeObjectURL(f.previewUrl); if (f.mediaPreviewUrl) URL.revokeObjectURL(f.mediaPreviewUrl); @@ -650,10 +639,7 @@ const InputFiles = forwardRef(({ v, showVoice, accepts, disabled = false, size, } if (removed?.previewUrl) URL.revokeObjectURL(removed.previewUrl); if (removed?.mediaPreviewUrl) URL.revokeObjectURL(removed.mediaPreviewUrl); - if (removed?.mediaCoverUrl?.startsWith('blob:')) { - tracePoster('revoke:remove', { id: removed.id }); - URL.revokeObjectURL(removed.mediaCoverUrl); - } + if (removed?.mediaCoverUrl?.startsWith('blob:')) URL.revokeObjectURL(removed.mediaCoverUrl); const res = filesRef.current.filter(file => String(file.id) !== String(clientId)); filesRef.current = res setFiles(res); diff --git a/src/frontend/client/src/utils/mediaAttachmentUtils.ts b/src/frontend/client/src/utils/mediaAttachmentUtils.ts index 265b5621a..bb3360d0a 100644 --- a/src/frontend/client/src/utils/mediaAttachmentUtils.ts +++ b/src/frontend/client/src/utils/mediaAttachmentUtils.ts @@ -72,20 +72,6 @@ export function readMediaDurationFromFile(file: File): Promise): void { - try { - const holder = window as unknown as { __posterTrace?: Record[] }; - if (!holder.__posterTrace) holder.__posterTrace = []; - holder.__posterTrace.push({ at: new Date().toISOString(), event, ...(data ?? {}) }); - if (holder.__posterTrace.length > 300) holder.__posterTrace.shift(); - } catch { - // Diagnostics must never break the upload flow. - } -} - /** How long to wait for the browser to decode a first frame before giving up. * A codec it cannot handle usually errors out at once, but some containers just * never fire an event — without this the promise would hang and leak the URL. */ @@ -101,19 +87,11 @@ export function captureVideoPosterFromFile(file: File): Promise { + const settle = (poster?: string) => { if (settled) return; settled = true; window.clearTimeout(timeoutId); - tracePoster('capture:end', { - name: file.name, - ok: !!poster, - reason, - ms: Date.now() - startedAt, - }); resolve(poster); }; @@ -125,11 +103,10 @@ export function captureVideoPosterFromFile(file: File): Promise { cleanup(); - settle(undefined, 'timeout'); + settle(undefined); }, VIDEO_POSTER_TIMEOUT_MS); video.onloadeddata = () => { - tracePoster('capture:loadeddata', { name: file.name }); video.currentTime = 0.001; }; video.onseeked = () => { @@ -138,7 +115,7 @@ export function captureVideoPosterFromFile(file: File): Promise { cleanup(); - settle(undefined, 'video-error'); + settle(undefined); }; video.src = url; });