Skip to content

feat(docs): user feedback + surfaced error frames in docs ask widget#23288

Merged
critesjosh merged 1 commit into
nextfrom
cb/0334e56dbe63
May 14, 2026
Merged

feat(docs): user feedback + surfaced error frames in docs ask widget#23288
critesjosh merged 1 commit into
nextfrom
cb/0334e56dbe63

Conversation

@AztecBot
Copy link
Copy Markdown
Collaborator

@AztecBot AztecBot commented 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.jsxthumbUp/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.jsxhandleFeedback, 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

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 · group: slackbot

@AztecBot AztecBot added the claudebox Owned by claudebox. it can push to this PR. label May 14, 2026
@critesjosh critesjosh marked this pull request as ready for review May 14, 2026 18:31
@critesjosh critesjosh self-assigned this May 14, 2026
@critesjosh critesjosh enabled auto-merge May 14, 2026 18:38
## 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`*
@critesjosh critesjosh added this pull request to the merge queue May 14, 2026
Merged via the queue into next with commit 9047030 May 14, 2026
21 checks passed
@critesjosh critesjosh deleted the cb/0334e56dbe63 branch May 14, 2026 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

claudebox Owned by claudebox. it can push to this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants