diff --git a/packages/tui/src/app.tsx b/packages/tui/src/app.tsx index 6f629e4222..4d4959dcc1 100644 --- a/packages/tui/src/app.tsx +++ b/packages/tui/src/app.tsx @@ -185,25 +185,24 @@ export const run = Effect.fn("Tui.run")(function* (input: TuiInput) { const renderer = yield* Effect.acquireRelease( Effect.tryPromise({ try: async () => { - const createVisibleRenderer = () => - createCliRenderer({ - externalOutputMode: "passthrough", - targetFps: 60, - gatherStats: false, - exitOnCtrlC: false, - useKittyKeyboard: {}, - autoFocus: false, - openConsoleOnError: false, - useMouse: !Flag.OPENCODE_DISABLE_MOUSE && input.config.mouse, - consoleOptions: { - keyBindings: [{ name: "y", ctrl: true, action: "copy-selection" }], - }, - }) if (process.env.OPENCODE_SIMULATION === "1" || process.env.OPENCODE_SIMULATION === "true") { const { Simulation } = await import("./simulation/simulation") - return Simulation.createSimulation(createVisibleRenderer) + return Simulation.createSimulation() } - return createVisibleRenderer() + + return createCliRenderer({ + externalOutputMode: "passthrough", + targetFps: 60, + gatherStats: false, + exitOnCtrlC: false, + useKittyKeyboard: {}, + autoFocus: false, + openConsoleOnError: false, + useMouse: !Flag.OPENCODE_DISABLE_MOUSE && input.config.mouse, + consoleOptions: { + keyBindings: [{ name: "y", ctrl: true, action: "copy-selection" }], + }, + }) }, catch: (error) => (error instanceof Error ? error : new Error(String(error))), }), diff --git a/packages/tui/src/simulation/simulation.ts b/packages/tui/src/simulation/simulation.ts index 934c83a285..b677b7f092 100644 --- a/packages/tui/src/simulation/simulation.ts +++ b/packages/tui/src/simulation/simulation.ts @@ -1,4 +1,4 @@ -import type { CliRenderer } from "@opentui/core" +import { createCliRenderer, type CliRenderer } from "@opentui/core" import { SimulationActions } from "./actions" import { SimulationRenderer } from "./renderer" import { SimulationServer } from "./server" @@ -6,14 +6,24 @@ import { SimulationServer } from "./server" /** * Simulation-mode renderer entry point. * - * Creates the renderer (fake when OPENCODE_SIMULATION_RENDERER=fake, the - * normal visible renderer otherwise) and starts the simulation control + * Creates the renderer (fake when OPENCODE_SIMULATION_RENDERER=fake, a + * visible terminal renderer otherwise) and starts the simulation control * server against it. The server stops when the renderer is destroyed, so the * caller only manages the renderer lifecycle. */ -export async function createSimulation(createVisibleRenderer: () => Promise): Promise { +export async function createSimulation(): Promise { const renderer = - process.env.OPENCODE_SIMULATION_RENDERER === "fake" ? await SimulationRenderer.create() : await createVisibleRenderer() + process.env.OPENCODE_SIMULATION_RENDERER === "fake" + ? await SimulationRenderer.create() + : await createCliRenderer({ + externalOutputMode: "passthrough", + targetFps: 60, + gatherStats: false, + exitOnCtrlC: false, + useKittyKeyboard: {}, + autoFocus: false, + openConsoleOnError: false, + }) const server = SimulationServer.start(SimulationActions.createHarness(renderer)) if (server) { process.stderr.write(`opencode simulation websocket: ${server.url}\n`)