@@ -3,6 +3,7 @@ import Animated from "react-native-reanimated";
33import { PR_ROW_LAYOUT } from "./pullRequestAnimations" ;
44import { useNavigation } from "@react-navigation/native" ;
55import type { PullRequestDetail } from "@t3tools/contracts" ;
6+ import type { MenuAction } from "@react-native-menu/menu" ;
67import type { ReactNode } from "react" ;
78import { Platform , Pressable , View } from "react-native" ;
89import { useSafeAreaInsets } from "react-native-safe-area-context" ;
@@ -128,7 +129,7 @@ export function PullRequestActionToolbar(props: {
128129 ) . changeRequest ;
129130 const threadLabel = agent . threads . length ? "Continue thread" : `Work on ${ shortLabel } ` ;
130131 const primaryLabel = pendingReview ? `Submit review · ${ draft . comments . length } ` : threadLabel ;
131- const chooseThread = agent . threads . length > 1 ;
132+ const chooseThread = agent . chooseThread ;
132133 const agentActions = agent . actions . filter ( ( action ) => action . task !== "ask" ) ;
133134 const open = ( mode : "review" | "comment" ) =>
134135 navigation . navigate ( "PullRequestReview" , { ...props . params , mode } ) ;
@@ -193,17 +194,6 @@ export function PullRequestActionToolbar(props: {
193194 </ View >
194195 ) ;
195196 }
196- const nativeThreadItems = threadMenuItems . map ( ( item ) => (
197- < Toolbar . MenuAction
198- key = { item . id }
199- icon = { item . image }
200- subtitle = { "subtitle" in item ? item . subtitle : undefined }
201- disabled = { "attributes" in item && item . attributes . disabled }
202- onPress = { ( ) => agent . select ( item . id ) }
203- >
204- < Toolbar . Label > { item . title } </ Toolbar . Label >
205- </ Toolbar . MenuAction >
206- ) ) ;
207197 const primaryControl = showPrimary ? (
208198 ! pendingReview && chooseThread ? (
209199 < Toolbar . Menu
@@ -222,7 +212,7 @@ export function PullRequestActionToolbar(props: {
222212 disabled = { primaryDisabled }
223213 separateBackground
224214 >
225- { nativeThreadItems }
215+ { renderThreadMenuItems ( threadMenuItems , agent . select ) }
226216 </ Toolbar . Menu >
227217 ) : (
228218 < Toolbar . Button
@@ -256,17 +246,7 @@ export function PullRequestActionToolbar(props: {
256246 { agentActions . map ( ( action ) =>
257247 chooseThread && ! action . disabled ? (
258248 < Toolbar . Menu key = { action . task } title = { action . title } icon = { action . icon } >
259- { agent . threadActions ( action . task ) . map ( ( item ) => (
260- < Toolbar . MenuAction
261- key = { item . id }
262- icon = { item . image }
263- subtitle = { "subtitle" in item ? item . subtitle : undefined }
264- disabled = { "attributes" in item && item . attributes . disabled }
265- onPress = { ( ) => agent . select ( item . id ) }
266- >
267- < Toolbar . Label > { item . title } </ Toolbar . Label >
268- </ Toolbar . MenuAction >
269- ) ) }
249+ { renderThreadMenuItems ( agent . threadActions ( action . task ) , agent . select ) }
270250 </ Toolbar . Menu >
271251 ) : (
272252 < Toolbar . MenuAction
@@ -308,3 +288,23 @@ export function PullRequestActionToolbar(props: {
308288 </ Toolbar >
309289 ) ;
310290}
291+
292+ function renderThreadMenuItems ( items : MenuAction [ ] , select : ( id : string ) => void ) : ReactNode {
293+ return items . map ( ( item ) =>
294+ item . subactions ? (
295+ < Toolbar . Menu key = { item . id } title = { item . title } icon = { item . image } >
296+ { renderThreadMenuItems ( item . subactions , select ) }
297+ </ Toolbar . Menu >
298+ ) : (
299+ < Toolbar . MenuAction
300+ key = { item . id }
301+ icon = { item . image }
302+ subtitle = { item . subtitle }
303+ disabled = { item . attributes ?. disabled }
304+ onPress = { ( ) => item . id && select ( item . id ) }
305+ >
306+ < Toolbar . Label > { item . title } </ Toolbar . Label >
307+ </ Toolbar . MenuAction >
308+ ) ,
309+ ) ;
310+ }
0 commit comments