@@ -15,11 +15,14 @@ import {
1515 Shield ,
1616 Terminal ,
1717 ArrowLeft ,
18- History
18+ History ,
19+ Download
1920} from "lucide-react" ;
2021import { Button } from "@/components/ui/button" ;
2122import { Card , CardContent , CardFooter } from "@/components/ui/card" ;
2223import { api , type Agent , type AgentRunWithMetrics } from "@/lib/api" ;
24+ import { save } from "@tauri-apps/plugin-dialog" ;
25+ import { invoke } from "@tauri-apps/api/core" ;
2326import { cn } from "@/lib/utils" ;
2427import { Toast , ToastContainer } from "@/components/ui/toast" ;
2528import { CreateAgent } from "./CreateAgent" ;
@@ -155,6 +158,35 @@ export const CCAgents: React.FC<CCAgentsProps> = ({ onBack, className }) => {
155158 await loadRuns ( ) ;
156159 } ;
157160
161+ const handleExportAgent = async ( agent : Agent ) => {
162+ try {
163+ // Show native save dialog
164+ const filePath = await save ( {
165+ defaultPath : `${ agent . name . toLowerCase ( ) . replace ( / \s + / g, '-' ) } .claudia.json` ,
166+ filters : [ {
167+ name : 'Claudia Agent' ,
168+ extensions : [ 'claudia.json' ]
169+ } ]
170+ } ) ;
171+
172+ if ( ! filePath ) {
173+ // User cancelled the dialog
174+ return ;
175+ }
176+
177+ // Export the agent to the selected file
178+ await invoke ( 'export_agent_to_file' , {
179+ id : agent . id ! ,
180+ filePath
181+ } ) ;
182+
183+ setToast ( { message : `Agent "${ agent . name } " exported successfully` , type : "success" } ) ;
184+ } catch ( err ) {
185+ console . error ( "Failed to export agent:" , err ) ;
186+ setToast ( { message : "Failed to export agent" , type : "error" } ) ;
187+ }
188+ } ;
189+
158190 // Pagination calculations
159191 const totalPages = Math . ceil ( agents . length / AGENTS_PER_PAGE ) ;
160192 const startIndex = ( currentPage - 1 ) * AGENTS_PER_PAGE ;
@@ -342,12 +374,13 @@ export const CCAgents: React.FC<CCAgentsProps> = ({ onBack, className }) => {
342374 Created: { new Date ( agent . created_at ) . toLocaleDateString ( ) }
343375 </ p >
344376 </ CardContent >
345- < CardFooter className = "p-4 pt-0 flex justify-center gap-2 " >
377+ < CardFooter className = "p-4 pt-0 flex justify-center gap-1 flex-wrap " >
346378 < Button
347379 size = "sm"
348380 variant = "ghost"
349381 onClick = { ( ) => handleExecuteAgent ( agent ) }
350382 className = "flex items-center gap-1"
383+ title = "Execute agent"
351384 >
352385 < Play className = "h-3 w-3" />
353386 Execute
@@ -357,15 +390,27 @@ export const CCAgents: React.FC<CCAgentsProps> = ({ onBack, className }) => {
357390 variant = "ghost"
358391 onClick = { ( ) => handleEditAgent ( agent ) }
359392 className = "flex items-center gap-1"
393+ title = "Edit agent"
360394 >
361395 < Edit className = "h-3 w-3" />
362396 Edit
363397 </ Button >
398+ < Button
399+ size = "sm"
400+ variant = "ghost"
401+ onClick = { ( ) => handleExportAgent ( agent ) }
402+ className = "flex items-center gap-1"
403+ title = "Export agent to .claudia.json"
404+ >
405+ < Download className = "h-3 w-3" />
406+ Export
407+ </ Button >
364408 < Button
365409 size = "sm"
366410 variant = "ghost"
367411 onClick = { ( ) => handleDeleteAgent ( agent . id ! ) }
368412 className = "flex items-center gap-1 text-destructive hover:text-destructive"
413+ title = "Delete agent"
369414 >
370415 < Trash2 className = "h-3 w-3" />
371416 Delete
@@ -452,4 +497,4 @@ export const CCAgents: React.FC<CCAgentsProps> = ({ onBack, className }) => {
452497 </ ToastContainer >
453498 </ div >
454499 ) ;
455- } ;
500+ } ;
0 commit comments