diff --git a/backend/src/routes/settings.ts b/backend/src/routes/settings.ts
index 2e4e91f4..665c070a 100644
--- a/backend/src/routes/settings.ts
+++ b/backend/src/routes/settings.ts
@@ -138,6 +138,9 @@ export function createSettingsRoutes(db: Database) {
if (error instanceof z.ZodError) {
return c.json({ error: 'Invalid config data', details: error.issues }, 400)
}
+ if (error instanceof Error && error.message.includes('already exists')) {
+ return c.json({ error: error.message }, 409)
+ }
return c.json({ error: 'Failed to create OpenCode config' }, 500)
}
})
diff --git a/backend/src/services/settings.ts b/backend/src/services/settings.ts
index 108c6ab8..e6886262 100644
--- a/backend/src/services/settings.ts
+++ b/backend/src/services/settings.ts
@@ -156,6 +156,12 @@ export class SettingsService {
request: CreateOpenCodeConfigRequest,
userId: string = 'default'
): OpenCodeConfigWithRaw {
+ // Check for existing config with the same name
+ const existing = this.getOpenCodeConfigByName(request.name, userId)
+ if (existing) {
+ throw new Error(`Config with name '${request.name}' already exists`)
+ }
+
const rawContent = typeof request.content === 'string'
? request.content
: JSON.stringify(request.content, null, 2)
diff --git a/frontend/src/components/message/MessagePart.tsx b/frontend/src/components/message/MessagePart.tsx
index 4522a4b4..b138371d 100644
--- a/frontend/src/components/message/MessagePart.tsx
+++ b/frontend/src/components/message/MessagePart.tsx
@@ -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 ? (
diff --git a/frontend/src/components/message/TextPart.tsx b/frontend/src/components/message/TextPart.tsx
index bf25d18e..d207f63a 100644
--- a/frontend/src/components/message/TextPart.tsx
+++ b/frontend/src/components/message/TextPart.tsx
@@ -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) {
diff --git a/frontend/src/components/settings/CreateConfigDialog.tsx b/frontend/src/components/settings/CreateConfigDialog.tsx
index bcac23c8..0381b321 100644
--- a/frontend/src/components/settings/CreateConfigDialog.tsx
+++ b/frontend/src/components/settings/CreateConfigDialog.tsx
@@ -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
diff --git a/frontend/src/contexts/TTSContext.tsx b/frontend/src/contexts/TTSContext.tsx
index 91cedeaf..2791f41e 100644
--- a/frontend/src/contexts/TTSContext.tsx
+++ b/frontend/src/contexts/TTSContext.tsx
@@ -31,6 +31,7 @@ export function TTSProvider({ children }: TTSProviderProps) {
const [state, setState] = useState('idle')
const [error, setError] = useState(null)
const [currentText, setCurrentText] = useState(null)
+ const [originalText, setOriginalText] = useState(null)
const abortControllerRef = useRef(null)
const audioRef = useRef(null)
@@ -67,6 +68,7 @@ export function TTSProvider({ children }: TTSProviderProps) {
cleanup()
setState('idle')
setCurrentText(null)
+ setOriginalText(null)
setError(null)
}, [cleanup])
@@ -240,7 +242,7 @@ export function TTSProvider({ children }: TTSProviderProps) {
stoppedRef.current = false
setError(null)
- // Store the sanitized text for playback
+ setOriginalText(text)
setCurrentText(sanitizedText)
abortControllerRef.current = new AbortController()
@@ -257,6 +259,7 @@ export function TTSProvider({ children }: TTSProviderProps) {
state,
error,
currentText,
+ originalText,
isEnabled,
isPlaying: state === 'playing',
isLoading: state === 'loading',
diff --git a/frontend/src/contexts/tts-context.ts b/frontend/src/contexts/tts-context.ts
index fe05a101..9889f70b 100644
--- a/frontend/src/contexts/tts-context.ts
+++ b/frontend/src/contexts/tts-context.ts
@@ -8,6 +8,7 @@ export interface TTSContextValue {
state: TTSState
error: string | null
currentText: string | null
+ originalText: string | null
isEnabled: boolean
isPlaying: boolean
isLoading: boolean
diff --git a/frontend/src/hooks/useRemoveMessage.ts b/frontend/src/hooks/useRemoveMessage.ts
index 629478e3..76bb78e0 100644
--- a/frontend/src/hooks/useRemoveMessage.ts
+++ b/frontend/src/hooks/useRemoveMessage.ts
@@ -1,6 +1,6 @@
import { useMutation, useQueryClient } from '@tanstack/react-query'
import { createOpenCodeClient } from '@/api/opencode'
-import { toast } from '@/lib/toast'
+import { showToast } from '@/lib/toast'
import type { MessageListResponse } from '@/api/types'
interface UseRemoveMessageOptions {
@@ -46,7 +46,7 @@ export function useRemoveMessage({ opcodeUrl, sessionId, directory }: UseRemoveM
)
}
- toast.error('Failed to remove message')
+ showToast.error('Failed to remove message')
},
onSuccess: () => {
queryClient.invalidateQueries({
@@ -117,7 +117,7 @@ export function useRefreshMessage({ opcodeUrl, sessionId, directory }: UseRefres
},
onError: (error) => {
console.error('Failed to refresh message:', error)
- toast.error('Failed to refresh message')
+ showToast.error('Failed to refresh message')
}
})
}
\ No newline at end of file
diff --git a/frontend/src/lib/utils.test.ts b/frontend/src/lib/utils.test.ts
index d34ba456..5dee401a 100644
--- a/frontend/src/lib/utils.test.ts
+++ b/frontend/src/lib/utils.test.ts
@@ -71,7 +71,7 @@ describe('sanitizeForTTS', () => {
it('should return empty string for empty input', () => {
expect(sanitizeForTTS('')).toBe('')
expect(sanitizeForTTS(' ')).toBe('')
- expect(sanitizeForTTS(null as any)).toBe('')
+ expect(sanitizeForTTS(null as unknown as string)).toBe('')
})
it('should handle headers and lists combined', () => {