Skip to content

Add reply-data filter and generic suggestion rendering - #198

Merged
HardeepAsrani merged 7 commits into
developmentfrom
feat/follow-up-questions
Jul 8, 2026
Merged

Add reply-data filter and generic suggestion rendering#198
HardeepAsrani merged 7 commits into
developmentfrom
feat/follow-up-questions

Conversation

@HardeepAsrani

@HardeepAsrani HardeepAsrani commented Jul 7, 2026

Copy link
Copy Markdown
Member

What this adds

The Hyve Lite base for per-turn suggestion chips, used by the Pro follow-up questions feature. The generation and UI live in the Pro companion (Codeinwp/hyve#259); this PR is the shared groundwork.

Part of Codeinwp/hyve#184 (closed by the Pro companion PR).

Changes

  • hyve_chat_reply_data filter on both reply paths (the streaming done event in Stream.php and get_chat for the poll fallback), so an extension can attach extra data to a reply. A filter that returns a non-array is ignored on both paths so it cannot corrupt the response.
  • Generic renderSuggestions() in the widget. addSuggestions (predefined questions) and the new per-turn follow-ups now share one renderer: it clears any prior chip row, builds each chip with textContent (not innerHTML) so nothing can inject markup, wires a click to send the question, and scrolls the freshly added chips into view.
  • get_chat now reports success using the same answered decision the streaming path uses, so both paths agree.

Manual QA

  1. Predefined questions still render before the conversation starts and still send on click.
  2. With the Pro branch active, follow-up chips appear under a successful answer, clicking one sends it, and stale chips clear on the next send.
  3. A chip row scrolls into view rather than sitting just below the fold.

HardeepAsrani and others added 6 commits June 29, 2026 06:42
- Redesign the frontend chat widget (header with avatar/name/status,
  modern bubbles, pill input, refined launcher, entrance animation).
- Add a global "Chat Sound" toggle and a per-visitor mute control in the
  chat menu; remove the open/close click sound.
- Add a "Message Timestamp" show/hide toggle.
- Show the welcome message and suggested questions on first load of the
  inline chat block.
- Inline the chat-button SVGs server-side (no runtime fetch / icon flash)
  and use a bundled SVG as the default icon instead of an emoji.
- Keep the typing dots, suggestion chips, and menu legible on similar
  colors, and theme the menu from the chat colors.
- Resolve outstanding PHPStan issues (gmdate guard, require_once ignore).
Reveal the assistant's reply progressively over Server-Sent Events, with a
graceful fallback to the existing background + polling flow on hosts that
buffer or cannot stream, so the bot keeps working everywhere.

- Add a custom admin-ajax streaming endpoint (Stream) that proxies OpenAI's
  stream to the browser; the API key stays server-side.
- Share a single prompt, JSON schema and response interpreter across the
  streaming and poll paths so replies never diverge by transport.
- The widget tries streaming first and falls back to polling when no event
  arrives in time; the outcome is cached per browser and re-probed after 24h.
- Decode the streamed `response` field incrementally via json_decode so
  escapes and surrogate-pair emoji render correctly while streaming.
- Preserve existing contracts: moderation stays up front, hyve_chat_request
  and hyve_chat_response fire once per reply, analytics unaffected.

Closes Codeinwp/hyve#183
- Redesign the frontend chat widget (header with avatar/name/status,
  modern bubbles, pill input, refined launcher, entrance animation).
- Add a global "Chat Sound" toggle and a per-visitor mute control in the
  chat menu; remove the open/close click sound.
- Add a "Message Timestamp" show/hide toggle.
- Show the welcome message and suggested questions on first load of the
  inline chat block.
- Inline the chat-button SVGs server-side (no runtime fetch / icon flash)
  and use a bundled SVG as the default icon instead of an emoji.
- Keep the typing dots, suggestion chips, and menu legible on similar
  colors, and theme the menu from the chat colors.
- Resolve outstanding PHPStan issues (gmdate guard, require_once ignore).
# Conflicts:
#	inc/Main.php
#	src/frontend/App.js

Co-authored-by: HardeepAsrani <2649903+HardeepAsrani@users.noreply.github.com>
…g-responses

Co-authored-by: HardeepAsrani <2649903+HardeepAsrani@users.noreply.github.com>
Add the hyve_chat_reply_data filter on both the streaming and poll reply
paths so extensions can attach extra data to a reply, and generalize the
frontend suggestion rendering into renderSuggestions so per-turn chips
reuse the predefined-questions UI. Chips are built with textContent to
avoid markup injection and scrolled into view after the reply lands.

Part of Codeinwp/hyve#184.
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

Plugin build for 8ae4501 is ready 🛎️!

@HardeepAsrani
HardeepAsrani changed the base branch from feat/streaming-responses to development July 8, 2026 20:26
@HardeepAsrani

Copy link
Copy Markdown
Member Author

@copilot resolve the merge conflicts in this pull request

…-questions

Co-authored-by: HardeepAsrani <2649903+HardeepAsrani@users.noreply.github.com>

Copilot AI commented Jul 8, 2026

Copy link
Copy Markdown

@copilot resolve the merge conflicts in this pull request

Resolved in 8ae4501.

@HardeepAsrani
HardeepAsrani merged commit 15ac4e8 into development Jul 8, 2026
7 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.

3 participants