fix(ui): retain scoped global session metadata

This commit is contained in:
Peter Steinberger
2026-07-27 00:43:08 -07:00
parent 64bf485ba2
commit d68adeb5f8
2 changed files with 22 additions and 4 deletions
+13 -4
View File
@@ -78,10 +78,19 @@ export function selectedChatSessionRow(state: ChatPageHost) {
return row;
}
const selectedAgentId = resolveUiSelectedGlobalAgentId(state);
const mismatchedOwner = [state.sessionsResultAgentId, row.observerDigest?.agentId].some(
(agentId) => agentId && normalizeAgentId(agentId) !== selectedAgentId,
);
return mismatchedOwner ? undefined : row;
if (
state.sessionsResultAgentId &&
normalizeAgentId(state.sessionsResultAgentId) !== selectedAgentId
) {
return undefined;
}
if (
row.observerDigest?.agentId &&
normalizeAgentId(row.observerDigest.agentId) !== selectedAgentId
) {
return { ...row, observerDigest: undefined };
}
return row;
}
function saveChatQueueForSession(state: ChatPageHost, sessionKey: string) {
+9
View File
@@ -239,6 +239,15 @@ describe("ChatStateController render lifecycle", () => {
expect(state.observerDigest?.headline).toBe("Reconnected live status");
expect(requestUpdate).toHaveBeenCalledOnce();
const projectedRow = state.sessionsResult?.sessions[0];
if (projectedRow?.observerDigest) {
projectedRow.observerDigest.agentId = "main";
}
const sanitized = selectedChatSessionRow(state);
expect(sanitized?.key).toBe("global");
expect(sanitized?.activeRunIds).toEqual(["run-work"]);
expect(sanitized?.observerDigest).toBeUndefined();
state.sessionsResultAgentId = "main";
expect(selectedChatSessionRow(state)).toBeUndefined();
});