Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(mobile): threads open with less waiting, and the Threads tab remembers drafts #24750

Mergedjuliusmarmingemerged 2 commits intomain fromrefs/pull/24750/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

Two follow-ups to #24742: opening a thread felt slow, and returning to the Threads tab after leaving a draft opened the last real thread instead of the draft.

Thread opening

Profiling a thread switch on the iPhone Duo simulator (dev build) found three things to cut:

  • Data loads late. A thread's data started loading only after navigation committed and the screen subscribed during render. The shared selection action now mounts the thread's state atom before it dispatches, holding it for 3 s until the screen takes over. It runs only on an actual selection, not on touch-down, so scrolling past rows fetches nothing.
  • Per-frame re-renders. ThreadComposer animates its height and reports a layout every frame, and ThreadDetailScreen stored each one in state. So every composer resize re-rendered the whole thread screen about 16 times (on thread switches, and when the composer grows while typing). The feed already follows the composer on the UI thread through onComposerLayout, and that state is only an estimate, so it now commits once the size settles.
  • Unchanged republishes. ThreadScreenBinding republished a fresh props object after every controller render, re-rendering the screen even when nothing it receives had changed. Publishing now skips shallow-equal props.

Measured on a thread switch: the per-frame burst after the switch went from about 16 thread-screen commits to one settle commit, and one of the three loading-status re-renders is gone.

Not changed:

  • Cold opens still wait on the disk cache and then the server snapshot in sequence. Running threads are never cached on disk, and the live subscription is released immediately on leave (re-opens within 5 minutes resume from memory).
  • Home rebuilds every list item and project map on each render, so selection re-renders every visible row. That memo break is upstream of the list hook.

Draft memory

workspaceSelectionsIn only recorded Thread routes with a thread id, so a draft shown after a chat was forgotten. The Threads tab now remembers that draft (route key and params, for the session only; dropped on load like the other route keys). Opening another chat replaces it.

After leaving a draft for Settings, the Threads tab reopens the draft

Verification

iPhone Duo simulator, unfolded:

  • Thread switches profiled before and after.
  • Draft, then Settings, then Chats reopens the draft.

vp run check:changed passes. A new tab-navigation test covers the draft returning, and being replaced by a later chat.

Claude Opus 5.5 in Claude Code, running in T3 Code.

