From 41f6d069670de6bc00afc3446cedf51b4beb8a48 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Tue, 20 Jan 2026 14:31:28 +0000 Subject: [PATCH] fix: align tui editor init (#1298) (thanks @sibbl) --- CHANGELOG.md | 1 + src/agents/model-compat.ts | 3 --- src/tui/components/custom-editor.ts | 20 +++----------------- src/tui/tui.ts | 2 +- 4 files changed, 5 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index acacb8d7e..dddfbdccb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ Docs: https://docs.clawd.bot ### Fixes - Web search: infer Perplexity base URL from API key source (direct vs OpenRouter). - TUI: keep thinking blocks ordered before content during streaming and isolate per-run assembly. (#1202) — thanks @aaronveklabs. +- TUI: align custom editor initialization with the latest pi-tui API. (#1298) — thanks @sibbl. - CLI: avoid duplicating --profile/--dev flags when formatting commands. - Exec: prefer bash when fish is default shell, falling back to sh if bash is missing. (#1297) — thanks @ysqander. - Exec: merge login-shell PATH for host=gateway exec while keeping daemon PATH minimal. (#1304) diff --git a/src/agents/model-compat.ts b/src/agents/model-compat.ts index 9ea9497ca..11f422c74 100644 --- a/src/agents/model-compat.ts +++ b/src/agents/model-compat.ts @@ -1,9 +1,6 @@ import type { Api, Model } from "@mariozechner/pi-ai"; export function normalizeModelCompat(model: Model): Model { - const isOpenAICompletionsModel = ( - candidate: Model, - ): candidate is Model<"openai-completions"> => candidate.api === "openai-completions"; const baseUrl = model.baseUrl ?? ""; const isZai = model.provider === "zai" || baseUrl.includes("api.z.ai"); if (!isZai || !isOpenAICompletionsModel(model)) return model; diff --git a/src/tui/components/custom-editor.ts b/src/tui/components/custom-editor.ts index f910b1859..54fbe819a 100644 --- a/src/tui/components/custom-editor.ts +++ b/src/tui/components/custom-editor.ts @@ -1,4 +1,4 @@ -import { Editor, Key, matchesKey } from "@mariozechner/pi-tui"; +import { Editor, type EditorTheme, Key, matchesKey } from "@mariozechner/pi-tui"; export class CustomEditor extends Editor { onEscape?: () => void; @@ -12,22 +12,8 @@ export class CustomEditor extends Editor { onShiftTab?: () => void; onAltEnter?: () => void; - constructor(tuiOrTheme: unknown, themeOrOptions?: unknown, options?: { paddingX?: number }) { - const hasTui = Boolean((tuiOrTheme as { terminal?: unknown })?.terminal); - const useTuiArg = hasTui && Editor.length >= 2; - - if (hasTui) { - const theme = themeOrOptions; - if (useTuiArg) { - super(tuiOrTheme as never, theme as never, options as never); - } else { - super(theme as never, options as never); - this.tui = tuiOrTheme as unknown as typeof this.tui; - } - return; - } - - super(tuiOrTheme as never, themeOrOptions as never); + constructor(theme: EditorTheme) { + super(theme); } handleInput(data: string): void { diff --git a/src/tui/tui.ts b/src/tui/tui.ts index a5e6e34d7..753f5511f 100644 --- a/src/tui/tui.ts +++ b/src/tui/tui.ts @@ -193,7 +193,7 @@ export async function runTui(opts: TuiOptions) { const statusContainer = new Container(); const footer = new Text("", 1, 0); const chatLog = new ChatLog(); - const editor = new CustomEditor(tui, editorTheme); + const editor = new CustomEditor(editorTheme); const root = new Container(); root.addChild(header); root.addChild(chatLog);