Refactor TTS into FloatingTTSButton component with amber/orange styling (#162)

This commit is contained in:
Chris Scott authored and GitHub committed 2026-03-21 00:06:02 -04:00
1 parent b9b5d50643
commit 2e634b5362
3 files changed
+63 -24

No files matched your search

@@ -1,8 +1,7 @@
import { memo } from 'react'
import type { components } from '@/api/opencode-types'
import { Volume2, Loader2 } from 'lucide-react'
import { Volume2, VolumeX, Loader2 } from 'lucide-react'
import { TextPart } from './TextPart'
import { SquareFill } from '@/components/ui/square-fill'
import { PatchPart } from './PatchPart'
import { ToolCallPart } from './ToolCallPart'
import { RetryPart } from './RetryPart'
@@ -59,14 +58,12 @@ function getCopyableContent(part: Part, allParts?: Part[]): string {
}
}
interface TTSButtonProps {
content: string
className?: string
}
export function TTSButton({ content, className = "" }: TTSButtonProps) {
function TTSButton({ content, className = "" }: TTSButtonProps) {
const { speak, stop, isEnabled, isPlaying, isLoading, originalText } = useTTS()
if (!isEnabled || !content.trim()) {
@@ -93,7 +90,7 @@ export function TTSButton({ content, className = "" }: TTSButtonProps) {
{isLoading && isThisPlaying ? (
<Loader2 className="w-4 h-4 animate-spin" />
) : isThisPlaying ? (
<SquareFill className="w-4 h-4" />
<VolumeX className="w-4 h-4" />
) : (
<Volume2 className="w-4 h-4" />
)}
@@ -101,8 +98,6 @@ export function TTSButton({ content, className = "" }: TTSButtonProps) {
)
}
export const MessagePart = memo(function MessagePart({ part, role, allParts, partIndex, onFileClick, onChildSessionClick, messageTextContent }: MessagePartProps) {
const copyableContent = getCopyableContent(part, allParts)
const isMobile = useMobile()