fix: avoid repeat mobile view commands

This commit is contained in:
Theo Browne committed 2026-08-14 21:12:06 -07:00
1 parent 5d1f1723bd
commit 120eab2e47
1 file changed
+12
@@ -96,6 +96,13 @@ function firstRouteParam(value: string | string[] | undefined): string | null {
return value ?? null;
}
function timestampCovers(timestamp: string | undefined, target: string): boolean {
if (timestamp === undefined) return false;
const timestampMs = Date.parse(timestamp);
const targetMs = Date.parse(target);
return Number.isFinite(timestampMs) && Number.isFinite(targetMs) && timestampMs >= targetMs;
}
function OpeningThreadLoadingScreen() {
return <LoadingScreen message="Opening thread…" messagePlacement="above-spinner" />;
}
@@ -288,6 +295,8 @@ function ThreadRouteContent(
const selectedThreadEnvironmentId = selectedThread?.environmentId ?? null;
const selectedThreadId = selectedThread?.id ?? null;
const selectedThreadCompletedAt = selectedThread?.latestTurn?.completedAt ?? null;
const selectedThreadViewedAtRef = useRef(selectedThread?.viewedAt);
selectedThreadViewedAtRef.current = selectedThread?.viewedAt;
const supportsThreadViewState = serverConfig?.environment.capabilities.threadViewState === true;
useFocusEffect(
useCallback(() => {
@@ -299,6 +308,9 @@ function ThreadRouteContent(
) {
return;
}
if (timestampCovers(selectedThreadViewedAtRef.current, selectedThreadCompletedAt)) {
return;
}
void viewThread({
environmentId: selectedThreadEnvironmentId,
input: {