pi-wakeup 0.2.0 → 0.2.1
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 +1 -1
- package/src/index.test.ts +2 -0
- package/src/index.ts +14 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-wakeup",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "schedule_wakeup / cancel_wakeup for the pi coding agent: session-local self-pacing, the pi analog of Claude Code's ScheduleWakeup dynamic mode.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/src/index.test.ts
CHANGED
|
@@ -40,6 +40,7 @@ function harness(
|
|
|
40
40
|
return idle;
|
|
41
41
|
},
|
|
42
42
|
ui: {
|
|
43
|
+
theme: { fg: (color: string, text: string) => `<${color}>${text}` },
|
|
43
44
|
notify: (text: string, level: string) => notifies.push({ text, level }),
|
|
44
45
|
setWidget: (key: string, lines: string[] | undefined) => {
|
|
45
46
|
if (opts.widgetThrows) throw new Error("stale widget ctx");
|
|
@@ -252,6 +253,7 @@ test("widget mode: scheduling shows a line above the editor and arms a refresh",
|
|
|
252
253
|
assert.equal(last.lines!.length, 1);
|
|
253
254
|
assert.match(last.lines![0], /2m/); // 120s from now()=1000 -> 2m remaining
|
|
254
255
|
assert.match(last.lines![0], /CI/);
|
|
256
|
+
assert.match(last.lines![0], /^<warning>⏰ /); // styled like the tmux bar
|
|
255
257
|
assert.equal(h.intervals.length, 1);
|
|
256
258
|
assert.equal(h.intervals[0].cancelled, false);
|
|
257
259
|
// The tmux runner is never touched in widget mode.
|
package/src/index.ts
CHANGED
|
@@ -194,6 +194,19 @@ export function createWakeup(pi: any, deps: Deps = {}): void {
|
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
+
// The widget line matches the tmux bar: a clock and the theme's warning
|
|
198
|
+
// (yellow) colour, so it stands out above the editor. The theme read is
|
|
199
|
+
// guarded like every other ctx.ui access; without one the line is plain.
|
|
200
|
+
function widgetLine(text: string): string {
|
|
201
|
+
const line = `⏰ ${text}`;
|
|
202
|
+
try {
|
|
203
|
+
const theme = ctx?.ui?.theme;
|
|
204
|
+
return theme && typeof theme.fg === "function" ? theme.fg("warning", line) : line;
|
|
205
|
+
} catch {
|
|
206
|
+
return line;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
197
210
|
// Render the current pending list to the chosen target, or clear it when
|
|
198
211
|
// nothing is pending. Runs inside timer/interval callbacks, so every tmux and
|
|
199
212
|
// ctx.ui call is guarded — a throw here must never escape (best-effort).
|
|
@@ -214,7 +227,7 @@ export function createWakeup(pi: any, deps: Deps = {}): void {
|
|
|
214
227
|
// Widget mode. Guard ctx.ui: a ctx captured at session_start goes stale
|
|
215
228
|
// after /reload or a session switch, and setWidget would then throw.
|
|
216
229
|
if (ctx?.ui?.setWidget) {
|
|
217
|
-
ctx.ui.setWidget("wakeup", text === undefined ? undefined : [text]);
|
|
230
|
+
ctx.ui.setWidget("wakeup", text === undefined ? undefined : [widgetLine(text)]);
|
|
218
231
|
}
|
|
219
232
|
} catch (error) {
|
|
220
233
|
log(`display refresh failed: ${String(error)}`);
|