Skip to content

Commit fd9c480

Browse files
authored
Merge pull request #62 from narumiruna/fix/plan-mode-accepted-implementation
fix(plan-mode): trigger accepted plans as follow-ups
2 parents ce8ecbf + a18fc19 commit fd9c480

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

MEMORY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- ty/ruff LSP servers may request `workspace/configuration`; respond with per-item empty config objects or diagnostic requests can hang.
1111
- pi-statusline is display-only; avoid prompt interception or customization commands unless intentionally reintroduced.
1212
- In Pi extensions, do not call action methods such as `getThinkingLevel()` during the factory load; defer them to `session_start` or later handlers.
13+
- Symptom: extension accept/execute actions from `agent_end` may not trigger a new turn. Cause: `pi.sendMessage({ triggerTurn: true })` only triggers when idle. Fix: use `pi.sendUserMessage(..., { deliverAs: "followUp" })` when `ctx.isIdle()` is false.
1314
- Extension statusline entries should be activity-based: only show an extension in status when it is actively running, retrying, or needs attention; avoid permanent “configured/ready/on” statuses.
1415
- Codex usage can be queried without Codex CLI by sending Pi's `openai-codex` bearer token to `https://chatgpt.com/backend-api/wham/usage`; response uses Codex `RateLimitStatusPayload` snake_case fields.
1516
- `pi-codex-usage` statusline must select a rate-limit bucket by current model id/name; `gpt-5.3-codex-spark` can use its own returned bucket instead of primary `codex`.

extensions/pi-plan-mode/src/plan-mode.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const STATUS_KEY = "plan-mode";
55
const PLAN_WIDGET_KEY = "plan-mode-plan";
66
const PLAN_CONTEXT_MESSAGE_TYPE = "plan-mode-context";
77
const PROPOSED_PLAN_MESSAGE_TYPE = "proposed-plan";
8-
const PLAN_IMPLEMENTATION_MESSAGE_TYPE = "plan-mode-implementation";
98
const PLAN_CONTEXT_MARKER = "[CODEX-LIKE PLAN MODE ACTIVE]";
109
const SAFE_BUILTIN_PLAN_TOOLS = new Set(["read", "bash", "grep", "find", "ls"]);
1110
const BLOCKED_BUILTIN_TOOLS = new Set(["edit", "write"]);
@@ -214,8 +213,7 @@ export default function planMode(pi: ExtensionAPI) {
214213
if (!wasEnabled) {
215214
ctx.ui.notify("Plan mode enabled. I will explore and plan, but not modify files.", "info");
216215
}
217-
if (ctx.isIdle()) pi.sendUserMessage(prompt);
218-
else pi.sendUserMessage(prompt, { deliverAs: "followUp" });
216+
sendPlanModeUserMessage(prompt, ctx);
219217
}
220218

221219
function exitPlanMode(ctx: ExtensionContext) {
@@ -226,6 +224,11 @@ export default function planMode(pi: ExtensionAPI) {
226224
updateUi(ctx);
227225
}
228226

227+
function sendPlanModeUserMessage(message: string, ctx: ExtensionContext) {
228+
if (ctx.isIdle()) pi.sendUserMessage(message);
229+
else pi.sendUserMessage(message, { deliverAs: "followUp" });
230+
}
231+
229232
function startImplementation(ctx: ExtensionContext) {
230233
const plan = state.latestPlan?.trim();
231234
exitPlanMode(ctx);
@@ -235,13 +238,9 @@ export default function planMode(pi: ExtensionAPI) {
235238
return;
236239
}
237240

238-
pi.sendMessage(
239-
{
240-
customType: PLAN_IMPLEMENTATION_MESSAGE_TYPE,
241-
content: `Plan mode is now disabled. Full tool access is restored. Implement this proposed plan now:\n\n${plan}`,
242-
display: true,
243-
},
244-
{ triggerTurn: true },
241+
sendPlanModeUserMessage(
242+
`Plan mode is now disabled. Full tool access is restored. Implement this proposed plan now:\n\n${plan}`,
243+
ctx,
245244
);
246245
}
247246

@@ -299,7 +298,7 @@ export default function planMode(pi: ExtensionAPI) {
299298
}
300299
if (choice === "Revise plan") {
301300
const refinement = await ctx.ui.editor("Revise the plan", "");
302-
if (refinement?.trim()) pi.sendUserMessage(refinement.trim());
301+
if (refinement?.trim()) sendPlanModeUserMessage(refinement.trim(), ctx);
303302
return;
304303
}
305304
if (choice === "Exit Plan mode") {

0 commit comments

Comments
 (0)