Skip to content
Source
Sign inSign up
pingdotgg/t3code

Synchronize mobile threads with authoritative shell snapshots #4163

Mergedjuliusmarmingemerged 4 commits intomain fromrefs/pull/4163/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

Summary

  • Refresh mobile shell and thread state from authoritative snapshots on connection and app resume.
  • Add completion markers and replay buffering to prevent missed events during snapshot loading.
  • Surface loading and catch-up status in the iOS workspace connection UI.
  • Add server and client-runtime coverage for synchronization, replay, and resubscription flows.

Testing

  • Added focused server router tests for completion markers and buffered shell events.
  • Added client-runtime tests for authoritative snapshot refresh and app-active resubscription.
  • Added mobile workspace connection status tests for initial loading and cached-thread catch-up.
  • Not run: local lint and test commands.

Note

Medium Risk Touches orchestration WebSocket replay, shell/thread sync state machines, and foreground resubscription—incorrect marker or buffering behavior could cause stale UI or missed updates, though coverage is extensive.

Overview Adds an end-to-end catch-up completion protocol for shell and thread subscriptions: streams can emit a { kind: "synchronized" } item after snapshot/replay when clients pass requestCompletionMarker, and ServerConfig advertises shellResumeCompletionMarker / threadResumeCompletionMarker.

Client runtime now loads an authoritative HTTP snapshot on each subscribe (replacing warm-cache-only resume), stays in synchronizing until the marker arrives, and uses subscribeDynamic plus app-foreground resubscribe to rebuild afterSequence and completion flags on session replacement. Deleted threads are not resurrected on foreground refresh.

Server buffers live shell events during full-snapshot fallback (same gap-closing pattern as thread subscribe) and injects the synchronized marker after catch-up when requested.

Mobile drops CompactBrandTitle in favor of a plain "Threads" header; the home empty state shows workspace connection status (including "Loading threads..." / "Syncing threads...") on iOS instead of a duplicate spinner when shell catch-up is pending.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 5dc6c173acfa2a41560092b957b51901e0fc6be5. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Synchronize mobile shell and thread state with authoritative server snapshots

  • Adds a synchronized completion marker to shell and thread subscription streams so clients know when catch-up replay is complete and live state begins. Server advertises support via shellResumeCompletionMarker / threadResumeCompletionMarker in ServerConfig.
  • Shell and thread state managers load an authoritative HTTP snapshot before resuming via afterSequence, replacing warm-cache-only resumption. State stays synchronizing until the synchronized marker arrives.
  • Both state managers resubscribe on app foreground (via ConnectionWakeups) and resume from the latest applied sequence, preventing stale data after the app returns from background.
  • Introduces subscribeDynamic in the RPC client to derive subscription inputs per session and trigger resubscriptions on external events (e.g. foreground wakeup).
  • Mobile home screen shows 'Syncing threads...' or 'Loading threads...' during shell synchronization and hides the loading spinner when the connection status banner is visible. Removes the CompactBrandTitle component, replacing it with the plain 'Threads' header title.
  • Risk: shell subscriptions previously streamed live events directly; they now buffer events published during snapshot loading and flush them after the snapshot, changing event ordering guarantees during the catch-up window.
Macroscope summarized 5dc6c17.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro

      Run ID: ec96494a-d45d-4b0e-9901-48f843ecb699

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests
      • Commit unit tests in branch `t3code/audit-mobile-thread-sync`

      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    3. Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

      Fix All in Cursor Bugbot Autofix is [ON](https://www.cursor.com/dashboard/bugbot), but a cloud agent failed to start. Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit d04128d697622614f8f58feaa60105f41c07bdbe. Configure [here](https://www.cursor.com/dashboard/bugbot).
    4. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Needs human review

      Introduces a new synchronization protocol with completion markers and foreground resubscription behavior across server and mobile client. The changes affect how thread data synchronization state is tracked and when resubscription occurs, representing meaningful new runtime behavior that warrants review.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    5. juliusmarminge added labels🚀 Mobile Continuous Deployment

    6. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium

      https://github.com/pingdotgg/t3code/blob/986a549ef84edf9d9d7a4b031aab206d5486ede9/packages/client-runtime/src/state/threads.ts#L107

      setSynchronizing unconditionally sets the thread status to "synchronizing", overwriting a "deleted" status. On a later session change or foreground resubscription, the makeSubscribeInput callback re-runs and the current.status !== "deleted" guard passes, so the client loads an HTTP snapshot and resurrects a thread whose cache was already removed. The guard in setReady preserves "deleted", but setSynchronizing does not. Consider adding the same current.status === "deleted" guard to setSynchronizing.

      ✅ Resolved in c52838d6788c13b26b893f2fc1517a7032ffca19

    7. github-actions[bot](GitHub profile, opens in a new tab)commented

      🚀 Expo continuous deployment is ready!

      • Project → t3-code
      • Platforms → android, ios
      • Scheme → t3code-preview
       🤖 Android🍎 iOS
      Fingerprint00e5b19bd3fc1481ea4ef627471c627133ebc3d7d68cf195f2e8866a1a50f9fa454fec49043e3ab8
      Build DetailsBuild Permalink
      DetailsDistribution: INTERNAL
      Build profile: preview:dev
      Runtime version: 00e5b19bd3fc1481ea4ef627471c627133ebc3d7
      App version: 0.1.0
      Git commit: 79d3ac6933f7cf6d608486c746cabd43edff126b
      Build Permalink
      DetailsDistribution: INTERNAL
      Build profile: preview:dev
      Runtime version: d68cf195f2e8866a1a50f9fa454fec49043e3ab8
      App version: 0.1.0
      Git commit: 79d3ac6933f7cf6d608486c746cabd43edff126b
      Update DetailsUpdate Permalink
      DetailsBranch: pr-4163
      Runtime version: 00e5b19bd3fc1481ea4ef627471c627133ebc3d7
      Git commit: 54c1f4c53ab148705b705af5de52a351cd4d2860
      Update Permalink
      DetailsBranch: pr-4163
      Runtime version: d68cf195f2e8866a1a50f9fa454fec49043e3ab8
      Git commit: 54c1f4c53ab148705b705af5de52a351cd4d2860
      Update QR
    8. juliusmarminge merged this8e3467f

    9. juliusmarminge closed this

Sign in to join this conversation.