Visitar URL original
fix(pi): render completed messages and errors by a4180p · Pull Request #1495 · backnotprop/plannotator · GitHub
Skip to content

fix(pi): render completed messages and errors - #1495

Merged
backnotprop merged 2 commits into
backnotprop:mainfrom
a4180p:fix/pi-completed-message-text
Sep 10, 2026
Merged

backnotprop merged 2 commits into
backnotprop:mainfrom
a4180p:fix/pi-completed-message-text

Conversation

@a4180p

@a4180p a4180p commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • map text blocks from Pi RPC message_end events for completed assistant messages
  • surface completed Pi request errors in Ask AI instead of reporting a successful empty response
  • cover completed assistant, failed assistant, and non-assistant messages

Pi documents message_end.message as the authoritative completed assistant response. The completed-message fallback lets Ask AI render a response when a Pi provider does not emit usable text_delta events. In particular, a failed Pi request (such as an upstream 429) previously ended as a successful empty Plannotator response; the provider now sends its errorMessage to the UI. The UI retains its existing streamed-text preference, so normal delta streaming is not duplicated.

Validation

  • bun run typecheck
  • bun test packages/ai/ai.test.ts

@a4180p
a4180p marked this pull request as draft September 10, 2026 08:11
@a4180p a4180p changed the title fix(pi): render completed assistant messages fix(pi): render completed messages and errors Sep 10, 2026
@a4180p
a4180p marked this pull request as ready for review September 10, 2026 08:16
@backnotprop

Copy link
Copy Markdown
Owner

Reviewed in depth before merge, including against the installed Pi package's actual RPC internals: message_end is authoritative and always follows deltas, but the existing first-text dedup guard in useAIChat (the same architecture the Claude provider uses) means normally streamed responses render byte-identically - no double-render. The no-delta path is real (agent-loop's !addedPartial branch), and the error branch targets the only place current Pi actually reports errors: the old message_update error mapping is dead code on current Pi, which is exactly why quota/auth errors rendered as blank successful answers. Verified the error path can't wedge the SSE drain (message_end → turn_end → agent_end still terminates normally) and the error field survives the subsequent result. Revert-verification: two of your three tests genuinely fail against main.

One follow-up we'll track on our side, not yours: in a no-delta session with tool use, the first-text guard keeps only the first assistant message's text - strictly better than today's empty response, and the same shape the Claude provider lives with, but a text-replaces-on-message-boundary refinement in useAIChat would improve both providers. Merging - excellent first contribution.

@backnotprop
backnotprop merged commit 6cf9223 into backnotprop:main Sep 10, 2026
24 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants