Skip to content

Commit 79fde43

Browse files
Merge remote-tracking branch 'origin/main' into fix/issue-33436
2 parents c699a10 + 7b24834 commit 79fde43

2 files changed

Lines changed: 65 additions & 14 deletions

File tree

‎apps/mobile/src/features/threads/ThreadFeed.tsx‎

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2568,15 +2568,25 @@ function useThreadFeedPresentation(
25682568
}
25692569

25702570
type DisclosureLayout = {
2571+
/** Each row's top relative to the anchor row's top, before the toggle. */
25712572
positions: ReadonlyMap<string, number>;
25722573
anchorIndex: number;
2574+
/** Distance from the anchor's top to the end of the content, before the toggle. */
2575+
anchorToEnd: number;
25732576
list: LegendListRef;
25742577
playing: boolean;
25752578
};
25762579
const DISCLOSURE_DETAIL_DELAY_MS = 135;
25772580
const DISCLOSURE_DETAIL_FADE_MS = 70;
25782581
const unsubscribeNothing = () => {};
25792582

2583+
function feedContentEnd(state: ReturnType<LegendListRef["getState"]>): number | undefined {
2584+
const last = state.data.length - 1;
2585+
if (last < 0) return undefined;
2586+
const position = state.positionAtIndex(last);
2587+
return position === undefined ? undefined : position + state.sizeAtIndex(last);
2588+
}
2589+
25802590
function DisclosureRow(props: {
25812591
itemKey: string;
25822592
index: number;
@@ -2587,18 +2597,35 @@ function DisclosureRow(props: {
25872597
const previous = layout?.positions.get(itemKey);
25882598
const subscribe = useCallback(
25892599
(notify: () => void) => {
2590-
if (!layout || layout.playing || previous === undefined || previous <= 0)
2591-
return unsubscribeNothing;
2592-
return layout.list.getState().listenToPosition(itemKey, notify);
2600+
if (!layout || layout.playing || previous === undefined) return unsubscribeNothing;
2601+
const state = layout.list.getState();
2602+
const stops = [
2603+
state.listenToPosition(itemKey, notify),
2604+
state.listen("totalSize", notify),
2605+
state.listen("isAtEnd", notify),
2606+
state.listen("isFollowingEnd", notify),
2607+
];
2608+
return () => {
2609+
for (const stop of stops) stop();
2610+
};
25932611
},
25942612
[itemKey, layout, previous],
25952613
);
2614+
// Rows hold their old screen spot relative to whatever stays still: the content end
2615+
// while the feed sits at the bottom (end follow, or a collapse that clamps the scroll),
2616+
// otherwise the anchored disclosure row.
25962617
const getOffset = () => {
2597-
if (!layout || layout.playing || previous === undefined || previous <= 0) return 0;
2618+
if (!layout || layout.playing || previous === undefined) return 0;
25982619
const state = layout.list.getState();
25992620
const position = state.positionAtIndex(props.index);
2621+
if (position === undefined) return 0;
2622+
if (state.isFollowingEnd || state.isAtEnd) {
2623+
const end = feedContentEnd(state);
2624+
return end === undefined ? 0 : previous - layout.anchorToEnd - (position - end);
2625+
}
2626+
if (previous <= 0) return 0;
26002627
const anchor = state.positionAtIndex(layout.anchorIndex);
2601-
return position === undefined || anchor === undefined ? 0 : previous - (position - anchor);
2628+
return anchor === undefined ? 0 : previous - (position - anchor);
26022629
};
26032630
const offset = useSyncExternalStore(subscribe, getOffset, getOffset);
26042631
const entering = !!layout && previous === undefined;
@@ -3386,6 +3413,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
33863413
const motion = {
33873414
positions,
33883415
anchorIndex,
3416+
anchorToEnd: (feedContentEnd(state) ?? anchor) - anchor,
33893417
list,
33903418
playing: false,
33913419
};

‎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)