@@ -2,7 +2,7 @@ import { RefreshIcon } from "~/components/ui/refresh-icon";
22import { ChevronDownIcon } from "lucide-react" ;
33import * as Duration from "effect/Duration" ;
44import * as Option from "effect/Option" ;
5- import { useEffect , useState , type ReactNode } from "react" ;
5+ import { useState , type ReactNode } from "react" ;
66import type {
77 BackgroundActivitySettings ,
88 SourceControlDiscoveryResult ,
@@ -161,24 +161,31 @@ function itemStatusDot(item: VcsDiscoveryItem | SourceControlProviderDiscoveryIt
161161 return "bg-success" ;
162162}
163163
164+ function sourceControlItemIcon (
165+ item : VcsDiscoveryItem | SourceControlProviderDiscoveryItem ,
166+ ) : ReactNode {
167+ const host = isProviderDiscoveryItem ( item ) ? sourceControlClients . find ( item . kind ) : undefined ;
168+ const Icon = isProviderDiscoveryItem ( item )
169+ ? host && sourceControlIcon ( host )
170+ : VCS_ICONS [ item . kind ] ;
171+ return Icon ? < Icon className = "size-4.5 text-foreground/80" aria-hidden /> : null ;
172+ }
173+
164174function SourceControlItemMark ( {
165175 item,
166176} : {
167177 readonly item : VcsDiscoveryItem | SourceControlProviderDiscoveryItem ;
168178} ) {
169179 const dotClassName = itemStatusDot ( item ) ;
170- const host = isProviderDiscoveryItem ( item ) ? sourceControlClients . find ( item . kind ) : undefined ;
171- const Icon = isProviderDiscoveryItem ( item )
172- ? host && sourceControlIcon ( host )
173- : VCS_ICONS [ item . kind ] ;
180+ const icon = sourceControlItemIcon ( item ) ;
174181
175- if ( ! Icon ) {
182+ if ( ! icon ) {
176183 return < span className = { cn ( "size-2 shrink-0 rounded-full" , dotClassName ) } aria-hidden /> ;
177184 }
178185
179186 return (
180187 < span className = "relative inline-flex size-5 shrink-0 items-center justify-center" >
181- < Icon className = "size-4.5 text-foreground/80" aria-hidden />
188+ { icon }
182189 < span
183190 className = { cn (
184191 "pointer-events-none absolute -left-0.5 -top-0.5 size-2 rounded-full ring-2 ring-background" ,
@@ -269,16 +276,16 @@ function DiscoveryItemRow({
269276 const [ isExpanded , setIsExpanded ] = useState ( false ) ;
270277 const hasDetails = children !== undefined ;
271278 const searchTargetId = useSettingsSearchTargetId ( ) ;
272-
273- useEffect ( ( ) => {
274- if (
275- ( item . kind === "git" && searchTargetId === searchableSetting ( "git-fetch-interval" ) . id ) ||
276- searchTargetId === sourceControlHostSettingsSearchId ( item . kind ) ||
277- ( item . kind === "github" && searchTargetId === searchableSetting ( "github-accounts" ) . id )
278- ) {
279- setIsExpanded ( true ) ;
280- }
281- } , [ item . kind , searchTargetId ] ) ;
279+ // A search jump to a setting inside this row opens it when the target arrives.
280+ const [ seenSearchTargetId , setSeenSearchTargetId ] = useState < string | null > ( null ) ;
281+ const targetsThisRow =
282+ ( item . kind === "git" && searchTargetId === searchableSetting ( "git-fetch-interval" ) . id ) ||
283+ searchTargetId === sourceControlHostSettingsSearchId ( item . kind ) ||
284+ ( item . kind === "github" && searchTargetId === searchableSetting ( "github-accounts" ) . id ) ;
285+ if ( targetsThisRow && ! isExpanded && seenSearchTargetId !== searchTargetId ) {
286+ setIsExpanded ( true ) ;
287+ }
288+ if ( seenSearchTargetId !== searchTargetId ) setSeenSearchTargetId ( searchTargetId ) ;
282289
283290 return (
284291 < div
0 commit comments