evOo-local/apps/web/src/lib/computer-screen.ts
cynarAI 6c7eed7580 Initial clean evOo-local from f00577b
Fresh history cut from cynarAI/evoo antigravity-handoff/project-timeline
(Voice First + project timeline). Brand docs/titles as evOo; keep @rakazo/*
packages as tech debt. Excludes node_modules, caches, secrets, voice blobs.
2026-09-20 17:15:16 +02:00

27 lines
788 B
TypeScript

export interface ComputerScreenResult {
url: string | null;
error: string | null;
}
/** Only the latest request for the visible computer may replace its screen or error. */
export async function loadComputerScreen(options: {
load: () => Promise<{ url: string | null }>;
isCurrent: () => boolean;
commit: (result: ComputerScreenResult) => void;
fallbackError: string;
}): Promise<string | null> {
let result: ComputerScreenResult;
try {
const screen = await options.load();
result = { url: screen.url, error: null };
} catch (error) {
result = {
url: null,
error: error instanceof Error && error.message ? error.message : options.fallbackError,
};
}
if (!options.isCurrent()) return null;
options.commit(result);
return result.url;
}