1+ import { useActiveThreadSort } from "../threads/use-active-thread-sort" ;
2+ import { ACTIVE_THREAD_SORT_OPTIONS } from "@t3tools/client-runtime/state/shared-settings" ;
13import { NativeHeaderToolbar , NativeStackScreenOptions } from "../../native/StackHeader" ;
24import { useCallback , useRef } from "react" ;
35import type { SearchBarCommands } from "react-native-screens" ;
@@ -22,12 +24,12 @@ export type { HomeHeaderEnvironment } from "./HomeHeader.types";
2224export function HomeHeader ( props : HomeHeaderProps ) {
2325 const searchBarRef = useRef < SearchBarCommands > ( null ) ;
2426 const iconColor = useUniwindTheme ( ) [ "--color-icon" ] ;
25- // Thread List v2 lays the list out in fixed creation order, so the
26- // sort/group filter controls would be silently ignored — hide them and
27- // key the "customized" icon state off the environment filter alone.
2827 const threadListV2Enabled = useThreadListV2Enabled ( ) ;
28+ const { order, setOrder, available } = useActiveThreadSort ( ) ;
2929 const hasCustomListOptions = threadListV2Enabled
30- ? props . selectedEnvironmentId !== null || props . selectedProjectKey !== null
30+ ? props . selectedEnvironmentId !== null ||
31+ props . selectedProjectKey !== null ||
32+ order !== "manual"
3133 : hasCustomHomeListOptions ( props ) ;
3234 const focusSearch = useCallback ( ( ) => {
3335 searchBarRef . current ?. focus ( ) ;
@@ -37,6 +39,7 @@ export function HomeHeader(props: HomeHeaderProps) {
3739 const filterMenu = buildHomeListFilterMenu ( {
3840 ...props ,
3941 listOrganization : ! threadListV2Enabled ,
42+ ...( available ? { activeThreadSort : { order, onChange : setOrder } } : { } ) ,
4043 } ) ;
4144
4245 return (
@@ -166,6 +169,20 @@ export function HomeHeader(props: HomeHeaderProps) {
166169 </ NativeHeaderToolbar . Menu >
167170 ) }
168171
172+ { threadListV2Enabled && available ? (
173+ < NativeHeaderToolbar . Menu title = "Sort active threads" >
174+ < NativeHeaderToolbar . Label > Sort active threads</ NativeHeaderToolbar . Label >
175+ { ACTIVE_THREAD_SORT_OPTIONS . map ( ( option ) => (
176+ < NativeHeaderToolbar . MenuAction
177+ key = { option . value }
178+ isOn = { order === option . value }
179+ onPress = { ( ) => setOrder ( option . value ) }
180+ >
181+ < NativeHeaderToolbar . Label > { option . label } </ NativeHeaderToolbar . Label >
182+ </ NativeHeaderToolbar . MenuAction >
183+ ) ) }
184+ </ NativeHeaderToolbar . Menu >
185+ ) : null }
169186 { threadListV2Enabled ? null : (
170187 < NativeHeaderToolbar . Menu title = "Sort threads" >
171188 < NativeHeaderToolbar . Label > Sort threads</ NativeHeaderToolbar . Label >
0 commit comments