mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-18 22:04:46 +00:00
Fix image rendering artifacts and improve show-images selector
- Image component returns correct number of lines (rows) for TUI accounting - Empty lines rendered first, then cursor moves up and image is drawn - This clears the space the image occupies before rendering - Add spacer before inline images in tool output - Create ShowImagesSelectorComponent with borders like other selectors - Use showSelector pattern for /show-images command
This commit is contained in:
parent
883b6b3f9f
commit
e4e234ecff
5 changed files with 81 additions and 70 deletions
|
|
@ -0,0 +1,45 @@
|
|||
import { Container, type SelectItem, SelectList } from "@mariozechner/pi-tui";
|
||||
import { getSelectListTheme } from "../theme/theme.js";
|
||||
import { DynamicBorder } from "./dynamic-border.js";
|
||||
|
||||
/**
|
||||
* Component that renders a show images selector with borders
|
||||
*/
|
||||
export class ShowImagesSelectorComponent extends Container {
|
||||
private selectList: SelectList;
|
||||
|
||||
constructor(currentValue: boolean, onSelect: (show: boolean) => void, onCancel: () => void) {
|
||||
super();
|
||||
|
||||
const items: SelectItem[] = [
|
||||
{ value: "yes", label: "Yes", description: "Show images inline in terminal" },
|
||||
{ value: "no", label: "No", description: "Show text placeholder instead" },
|
||||
];
|
||||
|
||||
// Add top border
|
||||
this.addChild(new DynamicBorder());
|
||||
|
||||
// Create selector
|
||||
this.selectList = new SelectList(items, 5, getSelectListTheme());
|
||||
|
||||
// Preselect current value
|
||||
this.selectList.setSelectedIndex(currentValue ? 0 : 1);
|
||||
|
||||
this.selectList.onSelect = (item) => {
|
||||
onSelect(item.value === "yes");
|
||||
};
|
||||
|
||||
this.selectList.onCancel = () => {
|
||||
onCancel();
|
||||
};
|
||||
|
||||
this.addChild(this.selectList);
|
||||
|
||||
// Add bottom border
|
||||
this.addChild(new DynamicBorder());
|
||||
}
|
||||
|
||||
getSelectList(): SelectList {
|
||||
return this.selectList;
|
||||
}
|
||||
}
|
||||
|
|
@ -107,6 +107,7 @@ export class ToolExecutionComponent extends Container {
|
|||
for (const img of imageBlocks) {
|
||||
// Show inline image only if terminal supports it AND user setting allows it
|
||||
if (caps.images && this.showImages && img.data && img.mimeType) {
|
||||
this.addChild(new Spacer(1));
|
||||
const imageComponent = new Image(
|
||||
img.data,
|
||||
img.mimeType,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue