Skip to content

Commit 70a0c18

Browse files
committed
fix: Fixed search issue of the marketplace. No we can query and get the agents as per search
1 parent abc5c9b commit 70a0c18

File tree

1 file changed

+27
-14
lines changed

1 file changed

+27
-14
lines changed

web/src/routes/+page.svelte

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@
7373
throw new Error("Failed to fetch agents");
7474
}
7575
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 ?? [];
8080
8181
// Combine agents from new API into sections
8282
if (ownedAgents?.length > 0) {
@@ -137,16 +137,29 @@
137137
};
138138
139139
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+
150163
151164
const formatGithubUrl = (url: string) => {
152165
const urlObj = new URL(url);

0 commit comments

Comments
 (0)