From 9caea0266e3640179ef279b4a7367761fd6a442a Mon Sep 17 00:00:00 2001 From: zihao <148683411+lisd33@users.noreply.github.com> Date: Sat, 28 Mar 2026 16:33:22 +0800 Subject: [PATCH] fix(frontend): separate mock and default LangGraph clients (#1504) Co-authored-by: Willem Jiang --- frontend/src/core/api/api-client.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/frontend/src/core/api/api-client.ts b/frontend/src/core/api/api-client.ts index 72f237c..b862515 100644 --- a/frontend/src/core/api/api-client.ts +++ b/frontend/src/core/api/api-client.ts @@ -30,8 +30,15 @@ function createCompatibleClient(isMock?: boolean): LangGraphClient { return client; } -let _singleton: LangGraphClient | null = null; +const _clients = new Map(); export function getAPIClient(isMock?: boolean): LangGraphClient { - _singleton ??= createCompatibleClient(isMock); - return _singleton; + const cacheKey = isMock ? "mock" : "default"; + let client = _clients.get(cacheKey); + + if (!client) { + client = createCompatibleClient(isMock); + _clients.set(cacheKey, client); + } + + return client; }