Skip to content

Commit de7e6c2

Browse files
committed
Add some cta to copy run command for agent
1 parent 110be0e commit de7e6c2

File tree

4 files changed

+85
-12
lines changed

4 files changed

+85
-12
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
'use client'
2+
3+
import { Copy } from 'lucide-react'
4+
import { Button } from '@/components/ui/button'
5+
import { toast } from '@/components/ui/use-toast'
6+
7+
interface CopyIdButtonProps {
8+
agentId: string
9+
}
10+
11+
export function CopyIdButton({ agentId }: CopyIdButtonProps) {
12+
const handleCopy = () => {
13+
navigator.clipboard.writeText(agentId)
14+
toast({
15+
description: `Agent ID copied to clipboard: "${agentId}"`,
16+
})
17+
}
18+
19+
return (
20+
<Button
21+
variant="outline"
22+
size="sm"
23+
onClick={handleCopy}
24+
className="flex items-center gap-2"
25+
>
26+
<Copy className="h-4 w-4" />
27+
Copy ID
28+
</Button>
29+
)
30+
}

web/src/app/publishers/[id]/agents/[agentId]/[version]/page.tsx

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import db from '@codebuff/common/db'
22
import * as schema from '@codebuff/common/db/schema'
33
import { and, eq } from 'drizzle-orm'
4-
import { ArrowLeft, Calendar, Code, Download, ExternalLink } from 'lucide-react'
4+
import { Calendar } from 'lucide-react'
55
import Link from 'next/link'
66
import { notFound } from 'next/navigation'
77

@@ -10,9 +10,11 @@ import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
1010
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
1111
import { BackButton } from '@/components/ui/back-button'
1212
import { TypeScriptViewer } from '@/components/agent/typescript-viewer'
13-
import { EnhancedCopyButton } from '@/components/ui/enhanced-copy-button'
13+
1414
import { cn } from '@/lib/utils'
1515
import { AgentUsageMetrics } from './agent-usage-metrics'
16+
import { RunAgentButton } from './run-agent-button'
17+
import { CopyIdButton } from './copy-id-button'
1618
import { Button } from '@/components/ui/button'
1719

1820
interface AgentDetailPageProps {
@@ -182,16 +184,9 @@ const AgentDetailPage = async ({ params }: AgentDetailPageProps) => {
182184
</div>
183185
</div>
184186
</div>
185-
<div className="flex flex-col items-end space-y-3">
186-
<div className="flex items-center space-x-2 text-sm">
187-
<code className="bg-muted/50 px-2 py-1 rounded text-xs font-mono text-muted-foreground">
188-
{publisherData.id}/{params.agentId}@{latestVersion}
189-
</code>
190-
<EnhancedCopyButton
191-
value={fullAgentId}
192-
className="p-1 text-muted-foreground/60 hover:text-muted-foreground"
193-
/>
194-
</div>
187+
<div className="flex items-end space-x-3">
188+
<CopyIdButton agentId={fullAgentId} />
189+
<RunAgentButton agentId={fullAgentId} />
195190
{/*
196191
Hide download button for now. (It doesn't do anything)
197192
<Button variant="outline" size="sm">
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
'use client'
2+
3+
import { Copy } from 'lucide-react'
4+
import { Button } from '@/components/ui/button'
5+
import { toast } from '@/components/ui/use-toast'
6+
7+
interface RunAgentButtonProps {
8+
agentId: string
9+
}
10+
11+
export function RunAgentButton({ agentId }: RunAgentButtonProps) {
12+
const handleCopy = () => {
13+
navigator.clipboard.writeText(`codebuff --agent ${agentId}`)
14+
toast({
15+
description: `Command copied to clipboard: "codebuff --agent ${agentId}"`,
16+
})
17+
}
18+
19+
return (
20+
<Button
21+
variant="outline"
22+
size="sm"
23+
onClick={handleCopy}
24+
className="flex items-center gap-2"
25+
>
26+
<Copy className="h-4 w-4" />
27+
Run this agent
28+
</Button>
29+
)
30+
}

web/src/app/store/page.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
Star,
1515
Plus,
1616
User,
17+
Copy,
1718
} from 'lucide-react'
1819
import Link from 'next/link'
1920
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
@@ -30,6 +31,7 @@ import {
3031
SelectValue,
3132
} from '@/components/ui/select'
3233
import { AnimatedElement } from '@/components/ui/landing/animated-element'
34+
import { toast } from '@/components/ui/use-toast'
3335
import { formatRelativeTime } from '@/lib/date-utils'
3436
import { cn } from '@/lib/utils'
3537
import type { PublisherProfileResponse } from '@codebuff/common/types/publisher'
@@ -234,6 +236,22 @@ const AgentStorePage = () => {
234236
>
235237
v{agent.version}
236238
</Badge>
239+
<div onClick={(e) => e.preventDefault()}>
240+
<button
241+
onClick={() => {
242+
navigator.clipboard.writeText(
243+
`codebuff --agent ${agent.id}`
244+
)
245+
toast({
246+
description: `Agent run command copied to clipboard:\n"codebuff --agent ${agent.id}"`,
247+
})
248+
}}
249+
className="p-1 hover:bg-muted/50 rounded transition-colors"
250+
title={`Copy: codebuff --agent ${agent.id}`}
251+
>
252+
<Copy className="h-3 w-3 text-muted-foreground hover:text-foreground" />
253+
</button>
254+
</div>
237255
</div>
238256
</div>
239257
<div className="flex flex-col items-end gap-3">

0 commit comments

Comments
 (0)