Skip to content

Commit 72062d2

Browse files
fix: cleanly restore terminal state on fatal error exit (#7359)
1 parent 9f90f0e commit 72062d2

File tree

1 file changed

+10
-2
lines changed
  • packages/opencode/src/cli/cmd/tui

1 file changed

+10
-2
lines changed

packages/opencode/src/cli/cmd/tui/app.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -653,9 +653,17 @@ function ErrorComponent(props: {
653653
mode?: "dark" | "light"
654654
}) {
655655
const term = useTerminalDimensions()
656+
const renderer = useRenderer()
657+
658+
const handleExit = async () => {
659+
renderer.setTerminalTitle("")
660+
renderer.destroy()
661+
props.onExit()
662+
}
663+
656664
useKeyboard((evt) => {
657665
if (evt.ctrl && evt.name === "c") {
658-
props.onExit()
666+
handleExit()
659667
}
660668
})
661669
const [copied, setCopied] = createSignal(false)
@@ -708,7 +716,7 @@ function ErrorComponent(props: {
708716
<box onMouseUp={props.reset} backgroundColor={colors.primary} padding={1}>
709717
<text fg={colors.bg}>Reset TUI</text>
710718
</box>
711-
<box onMouseUp={props.onExit} backgroundColor={colors.primary} padding={1}>
719+
<box onMouseUp={handleExit} backgroundColor={colors.primary} padding={1}>
712720
<text fg={colors.bg}>Exit</text>
713721
</box>
714722
</box>

0 commit comments

Comments
 (0)