Skip to content

Commit 2e473d0

Browse files
author
Sisyphus-AI
committed
Merge PR #19116: fix(opencode): reconnect on network disruptions
2 parents df9e1d9 + 2986f27 commit 2e473d0

10 files changed

Lines changed: 4341 additions & 4977 deletions

File tree

‎bun.lock‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx‎

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,7 +1302,9 @@ export function Prompt(props: PromptProps) {
13021302
flexDirection="row"
13031303
gap={1}
13041304
flexGrow={1}
1305-
justifyContent={status().type === "retry" ? "space-between" : "flex-start"}
1305+
justifyContent={
1306+
status().type === "retry" || status().type === "reconnecting" ? "space-between" : "flex-start"
1307+
}
13061308
>
13071309
<box flexShrink={0} flexDirection="row" gap={1}>
13081310
<box marginLeft={1}>
@@ -1367,6 +1369,41 @@ export function Prompt(props: PromptProps) {
13671369
</Show>
13681370
)
13691371
})()}
1372+
{(() => {
1373+
const reconnecting = createMemo(() => {
1374+
const s = status()
1375+
if (s.type !== "reconnecting") return
1376+
return s
1377+
})
1378+
const [visible, setVisible] = createSignal(false)
1379+
let timer: ReturnType<typeof setTimeout> | undefined
1380+
createEffect(() => {
1381+
const r = reconnecting()
1382+
if (r) {
1383+
timer = setTimeout(() => setVisible(true), 1000)
1384+
} else {
1385+
clearTimeout(timer)
1386+
setVisible(false)
1387+
}
1388+
})
1389+
onCleanup(() => clearTimeout(timer))
1390+
const msg = createMemo(() => {
1391+
const r = reconnecting()
1392+
if (!r) return
1393+
if (r.message.length > 80) return r.message.slice(0, 80) + "..."
1394+
return r.message
1395+
})
1396+
1397+
return (
1398+
<Show when={visible() && reconnecting()}>
1399+
<box>
1400+
<text fg={theme.warning}>
1401+
{msg()} [reconnecting attempt #{reconnecting()?.attempt}]
1402+
</text>
1403+
</box>
1404+
</Show>
1405+
)
1406+
})()}
13701407
</box>
13711408
</box>
13721409
<text fg={store.interrupt > 0 ? theme.primary : theme.text}>
@@ -1377,7 +1414,7 @@ export function Prompt(props: PromptProps) {
13771414
</text>
13781415
</box>
13791416
</Show>
1380-
<Show when={status().type !== "retry"}>
1417+
<Show when={status().type !== "retry" && status().type !== "reconnecting"}>
13811418
<box gap={2} flexDirection="row">
13821419
<Show when={editorFileLabelDisplay()}>{(file) => <text fg={theme.secondary}>{file()}</text>}</Show>
13831420
<Switch>

0 commit comments

Comments
 (0)