mirror of
https://github.com/stablyai/orca.git
synced 2026-10-23 08:03:39 +00:00
fix(ai-vault): normalize wrapped scan errors
This commit is contained in:
@@ -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')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user