fix(tui): preserve renderer initialization errors (#33996)

Co-authored-by: Shoubhit Dash <shoubhit2005@gmail.com>
This commit is contained in:
Luke Parker
2026-06-26 15:14:28 +05:30
committed by GitHub
co-authored by Shoubhit Dash
parent eeb5b1d8bc
commit 753d312c28
+5 -3
View File
@@ -8,7 +8,7 @@ import { ClipboardProvider, useClipboard } from "./context/clipboard"
import { ExitProvider, useExit } from "./context/exit" import { ExitProvider, useExit } from "./context/exit"
import { EpilogueProvider } from "./context/epilogue" import { EpilogueProvider } from "./context/epilogue"
import * as Selection from "./util/selection" import * as Selection from "./util/selection"
import { createCliRenderer, MouseButton, type CliRenderer } from "@opentui/core" import { createCliRenderer, MouseButton } from "@opentui/core"
import { RouteProvider, useRoute } from "./context/route" import { RouteProvider, useRoute } from "./context/route"
import { import {
Switch, Switch,
@@ -183,7 +183,8 @@ export const run = Effect.fn("Tui.run")(function* (input: TuiInput) {
const result = yield* Effect.scoped( const result = yield* Effect.scoped(
Effect.gen(function* () { Effect.gen(function* () {
const renderer = yield* Effect.acquireRelease( const renderer = yield* Effect.acquireRelease(
Effect.tryPromise(() => Effect.tryPromise({
try: () =>
createCliRenderer({ createCliRenderer({
externalOutputMode: "passthrough", externalOutputMode: "passthrough",
targetFps: 60, targetFps: 60,
@@ -197,7 +198,8 @@ export const run = Effect.fn("Tui.run")(function* (input: TuiInput) {
keyBindings: [{ name: "y", ctrl: true, action: "copy-selection" }], keyBindings: [{ name: "y", ctrl: true, action: "copy-selection" }],
}, },
}), }),
), catch: (error) => (error instanceof Error ? error : new Error(String(error))),
}),
(renderer) => (renderer) =>
Effect.sync(() => { Effect.sync(() => {
destroyRenderer(renderer) destroyRenderer(renderer)