mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 14:41:24 +00:00
fix (tui): suppress false no-output placeholders for external empty finals
This commit is contained in:
@@ -409,6 +409,44 @@ describe("tui-event-handlers: handleAgentEvent", () => {
|
||||
expect(chatLog.updateAssistant).toHaveBeenLastCalledWith("continued", "run-active");
|
||||
});
|
||||
|
||||
it("suppresses non-local empty final placeholders during concurrent runs", () => {
|
||||
const state = makeState({ activeChatRunId: "run-active" });
|
||||
const { chatLog, tui, setActivityStatus, loadHistory, isLocalRunId, forgetLocalRunId } =
|
||||
makeContext(state);
|
||||
const { handleChatEvent } = createEventHandlers({
|
||||
chatLog,
|
||||
tui,
|
||||
state,
|
||||
setActivityStatus,
|
||||
loadHistory,
|
||||
isLocalRunId,
|
||||
forgetLocalRunId,
|
||||
});
|
||||
|
||||
handleChatEvent({
|
||||
runId: "run-active",
|
||||
sessionKey: state.currentSessionKey,
|
||||
state: "delta",
|
||||
message: { content: "local stream" },
|
||||
});
|
||||
|
||||
loadHistory.mockClear();
|
||||
chatLog.finalizeAssistant.mockClear();
|
||||
chatLog.dropAssistant.mockClear();
|
||||
|
||||
handleChatEvent({
|
||||
runId: "run-other",
|
||||
sessionKey: state.currentSessionKey,
|
||||
state: "final",
|
||||
message: { content: [] },
|
||||
});
|
||||
|
||||
expect(chatLog.finalizeAssistant).not.toHaveBeenCalledWith("(no output)", "run-other");
|
||||
expect(chatLog.dropAssistant).toHaveBeenCalledWith("run-other");
|
||||
expect(loadHistory).not.toHaveBeenCalled();
|
||||
expect(state.activeChatRunId).toBe("run-active");
|
||||
});
|
||||
|
||||
it("drops streaming assistant when chat final has no message", () => {
|
||||
const state = makeState({ activeChatRunId: null });
|
||||
const { chatLog, tui, setActivityStatus } = makeContext(state);
|
||||
|
||||
@@ -172,7 +172,13 @@ export function createEventHandlers(context: EventHandlerContext) {
|
||||
: "";
|
||||
|
||||
const finalText = streamAssembler.finalize(evt.runId, evt.message, state.showThinking);
|
||||
chatLog.finalizeAssistant(finalText, evt.runId);
|
||||
const suppressEmptyExternalPlaceholder =
|
||||
finalText === "(no output)" && !isLocalRunId?.(evt.runId);
|
||||
if (suppressEmptyExternalPlaceholder) {
|
||||
chatLog.dropAssistant(evt.runId);
|
||||
} else {
|
||||
chatLog.finalizeAssistant(finalText, evt.runId);
|
||||
}
|
||||
noteFinalizedRun(evt.runId);
|
||||
clearActiveRunIfMatch(evt.runId);
|
||||
if (wasActiveRun) {
|
||||
|
||||
Reference in New Issue
Block a user