From 88192bcfb1fa3019f6b298e17fbc59255aee5d77 Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Mon, 24 Aug 2026 01:59:41 -0700 Subject: [PATCH] fix(ai-vault): normalize wrapped scan errors --- src/main/ai-vault/session-scanner-background.ts | 5 +---- src/shared/ai-vault-scan-error-message.test.ts | 9 +++++++++ src/shared/ai-vault-scan-error-message.ts | 6 +++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/ai-vault/session-scanner-background.ts b/src/main/ai-vault/session-scanner-background.ts index e1f7b76b971..6903e689a64 100644 --- a/src/main/ai-vault/session-scanner-background.ts +++ b/src/main/ai-vault/session-scanner-background.ts @@ -37,10 +37,7 @@ export function shouldUseAiVaultServiceProcess(): boolean { return process.env.NODE_ENV !== 'test' } -/** - * Without this a scan that tripped the circuit leaves the panel refusing every - * refresh for the rest of the fault window, with no way for the user to retry. - */ +// Let forced refreshes retry after a local service circuit opens. export function clearAiVaultBackgroundRestartCircuit(): void { if (shouldUseAiVaultServiceProcess()) { clearAiVaultServiceRestartCircuit() diff --git a/src/shared/ai-vault-scan-error-message.test.ts b/src/shared/ai-vault-scan-error-message.test.ts index 44124df72b5..0e3d929a47e 100644 --- a/src/shared/ai-vault-scan-error-message.test.ts +++ b/src/shared/ai-vault-scan-error-message.test.ts @@ -72,4 +72,13 @@ describe('describeAiVaultScanError', () => { expect(describeAiVaultScanError(authored)).toBe(authored) expect(describeAiVaultScanError('SSH relay is not ready')).toBe('SSH relay is not ready') }) + + it('removes transport wrappers before passing through an unknown message', () => { + expect( + describeAiVaultScanError( + "Error invoking remote method 'aiVault:listSessions': Error: SSH relay is not ready" + ) + ).toBe('SSH relay is not ready') + expect(describeAiVaultScanError('Relay Scanner is not ready')).toBe('Scanner is not ready') + }) }) diff --git a/src/shared/ai-vault-scan-error-message.ts b/src/shared/ai-vault-scan-error-message.ts index 80c0c0e484b..1449684ab8e 100644 --- a/src/shared/ai-vault-scan-error-message.ts +++ b/src/shared/ai-vault-scan-error-message.ts @@ -8,8 +8,8 @@ const RETRY = 'Refresh to try again.' /** Electron wraps every rejected `ipcMain.handle` before the renderer sees it. */ const IPC_INVOKE_PREFIX = /^Error invoking remote method '[^']*': (?:\w*Error: )?/ -/** Relay-hosted scans reuse the local wording behind a `Relay ` prefix. */ -const RELAY_PREFIX = /^Relay (?=AI Vault )/ +/** Relay-hosted scan errors carry a transport-only `Relay ` prefix. */ +const RELAY_PREFIX = /^Relay / /** Both the fork-based service and the legacy worker thread emit this family. */ const SCANNER = String.raw`AI Vault (?:service|scanner worker)` @@ -46,5 +46,5 @@ function humanize(text: string): string | null { /** Returns user-facing copy, or the original text when it is already meaningful. */ export function describeAiVaultScanError(raw: string): string { const text = raw.replace(IPC_INVOKE_PREFIX, '').replace(RELAY_PREFIX, '') - return humanize(text) ?? raw + return humanize(text) ?? text }