Files
cobble/src/functions/backend/db/computers/is-computer-busy.ts
T
tbenandClaude Opus 5.5 b9c5311fde Keep computers' browser sessions across restarts and recreates
Each computer's Chrome profile now lives on the data volume
(DATA_DIR/computer-browsers/<id>, mounted at ~/.cobble-browser) and
Chrome is pointed at it with --user-data-dir. The sandbox image resets
its own profile's preferences to session-only cookies on every boot,
which signed every site out whenever Chrome exited. New profiles are
seeded with the image's preferences minus that rule, stale Singleton
links are removed before each provision, and existing computers are
recreated once (skipped while a job runs on them).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 15:26:18 +01:00

21 lines
577 B
TypeScript

import BunSQLite from "@moduletrace/bun-sqlite";
type Params = {
computer_id: number | string;
};
/**
* Whether a job is working on the computer right now, so its browser or
* container must not be pulled from under it.
*/
export default async function isComputerBusy({ computer_id }: Params) {
return Boolean(
(
await BunSQLite.sql<{ id: number }>({
sql: `SELECT id FROM bots_queue WHERE computer_id = ? AND status = 'processing' LIMIT 1`,
values: [computer_id],
})
).payload?.[0],
);
}