diff --git a/src/renderer/src/lib/browser-cookie-import-toast.test.ts b/src/renderer/src/lib/browser-cookie-import-toast.test.ts index 23e04c53034..8ed73b8b8f8 100644 --- a/src/renderer/src/lib/browser-cookie-import-toast.test.ts +++ b/src/renderer/src/lib/browser-cookie-import-toast.test.ts @@ -73,6 +73,26 @@ describe('emitBrowserCookieImportToast', () => { expect(message).not.toContain('export') }) + it('uses the generic warning for a reason added by a newer runtime host', () => { + emitBrowserCookieImportToast( + { + ...summary, + warning: { + code: 'cookies-undecryptable', + failedCookies: 3, + reason: 'newer-runtime-reason' + } + } as unknown as BrowserCookieImportSummary, + 'Imported 0 cookies.', + 'Remote Mac' + ) + + expect(warningToastMock).toHaveBeenCalledWith( + '3 cookies could not be decrypted and were skipped. Close the source browser completely and try the import again.' + ) + expect(successToastMock).not.toHaveBeenCalled() + }) + it('shows separate host-specific Google guidance after success', () => { emitBrowserCookieImportToast( { ...summary, importedCookies: 2, skippedCookies: 1, googleCookiesSkipped: 1 }, diff --git a/src/renderer/src/lib/browser-cookie-import-toast.ts b/src/renderer/src/lib/browser-cookie-import-toast.ts index a8fa4aa6bae..70cb6da3a9a 100644 --- a/src/renderer/src/lib/browser-cookie-import-toast.ts +++ b/src/renderer/src/lib/browser-cookie-import-toast.ts @@ -4,6 +4,14 @@ import { translate } from '@/i18n/i18n' type CookieImportWarning = NonNullable +function formatUnknownCookieImportWarning(failedCookies: number): string { + return translate( + 'auto.lib.browser.cookie.import.toast.undecryptableUnknown', + '{{value0}} cookies could not be decrypted and were skipped. Close the source browser completely and try the import again.', + { value0: failedCookies } + ) +} + function formatCookieImportWarning(warning: CookieImportWarning): string { switch (warning.code) { case 'restart-fallback-unavailable': @@ -48,12 +56,10 @@ function formatCookieImportWarning(warning: CookieImportWarning): string { { value0: warning.failedCookies } ) case 'unknown': - return translate( - 'auto.lib.browser.cookie.import.toast.undecryptableUnknown', - '{{value0}} cookies could not be decrypted and were skipped. Close the source browser completely and try the import again.', - { value0: warning.failedCookies } - ) + return formatUnknownCookieImportWarning(warning.failedCookies) } + // Older clients can receive a reason added by a newer runtime host before their types know it. + return formatUnknownCookieImportWarning(warning.failedCookies) } }