mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-08 07:17:39 +00:00
feat: add api-error event support with folding for retry messages
Introduces support for displaying API error system messages in the web UI with automatic folding of consecutive retry messages to show only the latest state.
This commit is contained in:
@@ -13,6 +13,19 @@ export type EventPresentation = {
|
||||
}
|
||||
|
||||
export function getEventPresentation(event: AgentEvent): EventPresentation {
|
||||
if (event.type === 'api-error') {
|
||||
const { retryAttempt, maxRetries } = event as { retryAttempt: number; maxRetries: number }
|
||||
if (maxRetries > 0 && retryAttempt >= maxRetries) {
|
||||
return { icon: '⚠️', text: 'API error: Max retries reached' }
|
||||
}
|
||||
if (maxRetries > 0) {
|
||||
return { icon: '⏳', text: `API error: Retrying (${retryAttempt}/${maxRetries})` }
|
||||
}
|
||||
if (retryAttempt > 0) {
|
||||
return { icon: '⏳', text: 'API error: Retrying...' }
|
||||
}
|
||||
return { icon: '⚠️', text: 'API error' }
|
||||
}
|
||||
if (event.type === 'switch') {
|
||||
const mode = event.mode === 'local' ? 'local' : 'remote'
|
||||
return { icon: '🔄', text: `Switched to ${mode}` }
|
||||
|
||||
Reference in New Issue
Block a user