Skip to content

Commit 7a328c4

Browse files
fix(mobile): thread row timers no longer reflow the title every second (#33447)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent b8c2cfa commit 7a328c4

1 file changed

Lines changed: 32 additions & 9 deletions

File tree

‎apps/mobile/src/features/threads/thread-list-v2-items.tsx‎

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import { canSnooze } from "@t3tools/client-runtime/state/thread-settled";
3131
import { threadChipCopyTarget } from "@t3tools/client-runtime/thread-reference";
3232
import type { MenuAction } from "@react-native-menu/menu";
3333
import { memo, useCallback, useMemo, useState, type ComponentProps } from "react";
34-
import { Platform, Pressable, useWindowDimensions, View } from "react-native";
34+
import { Platform, Pressable, Text as RNText, useWindowDimensions, View } from "react-native";
3535
import type { SwipeableMethods } from "react-native-gesture-handler/ReanimatedSwipeable";
3636

3737
import type { ThreadListProvider } from "../../state/thread-list-environments";
@@ -84,7 +84,8 @@ import { PullRequestGlyph } from "../pull-requests/pullRequestGlyphs";
8484
import { pullRequestStatus } from "../pull-requests/pullRequestStatus";
8585

8686
interface StatusLabel {
87-
readonly label: string;
87+
// Null when the icon and timer carry the status on their own.
88+
readonly label: string | null;
8889
readonly icon: AppSymbolName;
8990
readonly className: string;
9091
readonly iconTintClassName: string;
@@ -109,13 +110,13 @@ const STATUS_LABEL_BY_STATUS: Partial<Record<ThreadListV2Status, StatusLabel>> =
109110
iconTintClassName: "accent-adaptive-fuchsia-600-300",
110111
},
111112
working: {
112-
label: "Working",
113+
label: null,
113114
icon: "circle.dashed",
114115
className: "text-adaptive-sky-600-400",
115116
iconTintClassName: "accent-adaptive-sky-600-400",
116117
},
117118
waiting: {
118-
label: "Waiting",
119+
label: null,
119120
icon: "circle.dashed.inset.filled",
120121
className: "text-foreground-muted",
121122
iconTintClassName: "accent-foreground-muted",
@@ -140,11 +141,28 @@ const DONE_STATUS_LABEL: StatusLabel = {
140141
iconTintClassName: "accent-adaptive-emerald-700-300",
141142
};
142143

143-
function ThreadListV2Duration(props: { readonly startedAt: string | null }) {
144+
// DM Sans has no tabular figures, so a ticking timer in it reflows the row every second.
145+
const TABULAR_DURATION_STYLE = {
146+
fontFamily: Platform.OS === "ios" ? "System" : "sans-serif",
147+
fontWeight: "700",
148+
fontVariant: ["tabular-nums"],
149+
} as const;
150+
151+
function ThreadListV2Duration(props: {
152+
readonly startedAt: string | null;
153+
readonly leadingSpace: boolean;
154+
}) {
144155
const startedAtMs = Date.parse(props.startedAt ?? "");
145156
const nowMs = useVisibleSecondClock(Number.isFinite(startedAtMs));
146157
if (!Number.isFinite(startedAtMs)) return null;
147-
return ` ${formatWorkingDurationLabel(nowMs - startedAtMs)}`;
158+
return (
159+
<>
160+
{props.leadingSpace ? " " : null}
161+
<RNText style={TABULAR_DURATION_STYLE}>
162+
{formatWorkingDurationLabel(nowMs - startedAtMs)}
163+
</RNText>
164+
</>
165+
);
148166
}
149167

150168
const CARD_MENU_ACTIONS: MenuAction[] = [
@@ -1218,15 +1236,20 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
12181236
<Text
12191237
className={cn(
12201238
"text-xs font-t3-bold",
1221-
(status === "working" || status === "waiting") && "tabular-nums",
12221239
selected ? selectedThreadRowColors.foregroundClassName : statusLabel.className,
12231240
)}
12241241
>
12251242
{statusLabel.label}
12261243
{status === "working" ? (
1227-
<ThreadListV2Duration startedAt={resolveThreadWorkingStartedAt(thread)} />
1244+
<ThreadListV2Duration
1245+
startedAt={resolveThreadWorkingStartedAt(thread)}
1246+
leadingSpace={statusLabel.label !== null}
1247+
/>
12281248
) : status === "waiting" ? (
1229-
<ThreadListV2Duration startedAt={thread.latestRun?.completedAt ?? null} />
1249+
<ThreadListV2Duration
1250+
startedAt={thread.latestRun?.completedAt ?? null}
1251+
leadingSpace={statusLabel.label !== null}
1252+
/>
12301253
) : null}
12311254
</Text>
12321255
</View>

0 commit comments

Comments
 (0)