mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-27 01:41:40 +00:00
fix(tui): preserve user message during slow model responses (#53115)
When a local run ends with an empty final event while another run is active, skip history reload to prevent clearing the user's pending message from the chat log. This fixes the 'message disappears' issue with slow models like Ollama.
This commit is contained in:
committed by
Peter Steinberger
parent
5e9ea804d4
commit
cc8ed8d25b
@@ -590,4 +590,21 @@ describe("tui-event-handlers: handleAgentEvent", () => {
|
||||
|
||||
expect(loadHistory).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("does not reload history for local run with empty final when another run is active (#53115)", () => {
|
||||
const { state, loadHistory, noteLocalRunId, handleChatEvent } = createHandlersHarness({
|
||||
state: { activeChatRunId: "run-main" },
|
||||
});
|
||||
|
||||
noteLocalRunId("run-local-empty");
|
||||
|
||||
handleChatEvent({
|
||||
runId: "run-local-empty",
|
||||
sessionKey: state.currentSessionKey,
|
||||
state: "final",
|
||||
});
|
||||
|
||||
expect(state.activeChatRunId).toBe("run-main");
|
||||
expect(loadHistory).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -158,9 +158,18 @@ export function createEventHandlers(context: EventHandlerContext) {
|
||||
const isLocalRun = isLocalRunId?.(runId) ?? false;
|
||||
if (isLocalRun) {
|
||||
forgetLocalRunId?.(runId);
|
||||
// Never reload history for local runs that ended without displayable output.
|
||||
// This prevents the user's message from disappearing when the backend is slow
|
||||
// (e.g., Ollama) and sends an empty final event before the response is ready.
|
||||
if (!opts?.allowLocalWithoutDisplayableFinal) {
|
||||
return;
|
||||
}
|
||||
// Skip history reload if a DIFFERENT run is still active.
|
||||
// This prevents clearing the user's pending message when a stale/concurrent
|
||||
// empty final event arrives while a new message is being processed.
|
||||
if (state.activeChatRunId && state.activeChatRunId !== runId) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (hasConcurrentActiveRun(runId)) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user