@@ -22,6 +22,7 @@ import { createMcpToolId } from '@/lib/mcp/shared'
2222import type { Credential } from '@/lib/oauth'
2323import {
2424 executeSelectorRequest ,
25+ type LoadedSelectorOptions ,
2526 loadAllSelectorOptions ,
2627} from '@/lib/selectors/client/execute-selector'
2728import { projectSelectorContext } from '@/lib/selectors/context'
@@ -58,6 +59,11 @@ export interface WorkflowSearchResolvedResource {
5859 inaccessible : boolean
5960}
6061
62+ export interface WorkflowSearchSelectorReplacementOptions {
63+ items : WorkflowSearchReplacementOption [ ]
64+ truncated : boolean
65+ }
66+
6167export const workflowSearchReplaceKeys = {
6268 all : selectorQueryRoots . workflowSearchReplace ,
6369 resourceDetails : ( ) => [ ...workflowSearchReplaceKeys . all , 'resource-detail' ] as const ,
@@ -476,7 +482,11 @@ export function useWorkflowSearchSelectorDetails(matches: WorkflowSearchMatch[])
476482
477483 return {
478484 queryKey : workflowSearchReplaceKeys . selectorDetail ( selectorKey , ordinal , revision ) ,
479- queryFn : async ( { signal } : { signal : AbortSignal } ) : Promise < SelectorOption | null > => {
485+ queryFn : async ( {
486+ signal,
487+ } : {
488+ signal : AbortSignal
489+ } ) : Promise < { option : SelectorOption | null ; truncated : boolean } > => {
480490 if ( manifest . supportsDetail ) {
481491 const result = await executeSelectorRequest ( {
482492 selectorKey,
@@ -485,16 +495,22 @@ export function useWorkflowSearchSelectorDetails(matches: WorkflowSearchMatch[])
485495 request : { kind : 'detail' , id : match . rawValue } ,
486496 signal,
487497 } )
488- return result . kind === 'detail' ? result . item : null
498+ return {
499+ option : result . kind === 'detail' ? result . item : null ,
500+ truncated : false ,
501+ }
489502 }
490503
491- const options = await loadAllSelectorOptions ( {
504+ const catalog = await loadAllSelectorOptions ( {
492505 selectorKey,
493506 scope,
494507 context,
495508 signal,
496509 } )
497- return options . find ( ( option ) => option . id === match . rawValue ) ?? null
510+ return {
511+ option : catalog . items . find ( ( option ) => option . id === match . rawValue ) ?? null ,
512+ truncated : catalog . truncated ,
513+ }
498514 } ,
499515 enabled : Boolean (
500516 selectorKey &&
@@ -503,13 +519,16 @@ export function useWorkflowSearchSelectorDetails(matches: WorkflowSearchMatch[])
503519 ( manifest . classification === 'local' || scope )
504520 ) ,
505521 staleTime : manifest . staleTime ?? WORKFLOW_SEARCH_SELECTOR_DETAIL_STALE_TIME ,
506- select : ( option : SelectorOption | null ) : WorkflowSearchResolvedResource => ( {
507- matchRawValue : match . rawValue ,
508- resourceGroupKey : match . resource ?. resourceGroupKey ,
509- label : option ?. label ?? match . rawValue ,
510- resolved : Boolean ( option ) ,
511- inaccessible : false ,
512- } ) ,
522+ select : ( { option, truncated } ) : WorkflowSearchResolvedResource => {
523+ const unresolvedIncompleteCatalog = ! option && truncated
524+ return {
525+ matchRawValue : match . rawValue ,
526+ resourceGroupKey : match . resource ?. resourceGroupKey ,
527+ label : option ?. label ?? match . rawValue ,
528+ resolved : Boolean ( option ) ,
529+ inaccessible : unresolvedIncompleteCatalog ,
530+ }
531+ } ,
513532 }
514533 } ) ,
515534 } )
@@ -773,15 +792,20 @@ export function useWorkflowSearchSelectorReplacementOptions(matches: WorkflowSea
773792 selectorKey && baseEnabled && ( manifest . classification === 'local' || scope )
774793 ) ,
775794 staleTime : manifest . staleTime ?? WORKFLOW_SEARCH_SELECTOR_REPLACEMENT_STALE_TIME ,
776- select : ( options : SelectorOption [ ] ) : WorkflowSearchReplacementOption [ ] =>
777- options . map ( ( option ) => ( {
795+ select : ( {
796+ items,
797+ truncated,
798+ } : LoadedSelectorOptions ) : WorkflowSearchSelectorReplacementOptions => ( {
799+ items : items . map ( ( option ) => ( {
778800 kind : match . kind ,
779801 value : option . id ,
780802 label : option . label ,
781803 selectorKey,
782804 selectorContext : context ,
783805 resourceGroupKey : match . resource ?. resourceGroupKey ,
784806 } ) ) ,
807+ truncated,
808+ } ) ,
785809 }
786810 } ) ,
787811 } )
0 commit comments