authorgravatar for 91240327+shivamhwp@users.noreply.github.comshivam <91240327+shivamhwp@users.noreply.github.com> 2026-08-05 11:30:10+05:30
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-08-05 11:30:10+05:30
log70de6e17860d7343a73e117e6e9e1ce41b1b633e
treef70c457da944bf98c2fb482944a20b8a4e84aed8
parent47dfc6526521866992f6b50beac4587b45114631
signature Signed by PGP key B5690EEEBB952194

fix(mobile): prevent Android thread search crash (#5386)


2 files changed, 14 insertions(+), 1 deletions(-)

packages/client-runtime/src/state/threadSearch.test.ts+13
...@@ -23,6 +23,19 @@ it("creates stable keys regardless of environment order", () => {...@@ -23,6 +23,19 @@ it("creates stable keys regardless of environment order", () => {
23 );23 );
24});24});
2525
26it("creates keys without array methods unavailable in Hermes", () => {
27 const descriptor = Object.getOwnPropertyDescriptor(Array.prototype, "toSorted");
28 Reflect.deleteProperty(Array.prototype, "toSorted");
29
30 try {
31 expect(makeThreadSearchKey([envB, envA], "needle")).toBe('[["env-a","env-b"],"needle"]');
32 } finally {
33 if (descriptor !== undefined) {
34 Reflect.defineProperty(Array.prototype, "toSorted", descriptor);
35 }
36 }
37});
38
26it("encodes scoped thread keys without delimiter collisions", () => {39it("encodes scoped thread keys without delimiter collisions", () => {
27 const first = threadSearchMatchKey({40 const first = threadSearchMatchKey({
28 environmentId: EnvironmentId.make("env\u0000thread"),41 environmentId: EnvironmentId.make("env\u0000thread"),
packages/client-runtime/src/state/threadSearch.ts+1-1
...@@ -28,7 +28,7 @@ export function makeThreadSearchKey(...@@ -28,7 +28,7 @@ export function makeThreadSearchKey(
28 query: string,28 query: string,
29): string {29): string {
30 return JSON.stringify([30 return JSON.stringify([
31 [...environmentIds].toSorted((left, right) => left.localeCompare(right)),31 [...environmentIds].sort((left, right) => left.localeCompare(right)),
32 query,32 query,
33 ]);33 ]);
34}34}