@@ -19,7 +19,7 @@ import {
1919
2020import { usePrimarySettings , useUpdatePrimarySettings } from "../../hooks/useSettings" ;
2121import { cn } from "../../lib/utils" ;
22- import { usePrimaryEnvironment } from "../../state/environments" ;
22+ import { useEnvironments , usePrimaryEnvironment } from "../../state/environments" ;
2323import { useEnvironmentQuery } from "../../state/query" ;
2424import { sourceControlEnvironment } from "../../state/sourceControl" ;
2525import { Badge } from "../ui/badge" ;
@@ -508,7 +508,15 @@ function EmptySourceControlDiscovery({
508508}
509509
510510export function SourceControlSettingsPanel ( ) {
511- const environmentId = usePrimaryEnvironment ( ) ?. environmentId ?? null ;
511+ const { environments } = useEnvironments ( ) ;
512+ const primaryEnvironment = usePrimaryEnvironment ( ) ;
513+ const fallbackEnvironment =
514+ environments . find ( ( environment ) => environment . connection . phase === "connected" ) ??
515+ environments [ 0 ] ??
516+ null ;
517+ const environmentId =
518+ primaryEnvironment ?. environmentId ?? fallbackEnvironment ?. environmentId ?? null ;
519+ const isPrimaryEnvironment = environmentId === primaryEnvironment ?. environmentId ;
512520 const discovery = useEnvironmentQuery (
513521 environmentId === null
514522 ? null
@@ -561,7 +569,9 @@ export function SourceControlSettingsPanel() {
561569 >
562570 { result . versionControlSystems . map ( ( item ) => (
563571 < DiscoveryItemRow key = { `vcs:${ item . kind } ` } item = { item } >
564- { item . kind === "git" ? < GitFetchIntervalSettings /> : undefined }
572+ { item . kind === "git" && isPrimaryEnvironment ? (
573+ < GitFetchIntervalSettings />
574+ ) : undefined }
565575 </ DiscoveryItemRow >
566576 ) ) }
567577 </ SettingsSection >
@@ -587,7 +597,7 @@ export function SourceControlSettingsPanel() {
587597 />
588598 ) }
589599
590- { environmentId !== null ? < SourceControlWritingSettingsSection /> : null }
600+ { isPrimaryEnvironment ? < SourceControlWritingSettingsSection /> : null }
591601 </ SettingsPageContainer >
592602 ) ;
593603}
0 commit comments