mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 21:03:42 +00:00
tui: coalesce sequential status messages (+ tests)
This commit is contained in:
parent
c214a33405
commit
8ebc4bcebe
2 changed files with 83 additions and 3 deletions
|
|
@ -76,6 +76,10 @@ export class InteractiveMode {
|
|||
private lastEscapeTime = 0;
|
||||
private changelogMarkdown: string | null = null;
|
||||
|
||||
// Status line tracking (for mutating immediately-sequential status updates)
|
||||
private lastStatusSpacer: Spacer | null = null;
|
||||
private lastStatusText: Text | null = null;
|
||||
|
||||
// Streaming message tracking
|
||||
private streamingComponent: AssistantMessageComponent | null = null;
|
||||
|
||||
|
|
@ -984,10 +988,29 @@ export class InteractiveMode {
|
|||
return textBlocks.map((c) => (c as { text: string }).text).join("");
|
||||
}
|
||||
|
||||
/** Show a status message in the chat */
|
||||
/**
|
||||
* Show a status message in the chat.
|
||||
*
|
||||
* If multiple status messages are emitted back-to-back (without anything else being added to the chat),
|
||||
* we update the previous status line instead of appending new ones to avoid log spam.
|
||||
*/
|
||||
private showStatus(message: string): void {
|
||||
this.chatContainer.addChild(new Spacer(1));
|
||||
this.chatContainer.addChild(new Text(theme.fg("dim", message), 1, 0));
|
||||
const children = this.chatContainer.children;
|
||||
const last = children.length > 0 ? children[children.length - 1] : undefined;
|
||||
const secondLast = children.length > 1 ? children[children.length - 2] : undefined;
|
||||
|
||||
if (last && secondLast && last === this.lastStatusText && secondLast === this.lastStatusSpacer) {
|
||||
this.lastStatusText.setText(theme.fg("dim", message));
|
||||
this.ui.requestRender();
|
||||
return;
|
||||
}
|
||||
|
||||
const spacer = new Spacer(1);
|
||||
const text = new Text(theme.fg("dim", message), 1, 0);
|
||||
this.chatContainer.addChild(spacer);
|
||||
this.chatContainer.addChild(text);
|
||||
this.lastStatusSpacer = spacer;
|
||||
this.lastStatusText = text;
|
||||
this.ui.requestRender();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue