mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
Fix tool call status stuck on running and improve mobile code block word-wrap
This commit is contained in:
1 parent
9a1b216125
commit
873321b088
4 files changed
+77
-12
No files matched your search
@@ -49,7 +49,7 @@ function CodeBlock({ children, className, ...props }: CodeBlockProps) {
|
||||
|
||||
return (
|
||||
<div className="relative">
|
||||
<pre className={`bg-accent p-1 rounded-lg overflow-x-auto border border-border my-4 ${className || ''}`} {...props}>
|
||||
<pre className={`bg-accent p-1 rounded-lg overflow-x-auto whitespace-pre-wrap break-words border border-border my-4 ${className || ''}`} {...props}>
|
||||
{children}
|
||||
</pre>
|
||||
<button
|
||||
@@ -82,7 +82,7 @@ export function TextPart({ part }: TextPartProps) {
|
||||
const isInline = !className || !className.includes('language-')
|
||||
if (isInline) {
|
||||
return (
|
||||
<code className={className || "bg-accent px-1.5 py-0.5 rounded text-sm text-foreground"} {...props}>
|
||||
<code className={className || "bg-accent px-1.5 py-0.5 rounded text-sm text-foreground break-all"} {...props}>
|
||||
{children}
|
||||
</code>
|
||||
)
|
||||
|
||||
@@ -19,7 +19,7 @@ function ClickableJson({ json, onFileClick }: { json: unknown; onFileClick?: (fi
|
||||
const references = detectFileReferences(jsonString)
|
||||
|
||||
if (references.length === 0) {
|
||||
return <pre className="bg-accent p-2 rounded text-xs overflow-x-auto">{jsonString}</pre>
|
||||
return <pre className="bg-accent p-2 rounded text-xs overflow-x-auto whitespace-pre-wrap break-words">{jsonString}</pre>
|
||||
}
|
||||
|
||||
const parts: React.ReactNode[] = []
|
||||
@@ -51,7 +51,7 @@ function ClickableJson({ json, onFileClick }: { json: unknown; onFileClick?: (fi
|
||||
parts.push(jsonString.slice(lastIndex))
|
||||
}
|
||||
|
||||
return <pre className="bg-accent p-2 rounded text-xs overflow-x-auto">{parts}</pre>
|
||||
return <pre className="bg-accent p-2 rounded text-xs overflow-x-auto whitespace-pre-wrap break-words">{parts}</pre>
|
||||
}
|
||||
|
||||
export function ToolCallPart({ part, onFileClick, onChildSessionClick }: ToolCallPartProps) {
|
||||
@@ -224,10 +224,35 @@ export function ToolCallPart({ part, onFileClick, onChildSessionClick }: ToolCal
|
||||
)}
|
||||
|
||||
{part.state.status === 'running' && (
|
||||
<div className="text-sm">
|
||||
<div className="text-zinc-400 mb-1">Input:</div>
|
||||
<ClickableJson json={part.state.input} onFileClick={onFileClick} />
|
||||
</div>
|
||||
<>
|
||||
{part.tool === 'bash' ? (
|
||||
<div className="text-sm">
|
||||
<div className="flex items-center gap-2 mb-1">
|
||||
<div className="text-muted-foreground">Command:</div>
|
||||
<CopyButton
|
||||
content={typeof part.state.input?.command === 'string' ? part.state.input.command : ''}
|
||||
title="Copy command"
|
||||
/>
|
||||
</div>
|
||||
<div className="bg-accent p-2 rounded text-xs overflow-x-auto whitespace-pre-wrap break-words">
|
||||
<span className="text-green-600 dark:text-green-400">$</span> {typeof part.state.input?.command === 'string' ? part.state.input.command : ''}
|
||||
</div>
|
||||
<div className="flex items-center gap-2 mt-2 text-xs text-yellow-600 dark:text-yellow-400">
|
||||
<Loader2 className="w-3 h-3 animate-spin" />
|
||||
<span>Running...</span>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div className="text-sm">
|
||||
<div className="text-muted-foreground mb-1">Input:</div>
|
||||
<ClickableJson json={part.state.input} onFileClick={onFileClick} />
|
||||
<div className="flex items-center gap-2 mt-2 text-xs text-yellow-600 dark:text-yellow-400">
|
||||
<Loader2 className="w-3 h-3 animate-spin" />
|
||||
<span>Running...</span>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
{part.state.status === 'completed' && (
|
||||
@@ -241,7 +266,7 @@ export function ToolCallPart({ part, onFileClick, onChildSessionClick }: ToolCal
|
||||
title="Copy command"
|
||||
/>
|
||||
</div>
|
||||
<div className="bg-accent p-2 rounded text-xs overflow-x-auto">
|
||||
<div className="bg-accent p-2 rounded text-xs overflow-x-auto whitespace-pre-wrap break-words">
|
||||
<span className="text-green-600 dark:text-green-400">$</span> {typeof part.state.input?.command === 'string' ? part.state.input.command : ''}
|
||||
</div>
|
||||
</div>
|
||||
@@ -270,7 +295,7 @@ export function ToolCallPart({ part, onFileClick, onChildSessionClick }: ToolCal
|
||||
{part.state.status === 'error' && (
|
||||
<div className="text-sm">
|
||||
<div className="text-red-600 dark:text-red-400 mb-1">Error:</div>
|
||||
<pre className="bg-accent p-2 rounded text-xs overflow-x-auto text-red-600 dark:text-red-300">
|
||||
<pre className="bg-accent p-2 rounded text-xs overflow-x-auto whitespace-pre-wrap break-words text-red-600 dark:text-red-300">
|
||||
{part.state.error}
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
@@ -272,13 +272,36 @@ export const useSSE = (opcodeUrl: string | null | undefined, directory?: string)
|
||||
const now = Date.now()
|
||||
const updated = currentData.map(msg => {
|
||||
if (msg.info.role !== 'assistant') return msg
|
||||
if ('completed' in msg.info.time && msg.info.time.completed) return msg
|
||||
|
||||
const updatedParts = msg.parts.map(part => {
|
||||
if (part.type !== 'tool') return part
|
||||
if (part.state.status !== 'running' && part.state.status !== 'pending') return part
|
||||
return {
|
||||
...part,
|
||||
state: {
|
||||
...part.state,
|
||||
status: 'completed' as const,
|
||||
output: part.state.status === 'running' ? '[Session ended - output not captured]' : '[Tool was pending when session ended]',
|
||||
title: part.state.status === 'running' ? (part.state as { title?: string }).title || '' : '',
|
||||
metadata: (part.state as { metadata?: Record<string, unknown> }).metadata || {},
|
||||
time: {
|
||||
start: (part.state as { time?: { start: number } }).time?.start || now,
|
||||
end: now
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const msgUpdated = updatedParts !== msg.parts
|
||||
if ('completed' in msg.info.time && msg.info.time.completed && !msgUpdated) return msg
|
||||
|
||||
return {
|
||||
...msg,
|
||||
info: {
|
||||
...msg.info,
|
||||
time: { ...msg.info.time, completed: now }
|
||||
}
|
||||
},
|
||||
parts: updatedParts
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -217,6 +217,23 @@ body {
|
||||
.prose-enhanced pre {
|
||||
margin-top: 1.5em;
|
||||
margin-bottom: 1.5em;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.prose-enhanced code {
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.prose-enhanced pre {
|
||||
padding: 0.5rem;
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
.prose-enhanced code {
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
}
|
||||
|
||||
.prose-enhanced :first-child {
|
||||
|
||||
Reference in new issue
Block a user