@juicesharp/rpiv-warp 2.15.0 → 2.16.0
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/CHANGELOG.md +6 -0
- package/README.md +11 -6
- package/config.ts +12 -0
- package/docs/detection.md +2 -1
- package/docs/events.md +63 -7
- package/index.ts +101 -7
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,12 @@ All notable changes to `@juicesharp/rpiv-warp` are documented here.
|
|
|
5
5
|
Format: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
6
6
|
Versioning: [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [2.16.0] - 2026-11-26
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- **Warp shows Blocked while Pi waits on any dialog, not only on listed tools.** A permission prompt ("allow this bash command?") or any other `ctx.ui` select, confirm, input or custom dialog left the tab reading in progress, and the heartbeat kept re-announcing the prompt every 15 s. rpiv-warp now also follows Pi's `ui_prompt_start`/`ui_prompt_end` events during a turn: the badge rises once and clears once, even when a questionnaire fires both its tool call and its prompt, in either order, and the heartbeat pauses while you're asked. A badge left up by a missed `agent_end` is cleared at the next turn. The new `promptBlocking` setting switches prompt-driven badges off; it defaults to off for anyone who set `blockingTools: []`, which keeps turning the badge off entirely. Thanks @jg33 ([#303](https://github.com/juicesharp/rpiv-mono/pull/303)).
|
|
13
|
+
|
|
8
14
|
## [2.15.0] - 2026-10-24
|
|
9
15
|
|
|
10
16
|
## [2.14.2] - 2026-10-23
|
package/README.md
CHANGED
|
@@ -32,7 +32,8 @@ tab or another app. You get:
|
|
|
32
32
|
|
|
33
33
|
- the tab title animating a braille spinner for as long as the turn runs
|
|
34
34
|
- an OS notification when Pi finishes, naming the project and quoting the reply
|
|
35
|
-
- an OS notification the moment Pi
|
|
35
|
+
- an OS notification the moment Pi blocks on your answer — a question, or a
|
|
36
|
+
permission prompt for a command it wants to run
|
|
36
37
|
|
|
37
38
|
Nothing to configure, no key to supply.
|
|
38
39
|
|
|
@@ -46,10 +47,13 @@ Nothing to configure, no key to supply.
|
|
|
46
47
|
mascot in the tab title for the whole turn (`⠴ - <repo>`, or
|
|
47
48
|
`⠴ - <session> - <repo>` once the session is named, so named tabs stay
|
|
48
49
|
distinguishable while they run), then the original label comes back.
|
|
49
|
-
- **A Blocked badge that never sticks** —
|
|
50
|
-
turn
|
|
50
|
+
- **A Blocked badge that never sticks** — it lights for a blocking tool and for
|
|
51
|
+
any extension UI prompt raised during a turn (a permission prompt, say), and an
|
|
52
|
+
ESC-aborted prompt or tool call is drained at turn end instead of leaving the
|
|
53
|
+
badge lit.
|
|
51
54
|
- **No false idle mid-task** — the running prompt is re-announced every 15
|
|
52
|
-
seconds while the turn is live
|
|
55
|
+
seconds while the turn is live, and paused while a blocking tool or prompt has
|
|
56
|
+
the badge lit.
|
|
53
57
|
- **Per-run badges for parked workflow questions** — each `/wf` run gets its own
|
|
54
58
|
badge keyed on the run id, so concurrent runs light up and clear independently.
|
|
55
59
|
- **Nothing to pay for where it can't help** — outside Warp or on a known-broken
|
|
@@ -70,10 +74,11 @@ Optional. Create `~/.config/rpiv-warp/config.json`:
|
|
|
70
74
|
|
|
71
75
|
| Key | What it does | Default |
|
|
72
76
|
| --- | --- | --- |
|
|
73
|
-
| `blockingTools` | Tool names
|
|
77
|
+
| `blockingTools` | Tool names whose calls raise the Blocked badge and clear it when they finish. `[]` turns the badge off entirely, prompts included, unless `promptBlocking` says otherwise. | `["ask_user_question"]` |
|
|
78
|
+
| `promptBlocking` | Whether an extension UI prompt raised during a turn (a questionnaire, a permission dialog, any `ctx.ui` select, confirm or input) raises the Blocked badge. | `true`, or `false` when `blockingTools` is `[]` |
|
|
74
79
|
| `heartbeatMs` | How often the running prompt is re-announced so Warp doesn't mark the tab idle. Set to `0` to disable. | `15000` |
|
|
75
80
|
|
|
76
|
-
|
|
81
|
+
All keys are optional, and a missing or malformed file falls back to the
|
|
77
82
|
defaults. If `XDG_CONFIG_HOME` is set to an absolute path the file is read from
|
|
78
83
|
`$XDG_CONFIG_HOME/rpiv-warp/config.json` instead, falling back to the
|
|
79
84
|
`~/.config` location when that file does not exist. Config is read once when the
|
package/config.ts
CHANGED
|
@@ -5,6 +5,7 @@ export const CONFIG_PATH = configPath("rpiv-warp");
|
|
|
5
5
|
export interface RpivWarpConfig {
|
|
6
6
|
readonly blockingTools?: readonly string[];
|
|
7
7
|
readonly heartbeatMs?: number;
|
|
8
|
+
readonly promptBlocking?: boolean;
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
export const DEFAULT_BLOCKING_TOOLS: readonly string[] = ["ask_user_question"];
|
|
@@ -28,3 +29,14 @@ export function getBlockingTools(): ReadonlySet<string> {
|
|
|
28
29
|
const filtered = list.filter((s): s is string => typeof s === "string" && s.length > 0);
|
|
29
30
|
return new Set(filtered);
|
|
30
31
|
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Whether an extension UI prompt (`ui_prompt_start`) raises the Blocked badge. An explicit
|
|
35
|
+
* boolean wins; unset, it is on, except beside an explicitly empty `blockingTools`, which was
|
|
36
|
+
* the documented way to turn the badge off and so keeps it off.
|
|
37
|
+
*/
|
|
38
|
+
export function getPromptBlocking(): boolean {
|
|
39
|
+
const config = loadConfig();
|
|
40
|
+
if (typeof config.promptBlocking === "boolean") return config.promptBlocking;
|
|
41
|
+
return !(Array.isArray(config.blockingTools) && getBlockingTools().size === 0);
|
|
42
|
+
}
|
package/docs/detection.md
CHANGED
|
@@ -63,7 +63,8 @@ gated. Upgrading Warp clears the gate; there is nothing to configure.
|
|
|
63
63
|
| `/dev/tty` unopenable (cron, no-TTY SSH) | Every write is silently swallowed. The `open`/`write`/`close` cycle is wrapped in a try/catch that never rethrows, so a failed notification cannot reach the agent loop. |
|
|
64
64
|
| Windows | Best-effort. There is no `/dev/tty`, so the same OSC bytes go to `process.stdout` and ConPTY forwards them to Warp. Skipped entirely when `process.stdout.isTTY` is false, so piped or redirected output is never polluted. This path is untested in the wild. |
|
|
65
65
|
| Detached workflow child sessions | The extension is not loaded at all. See below. |
|
|
66
|
-
| `blockingTools` configured empty | The `tool_call` and `tool_execution_end` handlers short-circuit
|
|
66
|
+
| `blockingTools` configured empty | The `tool_call` and `tool_execution_end` handlers short-circuit, so no tool name raises the badge, and `promptBlocking` defaults to `false`, so extension UI prompts don't either. Everything else is unaffected. |
|
|
67
|
+
| `promptBlocking: false` | `ui_prompt_start` short-circuits, so extension UI prompts never raise the badge; tools in `blockingTools` still do. |
|
|
67
68
|
| `heartbeatMs` set to `0` | The heartbeat interval never starts. |
|
|
68
69
|
| Terminal without an xterm title stack | The CSI push/pop sequences are ignored silently; the spinner still animates. |
|
|
69
70
|
|
package/docs/events.md
CHANGED
|
@@ -5,23 +5,62 @@ and the exact bytes and JSON that go out to the terminal.
|
|
|
5
5
|
|
|
6
6
|
## Lifecycle handlers
|
|
7
7
|
|
|
8
|
-
`rpiv-warp` registers exactly
|
|
8
|
+
`rpiv-warp` registers exactly nine `pi.on(...)` handlers. It registers no tools,
|
|
9
9
|
no slash commands, no widgets, and no keyboard shortcuts.
|
|
10
10
|
|
|
11
11
|
| Pi event | Emits | Side effects |
|
|
12
12
|
| --- | --- | --- |
|
|
13
13
|
| `session_start` | `session_start` — only when `reason === "startup"` | none |
|
|
14
14
|
| `before_agent_start` | nothing | captures the user prompt for `prompt_submit` and the heartbeat; a custom (`triggerTurn`) run captures nothing |
|
|
15
|
-
| `agent_start` | for a user run, `session_start` (defensive re-announce)
|
|
16
|
-
| `agent_end` |
|
|
17
|
-
| `tool_call` | `question_asked` — only for a tool in `blockingTools
|
|
18
|
-
| `tool_execution_end` | `tool_complete` — only for a tool in `blockingTools
|
|
15
|
+
| `agent_start` | a stale-reason `tool_complete` if a block reason outlived a missed `agent_end`; then, for a user run, `session_start` (defensive re-announce) and `prompt_submit` — for a custom (`triggerTurn`) run, nothing more | marks the turn active, starts the tab-title spinner, cancels the pending idle timer, starts the heartbeat |
|
|
16
|
+
| `agent_end` | the drain's `tool_complete` (see below), then `stop` | clears every block reason and marks the turn inactive, stops the spinner, stops the heartbeat, arms the 300 ms idle timer |
|
|
17
|
+
| `tool_call` | `question_asked` — only for a tool in `blockingTools`, and only on the 0→1 block-reason transition | records the call's input; on that transition, stops the spinner and pauses the heartbeat |
|
|
18
|
+
| `tool_execution_end` | `tool_complete` — only for a tool in `blockingTools`, and only on the 1→0 block-reason transition | restarts the spinner, resumes the heartbeat |
|
|
19
|
+
| `ui_prompt_start` | `question_asked` — for any extension UI prompt raised during a turn while `promptBlocking` is on, and only on the 0→1 block-reason transition | stops the spinner, pauses the heartbeat |
|
|
20
|
+
| `ui_prompt_end` | `tool_complete` — only on the 1→0 block-reason transition | restarts the spinner and resumes the heartbeat, but only if the turn is still live |
|
|
19
21
|
| `session_shutdown` | nothing | cancels the idle timer, stops the heartbeat, stops the spinner, clears pending state |
|
|
20
22
|
|
|
21
23
|
`/new`, `/resume`, `/fork` and `/reload` all fire `session_start` with a reason
|
|
22
24
|
other than `"startup"`, so none of them notify — you are already looking at the
|
|
23
25
|
terminal in those cases.
|
|
24
26
|
|
|
27
|
+
### The block-reason set
|
|
28
|
+
|
|
29
|
+
The Blocked badge is driven by one `Set<string>` of reasons, not by the handlers
|
|
30
|
+
independently. A key is either `tool:<toolCallId>` — one per outstanding
|
|
31
|
+
tool_call of a name in `blockingTools` — or `prompt`, for an extension UI prompt.
|
|
32
|
+
|
|
33
|
+
Two helpers own every transition:
|
|
34
|
+
|
|
35
|
+
- `addBlockReason(reason)` returns `true` only when the set went from empty to
|
|
36
|
+
non-empty. That is the moment Warp must be told `question_asked`.
|
|
37
|
+
- `removeBlockReason(reason)` returns `true` only when the reason was present and
|
|
38
|
+
the set is empty again. That is the moment Warp must be told `tool_complete`.
|
|
39
|
+
|
|
40
|
+
Raising on 0→1 and clearing on 1→0 is the same convention the
|
|
41
|
+
[workflow-question transport](#workflow-question-transport) already uses: it emits
|
|
42
|
+
`question_asked` and `tool_complete` for something that is not a tool call, and
|
|
43
|
+
attributes the clear to `tool_name: "ask_user_question"`.
|
|
44
|
+
|
|
45
|
+
A set of reasons, rather than a boolean or a counter, is what keeps the handlers
|
|
46
|
+
correct:
|
|
47
|
+
|
|
48
|
+
- `ask_user_question` fires **two** events in a single episode: `tool_call` (its
|
|
49
|
+
name is in the default `blockingTools`) and `ui_prompt_start` (the tool renders
|
|
50
|
+
through `ctx.ui`). Two independent per-handler booleans would raise
|
|
51
|
+
`question_asked` twice and clear the badge on the first of the two ends.
|
|
52
|
+
- Keying tool calls by `toolCallId` stops a second, still-open call of the same
|
|
53
|
+
tool from clearing the badge when the first one finishes.
|
|
54
|
+
- It tolerates event ordering. Pi delivers `ui_prompt_start` / `ui_prompt_end`
|
|
55
|
+
through `queueMicrotask`, so a `ui_prompt_end` can land after an overlapping
|
|
56
|
+
`tool_execution_end`; the badge clears only when the *last* reason goes away,
|
|
57
|
+
whichever that turns out to be.
|
|
58
|
+
|
|
59
|
+
`ui_prompt_start` no-ops outside a live turn, so a config modal raised between
|
|
60
|
+
turns never lights the badge. `ui_prompt_end` no-ops whenever its `prompt` reason
|
|
61
|
+
is absent — which is what makes the late end that arrives after `agent_end`
|
|
62
|
+
drained the reason emit nothing.
|
|
63
|
+
|
|
25
64
|
### User runs vs custom (`triggerTurn`) runs
|
|
26
65
|
|
|
27
66
|
Pi 1.2.0 fires `before_agent_start` for both a submitted prompt (`messageType: "user"`,
|
|
@@ -32,7 +71,7 @@ a custom run the extension leaves the captured query untouched and skips the def
|
|
|
32
71
|
`stop` at `agent_end` still fire, so a background turn shows activity without blanking or
|
|
33
72
|
re-announcing the tab's query.
|
|
34
73
|
|
|
35
|
-
### Why `agent_end` drains
|
|
74
|
+
### Why `agent_end` drains blocked state
|
|
36
75
|
|
|
37
76
|
Pressing ESC during a blocking tool aborts it, and an aborted tool never fires
|
|
38
77
|
`tool_execution_end`. Without a drain, Warp's Blocked badge would stay lit for the
|
|
@@ -40,12 +79,24 @@ rest of the session. `agent_end` therefore emits a `tool_complete` for every cal
|
|
|
40
79
|
still outstanding — carrying the tool name and the input captured at `tool_call`
|
|
41
80
|
time — before it emits `stop`.
|
|
42
81
|
|
|
82
|
+
A permission prompt reaches the drain by a different route: it blocks a tool that
|
|
83
|
+
is *not* in `blockingTools`, so no `tool_call` was ever captured for it and the
|
|
84
|
+
drain loop above has nothing to emit. When the turn ends with a prompt reason open
|
|
85
|
+
and the drain emitted nothing, `agent_end` emits one `tool_complete` itself —
|
|
86
|
+
`tool_name: "ask_user_question"`, no `tool_input` — to clear the badge.
|
|
87
|
+
|
|
88
|
+
Either route ends the same way: exactly one clear for one block episode, emitted
|
|
89
|
+
before `stop`. A late `ui_prompt_end` after that drain is a no-op, because its
|
|
90
|
+
reason was already removed. A reason that outlives its turn entirely — a crash or
|
|
91
|
+
reload that skipped `agent_end` — is reset at the next `agent_start`, which clears
|
|
92
|
+
the set and emits the same `tool_complete` before re-announcing the session.
|
|
93
|
+
|
|
43
94
|
## Timer-driven emissions
|
|
44
95
|
|
|
45
96
|
| Emission | Trigger |
|
|
46
97
|
| --- | --- |
|
|
47
98
|
| `idle_prompt` | 300 ms after `agent_end`, unless `agent_start` or `session_shutdown` cancels first. Carries the last assistant message as `summary`. |
|
|
48
|
-
| `prompt_submit` | Re-emitted every `heartbeatMs` (default 15000) while a turn is active, so Warp does not decide the session went idle mid-task. Paused
|
|
99
|
+
| `prompt_submit` | Re-emitted every `heartbeatMs` (default 15000) while a turn is active, so Warp does not decide the session went idle mid-task. Paused while a block reason is open — a blocking tool or an extension UI prompt — and stopped at turn end. |
|
|
49
100
|
|
|
50
101
|
Both timers, and the spinner's interval, are `unref()`d — a stray timer can never
|
|
51
102
|
hold the process open.
|
|
@@ -94,6 +145,11 @@ Per-event additions:
|
|
|
94
145
|
| `tool_complete` | `tool_name`, plus `tool_input` when the input was captured at `tool_call` |
|
|
95
146
|
| `session_start`, `question_asked` | none |
|
|
96
147
|
|
|
148
|
+
A `tool_complete` that clears a prompt-driven block — or that resets a stale
|
|
149
|
+
reason at `agent_start` — carries `tool_name: "ask_user_question"` and no
|
|
150
|
+
`tool_input`: the same shape the workflow-question transport emits to clear a
|
|
151
|
+
run's badge.
|
|
152
|
+
|
|
97
153
|
Example `stop` body:
|
|
98
154
|
|
|
99
155
|
```json
|
package/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { basename } from "node:path";
|
|
2
2
|
import type { ExtensionAPI, ExtensionContext, SessionEntry } from "@earendil-works/pi-coding-agent";
|
|
3
|
-
import { DEFAULT_HEARTBEAT_MS, getBlockingTools, getHeartbeatMs } from "./config.ts";
|
|
3
|
+
import { DEFAULT_HEARTBEAT_MS, getBlockingTools, getHeartbeatMs, getPromptBlocking } from "./config.ts";
|
|
4
4
|
import {
|
|
5
5
|
buildIdlePromptPayload,
|
|
6
6
|
buildPromptSubmitPayload,
|
|
@@ -43,6 +43,18 @@ let heartbeatMs = DEFAULT_HEARTBEAT_MS;
|
|
|
43
43
|
// them — that drain is what clears Warp's stale "Blocked" badge.
|
|
44
44
|
const pendingBlockingCalls = new Map<string, PendingBlockingCall>();
|
|
45
45
|
|
|
46
|
+
// Warp's "Blocked" badge
|
|
47
|
+
// is driven by *reasons*, not raw tool names. `question_asked` is emitted on the
|
|
48
|
+
// 0→1 transition and `tool_complete` on the 1→0 transition — the same
|
|
49
|
+
// convention as WorkflowQuestionTransport above. Keys: `tool:<toolCallId>` for
|
|
50
|
+
// blocking-tool calls, `PROMPT_BLOCK_REASON` for extension UI prompts. Using a
|
|
51
|
+
// set of reasons (not a counter or a boolean) is what makes the double-fire of
|
|
52
|
+
// `ask_user_question` — which fires `tool_call` AND `ui_prompt_start` — raise
|
|
53
|
+
// exactly once and clear exactly once, in either event order.
|
|
54
|
+
let turnActive = false;
|
|
55
|
+
const activeBlockReasons = new Set<string>();
|
|
56
|
+
const PROMPT_BLOCK_REASON = "prompt";
|
|
57
|
+
|
|
46
58
|
export function __resetState(): void {
|
|
47
59
|
pendingQuery = "";
|
|
48
60
|
activeRunIsCustom = false;
|
|
@@ -55,6 +67,8 @@ export function __resetState(): void {
|
|
|
55
67
|
heartbeatInterval = undefined;
|
|
56
68
|
}
|
|
57
69
|
heartbeatMs = DEFAULT_HEARTBEAT_MS;
|
|
70
|
+
turnActive = false;
|
|
71
|
+
activeBlockReasons.clear();
|
|
58
72
|
pendingBlockingCalls.clear();
|
|
59
73
|
}
|
|
60
74
|
|
|
@@ -140,6 +154,27 @@ function captureBlockingCall(toolCallId: string, toolName: string, input: unknow
|
|
|
140
154
|
pendingBlockingCalls.set(toolCallId, { toolName, input: asRecord(input) });
|
|
141
155
|
}
|
|
142
156
|
|
|
157
|
+
/**
|
|
158
|
+
* Add a reason Warp's badge should read "Blocked". Returns true iff this
|
|
159
|
+
* transitioned the reason set from empty → ≥1, i.e. the caller must emit
|
|
160
|
+
* `question_asked` exactly once for this block episode.
|
|
161
|
+
*/
|
|
162
|
+
function addBlockReason(reason: string): boolean {
|
|
163
|
+
const wasEmpty = activeBlockReasons.size === 0;
|
|
164
|
+
activeBlockReasons.add(reason);
|
|
165
|
+
return wasEmpty;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Remove a reason Warp's badge should read "Blocked". Returns true iff the
|
|
170
|
+
* reason was present AND this emptied the set, i.e. the caller must emit
|
|
171
|
+
* `tool_complete` exactly once for this block episode.
|
|
172
|
+
*/
|
|
173
|
+
function removeBlockReason(reason: string): boolean {
|
|
174
|
+
if (!activeBlockReasons.delete(reason)) return false;
|
|
175
|
+
return activeBlockReasons.size === 0;
|
|
176
|
+
}
|
|
177
|
+
|
|
143
178
|
function consumeBlockingCall(toolCallId: string): PendingBlockingCall | undefined {
|
|
144
179
|
const call = pendingBlockingCalls.get(toolCallId);
|
|
145
180
|
pendingBlockingCalls.delete(toolCallId);
|
|
@@ -164,6 +199,7 @@ export default function (pi: ExtensionAPI): void {
|
|
|
164
199
|
if (!warp.isWarp || !warp.supportsStructured) return;
|
|
165
200
|
|
|
166
201
|
const blockingTools = getBlockingTools();
|
|
202
|
+
const promptBlocking = getPromptBlocking();
|
|
167
203
|
heartbeatMs = getHeartbeatMs();
|
|
168
204
|
|
|
169
205
|
pi.on("session_start", async (event, ctx) => {
|
|
@@ -182,6 +218,24 @@ export default function (pi: ExtensionAPI): void {
|
|
|
182
218
|
});
|
|
183
219
|
|
|
184
220
|
pi.on("agent_start", async (_event, ctx) => {
|
|
221
|
+
// A missed `agent_end` (crash/reload) could leave a stale
|
|
222
|
+
// Blocked reason pinned, which would suppress every future raise AND leave
|
|
223
|
+
// Warp's badge lit. Reset BOTH structures here: the reason set and
|
|
224
|
+
// `pendingBlockingCalls` are created and removed together everywhere else, so
|
|
225
|
+
// clearing only the reasons would let the next `agent_end` drain the orphaned
|
|
226
|
+
// call and emit a `tool_complete` with nothing raised before it. Clearing the
|
|
227
|
+
// map unconditionally keeps the two provably in step — anything still pending
|
|
228
|
+
// at turn start is stale by definition, since `agent_end` drains it and
|
|
229
|
+
// `session_shutdown` clears it on every real turn. If a reason WAS pinned, tell
|
|
230
|
+
// Warp the block is over before announcing the new turn; Warp's badge is driven
|
|
231
|
+
// by reasons, so the map alone never warrants an emit.
|
|
232
|
+
const hadStaleReason = activeBlockReasons.size > 0;
|
|
233
|
+
activeBlockReasons.clear();
|
|
234
|
+
pendingBlockingCalls.clear();
|
|
235
|
+
if (hadStaleReason) {
|
|
236
|
+
emit(buildToolCompletePayload(ctx, "ask_user_question", undefined));
|
|
237
|
+
}
|
|
238
|
+
turnActive = true;
|
|
185
239
|
if (!activeRunIsCustom) {
|
|
186
240
|
emit(buildSessionStartPayload(ctx)); // Item 2: defensive re-announce
|
|
187
241
|
emit(buildPromptSubmitPayload(ctx, pendingQuery));
|
|
@@ -195,38 +249,78 @@ export default function (pi: ExtensionAPI): void {
|
|
|
195
249
|
// ESC/abort during a blocking tool never fires `tool_execution_end`, so the
|
|
196
250
|
// "Blocked" badge would stay stale. Drain any outstanding blocking calls
|
|
197
251
|
// (emit `tool_complete` for each) to unblock before announcing the stop.
|
|
252
|
+
const hadBlocked = activeBlockReasons.size > 0;
|
|
253
|
+
activeBlockReasons.clear();
|
|
254
|
+
let cleared = false;
|
|
198
255
|
for (const [, call] of pendingBlockingCalls) {
|
|
199
256
|
emit(buildToolCompletePayload(ctx, call.toolName, call.input));
|
|
257
|
+
cleared = true;
|
|
200
258
|
}
|
|
201
259
|
pendingBlockingCalls.clear();
|
|
260
|
+
if (hadBlocked && !cleared) {
|
|
261
|
+
// ESC during an extension UI prompt that gated a
|
|
262
|
+
// NON-blocking tool (e.g. a permission prompt). The drain above emitted
|
|
263
|
+
// nothing, so clear the badge here.
|
|
264
|
+
emit(buildToolCompletePayload(ctx, "ask_user_question", undefined));
|
|
265
|
+
}
|
|
202
266
|
emit(buildStopPayload(ctx, readBranch(ctx)));
|
|
203
267
|
stopSpinner();
|
|
204
268
|
stopHeartbeat(); // Item 4: stop heartbeat
|
|
269
|
+
turnActive = false;
|
|
205
270
|
startIdleTimer(ctx, readBranch(ctx)); // Item 3: schedule idle_prompt after 300ms
|
|
206
271
|
});
|
|
207
272
|
|
|
208
273
|
pi.on("tool_call", async (event, ctx) => {
|
|
209
274
|
if (!blockingTools.has(event.toolName)) return;
|
|
210
275
|
captureBlockingCall(event.toolCallId, event.toolName, event.input); // Item 6: capture input
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
276
|
+
if (addBlockReason(`tool:${event.toolCallId}`)) {
|
|
277
|
+
emit(buildQuestionAskedPayload(ctx));
|
|
278
|
+
stopSpinner();
|
|
279
|
+
stopHeartbeat(); // Item 4: pause heartbeat
|
|
280
|
+
}
|
|
214
281
|
});
|
|
215
282
|
|
|
216
283
|
pi.on("tool_execution_end", async (event, ctx) => {
|
|
217
284
|
if (!blockingTools.has(event.toolName)) return;
|
|
218
285
|
const pending = consumeBlockingCall(event.toolCallId); // Item 6: consume input
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
286
|
+
if (removeBlockReason(`tool:${event.toolCallId}`)) {
|
|
287
|
+
emit(buildToolCompletePayload(ctx, event.toolName, pending?.input));
|
|
288
|
+
startSpinner(titleSuffix(ctx));
|
|
289
|
+
startHeartbeat(ctx, heartbeatMs); // Item 4: resume heartbeat
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
// Raise Warp's Blocked badge for ANY blocking extension UI prompt, not just
|
|
294
|
+
// blockingTools name matches. Permission prompts are not tool calls — they are
|
|
295
|
+
// `ctx.ui` raised inside a `tool_call` handler on the gated tool — so the
|
|
296
|
+
// name-based check above can never see them.
|
|
297
|
+
pi.on("ui_prompt_start", async (_event, ctx) => {
|
|
298
|
+
if (!promptBlocking || !turnActive) return; // switched off, or a config modal etc. outside a turn
|
|
299
|
+
if (addBlockReason(PROMPT_BLOCK_REASON)) {
|
|
300
|
+
emit(buildQuestionAskedPayload(ctx));
|
|
301
|
+
stopSpinner();
|
|
302
|
+
stopHeartbeat();
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
pi.on("ui_prompt_end", async (_event, ctx) => {
|
|
307
|
+
if (!removeBlockReason(PROMPT_BLOCK_REASON)) return;
|
|
308
|
+
emit(buildToolCompletePayload(ctx, "ask_user_question", undefined));
|
|
309
|
+
if (turnActive) {
|
|
310
|
+
// Never (re)start a heartbeat outside a turn.
|
|
311
|
+
startSpinner(titleSuffix(ctx));
|
|
312
|
+
startHeartbeat(ctx, heartbeatMs);
|
|
313
|
+
}
|
|
222
314
|
});
|
|
223
315
|
|
|
224
316
|
pi.on("session_shutdown", async () => {
|
|
225
317
|
cancelIdleTimer();
|
|
226
318
|
stopHeartbeat();
|
|
227
319
|
pendingQuery = "";
|
|
320
|
+
activeBlockReasons.clear();
|
|
228
321
|
activeRunIsCustom = false;
|
|
229
322
|
pendingBlockingCalls.clear();
|
|
323
|
+
turnActive = false;
|
|
230
324
|
stopSpinner();
|
|
231
325
|
});
|
|
232
326
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juicesharp/rpiv-warp",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.16.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Pi extension. Native Warp terminal notifications, dispatched via OSC 777 on Pi lifecycle events.",
|
|
6
6
|
"keywords": [
|
|
@@ -59,6 +59,6 @@
|
|
|
59
59
|
"@earendil-works/pi-coding-agent": "*"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@juicesharp/rpiv-config": "^2.
|
|
62
|
+
"@juicesharp/rpiv-config": "^2.16.0"
|
|
63
63
|
}
|
|
64
64
|
}
|