MCPcopy Create free account
hub / github.com/anomalyco/opencode / SessionRetry

Function SessionRetry

packages/session-ui/src/components/session-retry.tsx:8–74  ·  view source on GitHub ↗
(props: { status: SessionStatus; show?: boolean })

Source from the content-addressed store, hash-verified

6import { Spinner } from "@opencode-ai/ui/spinner"
7
8export function SessionRetry(props: { status: SessionStatus; show?: boolean }) {
9 const i18n = useI18n()
10 const retry = createMemo(() => {
11 if (props.status.type !== "retry") return
12 return props.status
13 })
14 const [seconds, setSeconds] = createSignal(0)
15 createEffect(
16 on(retry, (current) => {
17 if (!current) return
18 const update = () => {
19 const next = retry()?.next
20 if (!next) return
21 setSeconds(Math.round((next - Date.now()) / 1000))
22 }
23 update()
24 const timer = setInterval(update, 1000)
25 onCleanup(() => clearInterval(timer))
26 }),
27 )
28 const message = createMemo(() => {
29 const current = retry()
30 if (!current) return ""
31 if (current.message.includes("exceeded your current quota") && current.message.includes("gemini")) {
32 return i18n.t("ui.sessionTurn.retry.geminiHot")
33 }
34 if (current.message.length > 80) return current.message.slice(0, 80) + "..."
35 return current.message
36 })
37 const truncated = createMemo(() => {
38 const current = retry()
39 if (!current) return false
40 return current.message.length > 80
41 })
42 const info = createMemo(() => {
43 const current = retry()
44 if (!current) return ""
45 const count = Math.max(0, seconds())
46 const delay = count > 0 ? i18n.t("ui.sessionTurn.retry.inSeconds", { seconds: count }) : ""
47 const retrying = i18n.t("ui.sessionTurn.retry.retrying")
48 const line = [retrying, delay].filter(Boolean).join(" ")
49 if (!line) return i18n.t("ui.sessionTurn.retry.attempt", { attempt: current.attempt })
50 return i18n.t("ui.sessionTurn.retry.attemptLine", { line, attempt: current.attempt })
51 })
52
53 return (
54 <Show when={retry() && (props.show ?? true)}>
55 <div data-slot="session-turn-retry">
56 <Card variant="error" class="error-card">
57 <div class="flex items-start gap-2">
58 <Spinner class="size-4 mt-0.5" />
59 <div class="min-w-0">
60 <Show when={truncated()} fallback={<div data-slot="session-turn-retry-message">{message()}</div>}>
61 <Tooltip value={retry()?.message ?? ""} placement="top">
62 <div data-slot="session-turn-retry-message" class="cursor-help truncate">
63 {message()}
64 </div>
65 </Tooltip>

Callers

nothing calls this directly

Calls 7

useI18nFunction · 0.90
updateFunction · 0.70
lineFunction · 0.70
onFunction · 0.50
retryFunction · 0.50
messageFunction · 0.50
infoFunction · 0.50

Tested by

no test coverage detected