mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-17 09:02:08 +00:00
Revert "fix(pi-dosbox): force image re-render to prevent ghosting during streaming"
This reverts commit 1668a59bff.
This commit is contained in:
parent
1668a59bff
commit
c083e195ad
1 changed files with 13 additions and 10 deletions
|
|
@ -65,6 +65,10 @@ export class DosboxComponent implements Component {
|
||||||
private imageTheme: ImageTheme;
|
private imageTheme: ImageTheme;
|
||||||
private loadingMessage = "Connecting to DOSBox...";
|
private loadingMessage = "Connecting to DOSBox...";
|
||||||
private errorMessage: string | null = null;
|
private errorMessage: string | null = null;
|
||||||
|
private cachedLines: string[] = [];
|
||||||
|
private cachedWidth = 0;
|
||||||
|
private cachedVersion = -1;
|
||||||
|
private version = 0;
|
||||||
private disposed = false;
|
private disposed = false;
|
||||||
private imageId: number;
|
private imageId: number;
|
||||||
private kittyPushed = false;
|
private kittyPushed = false;
|
||||||
|
|
@ -117,6 +121,7 @@ export class DosboxComponent implements Component {
|
||||||
{ maxWidthCells: MAX_WIDTH_CELLS, imageId: this.imageId },
|
{ maxWidthCells: MAX_WIDTH_CELLS, imageId: this.imageId },
|
||||||
{ widthPx: width, heightPx: height },
|
{ widthPx: width, heightPx: height },
|
||||||
);
|
);
|
||||||
|
this.version++;
|
||||||
this.tui.requestRender();
|
this.tui.requestRender();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -190,8 +195,7 @@ export class DosboxComponent implements Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
invalidate(): void {
|
invalidate(): void {
|
||||||
// No caching, so nothing to invalidate
|
this.cachedWidth = 0;
|
||||||
// Image component handles its own caching
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render(width: number): string[] {
|
render(width: number): string[] {
|
||||||
|
|
@ -204,18 +208,17 @@ export class DosboxComponent implements Component {
|
||||||
if (!this.image) {
|
if (!this.image) {
|
||||||
return [truncateToWidth("Waiting for DOSBox frame...", width)];
|
return [truncateToWidth("Waiting for DOSBox frame...", width)];
|
||||||
}
|
}
|
||||||
|
if (width === this.cachedWidth && this.cachedVersion === this.version) {
|
||||||
|
return this.cachedLines;
|
||||||
|
}
|
||||||
|
|
||||||
// Always render fresh - never cache. This ensures the image is re-rendered
|
|
||||||
// at the correct position even during streaming when lines above change.
|
|
||||||
// The cache in Image component handles avoiding redundant Kitty transmissions.
|
|
||||||
const imageLines = this.image.render(width);
|
const imageLines = this.image.render(width);
|
||||||
const footer = truncateToWidth("\x1b[2mCtrl+Q to detach (DOSBox keeps running)\x1b[22m", width);
|
const footer = truncateToWidth("\x1b[2mCtrl+Q to detach (DOSBox keeps running)\x1b[22m", width);
|
||||||
|
const lines = [...imageLines, footer];
|
||||||
|
|
||||||
// Add a unique suffix to force TUI to see these lines as "changed"
|
this.cachedLines = lines;
|
||||||
// This ensures the image is always re-rendered at correct position
|
this.cachedWidth = width;
|
||||||
const timestamp = `\x1b[0m\x1b[8m${Date.now()}\x1b[28m`;
|
this.cachedVersion = this.version;
|
||||||
const lines = imageLines.map((line, i) => (i === imageLines.length - 1 ? line + timestamp : line));
|
|
||||||
lines.push(footer);
|
|
||||||
|
|
||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue