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", () => {
2323 );
2424});
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
2639it("encodes scoped thread keys without delimiter collisions", () => {
2740 const first = threadSearchMatchKey({
2841 environmentId: EnvironmentId.make("env\u0000thread"),
packages/client-runtime/src/state/threadSearch.ts+1-1
......@@ -28,7 +28,7 @@ export function makeThreadSearchKey(
2828 query: string,
2929): string {
3030 return JSON.stringify([
31 [...environmentIds].toSorted((left, right) => left.localeCompare(right)),
31 [...environmentIds].sort((left, right) => left.localeCompare(right)),
3232 query,
3333 ]);
3434}