@@ -690,15 +690,17 @@ global.prepFlags = (flagsOptions: FlagsObject): FlagsObject => {
690690 if ( key === 'order' ) continue
691691 if ( key === 'sortChoicesKey' ) continue
692692
693+ // Strip non-serializable functions before sending to avoid IPC serialization issues
694+ const { onAction, condition, preview, ...rest } = value ?? { }
693695 let validFlag = {
694- ...value ,
696+ ...rest ,
695697 name : value ?. name || key ,
696698 shortcut : value ?. shortcut || '' ,
697699 description : value ?. description || '' ,
698700 value : key ,
699701 bar : value ?. bar || '' ,
700- preview : value ?. preview || '' ,
701- hasAction : Boolean ( value ?. onAction )
702+ preview : typeof preview === 'string' ? preview : '' ,
703+ hasAction : Boolean ( onAction )
702704 }
703705 validFlags [ key ] = validFlag
704706
@@ -724,7 +726,13 @@ global.prepFlags = (flagsOptions: FlagsObject): FlagsObject => {
724726 choice . group = value . group
725727 }
726728
727- global . __kitActionsMap . set ( value ?. name || key , choice )
729+ // Use the flag key (not the display name) as the map key, since that's what the UI sends back
730+ global . __kitActionsMap . set ( key , choice )
731+ // console.log(`[SDK] Storing action in map with key: ${key}`, {
732+ // name: choice.name,
733+ // onAction: typeof value?.onAction,
734+ // shortcut: choice.shortcut
735+ // })
728736 }
729737
730738 return validFlags
@@ -740,6 +748,15 @@ global.setFlags = async (flags: FlagsObject, options = {}) => {
740748 }
741749 }
742750 // TODO: Move props from FlagsObject like "order", "sortChoicesKey" to the options
751+ // console.log(`[SDK] Sending flags to app:`, {
752+ // flagKeys: Object.keys(flagsMessage.flags),
753+ // flagsWithHasAction: Object.entries(flagsMessage.flags).map(([k, v]) => ({
754+ // key: k,
755+ // name: (v as any).name,
756+ // hasAction: (v as any).hasAction,
757+ // shortcut: (v as any).shortcut
758+ // }))
759+ // })
743760 await global . sendWait ( Channel . SET_FLAGS , flagsMessage )
744761}
745762
@@ -1049,7 +1066,8 @@ export let actions: Action[] = [
10491066 description : 'Search for a script by contents' ,
10501067 shortcut : `${ cmd } +f` ,
10511068 onAction : async ( ) => {
1052- global . setFlags ( { } )
1069+ // Don't clear all flags - preserve existing action flags
1070+ // global.setFlags({})
10531071 await run ( kitPath ( 'cli' , 'find.js' ) )
10541072 } ,
10551073 group : 'Script Actions'
0 commit comments