11import { settlePromise , squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime" ;
22import { AsyncResult } from "effect/reactivity" ;
3+ import { getVcsTerminology , type VcsTerminology } from "@t3tools/shared/vcs" ;
4+ import { selectKind , selectUnsupportedReason , vcsEnvironment } from "../../state/vcs" ;
5+ import { useEnvironmentQuerySelector } from "../../state/query" ;
36import type { EnvironmentId , ThreadId } from "@t3tools/contracts" ;
47import { formatDiffCount } from "@t3tools/client-runtime/diff-count" ;
58import { useNavigation , type StaticScreenProps } from "@react-navigation/native" ;
@@ -72,6 +75,7 @@ import { reportShowcaseSceneRendered } from "../showcase/showcaseRenderSignal";
7275function ReviewHeader (
7376 props : Parameters < typeof useReviewHeaderPresentation > [ 0 ] & {
7477 readonly iconColor : string ;
78+ readonly vcsTerminology : VcsTerminology ;
7579 readonly sectionMenu : ReturnType < typeof buildReviewSectionMenu > ;
7680 readonly showSectionToolbar : boolean ;
7781 readonly showChangedFilesToggle : boolean ;
@@ -124,8 +128,19 @@ function ReviewHeader(
124128 id : "sections" ,
125129 inline : true ,
126130 items : [
127- sectionAction ( props . sectionMenu . branchChanges , "Changes" ) ,
128- sectionAction ( props . sectionMenu . workingTree , "Uncommitted" ) ,
131+ sectionAction (
132+ props . sectionMenu . branchChanges ,
133+ props . vcsTerminology . preserveReviewSectionTitles
134+ ? ( props . sectionMenu . branchChanges ?. title ?? "Changes" )
135+ : "Changes" ,
136+ ) ,
137+ sectionAction (
138+ props . sectionMenu . workingTree ,
139+ props . vcsTerminology . preserveReviewSectionTitles
140+ ? ( props . sectionMenu . workingTree ?. title ??
141+ props . vcsTerminology . workingTreeNounTitle )
142+ : "Uncommitted" ,
143+ ) ,
129144 sectionAction ( props . sectionMenu . latestTurn , "Latest turn" ) ,
130145 ] ,
131146 } ,
@@ -456,6 +471,14 @@ export function ReviewSheet(props: ReviewSheetProps) {
456471 const topContentInset = Platform . OS === "ios" ? safeArea . top : 0 ;
457472 const bottomContentInset =
458473 Platform . OS === "ios" ? safeArea . bottom + 8 : Math . max ( insets . bottom , 18 ) + 18 ;
474+ const vcsStatusAtom =
475+ selectedThreadCwd === null
476+ ? null
477+ : vcsEnvironment . status ( { environmentId, input : { cwd : selectedThreadCwd } } ) ;
478+ const vcsKind = useEnvironmentQuerySelector ( vcsStatusAtom , selectKind ) ;
479+ const vcsTerminology = getVcsTerminology ( vcsKind ) ;
480+ const vcsUnsupportedReason = useEnvironmentQuerySelector ( vcsStatusAtom , selectUnsupportedReason ) ;
481+ const vcsActionsSupported = vcsUnsupportedReason === null ;
459482
460483 useEffect ( ( ) => {
461484 showAuxiliaryPane ( "inspector" ) ;
@@ -469,15 +492,16 @@ export function ReviewSheet(props: ReviewSheetProps) {
469492 isSelectedSectionPending,
470493 diffPreviewRevision,
471494 } = useReviewSections ( {
472- enabled : isEnvironmentReady ,
495+ enabled : isEnvironmentReady && vcsActionsSupported ,
473496 environmentId,
474497 threadId,
475498 reviewCache,
499+ vcsKind,
476500 } ) ;
477501 useReviewDiffPrewarming ( {
478502 threadKey : reviewCache . threadKey ,
479- sections : reviewSections ,
480- selectedSectionId : selectedSection ?. id ?? null ,
503+ sections : vcsActionsSupported ? reviewSections : [ ] ,
504+ selectedSectionId : vcsActionsSupported ? ( selectedSection ?. id ?? null ) : null ,
481505 } ) ;
482506 const {
483507 headerDiffSummary,
@@ -489,8 +513,8 @@ export function ReviewSheet(props: ReviewSheetProps) {
489513 } = useReviewDiffData ( {
490514 threadKey : reviewCache . threadKey ,
491515 environmentId,
492- cwd : selectedThreadCwd ,
493- selectedSection,
516+ cwd : vcsActionsSupported ? selectedThreadCwd : null ,
517+ selectedSection : vcsActionsSupported ? selectedSection : null ,
494518 revision : diffPreviewRevision ,
495519 draftMessage,
496520 } ) ;
@@ -681,6 +705,16 @@ export function ReviewSheet(props: ReviewSheetProps) {
681705 . join ( " · " ) ;
682706 const headerTitleText = selectedSection ?. title ?? "Review changes" ;
683707
708+ if ( ! vcsActionsSupported ) {
709+ return (
710+ < ScreenContent >
711+ < Text accessibilityRole = "alert" className = "p-4 text-sm text-danger-foreground" >
712+ { vcsUnsupportedReason }
713+ </ Text >
714+ </ ScreenContent >
715+ ) ;
716+ }
717+
684718 return (
685719 < >
686720 < ReviewHeader
@@ -690,6 +724,7 @@ export function ReviewSheet(props: ReviewSheetProps) {
690724 subtitle = { headerSubtitle }
691725 androidSubtitle = { androidHeaderSubtitle }
692726 iconColor = { headerIcon }
727+ vcsTerminology = { vcsTerminology }
693728 selectedThreadCwd = { selectedThreadCwd }
694729 sectionMenu = { sectionMenu }
695730 selectedSection = { selectedSection }
0 commit comments