Skip to content

Commit 82ec5ad

Browse files
shivamhwpclaude
andcommitted
fix(mobile): keep the thread route while Reconnect retries
Reconnect clears the failure, so the environment reads as connecting while a thread that failed to sync still has its error. The route kept falling through to a new draft before the retry finished. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 045a5c2 commit 82ec5ad

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

‎apps/mobile/src/features/threads/thread-route-hydration.test.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,17 @@ describe("threadRouteOpensDraft", () => {
100100
).toBe(false);
101101
});
102102

103+
it("keeps the route while Reconnect retries a thread that failed to sync", () => {
104+
const failedDetail = {
105+
...settled,
106+
connectionState: "connecting" as const,
107+
detailStatus: "empty" as const,
108+
detailHasError: true,
109+
};
110+
expect(threadRouteIsHydrating(failedDetail)).toBe(false);
111+
expect(threadRouteOpensDraft(failedDetail)).toBe(false);
112+
});
113+
103114
it("opens a draft once the thread can't arrive", () => {
104115
expect(
105116
threadRouteOpensDraft({ connectionState: "reconnecting", detailStatus: "deleted" }),

‎apps/mobile/src/features/threads/thread-route-hydration.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,15 @@ export function threadRouteIsHydrating(input: {
4444

4545
/**
4646
* Replacing the route with a draft can't be undone, so a thread that may still arrive keeps its
47-
* route: a reconnecting environment often delivers it moments later.
47+
* route: a reconnecting environment often delivers it moments later, and Reconnect starts a
48+
* fresh connecting attempt.
4849
*/
4950
export function threadRouteOpensDraft(input: {
5051
readonly connectionState: EnvironmentConnectionPhase;
5152
readonly detailStatus: EnvironmentThreadStatus;
5253
}): boolean {
53-
return input.connectionState !== "reconnecting" || input.detailStatus === "deleted";
54+
if (input.detailStatus === "deleted") {
55+
return true;
56+
}
57+
return input.connectionState !== "reconnecting" && input.connectionState !== "connecting";
5458
}

0 commit comments

Comments
 (0)