Skip to content

Commit ad14ae5

Browse files
committed
fix(ui): global scope resolves the global sentinel as canonical main even pre-hello
1 parent b3e13b1 commit ad14ae5

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

‎ui/src/lib/sessions/session-key.ts‎

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,19 @@ export function resolveUiCanonicalMainSessionKey(
189189
host: Pick<UiSessionDefaultsHost, "agentsList" | "hello">,
190190
): string {
191191
const defaults = readSessionDefaults(host);
192-
return (
193-
normalizeOptionalString(defaults?.mainSessionKey) ??
194-
buildAgentMainSessionKey({
195-
agentId: resolveUiDefaultAgentId(host),
196-
mainKey: resolveUiConfiguredMainKey(host),
197-
})
198-
);
192+
const advertised = normalizeOptionalString(defaults?.mainSessionKey);
193+
if (advertised) {
194+
return advertised;
195+
}
196+
// Global scope routes main to the "global" sentinel even when the gateway
197+
// has not advertised a main session key yet (e.g. pre-hello snapshots).
198+
if (normalizeOptionalLowercaseString(host.agentsList?.scope) === "global") {
199+
return "global";
200+
}
201+
return buildAgentMainSessionKey({
202+
agentId: resolveUiDefaultAgentId(host),
203+
mainKey: resolveUiConfiguredMainKey(host),
204+
});
199205
}
200206

201207
function normalizeUiSessionEventKey(

0 commit comments

Comments
 (0)