fix: align tui editor init (#1298) (thanks @sibbl)

This commit is contained in:
Peter Steinberger committed 2026-01-20 14:31:28 +00:00
1 parent 73957ca92b
commit 04b92925e0
5 files changed
+5 -22

No files matched your search

-3
View File
@@ -5,9 +5,6 @@ function isOpenAICompletionsModel(model: Model<Api>): model is Model<"openai-com
}
export function normalizeModelCompat(model: Model<Api>): Model<Api> {
const isOpenAICompletionsModel = (
candidate: Model<Api>,
): 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;
-1
View File
@@ -24,7 +24,6 @@ import {
formatUpdateChannelLabel,
normalizeUpdateChannel,
resolveEffectiveUpdateChannel,
type UpdateChannel,
} from "../infra/update-channels.js";
import { defaultRuntime } from "../runtime.js";
import { formatDocsLink } from "../terminal/links.js";
+3 -17
View File
@@ -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 {
+1 -1
View File
@@ -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);