mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
feat(schedules): add read aloud playback to scheduled run reports
This commit is contained in:
1 parent
03500affe8
commit
092add1eb1
5 files changed
+107
-43
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { memo, useCallback, useMemo, useState } from 'react'
|
||||
import { Pencil, Loader2, Volume2, VolumeX } from 'lucide-react'
|
||||
import { Pencil, Loader2 } from 'lucide-react'
|
||||
import { assistantText } from '@opencode-manager/shared/opencode'
|
||||
import type {
|
||||
PromptAgentAttachment,
|
||||
@@ -20,8 +20,8 @@ import { StepFileChanges } from './StepFileChanges'
|
||||
import { UserMessageActionButtons } from './UserMessageActionButtons'
|
||||
import { EditableUserMessage, ClickableUserMessage } from './EditableUserMessage'
|
||||
import { useSettings } from '@/hooks/useSettings'
|
||||
import { useTTS } from '@/hooks/useTTS'
|
||||
import { CopyButton } from '@/components/ui/copy-button'
|
||||
import { TTSButton } from '@/components/ui/tts-button'
|
||||
import { backgroundShellID, collectBackgroundParts, type ShellNoticeOutcome } from '@/lib/backgroundWork'
|
||||
|
||||
function getMessageText(message: SessionMessageInfo): string {
|
||||
@@ -147,46 +147,6 @@ function UserAttachments({ files: attachedFiles, agents: attachedAgents, skills:
|
||||
)
|
||||
}
|
||||
|
||||
interface TTSButtonProps {
|
||||
messageId: string
|
||||
content: string
|
||||
}
|
||||
|
||||
function TTSButton({ messageId, content }: TTSButtonProps) {
|
||||
const { speakMessage, stop, isEnabled, isPlaying, isLoading, activeMessageId } = useTTS()
|
||||
|
||||
if (!isEnabled || !content.trim()) {
|
||||
return null
|
||||
}
|
||||
|
||||
const isThisPlaying = (isPlaying || isLoading) && activeMessageId === messageId
|
||||
|
||||
const handleClick = () => {
|
||||
if (isThisPlaying) {
|
||||
stop()
|
||||
} else {
|
||||
speakMessage(messageId, content)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<button
|
||||
onClick={handleClick}
|
||||
className={`p-1.5 rounded ${isThisPlaying ? 'bg-destructive/20 text-destructive hover:bg-destructive/30' : 'bg-card hover:bg-card-hover text-muted-foreground hover:text-foreground'}`}
|
||||
title={isThisPlaying ? 'Stop playback' : 'Read aloud'}
|
||||
disabled={isLoading && !isThisPlaying}
|
||||
>
|
||||
{isLoading && isThisPlaying ? (
|
||||
<Loader2 className="w-4 h-4 animate-spin" />
|
||||
) : isThisPlaying ? (
|
||||
<VolumeX className="w-4 h-4" />
|
||||
) : (
|
||||
<Volume2 className="w-4 h-4" />
|
||||
)}
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
function MessageDivider({ label }: { label: string }) {
|
||||
return (
|
||||
<div className="flex items-center gap-2 my-1 text-xs text-muted-foreground">
|
||||
|
||||
Reference in new issue
Block a user