Commit 1dec305
authored
fix(ui): show empty state when no model configs exist (kagent-dev#1930) (kagent-dev#1944)
---
Title:
fix(ui): show empty state when no model configs exist (kagent-dev#1930)
Description:
## What
When no `ModelConfig` resources are deployed, the UI showed a
"Failed to fetch models" error instead of rendering the normal empty
state ("no agents yet" / empty models page).
Fixes kagent-dev#1930
## Why
The backend's `StandardResponse.Data` field uses
`json:"data,omitempty"`,
so an empty list serializes with the `data` field omitted entirely
(e.g. `{"error":false,"message":"Successfully listed ModelConfigs"}`),
returned with HTTP 200.
The UI treated a missing `data` as a fetch failure:
```ts
if (!response.data || response.error) {
throw new Error(response.error || "Failed to fetch models");
}
```
So a valid "zero model configs" response was misread as an error and
surfaced via the shared error state in AgentsProvider (and on the
/models page).
Change
Treat a missing/empty list as a valid empty result, and only fail on an
explicit response.error — matching the existing defensive pattern in
AgentList (result.data || []):
- ui/src/components/AgentsProvider.tsx — fetchModels
- ui/src/app/models/page.tsx — fetchModels
This is a frontend-only fix; the backend omitempty behavior is
unchanged.
Screenshots
## Before:
<img width="1895" height="970" alt="Screenshot 2026-05-29 225451" src="https://github.com/user-attachments/assets/f15e192f-11c2-4547-abb4-d6bc22e2c78d" />
## After:
<img width="980" height="530" alt="image" src="https://github.com/user-attachments/assets/c812607d-0da9-42ed-81fb-590c9b5978a1" />
---------
Signed-off-by: gauravshinde1729 <shindegauravpict@gmail.com>1 parent 1b6f30a commit 1dec305
3 files changed
Lines changed: 77 additions & 8 deletions
File tree
- ui/src
- app/models
- components
- lib/__tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
34 | | - | |
| 33 | + | |
| 34 | + | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
37 | 39 | | |
38 | 40 | | |
39 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
128 | | - | |
129 | | - | |
| 128 | + | |
| 129 | + | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
133 | 136 | | |
134 | 137 | | |
135 | 138 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
| 1 | + | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
25 | 41 | | |
26 | 42 | | |
27 | 43 | | |
| |||
43 | 59 | | |
44 | 60 | | |
45 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
46 | 110 | | |
0 commit comments