fix(mobile): support Hermes collection sorting

Reuses the focused compatibility approach from closed PR #3923 and covers the remaining hardware-keyboard reverse iteration.

Co-authored-by: codex <[email protected]>
This commit is contained in:
Julius Marmingeandcodex committed 2026-08-14 11:23:26 +02:00
1 parent 9c65560b35
commit 32b749d07e
8 files changed
+72 -22

No files matched your search

@@ -3,6 +3,7 @@ import type {
OrchestrationV2ProviderCapabilities,
OrchestrationV2ThreadProjection,
} from "@t3tools/contracts";
import { copySorted } from "@t3tools/shared/Array";
type Projection = OrchestrationV2ThreadProjection;
type Run = Projection["runs"][number];
@@ -54,19 +55,17 @@ export function deriveThreadQueueWorkflowState(projection: Projection): ThreadQu
const activeRun = resolveActiveThreadRun(projection);
const session = resolveThreadProviderSession(projection);
const capabilities = session?.capabilities.turns;
const queuedRuns = projection.runs
.filter((run) => run.status === "queued")
.toSorted(
(left, right) =>
(left.queuePosition ?? left.ordinal) - (right.queuePosition ?? right.ordinal) ||
left.ordinal - right.ordinal,
)
.map((run) => ({
run,
text:
projection.messages.find((message) => message.id === run.userMessageId)?.text ??
"Queued message",
}));
const queuedRuns = copySorted(
projection.runs.filter((run) => run.status === "queued"),
(left, right) =>
(left.queuePosition ?? left.ordinal) - (right.queuePosition ?? right.ordinal) ||
left.ordinal - right.ordinal,
).map((run) => ({
run,
text:
projection.messages.find((message) => message.id === run.userMessageId)?.text ??
"Queued message",
}));
return {
activeRun,