@@ -19,6 +19,7 @@ import { useNavigation } from "@react-navigation/native";
1919import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients" ;
2020
2121import { useEnvironmentScope } from "../../state/session" ;
22+ import type { ThreadPrPresentation } from "../../state/thread-pr-presentation" ;
2223import { PullRequestGlyph } from "../pull-requests/pullRequestGlyphs" ;
2324import {
2425 basename ,
@@ -27,6 +28,7 @@ import {
2728 type TerminalMenuSession ,
2829} from "../terminal/terminalMenu" ;
2930import { projectScriptMenuLabel } from "@t3tools/shared/projectScripts" ;
31+ import { linkedPrBarConfirm , shortGitBarLabel } from "./threadGitBarPrimary" ;
3032
3133function truncateMiddle ( value : string , maxLength : number ) : string {
3234 if ( value . length <= maxLength ) {
@@ -79,6 +81,9 @@ export type ThreadGitMenuProps = {
7981 readonly hasThread ?: boolean ;
8082 readonly gitStatus : VcsStatusResult | null ;
8183 readonly gitOperationLabel : string | null ;
84+ /** Linked / branch PR badge for the thread bar — wins over the git quick-action pill. */
85+ readonly linkedPr ?: ThreadPrPresentation | null ;
86+ readonly onOpenLinkedPr ?: ( ) => void ;
8287 readonly onOpenFilesInspector ?: ( ) => void ;
8388 readonly onOpenGitInspector ?: ( ) => void ;
8489 readonly onMergeBack ?: ( ) => void ;
@@ -368,42 +373,10 @@ function threadGitMenuFromModel(
368373 } ;
369374}
370375
371- /** Short pill copy for the thread-bar CTA — full quick-action label stays in a11y. */
372- function shortGitBarLabel (
373- quickAction : ReturnType < typeof useThreadGitControlModel > [ "quickAction" ] ,
374- shortLabel : string ,
375- ) : { readonly label : string ; readonly disabled : boolean } | null {
376- if ( quickAction . kind === "open_pr" ) {
377- return { label : "View" , disabled : quickAction . disabled } ;
378- }
379- if ( quickAction . kind === "run_pull" ) {
380- return { label : "Pull" , disabled : quickAction . disabled } ;
381- }
382- if ( quickAction . kind === "run_action" ) {
383- switch ( quickAction . action ) {
384- case "create_pr" :
385- case "commit_push_pr" :
386- return { label : shortLabel , disabled : quickAction . disabled } ;
387- case "push" :
388- return { label : "Push" , disabled : quickAction . disabled } ;
389- case "commit" :
390- return { label : "Commit" , disabled : quickAction . disabled } ;
391- case "commit_push" :
392- // Default-branch ahead uses action commit_push with label "Push".
393- return {
394- label : quickAction . label === "Push" ? "Push" : "Commit" ,
395- disabled : quickAction . disabled ,
396- } ;
397- default :
398- return null ;
399- }
400- }
401- return null ;
402- }
403-
404376/**
405377 * Thread-bar git controls: a compact one-tap pill for the next git step, plus the overflow
406- * menu for everything else (review, more).
378+ * menu for everything else (review, more). A linked PR wins the pill so tap opens it (or the
379+ * multi-PR list) and long-press still reaches Push / Commit / … .
407380 */
408381export function useThreadGitBar ( props : ThreadGitMenuProps ) : {
409382 readonly primaryAction : AppBarConfirm | null ;
@@ -413,8 +386,21 @@ export function useThreadGitBar(props: ThreadGitMenuProps): {
413386 const terminology = sourceControlClients . get (
414387 props . gitStatus ?. sourceControlProvider ?. kind ,
415388 ) . changeRequest ;
416- const short = shortGitBarLabel ( model . quickAction , terminology . shortLabel ) ;
417- const primaryAction : AppBarConfirm | null = short
389+ const linkedPr = props . linkedPr ?? null ;
390+ const linkedPrimary : AppBarConfirm | null =
391+ linkedPr && props . onOpenLinkedPr
392+ ? {
393+ ...linkedPrBarConfirm ( linkedPr ) ,
394+ disabled : false ,
395+ onPress : props . onOpenLinkedPr ,
396+ }
397+ : null ;
398+ const short = shortGitBarLabel (
399+ model . quickAction ,
400+ terminology . shortLabel ,
401+ props . gitStatus ?. pr ?. state === "open" ? props . gitStatus . pr . number : null ,
402+ ) ;
403+ const gitPrimary : AppBarConfirm | null = short
418404 ? {
419405 label : short . label ,
420406 accessibilityLabel : model . quickAction . label ,
@@ -425,10 +411,15 @@ export function useThreadGitBar(props: ThreadGitMenuProps): {
425411 } ,
426412 }
427413 : null ;
414+ const primaryAction = linkedPrimary ?? gitPrimary ;
415+ // Linked-PR pill must keep Push/Commit in the hold menu; only omit when the pill *is* that action.
416+ const omitQuickAction =
417+ primaryAction !== null &&
418+ ! primaryAction . disabled &&
419+ ( linkedPrimary !== null ? model . quickAction . kind === "open_pr" : true ) ;
428420 return {
429421 primaryAction,
430- // Keep the menu quick-action (and its disabled hint) when the pill is disabled.
431- menu : threadGitMenuFromModel ( props , model , primaryAction !== null && ! primaryAction . disabled ) ,
422+ menu : threadGitMenuFromModel ( props , model , omitQuickAction ) ,
432423 } ;
433424}
434425
0 commit comments