Skip to content

feat: add privacy policy notice to chat interface - #192

Merged
HardeepAsrani merged 9 commits into
developmentfrom
feat/chat-privacynotice
Jul 8, 2026
Merged

feat: add privacy policy notice to chat interface#192
HardeepAsrani merged 9 commits into
developmentfrom
feat/chat-privacynotice

Conversation

@HardeepAsrani

@HardeepAsrani HardeepAsrani commented Jul 4, 2026

Copy link
Copy Markdown
Member

What this adds

A small, dismissible privacy notice in the chat widget "By chatting, you agree to our Privacy Policy." shown just above the input, with a shield icon and a close button.

This is the chat-UI follow-up to Codeinwp/hyve#250 (the disclosure side was handled in #187; this surfaces it inside the widget, like many chatbots do).

Base branch: this targets feat/streaming-responses. Please merge that first.

Screenshot 2026-07-04 at 5 46 03 AM

Behavior

  • Off by default. Enable it under Settings → General → “Privacy Notice.”
  • Links to your Privacy Policy page (the one set under Settings → Privacy). If no page is set, the notice is hidden entirely and the dashboard shows a warning under the toggle pointing you to Settings → Privacy.
  • Theme-aware label, link, and close button follow the chat’s colors (works on light and dark chat backgrounds).
  • Free version: while the notice shows it takes the place of the “Powered by Hyve” credit; once dismissed, the credit appears above the input.
  • Dismissal is remembered per browser the notice goes away when the visitor clicks the ✕ or sends their first message, and doesn’t come back.

For developers

  • hyve_privacy_notice_text — the notice sentence (keep a single %s for the link).
  • hyve_privacy_notice_link_text — the linked label (default “Privacy Policy”).
  • hyve_privacy_notice_url — the link target (defaults to get_privacy_policy_url()).

Tests

  • PHP unit coverage for the setting, frontend data, URL resolution, and filters (tests/php/unit/tests/test-privacy-notice.php).
  • Playwright e2e for render/no-render states, dismiss + persistence, and dismiss-on-send (tests/e2e/specs/privacy-notice.spec.js).

Manual QA

Prerequisite: set a Privacy Policy page under Settings → Privacy, and have an OpenAI key configured so the chat renders.

  1. Enable it. Go to Settings → General, set “Privacy Notice” to Enable, save. Open the chat on the front end → the notice appears above the input with a shield icon and the linked “Privacy Policy”.
  2. Link works. Click “Privacy Policy” → it opens your policy page in a new tab.
  3. Dismiss via ✕. Click the close button → the notice disappears; in the free version the “Powered by Hyve” credit now shows above the input. Reload → the notice stays gone.
  4. Dismiss by chatting. Clear the browser’s local storage (or use a fresh browser), reload with the notice showing, send a message → the notice disappears on send and stays gone on reload.
  5. No policy page. Under Settings → Privacy, unset the policy page (or use a site without one) → the notice no longer appears on the front end, and Settings → General shows a warning under the toggle linking to Settings → Privacy.
  6. Theming. Under Settings → Appearance, set a dark chat background → confirm the notice text, link, and ✕ stay readable.
  7. Off state. Set “Privacy Notice” back to Disable, save → the notice no longer appears and the “Powered by Hyve” credit shows normally.

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>
Adds an optional, dismissible privacy notice above the chat input that
links to the site's Privacy Policy page. Off by default, toggled from
Settings > General, and hidden when no policy page is set (with an admin
warning). The notice is theme-aware and, in the free version, replaces
the 'Powered by Hyve' credit until dismissed. Dismissal (via the close
button or sending a message) is remembered per browser.

Includes PHP unit and Playwright e2e coverage.
@HardeepAsrani
HardeepAsrani requested a review from abaicus July 4, 2026 00:41
@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown

Plugin build for 144849d 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

…acynotice

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 144849d.

@HardeepAsrani

Copy link
Copy Markdown
Member Author

@copilot resolve the merge conflicts in this pull request and fix possible JSLint/PhpLint and PHPCS errors.

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 and fix possible JSLint/PhpLint and PHPCS errors.

Addressed in 672255a. I verified there are no remaining conflict markers locally, fixed the JS lint failure in src/frontend/App.js, and re-ran npm run lint:js, composer run lint, and npm run build:frontend successfully.

@HardeepAsrani

Copy link
Copy Markdown
Member Author

@copilot resolve the merge conflicts in this pull request

…acynotice

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

Addressed in 88fb6ea.

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