@@ -42,10 +42,10 @@ export function FileSelectorInput({
4242 const params = useParams ( )
4343 const workflowIdFromUrl = ( params ?. workflowId as string ) || activeWorkflowId || ''
4444 // Central dependsOn gating for this selector instance
45- const { finalDisabled } = useDependsOnGate ( blockId , subBlock , {
46- disabled,
47- isPreview,
48- previewContextValues
45+ const { finalDisabled, dependsOn } = useDependsOnGate ( blockId , subBlock , {
46+ disabled,
47+ isPreview,
48+ previewContextValues,
4949 } )
5050
5151 // Helper to coerce various preview value shapes into a string ID
@@ -73,7 +73,7 @@ export function FileSelectorInput({
7373 const [ planIdValueFromStore ] = useSubBlockValue ( blockId , 'planId' )
7474 const [ teamIdValueFromStore ] = useSubBlockValue ( blockId , 'teamId' )
7575 const [ operationValueFromStore ] = useSubBlockValue ( blockId , 'operation' )
76-
76+
7777 // Use previewContextValues if provided (for tools inside agent blocks), otherwise use store values
7878 const connectedCredential = previewContextValues ?. credential ?? connectedCredentialFromStore
7979 const domainValue = previewContextValues ?. domain ?? domainValueFromStore
@@ -88,7 +88,7 @@ export function FileSelectorInput({
8888 ? getProviderIdFromServiceId ( subBlock . serviceId )
8989 : ( subBlock . provider as string ) || ''
9090 const { isForeignCredential } = useForeignCredential (
91- foreignCheckProvider ,
91+ subBlock . provider || subBlock . serviceId || 'outlook' ,
9292 ( connectedCredential as string ) || ''
9393 )
9494
@@ -121,6 +121,20 @@ export function FileSelectorInput({
121121 // Use preview value when in preview mode, otherwise use store value
122122 const value = isPreview ? previewValue : storeValue
123123
124+ const credentialDependencySatisfied = ( ( ) => {
125+ if ( ! dependsOn . includes ( 'credential' ) ) return true
126+ const normalizedCredential = coerceToIdString ( connectedCredential )
127+ if ( ! normalizedCredential || normalizedCredential . trim ( ) . length === 0 ) {
128+ return false
129+ }
130+ if ( isForeignCredential ) {
131+ return false
132+ }
133+ return true
134+ } ) ( )
135+
136+ const shouldForceDisable = ! credentialDependencySatisfied
137+
124138 // For Google Drive
125139 const clientId = getEnv ( 'NEXT_PUBLIC_GOOGLE_CLIENT_ID' ) || ''
126140 const apiKey = getEnv ( 'NEXT_PUBLIC_GOOGLE_API_KEY' ) || ''
@@ -144,7 +158,7 @@ export function FileSelectorInput({
144158 collaborativeSetSubblockValue ( blockId , subBlock . id , val )
145159 } }
146160 label = { subBlock . placeholder || 'Select Google Calendar' }
147- disabled = { finalDisabled }
161+ disabled = { finalDisabled || shouldForceDisable }
148162 showPreview = { true }
149163 credentialId = { credential }
150164 workflowId = { workflowIdFromUrl }
@@ -178,7 +192,7 @@ export function FileSelectorInput({
178192 requiredScopes = { subBlock . requiredScopes || [ ] }
179193 serviceId = { subBlock . serviceId }
180194 label = { subBlock . placeholder || 'Select Confluence page' }
181- disabled = { finalDisabled }
195+ disabled = { finalDisabled || shouldForceDisable }
182196 showPreview = { true }
183197 credentialId = { credential }
184198 workflowId = { workflowIdFromUrl }
@@ -212,7 +226,7 @@ export function FileSelectorInput({
212226 requiredScopes = { subBlock . requiredScopes || [ ] }
213227 serviceId = { subBlock . serviceId }
214228 label = { subBlock . placeholder || 'Select Jira issue' }
215- disabled = { finalDisabled }
229+ disabled = { finalDisabled || shouldForceDisable }
216230 showPreview = { true }
217231 credentialId = { credential }
218232 projectId = { ( projectIdValue as string ) || '' }
@@ -242,7 +256,7 @@ export function FileSelectorInput({
242256 requiredScopes = { subBlock . requiredScopes || [ ] }
243257 serviceId = { subBlock . serviceId }
244258 label = { subBlock . placeholder || 'Select Microsoft Excel file' }
245- disabled = { finalDisabled }
259+ disabled = { finalDisabled || shouldForceDisable }
246260 showPreview = { true }
247261 workflowId = { activeWorkflowId || '' }
248262 credentialId = { credential }
@@ -272,7 +286,7 @@ export function FileSelectorInput({
272286 requiredScopes = { subBlock . requiredScopes || [ ] }
273287 serviceId = { subBlock . serviceId }
274288 label = { subBlock . placeholder || 'Select Microsoft Word document' }
275- disabled = { finalDisabled }
289+ disabled = { finalDisabled || shouldForceDisable }
276290 showPreview = { true }
277291 />
278292 </ div >
@@ -300,7 +314,7 @@ export function FileSelectorInput({
300314 serviceId = { subBlock . serviceId }
301315 mimeType = { subBlock . mimeType }
302316 label = { subBlock . placeholder || 'Select OneDrive folder' }
303- disabled = { finalDisabled }
317+ disabled = { finalDisabled || shouldForceDisable }
304318 showPreview = { true }
305319 workflowId = { activeWorkflowId || '' }
306320 credentialId = { credential }
@@ -330,7 +344,7 @@ export function FileSelectorInput({
330344 requiredScopes = { subBlock . requiredScopes || [ ] }
331345 serviceId = { subBlock . serviceId }
332346 label = { subBlock . placeholder || 'Select SharePoint site' }
333- disabled = { finalDisabled }
347+ disabled = { finalDisabled || shouldForceDisable }
334348 showPreview = { true }
335349 workflowId = { activeWorkflowId || '' }
336350 credentialId = { credential }
@@ -366,7 +380,7 @@ export function FileSelectorInput({
366380 requiredScopes = { subBlock . requiredScopes || [ ] }
367381 serviceId = 'microsoft-planner'
368382 label = { subBlock . placeholder || 'Select task' }
369- disabled = { finalDisabled }
383+ disabled = { finalDisabled || shouldForceDisable }
370384 showPreview = { true }
371385 planId = { planId }
372386 workflowId = { activeWorkflowId || '' }
@@ -424,7 +438,7 @@ export function FileSelectorInput({
424438 requiredScopes = { subBlock . requiredScopes || [ ] }
425439 serviceId = { subBlock . serviceId }
426440 label = { subBlock . placeholder || 'Select Teams message location' }
427- disabled = { finalDisabled }
441+ disabled = { finalDisabled || shouldForceDisable }
428442 showPreview = { true }
429443 credential = { credential }
430444 selectionType = { selectionType }
@@ -467,7 +481,7 @@ export function FileSelectorInput({
467481 requiredScopes = { subBlock . requiredScopes || [ ] }
468482 serviceId = { subBlock . serviceId }
469483 label = { subBlock . placeholder || `Select ${ itemType } ` }
470- disabled = { finalDisabled }
484+ disabled = { finalDisabled || shouldForceDisable }
471485 showPreview = { true }
472486 credentialId = { credential }
473487 itemType = { itemType }
@@ -508,7 +522,7 @@ export function FileSelectorInput({
508522 provider = { provider }
509523 requiredScopes = { subBlock . requiredScopes || [ ] }
510524 label = { subBlock . placeholder || 'Select file' }
511- disabled = { finalDisabled }
525+ disabled = { finalDisabled || shouldForceDisable }
512526 serviceId = { subBlock . serviceId }
513527 mimeTypeFilter = { subBlock . mimeType }
514528 showPreview = { true }
0 commit comments