diff --git a/apps/mobile/src/lib/threadActivity.test.ts b/apps/mobile/src/lib/threadActivity.test.ts index 46a79b70acd2cf64c7c053f49138a83032ae02bf..fb85ce1e1cc371f9d86098688789ebf180d8f307 100644 --- a/apps/mobile/src/lib/threadActivity.test.ts +++ b/apps/mobile/src/lib/threadActivity.test.ts @@ -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", diff --git a/packages/client-runtime/src/work-log/presentation.ts b/packages/client-runtime/src/work-log/presentation.ts index 8d62bb0794ca92760c302c019ad71559932f078f..bfb04eda32477cf6c395690f7dbee07edca876dc 100644 --- a/packages/client-runtime/src/work-log/presentation.ts +++ b/packages/client-runtime/src/work-log/presentation.ts @@ -658,7 +658,9 @@ export function omitSupersededLifecycleMarkers( } } - 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( diff --git a/packages/client-runtime/src/work-log/userInput.ts b/packages/client-runtime/src/work-log/userInput.ts index 355083c04836174abe115181f82d2c6fc5df2988..18dea7dd83c29feb8436a03d1b3128239cacd7fc 100644 --- a/packages/client-runtime/src/work-log/userInput.ts +++ b/packages/client-runtime/src/work-log/userInput.ts @@ -27,8 +27,9 @@ function questionFingerprint( questions: ReadonlyArray, ): 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; }