@@ -347,6 +347,150 @@ function ProviderEnvironmentSection(props: {
347347 ) ;
348348}
349349
350+ type ProviderVersionAdvisoryPresentation = NonNullable <
351+ ReturnType < typeof getProviderVersionAdvisoryPresentation >
352+ > ;
353+
354+ /**
355+ * Shared update glyph for the list row and the editor header. Both open the
356+ * same "Update available" popover so copy-command vs in-place-update are not
357+ * two identical-looking buttons. Copy stays on the explicit copy control
358+ * inside the popover.
359+ */
360+ function ProviderUpdateAvailableControl ( props : {
361+ readonly displayName : string ;
362+ readonly versionAdvisory : ProviderVersionAdvisoryPresentation ;
363+ readonly onRunUpdate ?: ( ( ) => void ) | undefined ;
364+ readonly isUpdating : boolean ;
365+ readonly compact ?: boolean | undefined ;
366+ } ) {
367+ const updateCommand = props . versionAdvisory . updateCommand ;
368+ const { copyToClipboard } = useCopyToClipboard < { providerName : string } > ( {
369+ onCopy : ( { providerName } ) => {
370+ toastManager . add ( {
371+ type : "success" ,
372+ title : `${ providerName } update command copied` ,
373+ description : "Run it in a terminal when you are ready to update." ,
374+ } ) ;
375+ } ,
376+ onError : ( error , { providerName } ) => {
377+ toastManager . add (
378+ stackedThreadToast ( {
379+ type : "error" ,
380+ title : `Could not copy ${ providerName } update command` ,
381+ description : error . message ,
382+ } ) ,
383+ ) ;
384+ } ,
385+ } ) ;
386+
387+ return (
388+ < Popover >
389+ < Tooltip >
390+ < TooltipTrigger
391+ render = {
392+ < PopoverTrigger
393+ render = {
394+ < Button
395+ type = "button"
396+ size = { props . compact ? "icon-micro" : "icon-xs" }
397+ variant = { props . compact ? "ghost-muted" : "ghost" }
398+ className = { cn (
399+ props . compact
400+ ? "pointer-events-auto relative shrink-0"
401+ : "[--control-icon-color:currentColor]" ,
402+ ! props . compact &&
403+ ( props . versionAdvisory . emphasis === "strong"
404+ ? "text-warning hover:text-warning"
405+ : "text-muted-foreground hover:text-foreground" ) ,
406+ ) }
407+ aria-label = "Update available — view details"
408+ >
409+ { props . compact ? (
410+ < ArrowUpCircleIcon className = "size-3.5" />
411+ ) : (
412+ < ArrowUpCircleIcon />
413+ ) }
414+ </ Button >
415+ }
416+ />
417+ }
418+ />
419+ < TooltipPopup side = "top" > Update available</ TooltipPopup >
420+ </ Tooltip >
421+ < PopoverPopup
422+ side = "bottom"
423+ align = "end"
424+ className = "w-[min(21rem,calc(100vw-1.5rem))] [--popup-width:min(21rem,calc(100vw-1.5rem))]"
425+ >
426+ < div className = "grid min-w-0 gap-3" >
427+ < div className = "grid gap-0.5" >
428+ < p className = "text-[13px] font-semibold leading-tight text-foreground" >
429+ Update available
430+ </ p >
431+ < p
432+ className = { cn (
433+ "text-xs leading-snug" ,
434+ props . versionAdvisory . emphasis === "strong"
435+ ? "text-warning"
436+ : "text-muted-foreground" ,
437+ ) }
438+ >
439+ { props . versionAdvisory . detail }
440+ </ p >
441+ </ div >
442+ { props . onRunUpdate ? (
443+ < Button
444+ type = "button"
445+ size = "xs"
446+ variant = "outline"
447+ className = "w-full"
448+ disabled = { props . isUpdating }
449+ onClick = { props . onRunUpdate }
450+ >
451+ { props . isUpdating ? < Spinner /> : < DownloadIcon /> }
452+ { props . isUpdating ? "Updating" : "Update now" }
453+ </ Button >
454+ ) : null }
455+ { props . onRunUpdate && updateCommand ? (
456+ < div className = "flex items-center gap-2 text-[10px] font-medium uppercase tracking-wider text-muted-foreground" >
457+ < span aria-hidden className = "h-px flex-1 bg-border" />
458+ or, update manually using
459+ < span aria-hidden className = "h-px flex-1 bg-border" />
460+ </ div >
461+ ) : null }
462+ { updateCommand ? (
463+ < div className = "flex min-w-0 items-center gap-1 rounded-md border border-border/70 bg-muted/40 py-0.5 pr-0.5 pl-2" >
464+ < code className = "min-w-0 flex-1 truncate font-mono text-[11px] text-foreground" >
465+ { updateCommand }
466+ </ code >
467+ < Tooltip >
468+ < TooltipTrigger
469+ render = {
470+ < Button
471+ type = "button"
472+ size = "icon-xs"
473+ variant = "ghost"
474+ className = "shrink-0 text-muted-foreground hover:text-foreground"
475+ onClick = { ( ) =>
476+ copyToClipboard ( updateCommand , { providerName : props . displayName } )
477+ }
478+ aria-label = "Copy update command"
479+ >
480+ < CopyIcon className = "size-3" />
481+ </ Button >
482+ }
483+ />
484+ < TooltipPopup side = "top" > Copy command</ TooltipPopup >
485+ </ Tooltip >
486+ </ div >
487+ ) : null }
488+ </ div >
489+ </ PopoverPopup >
490+ </ Popover >
491+ ) ;
492+ }
493+
350494interface ProviderInstanceCardProps {
351495 readonly instanceId : ProviderInstanceId ;
352496 readonly instance : ProviderInstanceConfig ;
@@ -442,29 +586,19 @@ export function ProviderInstanceCard({
442586 : null ;
443587 const versionLabel = getProviderVersionLabel ( liveProvider ?. version ) ;
444588 const versionAdvisory = getProviderVersionAdvisoryPresentation ( liveProvider ?. versionAdvisory ) ;
445- const updateCommand = versionAdvisory ?. updateCommand ?? null ;
446589 const FallbackIconComponent = driverOption ?. icon ;
447590 const displayName =
448591 instance . displayName ?. trim ( ) || driverOption ?. label || String ( instance . driver ) ;
449592 const accentColor = normalizeProviderAccentColor ( instance . accentColor ) ;
450- const { copyToClipboard } = useCopyToClipboard < { providerName : string } > ( {
451- onCopy : ( { providerName } ) => {
452- toastManager . add ( {
453- type : "success" ,
454- title : `${ providerName } update command copied` ,
455- description : "Run it in a terminal when you are ready to update." ,
456- } ) ;
457- } ,
458- onError : ( error , { providerName } ) => {
459- toastManager . add (
460- stackedThreadToast ( {
461- type : "error" ,
462- title : `Could not copy ${ providerName } update command` ,
463- description : error . message ,
464- } ) ,
465- ) ;
466- } ,
467- } ) ;
593+ const updateAvailableControl = versionAdvisory ? (
594+ < ProviderUpdateAvailableControl
595+ displayName = { displayName }
596+ versionAdvisory = { versionAdvisory }
597+ onRunUpdate = { readOnly ? undefined : onRunUpdate }
598+ isUpdating = { isUpdating }
599+ compact = { mode === "list" }
600+ />
601+ ) : null ;
468602
469603 // Narrow `instance.driver` for callers that key on the closed
470604 // `ProviderDriverKind` union (e.g. `normalizeModelSlug`'s alias table). Custom
@@ -631,33 +765,7 @@ export function ProviderInstanceCard({
631765 { versionLabel }
632766 </ code >
633767 ) : null }
634- { versionAdvisory ? (
635- updateCommand ? (
636- < Tooltip >
637- < TooltipTrigger
638- render = {
639- < Button
640- type = "button"
641- size = "icon-micro"
642- variant = "ghost-muted"
643- className = "pointer-events-auto relative shrink-0"
644- aria-label = { `Copy ${ displayName } update command` }
645- onClick = { ( ) =>
646- copyToClipboard ( updateCommand , { providerName : displayName } )
647- }
648- >
649- < ArrowUpCircleIcon className = "size-3.5" />
650- </ Button >
651- }
652- />
653- < TooltipPopup side = "top" > Copy update command</ TooltipPopup >
654- </ Tooltip >
655- ) : (
656- < span role = "img" aria-label = "Update available" className = "inline-flex shrink-0" >
657- < ArrowUpCircleIcon className = "size-3.5 text-muted-foreground" />
658- </ span >
659- )
660- ) : null }
768+ { updateAvailableControl }
661769 </ span >
662770 < span className = "mt-0.5 flex items-start gap-1.5 text-[13px] leading-[1.45] text-muted-foreground/80" >
663771 { statusDotNode ? (
@@ -695,97 +803,7 @@ export function ProviderInstanceCard({
695803 aria-disabled = { readOnly || undefined }
696804 className = { cn ( "inline-flex items-center gap-1" , readOnly && "opacity-50" ) }
697805 >
698- { versionAdvisory ? (
699- < Popover >
700- < PopoverTrigger
701- render = {
702- < Button
703- type = "button"
704- size = "icon-xs"
705- variant = "ghost"
706- className = { cn (
707- "[--control-icon-color:currentColor]" ,
708- versionAdvisory . emphasis === "strong"
709- ? "text-warning hover:text-warning"
710- : "text-muted-foreground hover:text-foreground" ,
711- ) }
712- aria-label = "Update available — view details"
713- >
714- < ArrowUpCircleIcon />
715- </ Button >
716- }
717- />
718- < PopoverPopup
719- side = "bottom"
720- align = "end"
721- className = "w-[min(21rem,calc(100vw-1.5rem))] [--popup-width:min(21rem,calc(100vw-1.5rem))]"
722- >
723- < div className = "grid min-w-0 gap-3" >
724- < div className = "grid gap-0.5" >
725- < p className = "text-[13px] font-semibold leading-tight text-foreground" >
726- Update available
727- </ p >
728- < p
729- className = { cn (
730- "text-xs leading-snug" ,
731- versionAdvisory . emphasis === "strong"
732- ? "text-warning"
733- : "text-muted-foreground" ,
734- ) }
735- >
736- { versionAdvisory . detail }
737- </ p >
738- </ div >
739- { onRunUpdate ? (
740- < Button
741- type = "button"
742- size = "xs"
743- variant = "outline"
744- className = "w-full"
745- disabled = { isUpdating }
746- onClick = { onRunUpdate }
747- >
748- { isUpdating ? < Spinner /> : < DownloadIcon /> }
749- { isUpdating ? "Updating" : "Update now" }
750- </ Button >
751- ) : null }
752- { onRunUpdate && updateCommand ? (
753- < div className = "flex items-center gap-2 text-[10px] font-medium uppercase tracking-wider text-muted-foreground" >
754- < span aria-hidden className = "h-px flex-1 bg-border" />
755- or, update manually using
756- < span aria-hidden className = "h-px flex-1 bg-border" />
757- </ div >
758- ) : null }
759- { updateCommand ? (
760- < div className = "flex min-w-0 items-center gap-1 rounded-md border border-border/70 bg-muted/40 py-0.5 pr-0.5 pl-2" >
761- < code className = "min-w-0 flex-1 truncate font-mono text-[11px] text-foreground" >
762- { updateCommand }
763- </ code >
764- < Tooltip >
765- < TooltipTrigger
766- render = {
767- < Button
768- type = "button"
769- size = "icon-xs"
770- variant = "ghost"
771- className = "shrink-0 text-muted-foreground hover:text-foreground"
772- onClick = { ( ) =>
773- copyToClipboard ( updateCommand , { providerName : displayName } )
774- }
775- aria-label = "Copy update command"
776- >
777- < CopyIcon className = "size-3" />
778- </ Button >
779- }
780- />
781- < TooltipPopup side = "top" > Copy command</ TooltipPopup >
782- </ Tooltip >
783- </ div >
784- ) : null }
785- </ div >
786- </ PopoverPopup >
787- </ Popover >
788- ) : null }
806+ { updateAvailableControl }
789807 { titleTailNode }
790808 { onDelete ? (
791809 < Button
0 commit comments