@@ -29,6 +29,7 @@ import { Label, labelVariants } from "~/components/primitives/Label";
2929import { Paragraph } from "~/components/primitives/Paragraph" ;
3030import { FormError } from "~/components/primitives/FormError" ;
3131import { Switch } from "~/components/primitives/Switch" ;
32+ import { Spinner } from "~/components/primitives/Spinner" ;
3233import { readBoundedBodyText } from "~/utils/boundedRequestBody.server" ;
3334
3435import { trail } from "agentcrumbs" ; // @crumbs
@@ -262,6 +263,9 @@ function AutoArchiveForm({
262263 const valid = PreviewAutoArchivePolicy . safeParse ( JSON . parse ( policyKey ) ) . success ;
263264 const reviewed =
264265 valid && ! preview . pending && preview . data ?. ok && preview . data . policyKey === policyKey ;
266+ const checkingProtectedBranches =
267+ valid && ! reviewed && excluded . trim ( ) !== "" && ( preview . pending || requestedKey !== policyKey ) ;
268+ const protectedBranches = reviewed && preview . data ?. ok ? preview . data . protectedBranches : [ ] ;
265269 const busy = fetcher . state !== "idle" ;
266270 useEffect ( ( ) => {
267271 if ( ! valid || busy ) return ;
@@ -434,18 +438,25 @@ function AutoArchiveForm({
434438 < Paragraph > Checking branches…</ Paragraph >
435439 ) }
436440 </ section >
437- { reviewed && preview . data ?. ok && preview . data . protectedBranches . length > 0 && (
438- < section className = "max-h-48 overflow-y-auto" aria-labelledby = "protected-branches-title" >
441+ { ( checkingProtectedBranches || protectedBranches . length > 0 ) && (
442+ < section
443+ className = "max-h-48 overflow-y-auto"
444+ aria-labelledby = "protected-branches-title"
445+ aria-busy = { checkingProtectedBranches }
446+ >
439447 < h3 id = "protected-branches-title" className = { `${ labelVariants . medium . text } mb-2` } >
440448 Protected branches
449+ { checkingProtectedBranches && < Spinner color = "blue" className = "ml-1 size-3" /> }
441450 </ h3 >
442- < ul className = "list-disc space-y-1 pl-4 text-sm text-text-dimmed" >
443- { preview . data . protectedBranches . map ( ( branch ) => (
444- < li key = { branch } className = "break-words" >
445- { branch }
446- </ li >
447- ) ) }
448- </ ul >
451+ { ! checkingProtectedBranches && (
452+ < ul className = "list-disc space-y-1 pl-4 text-sm text-text-dimmed" >
453+ { protectedBranches . map ( ( branch ) => (
454+ < li key = { branch } className = "break-words" >
455+ { branch }
456+ </ li >
457+ ) ) }
458+ </ ul >
459+ ) }
449460 </ section >
450461 ) }
451462 </ Fieldset >
0 commit comments