EnergyVenom's picture
Astra: PO/GL actions, usage coverage, assisted sign-in, self-healing, recorder, new top navigation and theme (172a4e22a2bf)
fb62a97 verified
Raw History Blame Contribute Delete
1.47 kB
// Optional bridge exposed by the Electron preload (desktop/src/preload.js). Absent in a normal browser.
export interface DesktopBridge {
notify: (title: string, body: string) => void;
openSettings: () => void;
version: string;
}
declare global {
interface Window { fptDesktop?: DesktopBridge }
}
export const desktop = (): DesktopBridge | undefined => (typeof window !== 'undefined' ? window.fptDesktop : undefined);
const NOTIFY_ON: Record<string, string> = {
waiting_approval: 'is waiting for case approval',
waiting_sign_in: 'is waiting for someone to sign in to the pod',
waiting_review: 'is waiting for defect review',
completed: 'finished',
failed: 'failed',
killed: 'was stopped by the kill switch',
};
/** Compare two run-status snapshots; returns notification texts for runs that changed into an attention state. */
export function statusTransitions(prev: Record<string, string>, next: Record<string, string>): { title: string; body: string }[] {
const out: { title: string; body: string }[] = [];
for (const [id, raw] of Object.entries(next)) {
const [st, attention] = raw.split('|');
const [pst, pattention] = (prev[id] ?? '').split('|');
if (prev[id] === undefined) continue;
if (pst !== st && NOTIFY_ON[st]) out.push({ title: 'Astra (mock app)', body: `Run ${id} ${NOTIFY_ON[st]}` });
else if (attention && attention !== pattention) out.push({ title: 'Astra (mock app)', body: attention });
}
return out;
}