mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
Fixes #62 - Config file in workspace volume is now the source of truth * Preserve raw config content with comments instead of re-stringifying parsed JSON * Sync provider credentials to OpenCode server when adding or removing API keys * Add error handling for session errors with toast notifications and inline message display * Refactor provider settings to manage API keys directly with edit/delete support
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import { memo } from 'react'
|
|
import { AlertCircle, KeyRound, XCircle, Clock } from 'lucide-react'
|
|
import { parseOpenCodeError, type OpenCodeError } from '@/lib/opencode-errors'
|
|
|
|
interface MessageErrorProps {
|
|
error: OpenCodeError
|
|
}
|
|
|
|
const getErrorIcon = (errorName: string) => {
|
|
switch (errorName) {
|
|
case 'ProviderAuthError':
|
|
return KeyRound
|
|
case 'MessageAbortedError':
|
|
return XCircle
|
|
case 'MessageOutputLengthError':
|
|
return Clock
|
|
default:
|
|
return AlertCircle
|
|
}
|
|
}
|
|
|
|
export const MessageError = memo(function MessageError({ error }: MessageErrorProps) {
|
|
const parsed = parseOpenCodeError(error)
|
|
if (!parsed) return null
|
|
|
|
const Icon = getErrorIcon(error.name)
|
|
|
|
return (
|
|
<div className="flex items-start gap-2 p-3 rounded-md bg-destructive/10 border border-destructive/30 text-destructive">
|
|
<Icon className="h-4 w-4 mt-0.5 flex-shrink-0" />
|
|
<div className="flex-1 min-w-0">
|
|
<div className="font-medium text-sm">{parsed.title}</div>
|
|
<div className="text-xs text-destructive/80 mt-0.5">{parsed.message}</div>
|
|
</div>
|
|
</div>
|
|
)
|
|
})
|