Skip to content

feat(ask): pi-web-native ask_user_question with multi-select#37

Merged
setkyar merged 1 commit into
mainfrom
feature/questions
Jun 3, 2026
Merged

feat(ask): pi-web-native ask_user_question with multi-select#37
setkyar merged 1 commit into
mainfrom
feature/questions

Conversation

@setkyar
Copy link
Copy Markdown
Contributor

@setkyar setkyar commented Jun 3, 2026

Summary

pi-web previously relied on a third-party ask_user_question provider that
crashes in the headless RPC worker (it calls ctx.ui.custom(), which returns
undefined in RPC mode). This PR makes the interactive question card a
first-class, self-contained pi-web feature.

  • Add a bundled pi-ask extension (.pi/extensions/pi-ask.ts) that registers
    pi_web_ask_user_question. In RPC mode it records the questions and returns a
    details.awaitingChatReply result telling the model to stop and wait; the
    browser collects the answer and sends it back through the normal chat flow.
  • Honor each question's multiSelect flag in the card (checkbox toggling +
    collect-then-submit) instead of inferring single/multi from question count.
  • Render awaitingChatReply results as pending/clickable so the click-to-chat
    answer flow works; recognize both ask_user_question and
    pi_web_ask_user_question tool names.
  • Steer the model to the pi_web_ prefix via a before_agent_start
    system-prompt nudge plus a tool_call hard-redirect, so a separately
    installed bare ask_user_question is blocked before it can crash.

Related issue

Closes #

Type of change

  • feat — new feature

Live vs. Export

  • Considered both the live app and the export snapshot
  • Kept internal/ui/live_templates/ in sync with web/src/session/ changes
  • No live-only chrome (Vite scripts, active composer, SSE/API) leaked into export

Testing

  • make check passes (test + build + vet)
  • Frontend tests (vitest) cover the change
  • Go tests (go test ./...) cover the change
  • UI changes verified in a browser

Add a bundled pi-ask extension so pi-web ships its own ask_user_question
tool (pi_web_ask_user_question) instead of depending on a third-party
provider that crashes in pi-web's headless RPC worker.

- Honor each question's multiSelect flag in the question card (checkbox
  toggling + collect-then-submit) across all three render paths, instead
  of inferring single/multi from question count.
- Render tool results carrying details.awaitingChatReply as pending and
  clickable so the browser click-to-chat answer flow works.
- Recognize both ask_user_question and pi_web_ask_user_question names.
- Steer the model toward the pi_web_ prefix via a before_agent_start
  system-prompt nudge and a tool_call hard-redirect, avoiding name
  conflicts with other providers.
@setkyar setkyar merged commit 768e7d2 into main Jun 3, 2026
2 checks passed
@setkyar setkyar deleted the feature/questions branch June 3, 2026 10:21
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.

1 participant