mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
Fix TTS sanitization and message handling bugs
- Add duplicate config validation to backend - Fix TTS button comparison using original text - Track original vs sanitized text in TTS context - Update toast import in message hooks - Add type safety for error handling
This commit is contained in:
1 parent
698ad7b020
commit
44240f0aab
9 files changed
+23
-10
No files matched your search
@@ -65,13 +65,13 @@ interface TTSButtonProps {
|
||||
}
|
||||
|
||||
export function TTSButton({ content, className = "" }: TTSButtonProps) {
|
||||
const { speak, stop, isEnabled, isPlaying, isLoading, currentText } = useTTS()
|
||||
const { speak, stop, isEnabled, isPlaying, isLoading, originalText } = useTTS()
|
||||
|
||||
if (!isEnabled || !content.trim()) {
|
||||
return null
|
||||
}
|
||||
|
||||
const isThisPlaying = (isPlaying || isLoading) && currentText === content
|
||||
const isThisPlaying = (isPlaying || isLoading) && originalText === content
|
||||
|
||||
const handleClick = () => {
|
||||
if (isThisPlaying) {
|
||||
@@ -86,7 +86,7 @@ export function TTSButton({ content, className = "" }: TTSButtonProps) {
|
||||
onClick={handleClick}
|
||||
className={`p-1.5 rounded ${isThisPlaying ? 'bg-red-500/20 text-red-500 hover:bg-red-500/30' : 'bg-card hover:bg-card-hover text-muted-foreground hover:text-foreground'} ${className}`}
|
||||
title={isThisPlaying ? "Stop playback" : "Read aloud"}
|
||||
disabled={isLoading && currentText !== content}
|
||||
disabled={isLoading && originalText !== content}
|
||||
>
|
||||
{isLoading && isThisPlaying ? (
|
||||
<Loader2 className="w-4 h-4 animate-spin" />
|
||||
|
||||
@@ -243,7 +243,7 @@ export function TextPart({ part }: TextPartProps) {
|
||||
remarkPlugins={[remarkGfm]}
|
||||
rehypePlugins={[rehypeHighlight, rehypeRaw]}
|
||||
components={{
|
||||
code({ className, children, node, ...props }) {
|
||||
code({ className, children, ...props }) {
|
||||
const isInline = !className || !className.includes('language-')
|
||||
|
||||
if (className?.includes('language-mermaid') && mermaidComplete) {
|
||||
|
||||
@@ -36,7 +36,7 @@ export function CreateConfigDialog({ isOpen, onOpenChange, onCreate, isUpdating
|
||||
setIsDefault(false)
|
||||
setError('')
|
||||
setErrorLine(null)
|
||||
} catch (error) {
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof SyntaxError) {
|
||||
const match = error.message.match(/line (\d+)/i)
|
||||
const line = match ? parseInt(match[1]) : null
|
||||
|
||||
Reference in new issue
Block a user