summaryrefslogtreecommitdiffhomepage
path: root/packages/console
diff options
context:
space:
mode:
authorFrank <[email protected]>2026-03-18 10:59:52 -0400
committerFrank <[email protected]>2026-03-18 10:59:56 -0400
commit47cf267c232f6e36453eb3c7408c1e4d905a3239 (patch)
tree7243d1f07d2e69b55b237fa31f41c0560b2ad03f /packages/console
parent976aae7e4227cd0f29ac8081744a687743d425ef (diff)
downloadopencode-47cf267c232f6e36453eb3c7408c1e4d905a3239.tar.gz
opencode-47cf267c232f6e36453eb3c7408c1e4d905a3239.zip
zen: fix routing non OC traffic
Diffstat (limited to 'packages/console')
-rw-r--r--packages/console/app/src/routes/zen/util/handler.ts7
1 files changed, 5 insertions, 2 deletions
diff --git a/packages/console/app/src/routes/zen/util/handler.ts b/packages/console/app/src/routes/zen/util/handler.ts
index 9a0ab94f9..1996d48c5 100644
--- a/packages/console/app/src/routes/zen/util/handler.ts
+++ b/packages/console/app/src/routes/zen/util/handler.ts
@@ -120,6 +120,7 @@ export async function handler(
zenData,
authInfo,
modelInfo,
+ ip,
sessionId,
trialProviders,
retry,
@@ -402,6 +403,7 @@ export async function handler(
zenData: ZenData,
authInfo: AuthInfo,
modelInfo: ModelInfo,
+ ip: string,
sessionId: string,
trialProviders: string[] | undefined,
retry: RetryOptions,
@@ -430,10 +432,11 @@ export async function handler(
.flatMap((provider) => Array<typeof provider>(provider.weight ?? 1).fill(provider))
// Use the last 4 characters of session ID to select a provider
+ const identifier = sessionId.length ? sessionId : ip
let h = 0
- const l = sessionId.length
+ const l = identifier.length
for (let i = l - 4; i < l; i++) {
- h = (h * 31 + sessionId.charCodeAt(i)) | 0 // 32-bit int
+ h = (h * 31 + identifier.charCodeAt(i)) | 0 // 32-bit int
}
const index = (h >>> 0) % providers.length // make unsigned + range 0..length-1
const provider = providers[index || 0]