Skip to content

Commit e8e2ba5

Browse files
authored
fix: skip agent guard 404 redirect for newly created agents (#744)
When creating an agent, the navigation state already passes newAgent: true. The AgentGuard now checks this flag and skips the existence check, preventing a race condition where the guard redirects to 404 before the new agent appears in the fetched agents list.
1 parent 9944702 commit e8e2ba5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/frontend/src/components/AgentGuard.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useParams, useNavigate } from "@solidjs/router";
1+
import { useParams, useNavigate, useLocation } from "@solidjs/router";
22
import { createResource, createEffect, Show, type ParentComponent } from "solid-js";
33
import ErrorState from "./ErrorState.jsx";
44
import { getAgents } from "../services/api.js";
@@ -14,9 +14,11 @@ interface AgentsData {
1414
const AgentGuard: ParentComponent = (props) => {
1515
const params = useParams<{ agentName: string }>();
1616
const navigate = useNavigate();
17+
const location = useLocation<{ newAgent?: boolean }>();
1718
const [data, { refetch }] = createResource(() => getAgents() as Promise<AgentsData>);
1819

1920
createEffect(() => {
21+
if (location.state?.newAgent) return;
2022
const list = data()?.agents;
2123
if (!list) return;
2224
const exists = list.some(

0 commit comments

Comments
 (0)