fix: align input editor with message content padding

Adds paddingX option to Editor component and hardcodes paddingX: 1 in
coding-agent editors so the cursor/text aligns with chat message content.
This commit is contained in:
ferologics 2026-01-16 22:39:24 +01:00 committed by Mario Zechner
parent 20f5fcc79d
commit 48ea444bc4
7 changed files with 48 additions and 16 deletions

View file

@ -15,6 +15,7 @@
### Fixed
- Fixed crash during auto-compaction when summarization fails (e.g., quota exceeded). Now displays error message instead of crashing ([#792](https://github.com/badlogic/pi-mono/issues/792))
- Input editor now aligns with message content padding ([#791](https://github.com/badlogic/pi-mono/pull/791) by [@ferologics](https://github.com/ferologics))
- Fixed `--no-extensions` flag not preventing extension discovery ([#776](https://github.com/badlogic/pi-mono/issues/776))
- Fixed extension messages rendering twice on startup when `pi.sendMessage({ display: true })` is called during `session_start` ([#765](https://github.com/badlogic/pi-mono/pull/765) by [@dannote](https://github.com/dannote))
- Fixed `PI_CODING_AGENT_DIR` env var not expanding tilde (`~`) to home directory ([#778](https://github.com/badlogic/pi-mono/pull/778) by [@aliou](https://github.com/aliou))

View file

@ -1,4 +1,4 @@
import { Editor, type EditorTheme, type TUI } from "@mariozechner/pi-tui";
import { Editor, type EditorOptions, type EditorTheme, type TUI } from "@mariozechner/pi-tui";
import type { AppAction, KeybindingsManager } from "../../../core/keybindings.js";
/**
@ -15,8 +15,8 @@ export class CustomEditor extends Editor {
/** Handler for extension-registered shortcuts. Returns true if handled. */
public onExtensionShortcut?: (data: string) => boolean;
constructor(tui: TUI, theme: EditorTheme, keybindings: KeybindingsManager) {
super(tui, theme);
constructor(tui: TUI, theme: EditorTheme, keybindings: KeybindingsManager, options?: EditorOptions) {
super(tui, theme, options);
this.keybindings = keybindings;
}

View file

@ -7,7 +7,15 @@ import { spawnSync } from "node:child_process";
import * as fs from "node:fs";
import * as os from "node:os";
import * as path from "node:path";
import { Container, Editor, getEditorKeybindings, Spacer, Text, type TUI } from "@mariozechner/pi-tui";
import {
Container,
Editor,
type EditorOptions,
getEditorKeybindings,
Spacer,
Text,
type TUI,
} from "@mariozechner/pi-tui";
import type { KeybindingsManager } from "../../../core/keybindings.js";
import { getEditorTheme, theme } from "../theme/theme.js";
import { DynamicBorder } from "./dynamic-border.js";
@ -27,6 +35,7 @@ export class ExtensionEditorComponent extends Container {
prefill: string | undefined,
onSubmit: (value: string) => void,
onCancel: () => void,
options?: EditorOptions,
) {
super();
@ -44,7 +53,7 @@ export class ExtensionEditorComponent extends Container {
this.addChild(new Spacer(1));
// Create editor
this.editor = new Editor(tui, getEditorTheme());
this.editor = new Editor(tui, getEditorTheme(), options);
if (prefill) {
this.editor.setText(prefill);
}

View file

@ -241,7 +241,7 @@ export class InteractiveMode {
this.statusContainer = new Container();
this.widgetContainer = new Container();
this.keybindings = KeybindingsManager.create();
this.defaultEditor = new CustomEditor(this.ui, getEditorTheme(), this.keybindings);
this.defaultEditor = new CustomEditor(this.ui, getEditorTheme(), this.keybindings, { paddingX: 1 });
this.editor = this.defaultEditor;
this.editorContainer = new Container();
this.editorContainer.addChild(this.editor as Component);
@ -1150,6 +1150,7 @@ export class InteractiveMode {
this.hideExtensionEditor();
resolve(undefined);
},
{ paddingX: 1 },
);
this.editorContainer.clear();