fix: repair model compat + editor ctor

This commit is contained in:
Peter Steinberger
2026-01-20 16:19:46 +00:00
parent 844ff2ee8f
commit 0b0d8b2406
3 changed files with 16 additions and 11 deletions
+10 -6
View File
@@ -1,4 +1,11 @@
import { Editor, type EditorTheme, Key, matchesKey, type TUI } from "@mariozechner/pi-tui";
import {
Editor,
type EditorOptions,
type EditorTheme,
Key,
matchesKey,
type TUI,
} from "@mariozechner/pi-tui";
export class CustomEditor extends Editor {
onEscape?: () => void;
@@ -12,11 +19,8 @@ export class CustomEditor extends Editor {
onShiftTab?: () => void;
onAltEnter?: () => void;
constructor(tuiOrTheme: TUI | EditorTheme, themeMaybe?: EditorTheme) {
const useLegacyCtor = typeof themeMaybe !== "undefined" && Editor.length >= 2;
const args = (useLegacyCtor ? [tuiOrTheme, themeMaybe] : [themeMaybe ?? tuiOrTheme]) as
ConstructorParameters<typeof Editor>;
super(...args);
constructor(tui: TUI, theme: EditorTheme, options?: EditorOptions) {
super(tui, theme, options);
}
handleInput(data: string): void {
if (matchesKey(data, Key.alt("enter")) && this.onAltEnter) {
+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(editorTheme);
const editor = new CustomEditor(tui, editorTheme);
const root = new Container();
root.addChild(header);
root.addChild(chatLog);