@devries-cameron20 / t3code Mirror · read-only / commits / dec0732281
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 24, 00:15 UTC

refactor(mobile): isolate thread row appearance by platform (#12383)

Julius Marminge committed Sep 18, 2026 at 12:55 UTC dec0732281f5b7e787ad3a84e5cbe9a1607ea4ca
3 files changed +129 -124
apps/mobile/src/features/threads/thread-list-v2-items.tsx
+34 -124
@@ -1,3 +1,11 @@
1 +import {
2 + THREAD_LIST_V2_MONO_FONT as MONO_FONT,
3 + THREAD_LIST_V2_ROW_CONTENT_CLASS_NAME,
4 + THREAD_LIST_V2_ROW_DIVIDERS,
5 + selectedThreadRowColors,
6 + getThreadListV2NewBranchMenuTitle,
7 + getThreadListV2RowAppearance,
8 +} from "./thread-list-v2-row-appearance";
9 import { RowPressable } from "../../components/RowPressable";
10 import { CustomSnoozeSheet } from "./CustomSnoozeSheet";
11 import { appAtomRegistry } from "../../state/atom-registry";
@@ -13,7 +21,7 @@ import { canSnooze, resolveSnoozePresets } from "@t3tools/client-runtime/state/t
21 import { resolveSettledThreadTimestamp } from "@t3tools/client-runtime/state/thread-sort";
22 import type { MenuAction } from "@react-native-menu/menu";
23 import { memo, useCallback, useEffect, useMemo, useState, type ComponentProps } from "react";
16 -import { Alert, Platform, Pressable, useWindowDimensions, View } from "react-native";
24 +import { Alert, Pressable, useWindowDimensions, View } from "react-native";
25 import type { SwipeableMethods } from "react-native-gesture-handler/ReanimatedSwipeable";
26
27 import { SymbolView } from "../../components/AppSymbol";
@@ -49,12 +57,6 @@ import { ThreadSearchMatchExcerpt } from "./thread-search-match";
57 * hierarchy rather than card fills.
58 */
59
52 -const MONO_FONT = Platform.select({
53 - ios: "Menlo",
54 - android: "monospace",
55 - default: "monospace",
56 -});
57 -
60 // Status hues follow the system-wide convention set by sidebar v1 and the
61 // Live Activity/widgets (amber approval, indigo input, sky working) so a
62 // thread reads the same color everywhere it surfaces.
@@ -477,23 +479,9 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
479 const pr = useThreadPr(thread);
480
481 const theme = useUniwindTheme();
480 - const screenColor = theme["--color-screen"];
481 - const drawerColor = theme["--color-drawer"];
482 - const selectedBackgroundColor =
483 - theme[Platform.OS === "android" ? "--color-thread-selected" : "--color-user-bubble"];
482 const sidebarPane = props.pane === "sidebar";
483 const selected = props.selected === true;
486 - // The provider badge's border blends into the row's own surface, which
487 - // differs by pane and (for the sidebar pane) selection: the sidebar row
488 - // background becomes the selected fill or the drawer surface, while the
489 - // flat "screen" pane rows always sit on the screen background.
490 - const providerIconSurfaceColor = sidebarPane
491 - ? selected
492 - ? selectedBackgroundColor
493 - : Platform.OS === "android"
494 - ? screenColor
495 - : drawerColor
496 - : screenColor;
484 + const rowAppearance = getThreadListV2RowAppearance(theme, sidebarPane, selected);
485
486 const status = resolveThreadListV2Status(thread);
487 const statusLabel = STATUS_LABEL_BY_STATUS[status];
@@ -788,11 +776,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
776 <Text
777 className={cn(
778 "flex-1 text-sm font-t3-medium",
791 - selected
792 - ? Platform.OS === "android"
793 - ? "text-thread-selected-foreground-muted"
794 - : "text-user-bubble-foreground-muted"
795 - : "text-foreground-muted",
779 + selected ? selectedThreadRowColors.mutedForegroundClassName : "text-foreground-muted",
780 )}
781 numberOfLines={1}
782 >
@@ -811,9 +795,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
795 className={cn(
796 "text-xs tabular-nums",
797 selected
814 - ? Platform.OS === "android"
815 - ? "text-thread-selected-foreground"
816 - : "text-user-bubble-foreground"
798 + ? selectedThreadRowColors.foregroundClassName
799 : (statusLabel?.className ?? "text-foreground-tertiary"),
800 )}
801 >
@@ -823,11 +805,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
805 <Text
806 className={cn(
807 "mt-1 text-base font-t3-medium",
826 - selected
827 - ? Platform.OS === "android"
828 - ? "text-thread-selected-foreground"
829 - : "text-user-bubble-foreground"
830 - : "text-foreground",
808 + selected ? selectedThreadRowColors.foregroundClassName : "text-foreground",
809 )}
810 numberOfLines={2}
811 >
@@ -848,9 +826,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
826 className={cn(
827 "flex-1 text-xs",
828 selected
851 - ? Platform.OS === "android"
852 - ? "text-thread-selected-foreground-muted"
853 - : "text-user-bubble-foreground-muted"
829 + ? selectedThreadRowColors.mutedForegroundClassName
830 : "text-danger-foreground",
831 )}
832 numberOfLines={1}
@@ -869,9 +845,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
845 className={cn(
846 "shrink text-xs",
847 selected
872 - ? Platform.OS === "android"
873 - ? "text-thread-selected-foreground-muted"
874 - : "text-user-bubble-foreground-muted"
848 + ? selectedThreadRowColors.mutedForegroundClassName
849 : "text-foreground-muted",
850 )}
851 numberOfLines={1}
@@ -881,9 +855,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
855 className={cn(
856 "text-xs",
857 selected
884 - ? Platform.OS === "android"
885 - ? "text-thread-selected-foreground-muted"
886 - : "text-user-bubble-foreground-muted"
858 + ? selectedThreadRowColors.mutedForegroundClassName
859 : "text-foreground-muted",
860 )}
861 style={{ fontFamily: MONO_FONT }}
@@ -897,9 +869,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
869 className={cn(
870 "text-xs",
871 selected
900 - ? Platform.OS === "android"
901 - ? "text-thread-selected-foreground-muted"
902 - : "text-user-bubble-foreground-muted"
872 + ? selectedThreadRowColors.mutedForegroundClassName
873 : "text-foreground-tertiary",
874 )}
875 >
@@ -913,9 +883,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
883 size={11}
884 tintColorClassName={
885 selected
916 - ? Platform.OS === "android"
917 - ? "accent-thread-selected-foreground-muted"
918 - : "accent-user-bubble-foreground-muted"
886 + ? selectedThreadRowColors.mutedIconTintClassName
887 : "accent-foreground-tertiary"
888 }
889 />
@@ -932,9 +900,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
900 size={12}
901 tintColorClassName={
902 selected
935 - ? Platform.OS === "android"
936 - ? "accent-thread-selected-foreground"
937 - : "accent-user-bubble-foreground"
903 + ? selectedThreadRowColors.iconTintClassName
904 : pr.state === null || pr.isDraft
905 ? "accent-foreground-muted"
906 : pr.state === "open"
@@ -949,11 +915,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
915 accessibilityLabel={pr.accessibilityLabel}
916 className={cn(
917 "text-xs",
952 - selected
953 - ? Platform.OS === "android"
954 - ? "text-thread-selected-foreground"
955 - : "text-user-bubble-foreground"
956 - : pr.textClassName,
918 + selected ? selectedThreadRowColors.foregroundClassName : pr.textClassName,
919 )}
920 style={{ fontFamily: MONO_FONT }}
921 >
@@ -968,7 +930,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
930 displayName={props.providerInstance.displayName}
931 accentColor={props.providerInstance.accentColor}
932 showBadge={props.providerInstance.showBadge}
971 - surfaceColor={providerIconSurfaceColor}
933 + surfaceColor={rowAppearance.providerIconSurfaceColor}
934 />
935 ) : null}
936 </View>
@@ -979,14 +941,8 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
941 variant === "card" ? (
942 <RowPressable
943 key={`${thread.environmentId}:${thread.id}`}
982 - interactionClassName={
983 - selected && (sidebarPane || Platform.OS === "android")
984 - ? Platform.OS === "android"
985 - ? "bg-thread-selected-foreground"
986 - : "bg-user-bubble-foreground"
987 - : "bg-primary"
988 - }
989 - className={sidebarPane || Platform.OS === "android" ? undefined : "bg-screen"}
944 + interactionClassName={rowAppearance.interactionClassName}
945 + className={rowAppearance.className}
946 accessibilityHint={swipeAccessibilityHint}
947 accessibilityLabel={
948 props.hasQueuedMessages ? `${thread.title}, messages queued to send` : thread.title
@@ -997,19 +953,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
953 close();
954 onSelectThread(thread);
955 }}
1000 - style={
1001 - sidebarPane || Platform.OS === "android"
1002 - ? {
1003 - backgroundColor: selected
1004 - ? selectedBackgroundColor
1005 - : sidebarPane && Platform.OS !== "android"
1006 - ? drawerColor
1007 - : screenColor,
1008 - borderRadius: Platform.OS === "android" ? 20 : SIDEBAR_V2_ROW_RADIUS,
1009 - ...(sidebarPane ? { paddingHorizontal: 12, paddingVertical: 10 } : null),
1010 - }
1011 - : undefined
1012 - }
956 + style={rowAppearance.cardStyle}
957 >
958 {sidebarPane ? (
959 cardContent
@@ -1019,10 +963,8 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
963 separates rows. The opaque screen background stays so swipe
964 actions reveal behind the row. */
965 <View>
1022 - <View className={Platform.OS === "android" ? "px-3 py-2.5" : "px-5 py-2.5"}>
1023 - {cardContent}
1024 - </View>
1025 - {Platform.OS !== "android" && props.showTrailingDivider !== false ? (
966 + <View className={THREAD_LIST_V2_ROW_CONTENT_CLASS_NAME}>{cardContent}</View>
967 + {THREAD_LIST_V2_ROW_DIVIDERS && props.showTrailingDivider !== false ? (
968 <View className="ml-5 h-px bg-border-subtle" />
969 ) : null}
970 </View>
@@ -1031,36 +973,19 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
973 ) : (
974 <RowPressable
975 key={`${thread.environmentId}:${thread.id}`}
1034 - interactionClassName={
1035 - selected && (sidebarPane || Platform.OS === "android")
1036 - ? Platform.OS === "android"
1037 - ? "bg-thread-selected-foreground"
1038 - : "bg-user-bubble-foreground"
1039 - : "bg-primary"
1040 - }
976 + interactionClassName={rowAppearance.interactionClassName}
977 accessibilityHint={swipeAccessibilityHint}
978 accessibilityLabel={
979 props.hasQueuedMessages ? `${thread.title}, messages queued to send` : thread.title
980 }
981 accessibilityRole="button"
982 accessibilityState={{ selected }}
1047 - className={sidebarPane || Platform.OS === "android" ? undefined : "bg-screen"}
983 + className={rowAppearance.className}
984 onPress={() => {
985 close();
986 onSelectThread(thread);
987 }}
1052 - style={
1053 - sidebarPane || Platform.OS === "android"
1054 - ? {
1055 - backgroundColor: selected
1056 - ? selectedBackgroundColor
1057 - : sidebarPane && Platform.OS !== "android"
1058 - ? drawerColor
1059 - : screenColor,
1060 - borderRadius: Platform.OS === "android" ? 20 : SIDEBAR_V2_ROW_RADIUS,
1061 - }
1062 - : undefined
1063 - }
988 + style={rowAppearance.style}
989 >
990 {/* Settled history recedes: dimmed favicon + muted title. */}
991 <View
@@ -1084,11 +1009,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
1009 <Text
1010 className={cn(
1011 "text-base",
1087 - selected
1088 - ? Platform.OS === "android"
1089 - ? "text-thread-selected-foreground"
1090 - : "text-user-bubble-foreground"
1091 - : "text-foreground-muted",
1012 + selected ? selectedThreadRowColors.foregroundClassName : "text-foreground-muted",
1013 )}
1014 numberOfLines={1}
1015 >
@@ -1107,9 +1028,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
1028 className={cn(
1029 "text-sm tabular-nums",
1030 selected
1110 - ? Platform.OS === "android"
1111 - ? "text-thread-selected-foreground-muted"
1112 - : "text-user-bubble-foreground-muted"
1031 + ? selectedThreadRowColors.mutedForegroundClassName
1032 : snoozedRow
1033 ? "text-foreground-secondary"
1034 : "text-foreground-tertiary",
@@ -1131,15 +1050,9 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
1050 )}
1051 <ThreadSwipeable
1052 threadKey={`${thread.environmentId}:${thread.id}`}
1134 - backgroundColor={sidebarPane && Platform.OS !== "android" ? drawerColor : screenColor}
1053 + backgroundColor={rowAppearance.swipeBackgroundColor}
1054 compactActions={variant === "slim"}
1136 - containerStyle={
1137 - Platform.OS === "android"
1138 - ? { borderRadius: 20, overflow: "hidden", marginHorizontal: 8, marginVertical: 2 }
1139 - : sidebarPane
1140 - ? { borderRadius: SIDEBAR_V2_ROW_RADIUS, overflow: "hidden" }
1141 - : undefined
1142 - }
1055 + containerStyle={rowAppearance.swipeContainerStyle}
1056 enableTrackpadSwipe
1057 // Full swipe commits the advertised lifecycle action (Settle /
1058 // Un-settle), never the secondary snooze action.
@@ -1161,10 +1074,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
1074 ? [
1075 {
1076 id: "new-thread-on-branch",
1164 - title:
1165 - Platform.OS === "ios"
1166 - ? "New thread on branch"
1167 - : `New thread on ${thread.branch}`,
1077 + title: getThreadListV2NewBranchMenuTitle(thread.branch),
1078 image: "square.and.pencil",
1079 },
1080 ]
apps/mobile/src/features/threads/thread-list-v2-row-appearance.android.ts new
+46
@@ -0,0 +1,46 @@
1 +import type { ViewStyle } from "react-native";
2 +import type { MobileThemeVariables } from "../../lib/mobileTheme";
3 +
4 +export const THREAD_LIST_V2_MONO_FONT = "monospace";
5 +export const THREAD_LIST_V2_ROW_CONTENT_CLASS_NAME = "px-3 py-2.5";
6 +export const THREAD_LIST_V2_ROW_DIVIDERS = false;
7 +
8 +export const selectedThreadRowColors = {
9 + foregroundClassName: "text-thread-selected-foreground",
10 + mutedForegroundClassName: "text-thread-selected-foreground-muted",
11 + iconTintClassName: "accent-thread-selected-foreground",
12 + mutedIconTintClassName: "accent-thread-selected-foreground-muted",
13 +};
14 +
15 +export function getThreadListV2NewBranchMenuTitle(branch: string) {
16 + return `New thread on ${branch}`;
17 +}
18 +
19 +export function getThreadListV2RowAppearance(
20 + theme: MobileThemeVariables,
21 + sidebarPane: boolean,
22 + selected: boolean,
23 +) {
24 + const selectedBackgroundColor = theme["--color-thread-selected"];
25 + const style: ViewStyle = {
26 + backgroundColor: selected ? selectedBackgroundColor : theme["--color-screen"],
27 + borderRadius: 20,
28 + };
29 + const swipeContainerStyle: ViewStyle = {
30 + borderRadius: 20,
31 + overflow: "hidden",
32 + marginHorizontal: 8,
33 + marginVertical: 2,
34 + };
35 +
36 + return {
37 + className: undefined,
38 + interactionClassName: selected ? "bg-thread-selected-foreground" : "bg-primary",
39 + style,
40 + cardStyle: sidebarPane ? { ...style, paddingHorizontal: 12, paddingVertical: 10 } : style,
41 + swipeContainerStyle,
42 + swipeBackgroundColor: theme["--color-screen"],
43 + providerIconSurfaceColor:
44 + sidebarPane && selected ? selectedBackgroundColor : theme["--color-screen"],
45 + };
46 +}
apps/mobile/src/features/threads/thread-list-v2-row-appearance.ts new
+49
@@ -0,0 +1,49 @@
1 +import type { ViewStyle } from "react-native";
2 +import type { MobileThemeVariables } from "../../lib/mobileTheme";
3 +
4 +export const THREAD_LIST_V2_MONO_FONT = "Menlo";
5 +export const THREAD_LIST_V2_ROW_CONTENT_CLASS_NAME = "px-5 py-2.5";
6 +export const THREAD_LIST_V2_ROW_DIVIDERS = true;
7 +
8 +export const selectedThreadRowColors = {
9 + foregroundClassName: "text-user-bubble-foreground",
10 + mutedForegroundClassName: "text-user-bubble-foreground-muted",
11 + iconTintClassName: "accent-user-bubble-foreground",
12 + mutedIconTintClassName: "accent-user-bubble-foreground-muted",
13 +};
14 +
15 +export function getThreadListV2NewBranchMenuTitle(_branch: string) {
16 + return "New thread on branch";
17 +}
18 +
19 +export function getThreadListV2RowAppearance(
20 + theme: MobileThemeVariables,
21 + sidebarPane: boolean,
22 + selected: boolean,
23 +) {
24 + const selectedBackgroundColor = theme["--color-user-bubble"];
25 + const style: ViewStyle | undefined = sidebarPane
26 + ? {
27 + backgroundColor: selected ? selectedBackgroundColor : theme["--color-drawer"],
28 + borderRadius: 12,
29 + }
30 + : undefined;
31 + const swipeContainerStyle: ViewStyle | undefined = sidebarPane
32 + ? { borderRadius: 12, overflow: "hidden" }
33 + : undefined;
34 +
35 + return {
36 + className: sidebarPane ? undefined : "bg-screen",
37 + interactionClassName: selected && sidebarPane ? "bg-user-bubble-foreground" : "bg-primary",
38 + style,
39 + cardStyle: sidebarPane ? { ...style, paddingHorizontal: 12, paddingVertical: 10 } : undefined,
40 + swipeContainerStyle,
41 + swipeBackgroundColor: theme[sidebarPane ? "--color-drawer" : "--color-screen"],
42 + // Provider badges blend into the surface beneath them.
43 + providerIconSurfaceColor: sidebarPane
44 + ? selected
45 + ? selectedBackgroundColor
46 + : theme["--color-drawer"]
47 + : theme["--color-screen"],
48 + };
49 +}