feat: Add huxChat — stream-ready AI chat Alpine.js component#34
feat: Add huxChat — stream-ready AI chat Alpine.js component#34
Conversation
Agent-Logs-Url: https://github.com/markmead/hyperux/sessions/d05ebac7-4d1f-4d9f-8f9a-b6a40ed5130d Co-authored-by: markmead <50486078+markmead@users.noreply.github.com>
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
hyperux | f8896b6 | Commit Preview URL Branch Preview URL |
May 08 2026, 06:14 PM |
Agent-Logs-Url: https://github.com/markmead/hyperux/sessions/d05ebac7-4d1f-4d9f-8f9a-b6a40ed5130d Co-authored-by: markmead <50486078+markmead@users.noreply.github.com>
|
@copilot Nice start – an immediate issue I see is that newlines aren't shown in the chat message. Aside from that, can confirm how the following work?
Some features that would be nice:
Can you think of anything else? |
… huxChat Agent-Logs-Url: https://github.com/markmead/hyperux/sessions/c8a0745e-7462-4906-905d-c7de0b9ae61a Co-authored-by: markmead <50486078+markmead@users.noreply.github.com>
Agent-Logs-Url: https://github.com/markmead/hyperux/sessions/c8a0745e-7462-4906-905d-c7de0b9ae61a Co-authored-by: markmead <50486078+markmead@users.noreply.github.com>
Addressed in commit Newlines fixed — message content now uses Thinking messages — added Thumbs up/down — new Export chat — new Voice — API integration — the
|
|
@copilot Nice, some feedback:
|
…ompts, streaming demo Agent-Logs-Url: https://github.com/markmead/hyperux/sessions/074caaad-67ec-488c-9238-dedc2cd5b28b Co-authored-by: markmead <50486078+markmead@users.noreply.github.com>
Done in
|
There was a problem hiding this comment.
Pull request overview
Adds a new huxChat Alpine.js pattern to HyperUX: an interaction-ready chat scaffold (messages, streaming UX hooks, actions, export, and persisted voice toggle), plus a full demo and documentation page.
Changes:
- Registered new
huxChatAlpine data component inPatternRegistration.astro(state + message lifecycle helpers + demo streaming stub). - Added a complete demo UI (
Chat.astro) showcasing streaming/thinking states, actions (copy/rate/regenerate), export, and voice toggle. - Added a full pattern doc page (
chat.mdx) describing API, options, usage patterns, behavior contract, error handling, and accessibility notes.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
src/components/PatternRegistration.astro |
Registers huxChat and provides the scaffold behavior + demo _simulateResponse() implementation. |
src/components/demos/Chat.astro |
Implements the interactive demo UI used on the pattern page and for copyable snippets. |
src/content/patterns/chat.mdx |
Documents the new chat pattern (API/options/behavior/accessibility) and links the demo. |
|
@copilot Address the PR feedback. |
…generateResponse guard, a11y Agent-Logs-Url: https://github.com/markmead/hyperux/sessions/f74084ea-bcdc-4e3d-8bf0-6c97a1c64d92 Co-authored-by: markmead <50486078+markmead@users.noreply.github.com>
Done in
|
Replace inline SVGs in src/components/demos/Chat.astro with Lucide/Astro icon components (Download, Send, Mic, MicOff, ThumbsUp, ThumbsDown, RefreshCw, Clipboard) and apply several UI refinements: adjust container height/overflow, make message list spacing dynamic, tweak avatar sizes/labels, simplify typing indicator markup, reorder and restyle message action buttons, and update textarea/send button positioning and styles. Also update generated workerd runtime comment in worker-configuration.d.ts to a newer version.
Replace inline <svg> markup in Combobox, Dialog, and Dropdown demos with lucide/astro icon components. Adds imports for X and ChevronDown, swaps SVG blocks for <X /> and <ChevronDown /> (preserving bindings like x-bind:class), and adjusts size classes for the Combobox clear button for consistent styling and simpler markup.
| const thinkingInterval = setInterval(() => { | ||
| stepIndex = (stepIndex + 1) % thinkingSteps.length | ||
| this.thinkingMessage = thinkingSteps[stepIndex] | ||
| }, 3000) |
| link.click() | ||
|
|
||
| URL.revokeObjectURL(url) |
| `huxChat` is a logic scaffold for ChatGPT/Claude-style UIs. It manages a message thread, loading state, input handling, message actions, suggested prompts, thinking messages, response rating, chat export, and a voice toggle — without coupling you to any specific backend or streaming protocol. | ||
|
|
||
| Replace the `_simulateResponse()` call in `sendMessage()` and `regenerateResponse()` with your own `fetch`/SSE/WebSocket logic to connect to any AI backend. | ||
|
|
|
@copilot Address the feedback, but instead of making the |
… constraints note Agent-Logs-Url: https://github.com/markmead/hyperux/sessions/ca190480-a69d-4d3a-b8ab-4dd6c454adc7 Co-authored-by: markmead <50486078+markmead@users.noreply.github.com>
Done in
|
Introduces
huxChat, a logic scaffold for ChatGPT/Claude-style UIs. Covers the full interaction surface — message thread, live streaming, input handling, message actions, suggested prompts, thinking messages, response rating, chat export, and persisted voice toggle — without coupling to any backend.Registration (
PatternRegistration.astro)New
huxChatRegistrationscript block registeringAlpine.data('huxChat', ...):messages[](id,role,content,status: 'sending'|'complete'|'error',rating: 'up'|'down'|null),isLoading,inputValue,suggestedPrompts[],isVoiceEnabled,thinkingMessagesendMessage()— guards on empty input +isLoading; appends user message; calls response handler. Clearly marked API Integration Point. Developers setthis.thinkingMessageat key points in their fetch/SSE handler.scrollToBottom()— defers via$nextTickonx-ref="messageList"handleKeydown(event)—Entersends,Shift+Enterpasses throughcopyToClipboard(id)— writes message content from reactive state vianavigator.clipboard(nothuxCopy, which is DOM-source only); the toolbar "Copy Alpine.js + HTML" button useshuxCopyregenerateResponse(id)— splices from the target index and re-invokes the response handlerrateMessage(id, rating)— setsmessage.ratingto'up'or'down'; calling again with the same rating toggles it back tonullexportChat()— collects allcompletemessages, formats asYou: …/Assistant: …plain text, and triggers achat-export.txtdownload via Blob URLtoggleVoice()— flipsisVoiceEnabled, persists tolocalStorageunderhux-chat:voice-enabled; component manages state only — developers wire their own TTS callselectSuggestedPrompt(prompt)— fillsinputValueand callssendMessage()_simulateResponse()— demo stub that shows thinking messages for 1.5s (cycling every 3s), then streams a contextual response word-by-word at ~55ms/word; explicitly documented as the replacement point for real fetch/SSE/WebSocket logicDemo (
src/components/demos/Chat.astro)Working demo UI: scrollable
role="log"message list witharia-live="polite", user/assistant bubbles,whitespace-pre-wrapon message content for correct newline rendering, animated typing indicator with livethinkingMessagetext (cycles every 3s), word-by-word streaming simulation that demonstrates the real streaming UX, always-visible copy/thumbs-up/thumbs-down/regenerate actions (rating buttons highlight and reflect state viaaria-pressed), contextual suggested prompts on empty state ('What can this chat scaffold do?','Explain how streaming works here','How do I connect this to an API?'), auto-expanding textarea, export button (disabled when no complete messages), andaria-pressedvoice toggle.Docs (
src/content/patterns/chat.mdx)Full pattern page following HyperUX conventions: API → Options → Quick Start → Common Usage Patterns (API integration, thinking messages, message actions with rating, export, voice toggle) → Behavior Contract → Error Handling → Accessibility Notes → Notes. Includes a note clarifying the
huxCopyvsnavigator.clipboarddistinction for copy actions.