From dbda9a1787c863f1207803f5514e6451b4aebeaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=91=98=E9=98=BF=E6=B1=9F=28Relakkes?= =?UTF-8?q?=29?= Date: Thu, 1 Oct 2026 17:57:00 +0800 Subject: [PATCH] fix(chat): preserve initial image fallback call shape --- desktop/src/components/chat/AuthedImage.test.tsx | 2 ++ desktop/src/lib/useAuthedImageFallback.ts | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/desktop/src/components/chat/AuthedImage.test.tsx b/desktop/src/components/chat/AuthedImage.test.tsx index 22e606c2..f2dc55a8 100644 --- a/desktop/src/components/chat/AuthedImage.test.tsx +++ b/desktop/src/components/chat/AuthedImage.test.tsx @@ -28,6 +28,7 @@ describe('AuthedImage', () => { fireEvent.error(screen.getByRole('img')) await waitFor(() => expect(screen.getByRole('img')).toHaveAttribute('src', 'blob:x')) + expect(fetchServerImageBlobUrl).toHaveBeenCalledWith('http://127.0.0.1:1/a.png') expect(onFailure).not.toHaveBeenCalled() }) @@ -72,6 +73,7 @@ describe('AuthedImage', () => { await waitFor(() => expect(screen.getByRole('img')).toHaveAttribute('src', 'blob:retry')) expect(fetchServerImageBlobUrl).toHaveBeenCalledTimes(1) + expect(fetchServerImageBlobUrl).toHaveBeenCalledWith('http://127.0.0.1:1/a.png', true) }) it('ignores duplicate bare errors while authentication is pending and reports a decode failure once', async () => { diff --git a/desktop/src/lib/useAuthedImageFallback.ts b/desktop/src/lib/useAuthedImageFallback.ts index fe320333..2399844e 100644 --- a/desktop/src/lib/useAuthedImageFallback.ts +++ b/desktop/src/lib/useAuthedImageFallback.ts @@ -38,7 +38,8 @@ export function useAuthedImageFallback(src: string | undefined, onFailure?: () = return } current.state = 'fetching' - void fetchServerImageBlobUrl(src, retryWithCredential).then((url) => { + const request = retryWithCredential ? fetchServerImageBlobUrl(src, true) : fetchServerImageBlobUrl(src) + void request.then((url) => { if (!alive.current || attempt.current !== current) { URL.revokeObjectURL(url) return