Repository navigation
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Contributor
|
👋 Thanks for the contribution! LibreChat merges all changes into Nothing is needed from you; your commits, reviews and discussion are unchanged. If the diff now shows files you did not touch, rebase onto git remote add upstream https://github.com/LibreChat-AI/LibreChat.git
git fetch upstream dev
git rebase upstream/dev
git push --force-with-leaseMaintainers: apply the |
This branch has not been 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.
Impact
With "Cache TTS" enabled, clicking read-aloud on a message plays the audio of a different message whenever both messages start with a Markdown heading. Markdown answers with headings are the common case for an assistant, so this breaks the feature exactly where it matters most.
Cause
In
client/src/hooks/Input/useTextToSpeechExternal.ts, audio is stored withcache.put(new Request(inputText), response)and looked up withcaches.match(text)— the raw message text doubles as the cache key. The Cache API parses that string as a URL against the document base (<base href="/">) and ignores the fragment when matching. A message starting with#therefore keys to the site base URL whatever its content, and every such message shares one cache entry: the first audio stored is served for all of them. Text with#later (a heading after the first paragraph) collides with any other text sharing the same prefix up to that#;?or:early in the text mis-parse as query or scheme.Verified with a Node repro of the Cache API's key derivation (
new URL(text, base)with fragment stripped): two distinct messages starting with## R..ponse courteboth key tohttps://chat.example/— collision confirmed.Fix
Key the cache by a hash of
voice + text(getTTSCacheKey, FNV-1a) instead of the raw text, at both thecache.putandcaches.matchsites. The same repro shows the two messages now key to distinct entries (tts-audio-a8f33905vstts-audio-7601e7f4), the key is stable for the same text + voice, and it changes with the voice so switching voices does not serve stale audio. The key is a plain relative path, so it resolves cleanly as a Request URL.Fixes #16879.