Skip to content

Commit b06fdc8

Browse files
committed
fix: sidebar archived threads, split feed width, and split view archive actions
- Filter archived threads in buildThreadNavigationGroups so the sidebar matches the home list behavior - Initialize viewportWidth to 0 in split layout to avoid oversized first render, and include viewportWidth in LegendList extraData for repaint - Add long-press archive/delete actions to ThreadNavigationSidebar so thread management is available in split view
1 parent 2e26739 commit b06fdc8

3 files changed

Lines changed: 24 additions & 4 deletions

File tree

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,9 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
11341134
const initialScrollReadyRef = useRef(false);
11351135
const lastContentHeightRef = useRef(0);
11361136
const { width: windowWidth } = useWindowDimensions();
1137-
const [viewportWidth, setViewportWidth] = useState(windowWidth);
1137+
const [viewportWidth, setViewportWidth] = useState(() =>
1138+
props.layoutVariant === "split" ? 0 : windowWidth,
1139+
);
11381140
const [interactionState, setInteractionState] = useState<{
11391141
readonly copiedRowId: string | null;
11401142
readonly expandedWorkGroups: Record<string, boolean>;
@@ -1206,6 +1208,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
12061208
markdownStyles,
12071209
reviewCommentColors,
12081210
userBubbleColor,
1211+
viewportWidth,
12091212
}),
12101213
[
12111214
copiedRowId,
@@ -1215,6 +1218,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
12151218
markdownStyles,
12161219
reviewCommentColors,
12171220
userBubbleColor,
1221+
viewportWidth,
12181222
],
12191223
);
12201224
const presentedFeed = useMemo(

apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell";
22
import { SymbolView } from "expo-symbols";
3-
import { useMemo, useState } from "react";
4-
import { Pressable, ScrollView, StyleSheet, TextInput, View } from "react-native";
3+
import { useCallback, useMemo, useState } from "react";
4+
import { Alert, Pressable, ScrollView, StyleSheet, TextInput, View } from "react-native";
55
import { useSafeAreaInsets } from "react-native-safe-area-context";
66

77
import { AppText as Text } from "../../components/AppText";
@@ -10,6 +10,7 @@ import { scopedThreadKey } from "../../lib/scopedEntities";
1010
import { relativeTime } from "../../lib/time";
1111
import { useThemeColor } from "../../lib/useThemeColor";
1212
import { useProjects, useThreadShells } from "../../state/entities";
13+
import { useThreadListActions } from "../home/useThreadListActions";
1314
import { buildThreadNavigationGroups } from "./thread-navigation-groups";
1415
import { threadStatusTone } from "./threadPresentation";
1516

@@ -24,11 +25,23 @@ export function ThreadNavigationSidebar(props: {
2425
const projects = useProjects();
2526
const threads = useThreadShells();
2627
const [searchQuery, setSearchQuery] = useState("");
28+
const { archiveThread, confirmDeleteThread } = useThreadListActions();
2729
const groups = useMemo(
2830
() => buildThreadNavigationGroups({ projects, threads, searchQuery }),
2931
[projects, searchQuery, threads],
3032
);
3133

34+
const handleThreadLongPress = useCallback(
35+
(thread: EnvironmentThreadShell) => {
36+
Alert.alert(thread.title, undefined, [
37+
{ text: "Cancel", style: "cancel" },
38+
{ text: "Archive", onPress: () => archiveThread(thread) },
39+
{ text: "Delete", style: "destructive", onPress: () => confirmDeleteThread(thread) },
40+
]);
41+
},
42+
[archiveThread, confirmDeleteThread],
43+
);
44+
3245
const backgroundColor = useThemeColor("--color-drawer");
3346
const borderColor = useThemeColor("--color-border");
3447
const foregroundColor = useThemeColor("--color-foreground");
@@ -131,6 +144,7 @@ export function ThreadNavigationSidebar(props: {
131144
accessibilityLabel={thread.title}
132145
accessibilityRole="button"
133146
accessibilityState={{ selected }}
147+
onLongPress={() => handleThreadLongPress(thread)}
134148
onPress={() => props.onSelectThread(thread)}
135149
style={({ pressed }) => [
136150
styles.threadRow,

apps/mobile/src/features/threads/thread-navigation-groups.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ export function buildThreadNavigationGroups(input: {
3333

3434
return groupProjectsByRepository(input).flatMap((group) => {
3535
const threads = Arr.sort(
36-
group.projects.flatMap((projectGroup) => projectGroup.threads),
36+
group.projects
37+
.flatMap((projectGroup) => projectGroup.threads)
38+
.filter((thread) => thread.archivedAt === null),
3739
threadActivityOrder,
3840
);
3941
const title = group.projects[0]?.project.title ?? group.title;

0 commit comments

Comments
 (0)