Properties2
Icon
Order
30Pi Island requires some extensions to be patched for proper RPC mode support. This page documents the patches and their rationale.
pi-synthetic Extension
Location: ~/.pi/agent/git/github.com/aliou/pi-synthetic/
Problem
In RPC mode, Pi sets ctx.hasUI = true but ctx.ui.custom() returns undefined immediately (no-op). The pi-synthetic extension checks if (!ctx.hasUI) before falling back to console.log, so the fallback never triggers.
Patch
File: src/commands/quotas.ts
// Original code calls ctx.ui.custom() without checking the result
await ctx.ui.custom<void>((tui, theme, _kb, done) => {
// ... TUI rendering code
});
// Patched to fall back to notify when custom() returns undefined
const result = await ctx.ui.custom<void>((tui, theme, _kb, done) => {
// ... TUI rendering code
});
// If custom() returned undefined (RPC mode), use notify as fallback
if (result === undefined) {
const quotas = await fetchQuotas();
if (!quotas) {
ctx.ui.notify("Failed to fetch quotas", "error");
return;
}
ctx.ui.notify(formatQuotasPlain(quotas), "info");
}
Why This Works
ctx.ui.custom()in RPC mode immediately returnsundefinedctx.ui.notify()in RPC mode emits anextension_ui_requestevent withmethod: "notify"- Pi Island handles this event and displays the message in a terminal-style box
Upstream Fix
This patch should be submitted as a PR to the pi-synthetic repository. The recommended pattern for RPC-compatible extensions:
- Check if
ctx.ui.custom()returnsundefined - Fall back to
ctx.ui.notify()for simple text output - Or check
!ctx.hasUIforconsole.logfallback (ifhasUIis fixed in Pi)
Other Extensions
If other extensions have similar issues (using ctx.ui.custom() without RPC fallback), apply the same pattern:
const result = await ctx.ui.custom(...);
if (result === undefined) {
// RPC mode fallback
ctx.ui.notify("Your output text", "info");
}