fix(mobile): Recover thread state reliably after reconnects#4034
fix(mobile): Recover thread state reliably after reconnects#4034juliusmarminge wants to merge 3 commits into
Conversation
Co-authored-by: codex <codex@users.noreply.github.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
ApprovabilityVerdict: Approved Bug fix for reconnection handling with limited scope. The core change restores 'live' status when cached data exists after reconnect, adds automatic retry logic with timeouts, and includes comprehensive test coverage. Author is the primary contributor to these files. You can customize Macroscope's approvability policy. Learn more. |
Co-authored-by: codex <codex@users.noreply.github.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.
Reviewed by Cursor Bugbot for commit 2f86672. Configure here.
Co-authored-by: codex <codex@users.noreply.github.com>

Extracted from #3910.
Makes cached shell and thread state recover predictably after reconnects, preserves actionable error causes, retries stalled detail loading, and adds focused shell/thread synchronization coverage.
Validation inherited from #3910:
vp checkand mobile native lint passed before the split. The full typecheck is currently blocked in this workspace by unavailable mobile dependencies (expo-blur,expo-quick-actions, and@tabler/icons-react-native).Note
Recover thread and shell state reliably after reconnects in mobile
makeEnvironmentShellState.setReadyandmakeEnvironmentThreadState.setReadyto return to'live'status when cached data exists after a reconnect, even if no new sync events arrive.ThreadRouteScreen: when a thread detail stalls while connected, it retries at ~8s and ~12s, then surfaces a static error message if still unresolved.useEnvironmentThreadQueryanduseSelectedThreadDetailQueryhooks that exposerefresh,isPending, and preserved-on-failure state.causeFailureMessageutility inclient-runtimefor consistent user-facing error extraction fromCausevalues, replacing ad-hocCause.squashcalls.'live'on reconnect without waiting for new events; thread sync error message text may change for some failure shapes.Macroscope summarized 9ff248f.
Note
Medium Risk
Changes reconnect state transitions in shared client-runtime shell/thread sync and add timed refresh logic on the thread route; behavior is covered by new tests but affects live sync UX after reconnects.
Overview
Shell and thread sync now go
liveon reconnect when cached snapshot/data already exists, instead of staying insynchronizinguntil new stream events arrive (setReadyinshell.tsandthreads.ts). Tests cover reconnect with no new events.Mobile thread detail gains
useEnvironmentThreadQuery/useSelectedThreadDetailQuerywithrefreshandisPending, plusenvironmentThreadStateFromAsyncResultso refresh failures keep prior data while surfacing errors.ThreadRouteScreenadds a stall watchdog: while connected with no detail, it refreshes at 8s and 12s, then shows a user-facing load error if detail still never arrives.causeFailureMessageinclient-runtimecentralizes Effect Cause message extraction for mobile queries and thread/shell error strings.Reviewed by Cursor Bugbot for commit 9ff248f. Bugbot is set up for automated code reviews on this repo. Configure here.