diff options
Diffstat (limited to 'crates/dinggerd/assets/pi/pi-agent-state.ts')
| -rw-r--r-- | crates/dinggerd/assets/pi/pi-agent-state.ts | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/crates/dinggerd/assets/pi/pi-agent-state.ts b/crates/dinggerd/assets/pi/pi-agent-state.ts index 4c21afe..0719265 100644 --- a/crates/dinggerd/assets/pi/pi-agent-state.ts +++ b/crates/dinggerd/assets/pi/pi-agent-state.ts @@ -47,11 +47,12 @@ function sendRequestAttempt(request: unknown, timeoutMs: number): Promise<boolea }); } -async function sendRequest(request: unknown): Promise<void> { +// Whether the daemon got it. +async function sendRequest(request: unknown): Promise<boolean> { if (await sendRequestAttempt(request, 500)) { - return; + return true; } - await sendRequestAttempt(request, 1500); + return sendRequestAttempt(request, 1500); } type AgentState = "working" | "blocked" | "idle"; @@ -96,9 +97,13 @@ function savedImportance(ctx: any): Importance { return "normal"; } -function report(state: AgentState | undefined, message?: string): Promise<void> { - return sendRequest({ - id: `${source}:${Date.now()}:${Math.random().toString(36).slice(2)}`, +function requestId(): string { + return `${source}:${Date.now()}:${Math.random().toString(36).slice(2)}`; +} + +async function report(state: AgentState | undefined, message?: string): Promise<void> { + await sendRequest({ + id: requestId(), method: "pane.report_agent", params: { pane_id: paneId!, @@ -226,6 +231,28 @@ export default function (pi) { }, }); + // Like "mark as unread" in mail: dingger shows the agent as done again + // (a pane option; nothing is saved in the session). + pi.registerCommand("unread", { + description: "Mark this agent unread in dingger: it shows as done until you come back to it", + handler: async (_args: string, ctx: any) => { + if (agentActive || blockedCount > 0) { + ctx.ui.notify("only an idle agent can be marked unread", "error"); + return; + } + const delivered = await sendRequest({ + id: requestId(), + method: "pane.mark_unread", + params: { pane_id: paneId! }, + }); + if (delivered) { + ctx.ui.notify("marked unread: dingger shows it as done until you come back to it", "info"); + } else { + ctx.ui.notify("dingger is not running", "error"); + } + }, + }); + pi.on("session_start", async (event, ctx) => { // TUI only: RPC/JSON/print modes are headless. if (ctx?.mode !== "tui") { |
