fix: align tui editor init (#1298) (thanks @sibbl)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
import type { Api, Model } from "@mariozechner/pi-ai";
|
||||
|
||||
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,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 {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user