From 70de6e17860d7343a73e117e6e9e1ce41b1b633e Mon Sep 17 00:00:00 2001 From: shivam <91240327+shivamhwp@users.noreply.github.com> Date: Wed, 5 Aug 2026 11:30:10 +0530 Subject: [PATCH] fix(mobile): prevent Android thread search crash (#5386) --- .../client-runtime/src/state/threadSearch.test.ts | 13 +++++++++++++ packages/client-runtime/src/state/threadSearch.ts | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/client-runtime/src/state/threadSearch.test.ts b/packages/client-runtime/src/state/threadSearch.test.ts index 2f1430a51b6bba2daaea681df7ab302f51946b40..9e6c682e72d5bb813ec147ddfbd4097acefa5a66 100644 --- a/packages/client-runtime/src/state/threadSearch.test.ts +++ b/packages/client-runtime/src/state/threadSearch.test.ts @@ -23,6 +23,19 @@ it("creates stable keys regardless of environment order", () => { ); }); +it("creates keys without array methods unavailable in Hermes", () => { + const descriptor = Object.getOwnPropertyDescriptor(Array.prototype, "toSorted"); + Reflect.deleteProperty(Array.prototype, "toSorted"); + + try { + expect(makeThreadSearchKey([envB, envA], "needle")).toBe('[["env-a","env-b"],"needle"]'); + } finally { + if (descriptor !== undefined) { + Reflect.defineProperty(Array.prototype, "toSorted", descriptor); + } + } +}); + it("encodes scoped thread keys without delimiter collisions", () => { const first = threadSearchMatchKey({ environmentId: EnvironmentId.make("env\u0000thread"), diff --git a/packages/client-runtime/src/state/threadSearch.ts b/packages/client-runtime/src/state/threadSearch.ts index 4011a91cd58c33d6d3e618bfa8e2de1d897892c3..b71186421ca60576ede3aa6523dc47909228748e 100644 --- a/packages/client-runtime/src/state/threadSearch.ts +++ b/packages/client-runtime/src/state/threadSearch.ts @@ -28,7 +28,7 @@ export function makeThreadSearchKey( query: string, ): string { return JSON.stringify([ - [...environmentIds].toSorted((left, right) => left.localeCompare(right)), + [...environmentIds].sort((left, right) => left.localeCompare(right)), query, ]); } -- 2.54.0