Better Chat 1.0.0-test1
========================

Foundation build combining the stronger Custom Chat MB feature set with a new
theme-adaptive presentation layer designed for SMF 2.1 and Theme Lab themes.

Test1 goals:
- Preserve public chat, online users, private chats, typing/read behavior,
  uploads, persistence, mobile behavior, purge/settings controls.
- Remove the hard-coded light-theme presentation.
- Sample the currently active SMF theme at runtime for surfaces, header,
  text, links, borders, inputs, buttons and radius.
- Keep Better Chat CSS in the default theme so Theme Lab-generated themes do
  not need their own copied BetterChat.css.
- Remove dependency on the old attach.png image.

This is intentionally a test build. Existing chat tables are updated in place.


Test2 attachment restoration
----------------------------
- Restores public and private image attachment controls with delegated JS.
- Adds jpeg/webp support to the default extension set.
- Validates MIME type and upload size server-side.
- Re-creates/checks chat_uploads at upload time and reports permission errors.
- Returns real JSON success/error responses instead of silently reporting success.
- Displays upload progress/success/error feedback beside the compose field.
- Uses a thumbnail when available and falls back to the original image if thumbnail
  generation is unavailable.
- Adds an explicit upgrade path from 1.0.0-test1.


Test3 response-handling fix
---------------------------
- Fixes false "Upload failed" feedback when the image and thumbnail were
  actually uploaded successfully.
- AJAX endpoint now clears buffered markup before emitting JSON.
- Client parses the response defensively and distinguishes transport failures
  from response-format failures.
- Keeps Test2 attachment validation and Theme Lab styling intact.


Test4 duplicate-render + upload progress fix
--------------------------------------------
- Replaces text beside the paperclip with a real upload progress bar below
  the message input.
- Uses XHR upload progress for percentage feedback.
- Success/failure feedback now lives below the input and clears after success.
- Adds PHP and JavaScript one-time guards so Better Chat cannot render or boot
  twice in the same page request.
- Normalizes legacy Custom Chat integration hooks during install/upgrade.
  This addresses the duplicate white + themed chat windows seen after package
  installs and normal page/header navigation.
- Keeps the Test3 upload-response fix intact.


Test5 SMF AJAX ghost-window fix
-------------------------------
- Fixes the duplicate/ghost Forum Chat window that appeared after opening
  Profile, My Messages, Alerts, and during AJAX-driven package/admin actions.
- Better Chat now renders only for complete forum page requests.
- Explicitly skips SMF requests carrying X-SMF-AJAX, ;ajax, ;xml, and Better
  Chat's own action endpoint.
- Retains the Test4 upload progress bar and legacy-hook normalization.
- Restores an explicit application/json response header for chat JSON replies.


Test6 Theme Lab background bridge
---------------------------------
- Fixes chat header and own-message bubbles falling back to generic Curve2 blue.
- Theme bridge now captures both background-color and background-image.
- Theme Lab gradient/header/button treatments therefore carry into Better Chat.
- Keeps Test5 SMF AJAX ghost-window suppression and Test4 upload progress.


Test7 Smart Scroll
------------------
- Public group chat no longer snaps back to the bottom on every AJAX poll.
- If the reader is within 36px of the bottom, new messages continue to follow.
- If the reader scrolls upward, their historical reading position is preserved.
- Initial chat load still opens at the newest message.
- Private chat windows use the same smart-scroll behavior.
- Keeps Test6 Theme Lab colors, Test5 Casper fix, and Test4 upload progress.


Test8 Emoji Studio: Theme-aware Unicode picker, categories, search, recent emojis, cursor insertion, public/private chat.


Test9 Emoji Polish
------------------
- Emoji and attachment triggers now live inside the message input shell.
- Emoji picker closes immediately after an emoji is chosen and returns focus
  to the message field.
- Emoji category strip no longer needs a horizontal scrollbar.
- Emoji grid now scrolls vertically and includes bottom breathing room so the
  last row is never clipped.
- Adds deterministic bubble styling for Chromium/Edge instead of relying on
  fragile cascade/color-mix behavior for the core bubble surfaces.
- Keeps Test8 Emoji Studio, Test7 Smart Scroll, Theme Lab bridge, Casper fix,
  attachments, thumbnails and upload progress.


Test10 Emoji Scroll + Expanded Library
--------------------------------------
- Expands every emoji category substantially so categories contain real
  scrollable libraries instead of only a few visible rows.
- Gives the emoji grid an explicit vertical scroll viewport.
- Adds a visible themed scrollbar in Chromium/Edge/Chrome.
- Keeps Test9 integrated input icons, close-after-selection behavior and
  Edge bubble styling.


Test11 Private Notification Intelligence
----------------------------------------
- Fixes public/group chat header blinking because of new private messages.
  Public header now watches public message IDs only.
