fix(mobile): worktree setup clock pauses on hidden thread screens #20066
main fromrefs/pull/20066/head·merged by juliusmarminge View on GitHubA hidden mobile thread screen no longer re-renders every second for the worktree setup card and its "Working for" label.

Problem#
Mobile keeps a thread route mounted when another route is pushed over it (Files, Review, Terminal). The worktree setup card and the "Working for" header used a private one-second clock gated only on app state, so a hidden thread screen re-rendered every second until the app went to the background. #15397 fixed the same leak for the floating working timer and the subagent bar; these two labels were missed.
Change#
WorktreeSetupCard and WorktreeWorkingHeader now use the existing useVisibleSecondClock, which ticks only while the label is live, the screen is focused and the app is active, and re-reads the time before paint when ticking resumes. The private useSetupClock is deleted (+5/-19, one file). Nothing changes while the screen is visible.
Scope and approval#
Fixes #18922. Applies the hook #15397 added for the sibling timers to the two labels it missed.
Verification#
- Both components render only inside
ThreadFeedunder the native-stack thread routes, and the iPad column navigator supplies navigation context, souseIsFocusedalways resolves. The same subtree already uses the hook (ProviderSubagentBar,WorkingTimer,thread-subagent-group). use-visible-second-clock.test.tsxcovers the gating and the before-paint catch-up: 9/9 pass.vp run typecheckin apps/mobile and targeted lint: clean.- Two independent review rounds (Claude Opus 5.5 and GPT-6.1 Sol) found no issues.
- While a route sheet (agents, git overview, queue) covers part of the thread, these labels pause and jump to the right value when it closes, matching the floating timer since #15397.
- On an iPhone 17 Pro Max simulator (iOS 26.5, dev build), a render counter in
WorktreeSetupCardwas read while a worktree setup script ran. I measured 20 s with the thread visible, 20 s hidden under Files, and 20 s visible again, alternating builds: PR, main, PR, main.- main: 20 renders while hidden, in both runs, the same rate as while visible.
- this PR: 1 and 0 renders while hidden. The single render is the push transition, before the screen loses focus.
- Visible rates are unchanged, 19-20 per 20 s on both builds, and the label shows the correct elapsed time when the thread is shown again.
Original work by @bompus in #17701, taken over by maintainers.
Claude Opus 5.5 and Claude Fable 5.1 in Claude Code, with review by GPT-6.1 Sol in Codex.
🤖 Generated with Claude Code
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
juliusmarminge added labelsmacroscope-review
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
Approvability#
Verdict: Approved at
25b3b1bMacroscope's review found this PR approvable — This is a narrowly scoped mobile bug fix that reuses an existing visibility-aware clock, preserving visible timer behavior while preventing unnecessary updates on hidden thread screens. It changes one UI component file and introduces no schema, product-default, deployment, or static-analysis configuration changes.
No code changes detected at
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).17ed825. Prior analysis still applies.No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
-
⚙️ Run configuration
-
- Configuration used: Path: .coderabbit.config.ts
- Review profile: CHILL
- Plan: Team
- Run ID:
8a079104-abd4-4bb3-a29e-db5ef0e9ccf6
📥 Commits
-
Reviewing files that changed from the base of the PR and between 25b3b1bb3d9d129fc1ee7cf21d41e0ad5f2ee8a9 and 17ed825434027cdf8ce8268a0b6fe2acf5396888.
📒 Files selected for processing: 1
-
apps/mobile/src/features/threads/worktree-setup-card.tsx
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
-
📝 Walkthrough
-
The worktree setup card and working header now use
useVisibleSecondClock. The component-local clock hook, including its app-state listener and interval, was removed.Changes: Worktree setup clock
Layer / File(s) Summary Use the visible-second clock
apps/mobile/src/features/threads/worktree-setup-card.tsxWorktreeSetupCardretains its `runningPriority: ⬇️ Low
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Low
Suggested reviewers:
pixpmusic
Merge Risk: ⚪ Minimal · up to
17ed8-
The worktree labels pause while the thread is beneath a pushed route and refresh when it becomes visible again. No actionable merge-blocking risk remains.
Pre-merge checks:
4-
Check name Status Explanation Linked Issues check PR #20066satisfies the coding requirements in active issue#18922. Inapps/mobile/src/features/threads/worktree-setup-card.tsx, bothWorktreeSetupCardandWorktreeWorkingHeadernow use `useVisi…Out of Scope Changes check The whole-PR change is limited to apps/mobile/src/features/threads/worktree-setup-card.tsx. It directly replaces the clock identified by issue#18922with the existing visibility-aware hook. No unre…Title check The title clearly and concisely describes the fix: preventing the worktree setup clock from continuing on hidden mobile thread screens. It uses an appropriate conventional commit format. Description check The description includes all required sections: Problem, Change, Scope and approval, and Verification. It explains the affected behavior, implementation, issue reference, tests, lint and typecheck res…
✨ 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
-
Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
ℹ️ The exact PR base did not have a successful artifact. Baseline uses the latest successful
mainmeasurement shown below.Provider Metric Main baseline This PR Impact PR ceiling Codex Total thread wire 5.0 KiB 5.0 KiB +7 B (+0.1%) 6.8 KiB ✅ Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅ Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB +7 B (+0.6%) 2.0 KiB ✅ Codex Live turn WebSocket decoded 20.9 KiB 20.9 KiB 0 B (0.0%) 29.3 KiB ✅ Codex Live turn messages 2 2 0 (0.0%) 8 ✅ Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅ Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅ Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅ Claude Live turn WebSocket decoded 21.2 KiB 21.2 KiB 0 B (0.0%) 29.3 KiB ✅ Claude Live turn messages 2 2 0 (0.0%) 8 ✅ Baseline:
eef0e4e· PR result:25b3b1b· Source CI: failureScenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
- Codex decoded thread snapshot: 108.5 KiB
- Claude decoded thread snapshot: 108.8 KiB
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.
juliusmarminge merged thise74f477
juliusmarminge closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes