@@ -131,6 +131,137 @@ describe('collectForkDependentReconfigs', () => {
131131 ] )
132132 } )
133133
134+ it ( 'uses trigger canonical context for top-level trigger-mode reconfiguration' , ( ) => {
135+ vi . mocked ( getBlock ) . mockReturnValue (
136+ blockWith ( [
137+ {
138+ id : 'credential' ,
139+ title : 'Action Credential' ,
140+ type : 'oauth-input' ,
141+ canonicalParamId : 'oauthCredential' ,
142+ mode : 'basic' ,
143+ } ,
144+ {
145+ id : 'workspaceSelector' ,
146+ title : 'Action Workspace' ,
147+ type : 'project-selector' ,
148+ canonicalParamId : 'teamId' ,
149+ mode : 'basic' ,
150+ } ,
151+ {
152+ id : 'triggerCredentials' ,
153+ title : 'Trigger Credential' ,
154+ type : 'oauth-input' ,
155+ canonicalParamId : 'oauthCredential' ,
156+ mode : 'trigger' ,
157+ } ,
158+ {
159+ id : 'triggerWorkspaceId' ,
160+ title : 'Trigger Workspace' ,
161+ type : 'dropdown' ,
162+ canonicalParamId : 'teamId' ,
163+ dependsOn : [ 'triggerCredentials' ] ,
164+ selectorKey : 'clickup.workspaces' ,
165+ mode : 'trigger' ,
166+ } ,
167+ ] )
168+ )
169+ const state = sourceState ( 'clickup' , {
170+ credential : { value : 'action-credential' } ,
171+ workspaceSelector : { value : 'action-workspace' } ,
172+ triggerCredentials : { value : 'trigger-credential' } ,
173+ triggerWorkspaceId : { value : 'trigger-workspace' } ,
174+ } )
175+ state . blocks [ 'block-1' ] . triggerMode = true
176+
177+ const result = collectForkDependentReconfigs (
178+ [ replaceItem ] ,
179+ new Map ( [ [ 'wf-src' , state ] ] ) ,
180+ resolve
181+ )
182+
183+ expect ( result ) . toHaveLength ( 1 )
184+ expect ( result [ 0 ] ) . toMatchObject ( {
185+ parentSourceId : 'trigger-credential' ,
186+ subBlockKey : 'triggerWorkspaceId' ,
187+ context : { teamId : 'trigger-workspace' } ,
188+ } )
189+ } )
190+
191+ it ( 'keeps nested tool selector context in action mode inside a trigger block' , ( ) => {
192+ const agentConfig = blockWith ( [ { id : 'tools' , title : 'Tools' , type : 'tool-input' } ] )
193+ const clickupToolConfig = blockWith ( [
194+ {
195+ id : 'credential' ,
196+ title : 'Action Credential' ,
197+ type : 'oauth-input' ,
198+ canonicalParamId : 'oauthCredential' ,
199+ mode : 'basic' ,
200+ } ,
201+ {
202+ id : 'workspaceSelector' ,
203+ title : 'Action Workspace' ,
204+ type : 'project-selector' ,
205+ canonicalParamId : 'teamId' ,
206+ mode : 'basic' ,
207+ } ,
208+ {
209+ id : 'triggerCredentials' ,
210+ title : 'Trigger Credential' ,
211+ type : 'oauth-input' ,
212+ canonicalParamId : 'oauthCredential' ,
213+ mode : 'trigger' ,
214+ } ,
215+ {
216+ id : 'triggerWorkspaceId' ,
217+ title : 'Trigger Workspace' ,
218+ type : 'dropdown' ,
219+ canonicalParamId : 'teamId' ,
220+ mode : 'trigger' ,
221+ } ,
222+ {
223+ id : 'listId' ,
224+ title : 'List' ,
225+ type : 'short-input' ,
226+ dependsOn : [ 'credential' ] ,
227+ required : true ,
228+ } ,
229+ ] )
230+ vi . mocked ( getBlock ) . mockImplementation ( ( type ) =>
231+ type === 'agent' ? agentConfig : clickupToolConfig
232+ )
233+ const state = sourceState ( 'agent' , {
234+ tools : {
235+ value : [
236+ {
237+ type : 'clickup' ,
238+ params : {
239+ credential : 'action-credential' ,
240+ workspaceSelector : 'action-workspace' ,
241+ triggerCredentials : 'trigger-credential' ,
242+ triggerWorkspaceId : 'trigger-workspace' ,
243+ listId : 'list-1' ,
244+ } ,
245+ } ,
246+ ] ,
247+ } ,
248+ } )
249+ state . blocks [ 'block-1' ] . triggerMode = true
250+
251+ const result = collectForkDependentReconfigs (
252+ [ replaceItem ] ,
253+ new Map ( [ [ 'wf-src' , state ] ] ) ,
254+ resolve
255+ )
256+
257+ expect ( result ) . toHaveLength ( 1 )
258+ expect ( result [ 0 ] ) . toMatchObject ( {
259+ parentSourceId : 'action-credential' ,
260+ subBlockKey : 'tools[0].listId' ,
261+ context : { teamId : 'action-workspace' } ,
262+ } )
263+ } )
264+
134265 it ( 'skips an anchor whose canonical pair is in advanced (manual) mode - the value passes through' , ( ) => {
135266 vi . mocked ( getBlock ) . mockReturnValue (
136267 blockWith ( [
0 commit comments