Commit 17117dc
committed
fix(template): read agents list from clientConfig, drop /api/agents/info fetch
Reviewer caught the redundancy: the agents plugin already exposes
`{ agents, defaultAgent }` via `clientConfig()` at startup, inlined
into the boot HTML via `<script id="__appkit__">`. The template was
doing an extra `GET /api/agents/info` round-trip on mount to fetch
the same data that's already sitting in `window.__APPKIT_CONFIG__`
and readable via `usePluginClientConfig`.
Replace the useEffect + fetch + error-handling block with a
synchronous `usePluginClientConfig<AgentsClientConfig>('agents')`.
Net savings: -20 lines of effect/error/loading-state plumbing, one
fewer HTTP request on page load, no flicker between empty-then-
populated agent buttons because the data is available on first render.
`selectedAgent` is now initialised directly from
`defaultAgent ?? agents[0] ?? null` in `useState`, so there's no
intermediate "loading agents…" state. Input placeholder updates to
"No agents registered" when the registry is empty (which only happens
if the agents plugin loaded without any agents — config bug, worth
showing).
The `/api/agents/info` route is left in place on the server — it's
still useful for programmatic callers and debugging — just no longer
consumed by the template.
Signed-off-by: MarioCadenas <MarioCadenas@users.noreply.github.com>1 parent c557334 commit 17117dc
1 file changed
Lines changed: 23 additions & 24 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
20 | 27 | | |
21 | 28 | | |
22 | 29 | | |
23 | 30 | | |
24 | 31 | | |
25 | 32 | | |
26 | 33 | | |
27 | | - | |
28 | | - | |
29 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
30 | 38 | | |
31 | 39 | | |
32 | 40 | | |
33 | 41 | | |
34 | 42 | | |
35 | 43 | | |
36 | | - | |
37 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
38 | 52 | | |
39 | 53 | | |
40 | 54 | | |
| |||
68 | 82 | | |
69 | 83 | | |
70 | 84 | | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | 85 | | |
89 | 86 | | |
90 | 87 | | |
| |||
199 | 196 | | |
200 | 197 | | |
201 | 198 | | |
202 | | - | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
203 | 202 | | |
204 | 203 | | |
205 | 204 | | |
| |||
0 commit comments