Skip to content

Commit 3fd3d19

Browse files
V48 Gate 3 (implementation-only): repository-inventory refresh gets a real fetch state machine
The Refresh inventory flow on the deposit source selection tracked no connection-fetch state: clicking it silently nulled the connection and the UI lied mid-flight ('Connect a repository provider first...') with zero feedback. The connection fetch now has a loading state — the button disables and spins with 'Refreshing inventory…' while the connection/repository fetches run, the repository combobox placeholder reads 'Checking provider connection...' during the round-trip, and the provider dropdown's item description shows 'Checking connection…' instead of a premature 'Not connected'. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent c3877a5 commit 3fd3d19

1 file changed

Lines changed: 23 additions & 6 deletions

File tree

uapi/app/deposits/DepositSourceSelection.tsx

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export default function DepositSourceSelection({
8787
const [commits, setCommits] = useState<VCSCommit[]>([]);
8888
const [defaultBranch, setDefaultBranch] = useState<string | null>(null);
8989
const [isLoadingRepositories, setIsLoadingRepositories] = useState(false);
90+
const [isLoadingConnection, setIsLoadingConnection] = useState(true);
9091
const [isLoadingBranches, setIsLoadingBranches] = useState(false);
9192
const [isLoadingCommits, setIsLoadingCommits] = useState(false);
9293
const [error, setError] = useState<string | null>(null);
@@ -124,6 +125,7 @@ export default function DepositSourceSelection({
124125
useEffect(() => {
125126
let disposed = false;
126127
setError(null);
128+
setIsLoadingConnection(true);
127129
fetch(`/api/vcs/${provider}/connection`)
128130
.then(async (response) => {
129131
const payload = await readJsonResponse(response);
@@ -142,6 +144,9 @@ export default function DepositSourceSelection({
142144
? nextError.message
143145
: "Unable to load repository connection posture.",
144146
);
147+
})
148+
.finally(() => {
149+
if (!disposed) setIsLoadingConnection(false);
145150
});
146151
return () => {
147152
disposed = true;
@@ -462,9 +467,11 @@ export default function DepositSourceSelection({
462467
label: getProviderLabel(option),
463468
description:
464469
option === provider
465-
? connectionStatus?.connected
466-
? "Connected"
467-
: "Not connected"
470+
? isLoadingConnection
471+
? "Checking connection…"
472+
: connectionStatus?.connected
473+
? "Connected"
474+
: "Not connected"
468475
: null,
469476
}))}
470477
value={provider}
@@ -513,7 +520,9 @@ export default function DepositSourceSelection({
513520
placeholder={
514521
connectionStatus?.connected
515522
? "Select repository supply..."
516-
: "Connect a repository provider first..."
523+
: isLoadingConnection
524+
? "Checking provider connection..."
525+
: "Connect a repository provider first..."
517526
}
518527
className="w-full"
519528
/>
@@ -642,6 +651,7 @@ export default function DepositSourceSelection({
642651
<button
643652
type="button"
644653
aria-label="Refresh repository inventory"
654+
disabled={isLoadingConnection || isLoadingRepositories}
645655
onClick={() => {
646656
setConnectionStatus(null);
647657
setRepositories([]);
@@ -652,9 +662,16 @@ export default function DepositSourceSelection({
652662
setSourceSelectionError(null);
653663
setRefreshNonce((value) => value + 1);
654664
}}
655-
className="mt-3 inline-flex items-center gap-2 text-[0.66rem] uppercase tracking-[0.18em] text-neutral-500 transition hover:text-neutral-300"
665+
className="mt-3 inline-flex items-center gap-2 text-[0.66rem] uppercase tracking-[0.18em] text-neutral-500 transition hover:text-neutral-300 disabled:cursor-not-allowed disabled:opacity-60"
656666
>
657-
<RefreshCw className="h-3 w-3" /> Refresh inventory
667+
<RefreshCw
668+
className={`h-3 w-3 ${
669+
isLoadingConnection || isLoadingRepositories ? "animate-spin" : ""
670+
}`}
671+
/>{" "}
672+
{isLoadingConnection || isLoadingRepositories
673+
? "Refreshing inventory…"
674+
: "Refresh inventory"}
658675
</button>
659676
</section>
660677
);

0 commit comments

Comments
 (0)