Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion apps/mobile/src/lib/threadActivity.test.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion packages/client-runtime/src/work-log/presentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 2 additions & 1 deletion packages/client-runtime/src/work-log/userInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Loading