File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { describe , expect , it } from 'vitest' ;
2+ import { selectMcpJsonDir } from './register.js' ;
3+
4+ describe ( 'selectMcpJsonDir' , ( ) => {
5+ it ( 'returns worktreePath when defined' , ( ) => {
6+ expect ( selectMcpJsonDir ( '/worktrees/my-task' , '/project' ) ) . toBe ( '/worktrees/my-task' ) ;
7+ } ) ;
8+
9+ it ( 'returns projectRoot when worktreePath is undefined' , ( ) => {
10+ expect ( selectMcpJsonDir ( undefined , '/project' ) ) . toBe ( '/project' ) ;
11+ } ) ;
12+
13+ it ( 'returns empty string when worktreePath is empty string (nullish coalescing only catches null/undefined)' , ( ) => {
14+ expect ( selectMcpJsonDir ( '' , '/project' ) ) . toBe ( '' ) ;
15+ } ) ;
16+ } ) ;
Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ vi.mock('./core', () => ({
5454 if ( prop === 'agents' ) return mockAgents ;
5555 if ( prop === 'taskOrder' ) return mockTaskOrder ;
5656 if ( prop === 'collapsedTaskOrder' ) return [ ] ;
57+ if ( prop === 'availableAgents' ) return [ ] ;
5758 return undefined ;
5859 } ,
5960 } ) ,
Original file line number Diff line number Diff line change @@ -977,18 +977,22 @@ export function initMCPListeners(): () => void {
977977 skipPermissions : evt . skipPermissions ?? false ,
978978 } ;
979979
980+ const cmd = evt . agentCommand ?? 'claude' ;
981+ const matchedDef = store . availableAgents ?. find ( ( a ) => a . command === cmd ) ;
982+ const agentDef = matchedDef ?? {
983+ id : cmd ,
984+ name : cmd ,
985+ command : cmd ,
986+ args : evt . agentArgs ?? [ ] ,
987+ resume_args : [ ] ,
988+ skip_permissions_args : [ '--dangerously-skip-permissions' ] ,
989+ description : '' ,
990+ } ;
991+
980992 const agent : Agent = {
981993 id : evt . agentId ,
982994 taskId : evt . taskId ,
983- def : {
984- id : 'claude' ,
985- name : 'Claude Code' ,
986- command : evt . agentCommand ?? 'claude' ,
987- args : evt . agentArgs ?? [ ] ,
988- resume_args : [ ] ,
989- skip_permissions_args : [ '--dangerously-skip-permissions' ] ,
990- description : '' ,
991- } ,
995+ def : matchedDef ? { ...matchedDef , args : evt . agentArgs ?? matchedDef . args } : agentDef ,
992996 resumed : false ,
993997 status : 'running' ,
994998 exitCode : null ,
You can’t perform that action at this time.
0 commit comments