|
73 | 73 | throw new Error("Failed to fetch agents");
|
74 | 74 | }
|
75 | 75 |
|
76 |
| - agents = _agents.public_agents.agents; |
77 |
| - ownedAgents = _agents.owned_agents.agents; |
78 |
| - sharedAgents = _agents.shared_agents.agents; |
79 |
| - spotlightAgents = _agents.spotlight_agents.agents; |
| 76 | + agents = _agents.public_agents.agents ?? []; |
| 77 | + ownedAgents = _agents.owned_agents.agents ?? []; |
| 78 | + sharedAgents = _agents.shared_agents.agents ?? []; |
| 79 | + spotlightAgents = _agents.spotlight_agents.agents ?? []; |
80 | 80 |
|
81 | 81 | // Combine agents from new API into sections
|
82 | 82 | if (ownedAgents?.length > 0) {
|
|
137 | 137 | };
|
138 | 138 |
|
139 | 139 | const search = debounce(async (value: string) => {
|
140 |
| - searchValue = value.toLowerCase(); |
141 |
| - filteredAgents = sections["All Agents"].filter((agent) => { |
142 |
| - return ( |
143 |
| - agent.metadata.display_name.toLowerCase().includes(searchValue) || |
144 |
| - agent.author?.name.toLowerCase().includes(searchValue) || |
145 |
| - agent.author?.source_url?.toLowerCase().includes(searchValue) |
146 |
| - ); |
147 |
| - }); |
148 |
| - appInsights.trackEvent({ name: "Search", properties: { searchValue } }); // Track custom event |
149 |
| - }, SEARCH_DEBOUNCE_DELAY); |
| 140 | + searchValue = value; |
| 141 | + filteredAgents = []; |
| 142 | +
|
| 143 | + // Combine agents from all sections to filter |
| 144 | + debugger; |
| 145 | + const allAgents = [ |
| 146 | + ...ownedAgents, |
| 147 | + ...sharedAgents, |
| 148 | + ...spotlightAgents, |
| 149 | + ...agents |
| 150 | + ]; |
| 151 | +
|
| 152 | + filteredAgents = allAgents.filter((agent) => { |
| 153 | + return ( |
| 154 | + agent.metadata.display_name.toLowerCase().includes(searchValue.toLocaleLowerCase()) || |
| 155 | + agent.author?.name?.toLowerCase().includes(searchValue.toLocaleLowerCase()) || |
| 156 | + agent.author?.source_url?.toLowerCase().includes(searchValue.toLocaleLowerCase()) |
| 157 | + ); |
| 158 | + }); |
| 159 | +
|
| 160 | + appInsights.trackEvent({ name: "Search", properties: { searchValue } }); // Track custom event |
| 161 | +}, SEARCH_DEBOUNCE_DELAY); |
| 162 | +
|
150 | 163 |
|
151 | 164 | const formatGithubUrl = (url: string) => {
|
152 | 165 | const urlObj = new URL(url);
|
|
0 commit comments