@narumitw/pi-caffeinate 0.46.0 → 0.49.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -2
- package/src/caffeinate.ts +6 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@narumitw/pi-caffeinate",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.49.2",
|
|
4
4
|
"description": "Pi extension that keeps the computer awake while the agent is running.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,6 +28,9 @@
|
|
|
28
28
|
"format": "biome check --write .",
|
|
29
29
|
"typecheck": "tsc --noEmit"
|
|
30
30
|
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"@earendil-works/pi-coding-agent": "*"
|
|
33
|
+
},
|
|
31
34
|
"devDependencies": {
|
|
32
35
|
"@biomejs/biome": "2.5.6",
|
|
33
36
|
"@earendil-works/pi-coding-agent": "0.83.0",
|
|
@@ -40,6 +43,6 @@
|
|
|
40
43
|
"directory": "extensions/pi-caffeinate"
|
|
41
44
|
},
|
|
42
45
|
"dependencies": {
|
|
43
|
-
"@narumitw/pi-tui-kit": "^0.
|
|
46
|
+
"@narumitw/pi-tui-kit": "^0.49.1"
|
|
44
47
|
}
|
|
45
48
|
}
|
package/src/caffeinate.ts
CHANGED
|
@@ -5,7 +5,6 @@ import type {
|
|
|
5
5
|
ExtensionCommandContext,
|
|
6
6
|
ExtensionContext,
|
|
7
7
|
} from "@earendil-works/pi-coding-agent";
|
|
8
|
-
import { defineMenu, runMenu } from "@narumitw/pi-tui-kit";
|
|
9
8
|
import { startInhibitorProcess, stopInhibitorProcess } from "./inhibitor-process.js";
|
|
10
9
|
import { formatMode, getInhibitorCommand, type InhibitorCommand } from "./inhibitors.js";
|
|
11
10
|
import {
|
|
@@ -171,6 +170,10 @@ async function runCaffeinateMenu(ctx: CommandContext, generation: number, start:
|
|
|
171
170
|
: `The pi-caffeinate menu requires TUI or RPC mode.\n\n${buildCommandGuide()}\n\n${describeState()}`,
|
|
172
171
|
);
|
|
173
172
|
}
|
|
173
|
+
const menuSignal = state.menuController.signal;
|
|
174
|
+
const isCurrent = () => generation === state.sessionGeneration && !menuSignal.aborted;
|
|
175
|
+
const { defineMenu, runMenu } = await import("@narumitw/pi-tui-kit");
|
|
176
|
+
if (!isCurrent()) return;
|
|
174
177
|
type Screen = "main" | "mode";
|
|
175
178
|
type Action = "display" | "sleep" | "status" | "stop" | "help";
|
|
176
179
|
const menu = defineMenu<undefined, Screen, Action>({
|
|
@@ -223,8 +226,8 @@ async function runCaffeinateMenu(ctx: CommandContext, generation: number, start:
|
|
|
223
226
|
});
|
|
224
227
|
await runMenu(ctx, menu, {
|
|
225
228
|
getState: () => undefined,
|
|
226
|
-
signal:
|
|
227
|
-
isCurrent
|
|
229
|
+
signal: menuSignal,
|
|
230
|
+
isCurrent,
|
|
228
231
|
});
|
|
229
232
|
}
|
|
230
233
|
|