Skip to content

Commit ccd9533

Browse files
committed
feat(ui): add web search widget and enhance tool widgets
- Add WebSearchWidget for displaying search results with collapsible sections and clickable links - Enhance GrepWidget with improved result parsing, visual design, and structured display - Replace external links in GitHubAgentBrowser with Tauri shell integration for desktop security - Update StreamMessage to support WebSearch tool rendering - Add ReactMarkdown support for rich text display in search results
1 parent 915914e commit ccd9533

File tree

3 files changed

+427
-38
lines changed

3 files changed

+427
-38
lines changed

src/components/GitHubAgentBrowser.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { Badge } from "@/components/ui/badge";
1818
import { api, type GitHubAgentFile, type AgentExport, type Agent } from "@/lib/api";
1919
import { type AgentIconName } from "./CCAgents";
2020
import { ICON_MAP } from "./IconPicker";
21+
import { open } from "@tauri-apps/plugin-shell";
2122

2223
interface GitHubAgentBrowserProps {
2324
isOpen: boolean;
@@ -148,6 +149,15 @@ export const GitHubAgentBrowser: React.FC<GitHubAgentBrowserProps> = ({
148149
return <Icon className="h-8 w-8" />;
149150
};
150151

152+
const handleGitHubLinkClick = async (e: React.MouseEvent) => {
153+
e.preventDefault();
154+
try {
155+
await open("https://github.com/getAsterisk/claudia/tree/main/cc_agents");
156+
} catch (error) {
157+
console.error('Failed to open GitHub link:', error);
158+
}
159+
};
160+
151161
return (
152162
<Dialog open={isOpen} onOpenChange={onClose}>
153163
<DialogContent className="max-w-4xl max-h-[80vh] overflow-hidden flex flex-col">
@@ -163,15 +173,13 @@ export const GitHubAgentBrowser: React.FC<GitHubAgentBrowserProps> = ({
163173
<div className="px-4 py-3 bg-muted/50 rounded-lg mb-4">
164174
<p className="text-sm text-muted-foreground">
165175
Agents are fetched from{" "}
166-
<a
167-
href="https://github.com/getAsterisk/claudia/tree/main/cc_agents"
168-
target="_blank"
169-
rel="noopener noreferrer"
176+
<button
177+
onClick={handleGitHubLinkClick}
170178
className="text-primary hover:underline inline-flex items-center gap-1"
171179
>
172180
github.com/getAsterisk/claudia/cc_agents
173181
<Globe className="h-3 w-3" />
174-
</a>
182+
</button>
175183
</p>
176184
<p className="text-sm text-muted-foreground mt-1">
177185
You can contribute your custom agents to the repository!

src/components/StreamMessage.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ import {
3434
SystemInitializedWidget,
3535
TaskWidget,
3636
LSResultWidget,
37-
ThinkingWidget
37+
ThinkingWidget,
38+
WebSearchWidget
3839
} from "./ToolWidgets";
3940

4041
interface StreamMessageProps {
@@ -239,6 +240,12 @@ const StreamMessageComponent: React.FC<StreamMessageProps> = ({ message, classNa
239240
return <GrepWidget pattern={input.pattern} include={input.include} path={input.path} exclude={input.exclude} result={toolResult} />;
240241
}
241242

243+
// WebSearch tool
244+
if (toolName === "websearch" && input?.query) {
245+
renderedSomething = true;
246+
return <WebSearchWidget query={input.query} result={toolResult} />;
247+
}
248+
242249
// Default - return null
243250
return null;
244251
};
@@ -354,7 +361,7 @@ const StreamMessageComponent: React.FC<StreamMessageProps> = ({ message, classNa
354361
const toolUse = prevMsg.message.content.find((c: any) => c.type === 'tool_use' && c.id === content.tool_use_id);
355362
if (toolUse) {
356363
const toolName = toolUse.name?.toLowerCase();
357-
const toolsWithWidgets = ['task','edit','multiedit','todowrite','ls','read','glob','bash','write','grep'];
364+
const toolsWithWidgets = ['task','edit','multiedit','todowrite','ls','read','glob','bash','write','grep','websearch'];
358365
if (toolsWithWidgets.includes(toolName) || toolUse.name?.startsWith('mcp__')) {
359366
hasCorrespondingWidget = true;
360367
}

0 commit comments

Comments
 (0)