codeburn/app/renderer/lib/ipc.ts
Resham Joshi a0e66e3fcd
fix: desktop not-found panel gives app advice, not npm (#1701)
For a bundled CLI the not-found panel now tells desktop users to reopen or reinstall the app instead of installing from npm. Strings in all six locales.
2026-10-09 12:31:19 +02:00

23 lines
972 B
TypeScript

import type { CliError, CodeburnBridge } from './types'
// The preload script (app/electron/preload.ts) exposes `window.codeburn` as the
// typed CodeburnBridge (methods resolve to CLI JSON or reject with a plain
// CliError).
declare global {
interface Window {
codeburn: CodeburnBridge
}
}
/** The typed bridge. Import this instead of touching `window` directly. */
export const codeburn: CodeburnBridge = window.codeburn
/** Coerce anything thrown across the IPC boundary into a CliError shape. */
export function normalizeCliError(err: unknown): CliError {
if (err && typeof err === 'object' && 'kind' in err && typeof (err as CliError).kind === 'string') {
const e = err as CliError
return { kind: e.kind, message: e.message ?? 'codeburn CLI error', ...(e.cold ? { cold: true as const } : {}), ...(e.stage ? { stage: e.stage } : {}) }
}
const message = err instanceof Error ? err.message : String(err)
return { kind: 'nonzero', message }
}