fix(tui): preserve renderer initialization errors (#33996)
Co-authored-by: Shoubhit Dash <shoubhit2005@gmail.com>
This commit is contained in:
@@ -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,21 +183,23 @@ 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({
|
||||||
createCliRenderer({
|
try: () =>
|
||||||
externalOutputMode: "passthrough",
|
createCliRenderer({
|
||||||
targetFps: 60,
|
externalOutputMode: "passthrough",
|
||||||
gatherStats: false,
|
targetFps: 60,
|
||||||
exitOnCtrlC: false,
|
gatherStats: false,
|
||||||
useKittyKeyboard: {},
|
exitOnCtrlC: false,
|
||||||
autoFocus: false,
|
useKittyKeyboard: {},
|
||||||
openConsoleOnError: false,
|
autoFocus: false,
|
||||||
useMouse: !Flag.OPENCODE_DISABLE_MOUSE && input.config.mouse,
|
openConsoleOnError: false,
|
||||||
consoleOptions: {
|
useMouse: !Flag.OPENCODE_DISABLE_MOUSE && input.config.mouse,
|
||||||
keyBindings: [{ name: "y", ctrl: true, action: "copy-selection" }],
|
consoleOptions: {
|
||||||
},
|
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)
|
||||||
|
|||||||
Reference in New Issue
Block a user