You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(docs): user feedback + surfaced error frames in docs ask widget (#23288)
## 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`*
0 commit comments