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.
27 lines
788 B
TypeScript
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;
|
|
}
|