Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat(desktop): keep the machine awake while local agents work #5535

Closedleo-mathurin(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/5535/headopened View on GitHub

Showing 22 changed files with 165 additions and 0 deletions (loading 19).

x
0 of 22 viewed, 22 left
95 additions and 0 deletionsapps/desktop/src/electron/ElectronPowerSaveBlocker.test.tsAdded
View file
@@ -0,0 +1,95 @@
+import { assert, describe, it } from "@effect/vitest";
+import * as Effect from "effect/Effect";
+​
+import * as ElectronPowerSaveBlocker from "./ElectronPowerSaveBlocker.ts";
+​
+function makeStubApi() {
+ const calls: string[] = [];
+ const started = new Set<number>();
+ let nextId = 0;
+ const api: ElectronPowerSaveBlocker.PowerSaveBlockerApi = {
+ start: (type) => {
+ const id = nextId++;
+ started.add(id);
+ calls.push(`start:${type}:${id}`);
+ return id;
+ },
+ stop: (id) => {
+ calls.push(`stop:${id}`);
+ return started.delete(id);
+ },
+ isStarted: (id) => started.has(id),
+ };
+ return { api, calls, started };
+}
+​
+describe("ElectronPowerSaveBlocker", () => {
+ it.effect("starts a single prevent-app-suspension blocker and is idempotent", () =>
+ Effect.gen(function* () {
+ const { api, calls, started } = makeStubApi();
+ const service = ElectronPowerSaveBlocker.make(api);