Skip to content

Commit e462f6d

Browse files
fix(mobile): a moved thread is followed when its screen comes back into view
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
1 parent f9b222d commit e462f6d

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

‎apps/mobile/src/features/threads/ThreadHandoffCard.tsx‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useAtomValue } from "@effect/atom-react";
2-
import { StackActions, useNavigation } from "@react-navigation/native";
2+
import { StackActions, useIsFocused, useNavigation } from "@react-navigation/native";
33
import {
44
isAtomCommandInterrupted,
55
squashAtomCommandFailure,
@@ -103,9 +103,10 @@ export function ThreadHandoffCard({ thread }: { readonly thread: EnvironmentThre
103103
label: moved?.label ?? "",
104104
title: thread.title,
105105
});
106-
const follow = useEffectEvent((reachable: boolean) => {
107-
// Another screen the user opened on top is theirs to keep.
108-
if (moved === null || !navigation.isFocused()) return;
106+
const screenFocused = useIsFocused();
107+
const follow = useEffectEvent((reachable: boolean, focused: boolean) => {
108+
// Another screen the user opened on top is theirs to keep; coming back follows then.
109+
if (moved === null || !focused) return;
109110
if (reachable) {
110111
navigation.dispatch(
111112
StackActions.replace("Thread", {
@@ -121,8 +122,8 @@ export function ThreadHandoffCard({ thread }: { readonly thread: EnvironmentThre
121122
});
122123
// oxlint-disable-next-line t3code/no-unreasoned-state-sync -- a move the server reports takes the screen to the thread it continues as, pairing over the network first
123124
useEffect(() => {
124-
if (movedId !== undefined) follow(connectedThere);
125-
}, [movedId, connectedThere]);
125+
if (movedId !== undefined) follow(connectedThere, screenFocused);
126+
}, [movedId, connectedThere, screenFocused]);
126127
if (handoff === null && threadAwaitsAdoption(thread)) {
127128
return <AdoptMovedThread thread={thread} canAdopt={canAdopt} />;
128129
}

0 commit comments

Comments
 (0)