Skip to content

Commit 2d9fd4e

Browse files
committed
fix(tui): refresh history for non-local final events
1 parent 4ee3d5d commit 2d9fd4e

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

src/tui/tui-event-handlers.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ describe("tui-event-handlers: handleAgentEvent", () => {
689689
);
690690
});
691691

692-
it("does not refresh history after a displayable non-local chat final", () => {
692+
it("refreshes history after a displayable non-local chat final", () => {
693693
const { state, loadHistory, handleChatEvent } = createHandlersHarness({
694694
state: { activeChatRunId: null },
695695
});
@@ -701,7 +701,7 @@ describe("tui-event-handlers: handleAgentEvent", () => {
701701
message: { content: [{ type: "text", text: "done" }] },
702702
});
703703

704-
expect(loadHistory).not.toHaveBeenCalled();
704+
expect(loadHistory).toHaveBeenCalledTimes(1);
705705
});
706706

707707
it("forces render when a command final only adds system text", () => {

src/tui/tui-event-handlers.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,11 @@ export function createEventHandlers(context: EventHandlerContext) {
513513
}
514514
const hasDisplayableFinal = hasDisplayableFinalEvent(evt);
515515
if (hasDisplayableFinal) {
516-
forgetLocalRunId?.(evt.runId);
516+
if (isLocalRunId?.(evt.runId)) {
517+
forgetLocalRunId?.(evt.runId);
518+
} else {
519+
maybeRefreshHistoryForRun(evt.runId);
520+
}
517521
} else {
518522
maybeRefreshHistoryForRun(evt.runId);
519523
}

0 commit comments

Comments
 (0)