Support hosting the voice/signaling server on a separate host - #7
Merged
Merged
Conversation
The voice WebSocket endpoints (/api/voice-broker, /api/voice-agent) cannot run on Vercel serverless, so voice mode needs a long-lived host (Azure VM). - Client: VITE_VOICE_WS_URL overrides the voice WebSocket base URL so the deployed app can target a dedicated voice server instead of its own host. - Server: VOICE_ALLOWED_ORIGINS allowlists web app origins for the broker's cross-origin WebSocket handshake, keeping the same-origin default intact. - Document the Azure split and VM requirements in docs/azure-voice-server.md. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G44QpwoYEKBiJAVActtSPp
- PDF viewer: serve pdf.js cMaps + standard fonts (new vite plugin) so Japanese/CJK PDFs render their text instead of blank pages. - Chat: render markdown live while streaming (no raw-syntax flash), with throttled ~20fps commits so parsing stays smooth on long answers. - Language: replies now follow the language of the user's message instead of being forced to the app UI language. - Mermaid: cohesive base theme (dark zinc for chat, light for revision books), pill edge labels, rounded nodes, wider spacing, CJK-safe fonts. - Home: remove the intro card panel background/overlays that separated the navbar and settings icon; pin carousel dots to the bottom, aligned with the chat button; unify page background tone. - Web images: genmoji-style materialize animation (blur condense, light sweep, halo) with stagger and reduced-motion support. - Read Aloud: fall back to browser speech synthesis when server TTS keys are missing, and route CJK text away from English-only Deepgram voices; stop control cancels browser speech too. - Chat actions: remove Add to Graph (keep Create Flashcard + Read Aloud). - Library Context dropdown: full chat-bar-width panel with scroll instead of a narrow popover. - Revision books: enforce a student-revision chapter format (TL;DR quote, key ideas, worked example, common mistakes, self-check) plus blockquote callouts and tighter heading rhythm; flashcard prompt now generates atomic recall cards in the source language; larger flashcard. - Tests: drop Add to Graph cases, fix duplicate-text query in revision flow test. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G44QpwoYEKBiJAVActtSPp
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR primarily enables running the voice/signaling WebSocket endpoints on a separate long-lived host (e.g. Azure VM) while keeping the web app on Vercel, by adding a client-side WebSocket base URL override and a server-side origin allowlist for cross-origin WS handshakes. It also includes several additional UI/UX, PDF rendering, Mermaid theming, and test updates.
Changes:
- Add
VITE_VOICE_WS_URLsupport in the client so voice sockets can target a dedicated voice server host. - Add
VOICE_ALLOWED_ORIGINSallowlist on the server to permit cross-origin WebSocket handshakes for/api/voice-brokerwhile keeping same-origin behavior by default. - Add pdf.js CJK asset serving/copying and various UI/mermaid/TTS behavior updates with corresponding test adjustments.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| vite.config.ts | Adds a Vite plugin to serve/copy pdf.js cMaps and standard fonts into the build output. |
| src/components/PdfViewer.tsx | Configures react-pdf/pdf.js to use cMaps and standard fonts from /pdfjs-assets/.... |
| src/components/ChatPanel.tsx | Adds configurable voice WS base URL, updates Mermaid theming/styling, adjusts streamed markdown rendering, updates Read Aloud fallback behavior, and removes “Add to Graph”. |
| server.ts | Adds VOICE_ALLOWED_ORIGINS allowlist support and updates prompt/system-instruction behavior. |
| docs/azure-voice-server.md | Documents the Vercel (web) + Azure VM (voice WS) split and deployment requirements. |
| .env.example | Documents and adds VITE_VOICE_WS_URL and VOICE_ALLOWED_ORIGINS example entries. |
| src/views/StudyView.tsx | Adjusts StudyView layout/styling. |
| src/views/RevisionView.tsx | Updates Mermaid initialization and various RevisionView UI styles/markdown component rendering. |
| tests/rendered-revision-flows.test.tsx | Updates assertion to handle multiple “Retrieval Practice” occurrences. |
| tests/rendered-chatpanel-expanded.test.tsx | Updates tests to reflect removal of “Add to Graph” and removes the related follow-up request test. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+949
to
+953
| if (configured) { | ||
| return configured | ||
| .replace(/^https:/i, "wss:") | ||
| .replace(/^http:/i, "ws:") | ||
| .replace(/\/+$/, ""); |
Comment on lines
+15
to
+18
| // pdf.js needs its cMaps (CJK character maps) and standard fonts served as | ||
| // static files or Japanese/Chinese/Korean PDFs render without any text. This | ||
| // serves them from node_modules in dev and copies them into dist on build. | ||
| const pdfjsAssetsPlugin = (): Plugin => { |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The voice WebSocket endpoints (/api/voice-broker, /api/voice-agent) cannot
run on Vercel serverless, so voice mode needs a long-lived host (Azure VM).
deployed app can target a dedicated voice server instead of its own host.
cross-origin WebSocket handshake, keeping the same-origin default intact.
Co-Authored-By: Claude Fable 5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01G44QpwoYEKBiJAVActtSPp