🤖 Generated with Claude Code

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

      Approvability

      Verdict: Needs Human Approval

      Macroscope's review found this PR requires human approval — This PR changes several production mobile paths: it preloads thread state, alters composer and swipeable rendering behavior, and adds automatic draft restoration for the Threads tab. The behavior is cross-cutting and user-facing rather than a small isolated change, so it merits human review.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    2. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →

      No actionable comments were generated in the recent review.

      Recent review info
      Run configuration
      Commits

      Reviewing files that changed from the base of the PR and between 90219e10d1b5e2366f839588ada2ac60eb0b4cb0 and d31fb36c96a4b3901716d2b100a40574eb60418f.

      Files selected for processing: 1
      • apps/mobile/src/features/home/thread-swipe-actions.tsx

      Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

      Walkthrough

      Workspace selection now preserves draft Thread routes. Thread selection starts mounting thread state before navigation, composer height changes settle after layout reports, and swipe actions reuse cached rendering elements and stable configuration.

      Changes: Workspace Draft Route Restoration

      Layer / File(s)Summary
      Save and restore draft Thread routes
      apps/mobile/src/persistence/mobile-preferences.ts, apps/mobile/src/features/workspace/workspace-tab-navigation.ts, apps/mobile/src/features/workspace/workspace-selection-store.ts, apps/mobile/src/features/workspace/workspace-tab-navigation.test.ts
      Workspace selections store keyed Thread routes without a threadId as drafts. The Threads tab restores a saved draft, and identified threads replace the draft. A test covers draft restoration and replacement by a regular chat.

      Thread Opening and Screen Updates

      Layer / File(s)Summary
      Mount thread state before navigation
      apps/mobile/src/state/threads.ts, apps/mobile/src/features/workspace/useSelectWorkspaceDetail.ts, apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx
      Thread detail selection starts mounting the environment-thread state atom before navigation. The mount is released after 3,000 ms.
      Settle composer height updates
      apps/mobile/src/features/threads/ThreadDetailScreen.tsx
      The first composer layout report sets the height estimate. Later reports reset a 220 ms timer, and unmounting clears the pending timer.

      Thread Swipe Action Rendering

      Layer / File(s)Summary
      Stabilize swipe action rendering
      apps/mobile/src/features/home/thread-swipe-actions.tsx
      The swipeable row uses memoized callbacks and styles, a shared fail-offset constant, and a cached right-action element that is rebuilt when tracked dependencies change.
      Priority: Normal

      Estimated code review effort: 3 (Moderate) | ~20 minutes

      Change: Bug fix

      Sequence Diagram(s)

      sequenceDiagram
        participant AdaptiveWorkspaceLayout
        participant startOpeningDetail
        participant startOpeningEnvironmentThread
        participant ThreadStateAtom
        participant WorkspaceNavigation
        AdaptiveWorkspaceLayout->>startOpeningDetail: Start opening selected detail
        startOpeningDetail->>startOpeningEnvironmentThread: Pass environmentId and threadId
        startOpeningEnvironmentThread->>ThreadStateAtom: Mount thread state atom
        startOpeningEnvironmentThread->>startOpeningEnvironmentThread: Schedule mount release after 3000 ms
        AdaptiveWorkspaceLayout->>WorkspaceNavigation: Dispatch detail navigation

      Possibly related issues

      • pingdotgg/t3code#24192 — The issue reports a delay when opening an existing mobile thread. This change mounts thread state before navigation.
      • pingdotgg/t3code#15974 — The issue reports that a new-task draft does not resume after navigating away. This change saves and restores the draft Thread route.
      • pingdotgg/t3code#24305 — The issue reports blank Android transcripts when activating existing threads. This change starts loading thread state earlier, but the reported provider-switch or Back-navigation causes are not established here.

      Suggested labels: bugfix

      Suggested reviewers: maria-rcks

      Merge Risk: Minimal · up to d31fb

      The reviewed navigation and rendering changes have no identified issue that needs fixing before merge; normal checks remain appropriate.

      Pre-merge checks: Passed 3 · Failed 1
      Failed Failed checks: 1 warning
      Check nameStatusExplanationResolution
      Description checkWarningThe description explains the problems, implementation, and verification results in detail. However, it omits the required Scope and approval information, does not use the required Problem and Change s…Add the required Problem, Change, Scope and approval, and Verification sections. Link the triaged issue or approved discussion and include the approval evidence, or explain why this focused fix qualifies for an exemption. Add clear before/a…
      Passed Passed checks: 3 passed
      Check nameStatusExplanation
      Title checkPassedThe title clearly summarizes both primary changes: faster thread opening and Threads-tab draft retention.
      Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
      Full details: Description check

      Explanation

      The description explains the problems, implementation, and verification results in detail. However, it omits the required Scope and approval information, does not use the required Problem and Change section headings, and does not provide the required before/after UI evidence or a recording for timing and interaction changes.

      Resolution

      Add the required Problem, Change, Scope and approval, and Verification sections. Link the triaged issue or approved discussion and include the approval evidence, or explain why this focused fix qualifies for an exemption. Add clear before/after screenshots and a short recording that demonstrates the thread-opening timing and draft-restoration behavior.

      Finishing Touches
      📝 Generate docstrings
      • Commit to this branch
      • Create a new PR
      🧪 Generate unit tests (beta)
      • Commit to this branch
      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
      Comment `@coderabbitai help` to get the list of available commands.
    3. juliusmarminge merged this8d3261e

    4. juliusmarminge closed this

Sign in to join this conversation.