fix(ui): deduplicate agent catalog error messages in CreateProjectAgentSheet (#2428)

This commit is contained in:
PRADEEP SAHU 2026-07-05 18:45:43 +05:30 committed by GitHub
parent cbaffd2cb4
commit 608333bd54
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 11 deletions

View File

@ -58,6 +58,11 @@ export function CreateProjectAgentSheet({
? agentsQuery.error.message ? agentsQuery.error.message
: "Could not load agent catalog." : "Could not load agent catalog."
: null; : null;
const displayError = refreshAgentsMutation.isError
? refreshAgentsMutation.error instanceof Error
? refreshAgentsMutation.error.message
: "Could not refresh agent catalog."
: agentsError;
const [workerAgent, setWorkerAgent] = useState(""); const [workerAgent, setWorkerAgent] = useState("");
const [orchestratorAgent, setOrchestratorAgent] = useState(""); const [orchestratorAgent, setOrchestratorAgent] = useState("");
const [intake, setIntake] = useState<IntakeForm>(EMPTY_INTAKE); const [intake, setIntake] = useState<IntakeForm>(EMPTY_INTAKE);
@ -143,12 +148,13 @@ export function CreateProjectAgentSheet({
</button> </button>
</div> </div>
{agentsError && ( {displayError && (
<div className="flex items-center justify-between gap-3 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-[12px] leading-5 text-destructive"> <div className="flex items-center justify-between gap-3 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-[12px] leading-5 text-destructive">
<span>{agentsError}</span> <span>{displayError}</span>
<button <button
type="button" type="button"
className="shrink-0 rounded text-foreground underline-offset-2 hover:underline" className="shrink-0 rounded text-foreground underline-offset-2 hover:underline disabled:pointer-events-none disabled:opacity-50"
disabled={refreshAgentsMutation.isPending}
onClick={() => refreshAgentsMutation.mutate()} onClick={() => refreshAgentsMutation.mutate()}
> >
Retry Retry
@ -156,14 +162,6 @@ export function CreateProjectAgentSheet({
</div> </div>
)} )}
{refreshAgentsMutation.isError && (
<div className="rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-[12px] leading-5 text-destructive">
{refreshAgentsMutation.error instanceof Error
? refreshAgentsMutation.error.message
: "Could not refresh agent catalog."}
</div>
)}
<div className="border-t border-border pt-4"> <div className="border-t border-border pt-4">
<IntakeFields form={intake} onChange={(patch) => setIntake((f) => ({ ...f, ...patch }))} compact /> <IntakeFields form={intake} onChange={(patch) => setIntake((f) => ({ ...f, ...patch }))} compact />
</div> </div>