mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-28 18:33:37 +00:00
fix(tui): prune chat log system messages atomically
This commit is contained in:
@@ -53,6 +53,22 @@ describe("ChatLog", () => {
|
||||
expect(chatLog.children.length).toBe(20);
|
||||
});
|
||||
|
||||
it("prunes system messages atomically when a non-system entry overflows the log", () => {
|
||||
const chatLog = new ChatLog(20);
|
||||
for (let i = 1; i <= 20; i++) {
|
||||
chatLog.addSystem(`system-${i}`);
|
||||
}
|
||||
|
||||
chatLog.addUser("hello");
|
||||
|
||||
const rendered = chatLog.render(120).join("\n");
|
||||
expect(rendered).not.toMatch(/\bsystem-1\b/);
|
||||
expect(rendered).toMatch(/\bsystem-2\b/);
|
||||
expect(rendered).toMatch(/\bsystem-20\b/);
|
||||
expect(rendered).toContain("hello");
|
||||
expect(chatLog.children.length).toBe(20);
|
||||
});
|
||||
|
||||
it("renders BTW inline and removes it when dismissed", () => {
|
||||
const chatLog = new ChatLog(40);
|
||||
|
||||
|
||||
@@ -57,9 +57,15 @@ export class ChatLog extends Container {
|
||||
this.btwMessage = null;
|
||||
}
|
||||
|
||||
private createSystemMessage(text: string): Container {
|
||||
const entry = new Container();
|
||||
entry.addChild(new Spacer(1));
|
||||
entry.addChild(new Text(theme.system(text), 1, 0));
|
||||
return entry;
|
||||
}
|
||||
|
||||
addSystem(text: string) {
|
||||
this.append(new Spacer(1));
|
||||
this.append(new Text(theme.system(text), 1, 0));
|
||||
this.append(this.createSystemMessage(text));
|
||||
}
|
||||
|
||||
addUser(text: string) {
|
||||
|
||||
Reference in New Issue
Block a user