- Private chat headers blink only for new incoming private messages.
- Adds optional notification sound for private messages when the private chat
  is not focused or the browser page/tab is not focused.
- Adds optional browser-title blinking while the page is in the background:
  "Hey, you got a message from <name>!"
- Sound and title notifications can be enabled/disabled independently in the
  Better Chat admin settings.
- Notifications are deduplicated by private message ID so polling does not
  replay the same alert every few seconds.
- Returning focus restores the normal browser title.


Test12 Notification Controls + Admin Language
---------------------------------------------
- Admin can customize browser title alert text with {username}; default is
  "{username} has sent you a new message..."
- Adds a master notification-sound setting plus an option allowing members
  to choose their own sound preference.
- Members get a speaker toggle in group and private chat headers when allowed;
  preference is stored locally in that browser.
- Enabling sound from the header plays a short confirmation tone.
- Emoji and attachment actions are visually icon-only: no button box,
  border, shadow, hover fill, or radius.
- Message inputs reserve enough right-side space so text cannot run behind
  the emoji/attachment controls.
- Reworks the English admin language file so section headings, settings,
  purge choices, uploads, and history controls are language-backed.


Test13 Admin Language Load Fix
------------------------------
- Explicitly loads Better Chat language strings before admin settings are built.
- Adds safe English fallbacks for every Better Chat admin setting.
- Clear History callback independently loads its language strings.
- Test12 chat behavior is otherwise unchanged.


Test14 AJAX / Database Hardening
--------------------------------
- Prevents overlapping public polls when a previous AJAX request is still active.
- Prevents duplicate overlapping private polls for the same member.
- Polls multiple open private chats sequentially instead of firing them together.
- Private polls no longer repeat the forum-wide online-member query.
- Auto-purge maintenance runs only from the public poll.
- Replaces setInterval with request-aware scheduling: 5 seconds while visible,
  10 seconds in a background tab, quick refresh on return.
- Consolidates chat JSON exits through the clean Better Chat JSON responder.
- Reduces transient PHP/MySQL connection pressure that can surface as a false
  mysqli handle during aggressive polling.


Test15 Install Screen + Sound Control Fix
-----------------------------------------
- Better Chat is suppressed throughout SMF Package Manager, avoiding the temporary
  Curve2-styled, non-populated chat shell shown during install/extract/upgrade pages.
- Normal forum and admin pages continue to render Better Chat.
- Sound-toggle clicks no longer bubble into group/private header minimize behavior.
- Private chat headers use delegated toggle handling and explicitly ignore sound/close controls.
- Pointer/touch propagation guards stop synthesized mobile clicks from toggling chat state.
- Keeps Test14 AJAX/database hardening intact.


Test16 No-Flash Load
--------------------
- Better Chat is hidden at the HTML level before the browser can paint its
  unstyled/default shell.
- Persisted minimized/maximized state is applied while the widget is hidden.
- Theme Bridge and sound-button state are applied before the widget is revealed.
- The chat becomes visible on the next animation frame only after initialization.
- Prevents the split-second maximized, unstyled/default-font flash between pages
  and during refreshes.
- Keeps Test15 Package Manager suppression and sound-control event isolation.


Test17 Environment, Cache & Video Capabilities
----------------------------------------------
- Adds an Environment & Capabilities panel to Better Chat admin settings.
- Detects active SMF cache API plus Memcached, Memcache, Redis and APCu PHP support.
- Better Chat uses SMF's configured cache API when active; otherwise APCu is used
  when available. It does not guess Memcached/Redis server addresses merely because
  a PHP extension exists.
- Caches the online-user list for 15 seconds to reduce repeated database reads.
- Detects FFmpeg automatically from common paths or PATH, with an admin path override.
- Video attachments are exposed only when enabled, FFmpeg is detected, and PHP exec
  is available.
- Adds MP4/WebM attachment support, configurable video size/extensions, FFmpeg-based
  validation/poster generation, and inline HTML5 video playback.
- Keeps Test16 no-flash initialization and all prior notification/chat behavior.


Test18 Header Minimize Button Fix
---------------------------------
- Restores the dedicated group-chat minimize/maximize button.
- #chat-toggle now has its own isolated click handler instead of being ignored by
  the group-header handler with no follow-up action.
- Button changes from minus to plus while minimized and back to minus when open.
- ARIA label/title follow the current state.
- Header clicks and button clicks keep localStorage minimized state synchronized.
- Pointer/touch propagation remains isolated from the sound button/header.


Test22 Header Minimize Capture Fix
----------------------------------
- Replaces the competing group-header/button toggle paths with one shared toggle routine.
- Binds #chat-toggle directly in the capture phase so header/theme event handlers cannot
  swallow the click before Better Chat receives it.
- Keeps + / minus text, tooltip, ARIA label and localStorage state synchronized for both
  button clicks and normal group-header clicks.
- Preserves the sound-button isolation and all Test18 behavior.
