fix(ui): retry autonomous runtime control readback
Some checks failed
CD Pipeline / workflow-shape (push) Successful in 0s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Successful in 37s
CD Pipeline / post-deploy-checks (push) Has been cancelled
CD Pipeline / build-and-deploy (push) Has been cancelled
Some checks failed
CD Pipeline / workflow-shape (push) Successful in 0s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Successful in 37s
CD Pipeline / post-deploy-checks (push) Has been cancelled
CD Pipeline / build-and-deploy (push) Has been cancelled
This commit is contained in:
@@ -361,6 +361,12 @@ function settledPublicValue<T>(result: PromiseSettledResult<T>): T | null {
|
||||
return result.status === 'fulfilled' ? sanitizePublicSnapshot(result.value) : null
|
||||
}
|
||||
|
||||
const AUTONOMOUS_RUNTIME_CONTROL_RETRY_DELAYS_MS = [1500, 5000, 12000, 25000] as const
|
||||
|
||||
function hasAutonomousRuntimeControlDeployMarker(snapshot: AiAgentAutonomousRuntimeControlSnapshot | null): boolean {
|
||||
return Boolean(snapshot?.program_status?.deploy_readback_marker)
|
||||
}
|
||||
|
||||
function toneColor(tone: 'ok' | 'warn' | 'danger' | 'neutral') {
|
||||
if (tone === 'ok') return '#22C55E'
|
||||
if (tone === 'warn') return '#F59E0B'
|
||||
@@ -1546,6 +1552,39 @@ export function AutomationInventoryTab() {
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false
|
||||
let retryTimeout: number | null = null
|
||||
|
||||
const scheduleReadback = (attemptIndex: number) => {
|
||||
const delayMs = AUTONOMOUS_RUNTIME_CONTROL_RETRY_DELAYS_MS[attemptIndex]
|
||||
retryTimeout = window.setTimeout(() => {
|
||||
if (cancelled) return
|
||||
apiClient.getAiAgentAutonomousRuntimeControl()
|
||||
.then(value => {
|
||||
if (cancelled) return
|
||||
const nextSnapshot = sanitizePublicSnapshot(value)
|
||||
setAutonomousRuntimeControl(nextSnapshot)
|
||||
if (!hasAutonomousRuntimeControlDeployMarker(nextSnapshot) && attemptIndex + 1 < AUTONOMOUS_RUNTIME_CONTROL_RETRY_DELAYS_MS.length) {
|
||||
scheduleReadback(attemptIndex + 1)
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
if (!cancelled && attemptIndex + 1 < AUTONOMOUS_RUNTIME_CONTROL_RETRY_DELAYS_MS.length) {
|
||||
scheduleReadback(attemptIndex + 1)
|
||||
}
|
||||
})
|
||||
}, delayMs)
|
||||
}
|
||||
|
||||
scheduleReadback(0)
|
||||
|
||||
return () => {
|
||||
cancelled = true
|
||||
if (retryTimeout !== null) window.clearTimeout(retryTimeout)
|
||||
}
|
||||
}, [])
|
||||
|
||||
const groupedAssets = useMemo(() => {
|
||||
const groups = new Map<string, AiAgentAutomationInventorySnapshot['assets']>()
|
||||
if (!snapshot) return []
|
||||
|
||||
Reference in New Issue
Block a user