@@ -248,7 +248,7 @@ function GeneralSettings() {
248248
249249function AgentsSettings ( ) {
250250 const { config, saveConfig, saving, error } = useMiyaConfig ( )
251- const agents = Array . isArray ( config . agents ) ? config . agents : [ ]
251+ const agents = ( Array . isArray ( config . agents ) ? config . agents : [ ] ) . filter ( ( agent ) => agent . type !== 'builtin' )
252252 const [ editing , setEditing ] = useState ( null )
253253 const [ adding , setAdding ] = useState ( false )
254254 const [ form , setForm ] = useState ( { name : '' , enabled : true , command : '' , args : '' } )
@@ -269,7 +269,8 @@ function AgentsSettings() {
269269 const handleSave = async ( ) => {
270270 if ( ! form . command . trim ( ) ) return
271271 await saveConfig ( ( prev ) => {
272- const id = uniqueAgentId ( form , prev . agents || [ ] , editing )
272+ const reserved = Object . keys ( prev . profiles || { } ) . map ( ( id ) => ( { id } ) )
273+ const id = uniqueAgentId ( form , [ ...( prev . agents || [ ] ) , ...reserved ] , editing )
273274 const agents = ( prev . agents || [ ] ) . filter ( ( agent ) => agent . id !== id )
274275 agents . push ( {
275276 id,
@@ -312,8 +313,8 @@ function AgentsSettings() {
312313 return (
313314 < div className = "space-y-4" >
314315 < SectionHeader
315- title = "Agents"
316- description = "Manage built-in profile agents and external ACP agents ."
316+ title = "External Agents"
317+ description = "Manage ACP agents such as OpenCode. Profiles appear automatically in Chat ."
317318 action = { (
318319 < Button size = "sm" onClick = { startAdd } disabled = { adding || editing !== null } >
319320 < Plus className = "size-3.5 mr-1" /> Add Agent
@@ -328,21 +329,14 @@ function AgentsSettings() {
328329 < div className = "min-w-0" >
329330 < div className = "flex items-center gap-2" >
330331 < p className = "font-medium text-sm" > { agent . name || agent . id } </ p >
331- { agent . type === 'builtin' && < span className = "rounded border px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-muted-foreground" > Built in</ span > }
332332 </ div >
333333 < p className = "text-xs text-muted-foreground font-mono truncate" >
334- { agent . type === 'builtin'
335- ? `${ agent . profile || 'no profile' } / ${ config . profiles ?. [ agent . profile ] ?. model || 'no model' } `
336- : `${ agent . type || 'stdio' } / ${ commandFromAgent ( agent ) } ` }
334+ { agent . type || 'stdio' } / { commandFromAgent ( agent ) }
337335 </ p >
338336 </ div >
339337 < div className = "flex items-center gap-2 shrink-0 ml-2" >
340- { agent . type !== 'builtin' && (
341- < >
342- < Button variant = "ghost" size = "icon-xs" onClick = { ( ) => startEdit ( agent ) } > < Pencil className = "size-3" /> </ Button >
343- < Button variant = "ghost" size = "icon-xs" onClick = { ( ) => handleDelete ( agent . id ) } > < Trash2 className = "size-3" /> </ Button >
344- </ >
345- ) }
338+ < Button variant = "ghost" size = "icon-xs" onClick = { ( ) => startEdit ( agent ) } > < Pencil className = "size-3" /> </ Button >
339+ < Button variant = "ghost" size = "icon-xs" onClick = { ( ) => handleDelete ( agent . id ) } > < Trash2 className = "size-3" /> </ Button >
346340 < Switch
347341 checked = { agent . enabled !== false }
348342 onChange = { ( enabled ) => handleToggleEnabled ( agent . id , enabled ) }
@@ -354,7 +348,7 @@ function AgentsSettings() {
354348 ) }
355349 </ div >
356350 ) ) }
357- { agents . length === 0 && < div className = "px-4 py-8 text-center text-xs text-muted-foreground" > No agents configured</ div > }
351+ { agents . length === 0 && < div className = "px-4 py-8 text-center text-xs text-muted-foreground" > No external agents configured</ div > }
358352 { adding && < div className = "px-4 py-3" > { editor } </ div > }
359353 </ div >
360354 < ConfigError error = { error } />
@@ -433,50 +427,15 @@ function ProfilesSettings({ onSelectItem }) {
433427 contextWindowTokens : Number ( form . contextWindowTokens ) || 0 ,
434428 contextWarnRatio : Number ( form . contextWarnRatio ) || 0 ,
435429 }
436- const agents = Array . isArray ( prev . agents ) ? [ ...prev . agents ] : [ ]
437- if ( editing ) {
438- const previousGeneratedName = editing === 'default' ? 'Miya Default' : editing
439- for ( let index = 0 ; index < agents . length ; index += 1 ) {
440- if ( agents [ index ] . type === 'builtin' && agents [ index ] . profile === editing ) {
441- agents [ index ] = {
442- ...agents [ index ] ,
443- profile : id ,
444- name : agents [ index ] . name === previousGeneratedName
445- ? ( id === 'default' ? 'Miya Default' : id )
446- : agents [ index ] . name ,
447- }
448- }
449- }
450- }
451- if ( ! agents . some ( ( agent ) => agent . type === 'builtin' && agent . profile === id ) ) {
452- const baseId = `miya-${ id } `
453- let agentId = baseId
454- let suffix = 2
455- const used = new Set ( agents . map ( ( agent ) => agent . id ) )
456- while ( used . has ( agentId ) ) {
457- agentId = `${ baseId } -${ suffix } `
458- suffix += 1
459- }
460- agents . push ( {
461- id : agentId ,
462- name : id === 'default' ? 'Miya Default' : id ,
463- enabled : true ,
464- type : 'builtin' ,
465- profile : id ,
466- command : 'miya-agent' ,
467- args : [ 'acp' ] ,
468- } )
469- }
470- return { ...prev , profiles, agents }
430+ return { ...prev , profiles }
471431 } )
472432 handleCancel ( )
473433 }
474434 const handleDelete = async ( id ) => {
475435 await saveConfig ( ( prev ) => {
476436 const profiles = { ...( prev . profiles || { } ) }
477437 delete profiles [ id ]
478- const agents = ( prev . agents || [ ] ) . filter ( ( agent ) => ! ( agent . type === 'builtin' && agent . profile === id ) )
479- return { ...prev , profiles, agents }
438+ return { ...prev , profiles }
480439 } )
481440 }
482441
0 commit comments