fix(mobile): prevent Hermes crashes when opening threads (#11233)

This commit is contained in:
Jake Leventhal authored and GitHub committed 2026-09-11 09:01:23 -07:00
1 parent 5eecc24a10
commit 2ebc9fa4ed
3 files changed
+21 -3

No files matched your search

+16 -1
View File
@@ -1,5 +1,5 @@
import { derivePendingRequests } from "@t3tools/client-runtime/pending-requests";
import { describe, expect, it } from "vite-plus/test";
import { beforeEach, describe, expect, it } from "vite-plus/test";
import {
ApprovalRequestId,
@@ -27,6 +27,21 @@ import {
type WorkLogEntry,
} from "./threadActivity";
// Match Hermes: these ES2023 array methods are absent on mobile.
beforeEach(() => {
const methods = ["toSorted", "toReversed"] as const;
const descriptors = methods.map((method) =>
Object.getOwnPropertyDescriptor(Array.prototype, method),
);
for (const method of methods) Reflect.deleteProperty(Array.prototype, method);
return () => {
for (const [index, method] of methods.entries()) {
const descriptor = descriptors[index];
if (descriptor) Reflect.defineProperty(Array.prototype, method, descriptor);
}
};
});
const singleSelectQuestion = {
id: "runtime",
header: "Runtime",
@@ -658,7 +658,9 @@ export function omitSupersededLifecycleMarkers<T>(
}
}
return reversedEntries.toReversed();
// Hermes lacks toReversed; this array is local, so reversing it cannot mutate the input.
// oxlint-disable-next-line unicorn/no-array-reverse
return reversedEntries.reverse();
}
export function toolGroupSummaryKind(
@@ -27,8 +27,9 @@ function questionFingerprint(
questions: ReadonlyArray<unknown>,
): string | undefined {
const texts = questions.map((question) => (typeof question === "string" ? question.trim() : ""));
// Sort the fresh array in place because Hermes does not provide toSorted.
return texts.length > 0 && texts.every(Boolean)
? JSON.stringify([turnId, texts.toSorted()])
? JSON.stringify([turnId, texts.sort()])
: undefined;
}