Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

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

shivam70de6e17860d
diff --git a/packages/client-runtime/src/state/threadSearch.test.ts b/packages/client-runtime/src/state/threadSearch.test.ts
index 2f1430a51..9e6c682e7 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 4011a91cd..b71186421 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,
]);
}