fix(ai-vault): normalize wrapped scan errors

This commit is contained in:
Brennan Benson
2026-08-24 01:59:41 -07:00
parent c9f3a691a7
commit 88192bcfb1
3 changed files with 13 additions and 7 deletions
@@ -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()
@@ -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')
})
})
+3 -3
View File
@@ -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
}