@devries-cameron20 / t3code Mirror · read-only / commits / e74f477eed
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 23, 08:00 UTC

fix(mobile): worktree setup clock pauses on hidden thread screens (#20066)

Co-authored-by: Aaron Queen <bompus@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Oct 15, 2026 at 20:08 UTC e74f477eed81012834e518ba172d0a83e33fe55e
1 file changed +5 -19
apps/mobile/src/features/threads/worktree-setup-card.tsx
+5 -19
@@ -5,14 +5,15 @@ import {
5 } from "@t3tools/contracts";
6 import { worktreeSetupAgentStarted } from "@t3tools/client-runtime/worktree-setup";
7 import { formatDuration } from "@t3tools/shared/orchestrationTiming";
8 -import { useEffect, useState } from "react";
9 -import { AppState, Platform, Pressable, ScrollView, View } from "react-native";
8 +import { useState } from "react";
9 +import { Platform, Pressable, ScrollView, View } from "react-native";
10 import { useSafeAreaInsets } from "react-native-safe-area-context";
11 import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
12 import { AppText as Text } from "../../components/ui/AppText";
13 import { SymbolView, type AppSymbolName } from "../../components/ui/AppSymbol";
14 import { WorktreeSetupSheet } from "./worktree-setup-sheet";
15 import { ShimmeringWorkContent } from "./thread-work-log";
16 +import { useVisibleSecondClock } from "./use-visible-second-clock";
17
18 export interface WorktreeSetupCardProps {
19 snapshot: WorktreeSetupSnapshot;
@@ -45,7 +46,7 @@ export function WorktreeSetupCard(props: WorktreeSetupCardProps) {
46 const backgroundSetup = handedOff && running;
47 const scriptName = snapshot.setupScript?.name ?? "Setup script";
48 const [detailsOpen, setDetailsOpen] = useState(false);
48 - const now = useSetupClock(running || working);
49 + const now = useVisibleSecondClock(running || working);
50 const failed =
51 snapshot.phase === "failed" || snapshot.stages.some((stage) => stage.status === "failed");
52 const label =
@@ -147,7 +148,7 @@ export function WorktreeSetupCard(props: WorktreeSetupCardProps) {
148 }
149
150 export function WorktreeWorkingHeader({ startedAt }: { startedAt: string }) {
150 - const now = useSetupClock(true);
151 + const now = useVisibleSecondClock(true);
152 return (
153 <View className="py-1">
154 <View className="min-h-11 flex-row items-center border-b border-border px-1">
@@ -188,21 +189,6 @@ function HeaderLabel({
189 );
190 }
191
191 -function useSetupClock(active: boolean) {
192 - const [now, setNow] = useState(Date.now);
193 - const [appState, setAppState] = useState(AppState.currentState);
194 - useEffect(() => {
195 - const subscription = AppState.addEventListener("change", setAppState);
196 - return () => subscription.remove();
197 - }, []);
198 - useEffect(() => {
199 - if (!active || appState !== "active") return;
200 - const timer = setInterval(() => setNow(Date.now()), 1000);
201 - return () => clearInterval(timer);
202 - }, [active, appState]);
203 - return now;
204 -}
205 -
192 function SetupDetailsSheet({
193 snapshot,
194 turnStarted,