Skip to content

Commit 5fc2e6c

Browse files
committed
fix(webchat): accept gateway hello snapshot shape
1 parent 42b5a6a commit 5fc2e6c

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

ui/src/ui/chat/composer-persistence.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,7 @@ type ChatComposerPersistenceState = {
1212
assistantAgentId?: string | null;
1313
agentsList?: { defaultId?: string | null; mainKey?: string | null } | null;
1414
hello?: {
15-
snapshot?: {
16-
sessionDefaults?: {
17-
defaultAgentId?: string | null;
18-
mainKey?: string | null;
19-
} | null;
20-
} | null;
15+
snapshot?: unknown;
2116
} | null;
2217
sessionKey: string;
2318
chatMessage: string;
@@ -46,7 +41,18 @@ function storageKeyForGateway(gatewayUrl: string | null | undefined): string {
4641
}
4742

4843
function readHelloDefaultAgentId(state: Pick<ChatComposerPersistenceState, "hello">) {
49-
return state.hello?.snapshot?.sessionDefaults?.defaultAgentId?.trim() || undefined;
44+
const snapshot = state.hello?.snapshot;
45+
if (!snapshot || typeof snapshot !== "object") {
46+
return undefined;
47+
}
48+
const defaults = (snapshot as { sessionDefaults?: unknown }).sessionDefaults;
49+
if (!defaults || typeof defaults !== "object") {
50+
return undefined;
51+
}
52+
const defaultAgentId = (defaults as { defaultAgentId?: unknown }).defaultAgentId;
53+
return typeof defaultAgentId === "string" && defaultAgentId.trim()
54+
? defaultAgentId.trim()
55+
: undefined;
5056
}
5157

5258
function resolveComposerAgentScope(

0 commit comments

Comments
 (0)