feat(docs): user feedback + surfaced error frames in docs ask widget#23288
Merged
Conversation
critesjosh
approved these changes
May 14, 2026
## Summary
Two small changes to the `AztecDocsWidget` (the in-docs "Ask Aztec" panel that talks to honk-ai):
### 1. User feedback (thumbs up / down on assistant replies)
After an assistant message finishes streaming, render thumbs-up / thumbs-down buttons. Clicking one POSTs to `${apiHost}/api/feedback` with `{ conversation_id, question_index, feedback: "like" | "dislike", api_key }` (matching honk-ai's existing `SubmitFeedback` route in `application/api/answer/routes/feedback.py`). The choice is locked client-side (`feedbackByIndex` per-message-index) so a user can vote once; both buttons become disabled after the first vote, with the active choice highlighted.
Files:
- `docs/src/components/AztecDocsWidget/Icons.jsx` — `thumbUp`/`thumbDown` SVGs.
- `docs/src/components/AztecDocsWidget/Message.jsx` — feedback row, only for assistant messages with a non-empty `response`, hidden while streaming.
- `docs/src/components/AztecDocsWidget/Panel.jsx` — passes the `onFeedback` callback down.
- `docs/src/components/AztecDocsWidget/index.jsx` — `handleFeedback`, marks the message as voted optimistically and short-circuits repeat clicks. On POST failure, the optimistic mark is reverted and an inline "Couldn't save feedback." note is shown so the user can retry.
- `docs/src/components/AztecDocsWidget/sendFeedback.js` — small fetch helper that throws on non-2xx so the caller can surface the failure.
### 2. Surface backend errors to the user
honk-ai PR #129 changed `complete_stream` to emit a `type: "error"` SSE frame with the sanitized real cause (timeout / 429 / 503 / …) instead of the generic "Please try again later". The docs widget previously consumed only `answer` / `source` / `id` / `end` frames and silently dropped `error` frames. This PR adds an `onError` path:
- `streamAnswer.js` — branch on `type === "error"` and invoke a new `onError(message)` callback, reading `parsed.error` to match honk-ai's frame shape (`{"type": "error", "error": "..."}`).
- `index.jsx` — store the error on the active assistant message as `error: <text>`, stop the streaming spinner.
- `Message.jsx` — when `message.error` is set, render the body inside a vermillion `[error]` alert box so the user actually sees what went wrong (rate limit, upstream timeout, etc.) instead of a stalled empty bubble.
Together with honk-ai #129 this means: backend failures now reach the docs widget user with a real, actionable cause; and we start collecting per-message feedback signal from the docs surface.
## Related
- honk-ai #129 (server-side error relay + per-message logging) — required for the error path to deliver useful messages.
- Thread context: docs-widget gap identified in the activity report (https://gist.github.com/AztecBot/4932e495f8d622cc3c82c1776e37f891).
## Test plan
- [ ] `yarn workspace docs start` and exercise the widget: trigger a normal answer, click thumbs up/down, verify a POST to `/api/feedback` with the expected payload and that both buttons lock after one click.
- [ ] Click the opposite thumb after voting; verify nothing happens (no second POST, state unchanged).
- [ ] Simulate a backend error frame (e.g. point widget at a stub that emits `{"type":"error","error":"upstream timeout"}`); verify the vermillion alert renders with the real text and the spinner stops.
- [ ] Simulate a feedback POST failure (e.g. 500); verify the "Couldn't save feedback." note renders and the user can re-vote.
---
*Created by [claudebox](https://claudebox.work/v2/sessions/0334e56dbe6330cd) · group: `slackbot`*
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two small changes to the
AztecDocsWidget(the in-docs "Ask Aztec" panel that talks to honk-ai):1. User feedback (thumbs up / down on assistant replies)
After an assistant message finishes streaming, render thumbs-up / thumbs-down buttons. Clicking one POSTs to
${apiHost}/api/feedbackwith{ conversation_id, question_index, feedback: "like" | "dislike", api_key }(matching honk-ai's existingSubmitFeedbackroute inapplication/api/answer/routes/feedback.py). The choice is locked client-side (feedbackByIndexper-message-index) so a user can vote once; both buttons become disabled after the first vote, with the active choice highlighted.Files:
docs/src/components/AztecDocsWidget/Icons.jsx—thumbUp/thumbDownSVGs.docs/src/components/AztecDocsWidget/Message.jsx— feedback row, only for assistant messages with a non-emptyresponse, hidden while streaming.docs/src/components/AztecDocsWidget/Panel.jsx— passes theonFeedbackcallback down.docs/src/components/AztecDocsWidget/index.jsx—handleFeedback, marks the message as voted optimistically and short-circuits repeat clicks. On POST failure, the optimistic mark is reverted and an inline "Couldn't save feedback." note is shown so the user can retry.docs/src/components/AztecDocsWidget/sendFeedback.js— small fetch helper that throws on non-2xx so the caller can surface the failure.2. Surface backend errors to the user
honk-ai PR #129 changed
complete_streamto emit atype: "error"SSE frame with the sanitized real cause (timeout / 429 / 503 / …) instead of the generic "Please try again later". The docs widget previously consumed onlyanswer/source/id/endframes and silently droppederrorframes. This PR adds anonErrorpath:streamAnswer.js— branch ontype === "error"and invoke a newonError(message)callback, readingparsed.errorto match honk-ai's frame shape ({"type": "error", "error": "..."}).index.jsx— store the error on the active assistant message aserror: <text>, stop the streaming spinner.Message.jsx— whenmessage.erroris set, render the body inside a vermillion[error]alert box so the user actually sees what went wrong (rate limit, upstream timeout, etc.) instead of a stalled empty bubble.Together with honk-ai #129 this means: backend failures now reach the docs widget user with a real, actionable cause; and we start collecting per-message feedback signal from the docs surface.
Related
Test plan
yarn workspace docs startand exercise the widget: trigger a normal answer, click thumbs up/down, verify a POST to/api/feedbackwith the expected payload and that both buttons lock after one click.{"type":"error","error":"upstream timeout"}); verify the vermillion alert renders with the real text and the spinner stops.Created by claudebox · group:
slackbot