diff --git a/frontend/src/components/message/MessagePart.tsx b/frontend/src/components/message/MessagePart.tsx
index aaf68ff3..4522a4b4 100644
--- a/frontend/src/components/message/MessagePart.tsx
+++ b/frontend/src/components/message/MessagePart.tsx
@@ -4,9 +4,12 @@ import { Volume2, Square, Loader2 } from 'lucide-react'
import { TextPart } from './TextPart'
import { PatchPart } from './PatchPart'
import { ToolCallPart } from './ToolCallPart'
+import { RetryPart } from './RetryPart'
import { useTTS } from '@/hooks/useTTS'
import { CopyButton } from '@/components/ui/copy-button'
+type RetryPartType = components['schemas']['RetryPart']
+
type Part = components['schemas']['Part']
interface MessagePartProps {
@@ -152,6 +155,8 @@ export const MessagePart = memo(function MessagePart({ part, role, allParts, par
{part.filename || 'File'}
)
+ case 'retry':
+ return
default:
return
}
diff --git a/frontend/src/components/message/MessageThread.tsx b/frontend/src/components/message/MessageThread.tsx
index 1ca1792e..391dab9a 100644
--- a/frontend/src/components/message/MessageThread.tsx
+++ b/frontend/src/components/message/MessageThread.tsx
@@ -1,4 +1,4 @@
-import { memo } from 'react'
+import { memo, useMemo } from 'react'
import { MessagePart } from './MessagePart'
import type { MessageWithParts } from '@/api/types'
@@ -24,12 +24,24 @@ const isMessageStreaming = (msg: MessageWithParts): boolean => {
return !('completed' in msg.info.time && msg.info.time.completed)
}
-const isMessageThinking = (msg: MessageWithParts): boolean => {
- if (msg.info.role !== 'assistant') return false
- return msg.parts.length === 0 && isMessageStreaming(msg)
+
+
+const findPendingAssistantMessageId = (messages: MessageWithParts[]): string | undefined => {
+ for (let i = messages.length - 1; i >= 0; i--) {
+ const msg = messages[i]
+ if (msg.info.role === 'assistant' && isMessageStreaming(msg)) {
+ return msg.info.id
+ }
+ }
+ return undefined
}
export const MessageThread = memo(function MessageThread({ messages, onFileClick, onChildSessionClick }: MessageThreadProps) {
+ const pendingAssistantId = useMemo(() => {
+ if (!messages) return undefined
+ return findPendingAssistantMessageId(messages)
+ }, [messages])
+
if (!messages || messages.length === 0) {
return (
@@ -42,7 +54,7 @@ export const MessageThread = memo(function MessageThread({ messages, onFileClick
{messages.map((msg) => {
const streaming = isMessageStreaming(msg)
- const thinking = isMessageThinking(msg)
+ const isQueued = msg.info.role === 'user' && pendingAssistantId && msg.info.id > pendingAssistantId
return (
@@ -65,35 +79,28 @@ export const MessageThread = memo(function MessageThread({ messages, onFileClick
{new Date(msg.info.time.created).toLocaleTimeString()}
)}
- {streaming && (
-
- ● Generating...
+ {isQueued && (
+
+ QUEUED
)}
- {thinking ? (
-
- ▋
- Thinking...
-
- ) : (
-
- {msg.parts.map((part, index) => (
-
-
-
- ))}
-
- )}
+
+ {msg.parts.map((part, index) => (
+
+
+
+ ))}
+
)
diff --git a/frontend/src/components/message/PromptInput.tsx b/frontend/src/components/message/PromptInput.tsx
index 277646c7..77d65c04 100644
--- a/frontend/src/components/message/PromptInput.tsx
+++ b/frontend/src/components/message/PromptInput.tsx
@@ -11,6 +11,7 @@ import { ChevronDown } from 'lucide-react'
import { CommandSuggestions } from '@/components/command/CommandSuggestions'
import { MentionSuggestions, type MentionItem } from './MentionSuggestions'
+import { SessionStatusIndicator } from '@/components/ui/session-status-indicator'
import { detectMentionTrigger, parsePromptToParts, getFilename, filterAgentsByQuery } from '@/lib/promptParser'
import { getModel, formatModelName } from '@/api/providers'
import type { components } from '@/api/opencode-types'
@@ -119,6 +120,23 @@ export function PromptInput({
const handleSubmit = () => {
if (!prompt.trim() || disabled) return
+
+ if (hasActiveStream) {
+ const parts = parsePromptToParts(prompt, attachedFiles)
+ sendPrompt.mutate({
+ sessionID,
+ parts,
+ model: currentModel,
+ agent: selectedAgent || currentMode
+ })
+ setPrompt('')
+ setAttachedFiles(new Map())
+ setSelectedAgent(null)
+ if (textareaRef.current) {
+ textareaRef.current.style.height = 'auto'
+ }
+ return
+ }
if (isBashMode) {
const command = prompt.startsWith('!') ? prompt.slice(1) : prompt
@@ -454,16 +472,20 @@ export function PromptInput({
}, [selectedModel, currentModel])
useEffect(() => {
- if (textareaRef.current && !disabled && !hasActiveStream) {
+ if (textareaRef.current && !disabled) {
textareaRef.current.focus()
}
- }, [disabled, hasActiveStream])
+ }, [disabled])
return (
-
+ {hasActiveStream && (
+
+
+
+ )}
)}
+ {hasActiveStream && (
+
+ )}
diff --git a/frontend/src/components/message/ToolCallPart.tsx b/frontend/src/components/message/ToolCallPart.tsx
index 532a93f2..838ca41a 100644
--- a/frontend/src/components/message/ToolCallPart.tsx
+++ b/frontend/src/components/message/ToolCallPart.tsx
@@ -3,7 +3,7 @@ import type { components } from '@/api/opencode-types'
import { useSettings } from '@/hooks/useSettings'
import { useUserBash } from '@/stores/userBashStore'
import { detectFileReferences } from '@/lib/fileReferences'
-import { ExternalLink } from 'lucide-react'
+import { ExternalLink, Loader2 } from 'lucide-react'
import { CopyButton } from '@/components/ui/copy-button'
type ToolPart = components['schemas']['ToolPart']
@@ -87,13 +87,15 @@ export function ToolCallPart({ part, onFileClick, onChildSessionClick }: ToolCal
const getStatusIcon = () => {
switch (part.state.status) {
case 'completed':
- return '✓'
+ return ✓
case 'error':
- return '✗'
+ return ✗
case 'running':
- return '⟳'
+ return
+ case 'pending':
+ return
default:
- return '○'
+ return ○
}
}
@@ -150,8 +152,23 @@ export function ToolCallPart({ part, onFileClick, onChildSessionClick }: ToolCal
)
}
+ const getBorderStyle = () => {
+ switch (part.state.status) {
+ case 'running':
+ return 'border-yellow-500/50 shadow-sm shadow-yellow-500/10'
+ case 'pending':
+ return 'border-blue-500/30'
+ case 'error':
+ return 'border-red-500/30'
+ case 'completed':
+ return 'border-border'
+ default:
+ return 'border-border'
+ }
+ }
+
return (
-
+
{expanded && (
-
+
+ {part.state.status === 'pending' && (
+
+
+
+
+
+
+
Preparing tool call...
+
+ )}
+
{part.state.status === 'running' && (
Input:
diff --git a/frontend/src/hooks/useSSE.ts b/frontend/src/hooks/useSSE.ts
index 9de76d96..dd58ba2f 100644
--- a/frontend/src/hooks/useSSE.ts
+++ b/frontend/src/hooks/useSSE.ts
@@ -5,6 +5,7 @@ import type { SSEEvent, MessageListResponse } from '@/api/types'
import { permissionEvents } from './usePermissionRequests'
import { showToast } from '@/lib/toast'
import { settingsApi } from '@/api/settings'
+import { useSessionStatus } from '@/stores/sessionStatusStore'
const MAX_RECONNECT_DELAY = 30000
const INITIAL_RECONNECT_DELAY = 1000
@@ -50,6 +51,7 @@ export const useSSE = (opcodeUrl: string | null | undefined, directory?: string)
const [isConnected, setIsConnected] = useState(false)
const [error, setError] = useState
(null)
const [isReconnecting, setIsReconnecting] = useState(false)
+ const setSessionStatus = useSessionStatus((state) => state.setStatus)
const scheduleReconnect = useCallback((connectFn: () => void) => {
if (!mountedRef.current) return
@@ -126,6 +128,16 @@ export const useSSE = (opcodeUrl: string | null | undefined, directory?: string)
const sessionID = part.sessionID
const messageID = part.messageID
+ if (part.type === 'retry') {
+ const retryPart = part as { attempt: number; error: { data: { message: string } } }
+ setSessionStatus(sessionID, {
+ type: 'retry',
+ attempt: retryPart.attempt,
+ message: retryPart.error?.data?.message || 'Retrying...',
+ next: Date.now() + 5000
+ })
+ }
+
const currentData = queryClient.getQueryData(['opencode', 'messages', opcodeUrl, sessionID, directory])
if (!currentData) return
@@ -163,6 +175,13 @@ export const useSSE = (opcodeUrl: string | null | undefined, directory?: string)
const { info } = event.properties
const sessionID = info.sessionID
+ if (info.role === 'assistant') {
+ const isComplete = 'completed' in info.time && info.time.completed
+ if (!isComplete) {
+ setSessionStatus(sessionID, { type: 'busy' })
+ }
+ }
+
const currentData = queryClient.getQueryData(['opencode', 'messages', opcodeUrl, sessionID, directory])
if (!currentData) {
queryClient.setQueryData(['opencode', 'messages', opcodeUrl, sessionID, directory], [{ info, parts: [] }])
@@ -244,6 +263,9 @@ export const useSSE = (opcodeUrl: string | null | undefined, directory?: string)
if (!('sessionID' in event.properties)) break
const { sessionID } = event.properties
+
+ setSessionStatus(sessionID, { type: 'idle' })
+
const currentData = queryClient.getQueryData(['opencode', 'messages', opcodeUrl, sessionID, directory])
if (!currentData) break
@@ -390,7 +412,7 @@ export const useSSE = (opcodeUrl: string | null | undefined, directory?: string)
setIsConnected(false)
}
}
- }, [client, queryClient, opcodeUrl, directory, scheduleReconnect, resetReconnectDelay])
+ }, [client, queryClient, opcodeUrl, directory, scheduleReconnect, resetReconnectDelay, setSessionStatus])
return { isConnected, error, isReconnecting }
}