@@ -387,6 +387,11 @@ export async function registerSlackMonitorSlashCommands(params: {
387387 const slashCommand = resolveSlackSlashCommandConfig (
388388 ctx . slashCommand ?? account . config . slashCommand ,
389389 ) ;
390+ // App Home and argument handlers must share the registered command mode;
391+ // explicit single-command mode also avoids loading inactive native runtimes.
392+ let registration : SlackCommandRegistration = slashCommand . enabled
393+ ? { mode : "single" , name : slashCommand . name }
394+ : { mode : "disabled" } ;
390395
391396 const handleSlashCommand = async ( p : {
392397 command : SlackCommandMiddlewareArgs [ "command" ] ;
@@ -872,22 +877,22 @@ export async function registerSlackMonitorSlashCommands(params: {
872877 }
873878 } ;
874879
875- const nativeEnabled = resolveNativeCommandsEnabled ( {
876- providerId : "slack" ,
877- providerSetting : account . config . commands ?. native ,
878- globalSetting : startupCfg . commands ?. native ,
879- } ) ;
880- const nativeSkillsEnabled = resolveNativeSkillsEnabled ( {
881- providerId : "slack" ,
882- providerSetting : account . config . commands ?. nativeSkills ,
883- globalSetting : startupCfg . commands ?. nativeSkills ,
884- } ) ;
885-
886880 let nativeCommands : Array < { name : string } > = [ ] ;
887881 let slashCommandsRuntime : typeof import ( "./slash-commands.runtime.js" ) | null = null ;
888- if ( nativeEnabled ) {
882+ if (
883+ registration . mode === "disabled" &&
884+ resolveNativeCommandsEnabled ( {
885+ providerId : "slack" ,
886+ providerSetting : account . config . commands ?. native ,
887+ globalSetting : startupCfg . commands ?. native ,
888+ } )
889+ ) {
889890 slashCommandsRuntime = await loadSlashCommandsRuntime ( ) ;
890- const skillCommands = nativeSkillsEnabled
891+ const skillCommands = resolveNativeSkillsEnabled ( {
892+ providerId : "slack" ,
893+ providerSetting : account . config . commands ?. nativeSkills ,
894+ globalSetting : startupCfg . commands ?. nativeSkills ,
895+ } )
891896 ? ( await loadSlashSkillCommandsRuntime ( ) ) . listSkillCommandsForAgents ( { cfg : startupCfg } )
892897 : [ ] ;
893898 nativeCommands = slashCommandsRuntime . listNativeCommandSpecsForConfig ( startupCfg , {
@@ -906,11 +911,12 @@ export async function registerSlackMonitorSlashCommands(params: {
906911 existingNativeNames . add ( normalizedName ) ;
907912 nativeCommands . push ( pluginCommand ) ;
908913 }
914+ registration = nativeCommands . length > 0 ? { mode : "native" } : { mode : "disabled" } ;
909915 }
910916
911- if ( slashCommand . enabled ) {
917+ if ( registration . mode === "single" ) {
912918 ctx . app . command (
913- buildSlackSlashCommandMatcher ( slashCommand . name ) ,
919+ buildSlackSlashCommandMatcher ( registration . name ) ,
914920 async ( { command, ack, respond, body } : SlackCommandMiddlewareArgs ) => {
915921 await handleSlashCommand ( {
916922 command,
@@ -921,7 +927,7 @@ export async function registerSlackMonitorSlashCommands(params: {
921927 } ) ;
922928 } ,
923929 ) ;
924- } else if ( nativeCommands . length > 0 ) {
930+ } else if ( registration . mode === "native" ) {
925931 if ( ! slashCommandsRuntime ) {
926932 throw new Error ( "Missing commands runtime for native Slack commands." ) ;
927933 }
@@ -960,14 +966,7 @@ export async function registerSlackMonitorSlashCommands(params: {
960966 logVerbose ( "slack: slash commands disabled" ) ;
961967 }
962968
963- const registration : SlackCommandRegistration =
964- nativeCommands . length > 0
965- ? { mode : "native" }
966- : slashCommand . enabled
967- ? { mode : "single" , name : slashCommand . name }
968- : { mode : "disabled" } ;
969-
970- if ( nativeCommands . length === 0 || ! supportsInteractiveArgMenus ) {
969+ if ( registration . mode !== "native" || ! supportsInteractiveArgMenus ) {
971970 return registration ;
972971 }
973972
0 commit comments