UI: reload history after terminal tool runs

This commit is contained in:
Val Alexander 2026-03-13 19:19:06 -05:00
parent d1c6458e5a
commit fabd5ad5e1
No known key found for this signature in database
2 changed files with 37 additions and 1 deletions

View File

@ -380,6 +380,42 @@ describe("connectGateway", () => {
expect(loadChatHistoryMock).toHaveBeenCalledTimes(1);
});
it("reloads chat history after an error chat event when tool output was used", () => {
const host = createHost();
connectGateway(host);
const client = gatewayClientInstances[0];
expect(client).toBeDefined();
client.emitEvent({
event: "agent",
payload: {
runId: "engine-run-1",
seq: 1,
stream: "tool",
ts: 1,
sessionKey: "main",
data: {
toolCallId: "tool-1",
name: "fetch",
phase: "result",
result: { text: "ok" },
},
},
});
client.emitEvent({
event: "chat",
payload: {
runId: "engine-run-1",
sessionKey: "main",
state: "error",
},
});
expect(loadChatHistoryMock).toHaveBeenCalledTimes(1);
});
});
describe("resolveControlUiClientVersion", () => {

View File

@ -301,7 +301,7 @@ function handleTerminalChatEvent(
}
// Reload history when tools were used so the persisted tool results
// replace the now-cleared streaming state.
if (hadToolEvents && state === "final") {
if (hadToolEvents) {
void loadChatHistory(host as unknown as OpenClawApp);
return true;
}