fix: gate TUI lifecycle updates to active run (#1567) (thanks @vignesh07)

This commit is contained in:
Peter Steinberger
2026-01-24 07:23:25 +00:00
parent 8f4426052c
commit ad7fc4964a
3 changed files with 33 additions and 1 deletions

View File

@@ -125,7 +125,8 @@ export function createEventHandlers(context: EventHandlerContext) {
syncSessionKey();
// Agent events (tool streaming, lifecycle) are emitted per-run. Filter against the
// active chat run id, not the session id.
if (evt.runId !== state.activeChatRunId && !sessionRuns.has(evt.runId)) return;
const isActiveRun = evt.runId === state.activeChatRunId;
if (!isActiveRun && !sessionRuns.has(evt.runId)) return;
if (evt.stream === "tool") {
const data = evt.data ?? {};
const phase = asString(data.phase, "");
@@ -147,6 +148,7 @@ export function createEventHandlers(context: EventHandlerContext) {
return;
}
if (evt.stream === "lifecycle") {
if (!isActiveRun) return;
const phase = typeof evt.data?.phase === "string" ? evt.data.phase : "";
if (phase === "start") setActivityStatus("running");
if (phase === "end") setActivityStatus("idle");