@@ -19,7 +19,8 @@ import {
1919  DEFAULT_SYSTEM_MESSAGES_URL , 
2020}  from  "core/llm/defaultSystemMessages" ; 
2121import  {  getRuleDisplayName  }  from  "core/llm/rules/rules-utils" ; 
22- import  {  useContext ,  useMemo  }  from  "react" ; 
22+ import  {  useContext ,  useMemo ,  useState  }  from  "react" ; 
23+ import  {  DropdownButton  }  from  "../../../components/DropdownButton" ; 
2324import  HeaderButtonWithToolTip  from  "../../../components/gui/HeaderButtonWithToolTip" ; 
2425import  Switch  from  "../../../components/gui/Switch" ; 
2526import  {  useEditBlock  }  from  "../../../components/mainInput/Lump/useEditBlock" ; 
@@ -173,8 +174,8 @@ const RuleCard: React.FC<RuleCardProps> = ({ rule }) => {
173174    ) ; 
174175  } 
175176
176-   const  smallFont  =  useFontSize ( - 2 ) ; 
177-   const  tinyFont  =  useFontSize ( - 3 ) ; 
177+   const  smallFont  =  fontSize ( - 2 ) ; 
178+   const  tinyFont  =  fontSize ( - 3 ) ; 
178179  return  ( 
179180    < div 
180181      className = { `border-border flex flex-col rounded-sm px-2 py-1.5 transition-colors ${ isDisabled  ? "opacity-50"  : "" }  } 
@@ -386,18 +387,30 @@ function addDefaultSystemMessage(
386387  } 
387388} 
388389
390+ // Define dropdown options for global rules 
391+ const  globalRulesOptions  =  [ 
392+   {  value : "workspace" ,  label : "Current workspace"  } , 
393+   {  value : "global" ,  label : "Global"  } , 
394+ ] ; 
395+ 
389396function  RulesSubSection ( )  { 
390397  const  {  selectedProfile }  =  useAuth ( ) ; 
391398  const  config  =  useAppSelector ( ( store )  =>  store . config . config ) ; 
392399  const  mode  =  useAppSelector ( ( store )  =>  store . session . mode ) ; 
393400  const  ideMessenger  =  useContext ( IdeMessengerContext ) ; 
394401  const  isLocal  =  selectedProfile ?. profileType  ===  "local" ; 
402+   const  [ globalRulesMode ,  setGlobalRulesMode ]  =  useState < string > ( "workspace" ) ; 
395403
396-   const  handleAddRule  =  ( )  =>  { 
404+   const  handleAddRule  =  ( mode ?: string )  =>  { 
405+     const  currentMode  =  mode  ||  globalRulesMode ; 
397406    if  ( isLocal )  { 
398-       void  ideMessenger . request ( "config/addLocalWorkspaceBlock" ,  { 
399-         blockType : "rules" , 
400-       } ) ; 
407+       if  ( currentMode  ===  "global" )  { 
408+         void  ideMessenger . request ( "config/addGlobalRule" ,  undefined ) ; 
409+       }  else  { 
410+         void  ideMessenger . request ( "config/addLocalWorkspaceBlock" ,  { 
411+           blockType : "rules" , 
412+         } ) ; 
413+       } 
401414    }  else  { 
402415      void  ideMessenger . request ( "controlPlane/openUrl" ,  { 
403416        path : "?type=rules" , 
@@ -406,6 +419,11 @@ function RulesSubSection() {
406419    } 
407420  } ; 
408421
422+   const  handleOptionClick  =  ( value : string )  =>  { 
423+     setGlobalRulesMode ( value ) ; 
424+     handleAddRule ( value ) ; 
425+   } ; 
426+ 
409427  const  sortedRules : RuleWithSource [ ]  =  useMemo ( ( )  =>  { 
410428    const  rules  =  [ ...config . rules . map ( ( rule )  =>  ( {  ...rule  } ) ) ] ; 
411429
@@ -448,12 +466,22 @@ function RulesSubSection() {
448466
449467  return  ( 
450468    < div > 
451-       < ConfigHeader 
452-         title = "Rules" 
453-         variant = "sm" 
454-         onAddClick = { handleAddRule } 
455-         addButtonTooltip = "Add rule" 
456-       /> 
469+       { isLocal  ? ( 
470+         < DropdownButton 
471+           title = "Rules" 
472+           variant = "sm" 
473+           options = { globalRulesOptions } 
474+           onOptionClick = { handleOptionClick } 
475+           addButtonTooltip = "Add rules" 
476+         /> 
477+       )  : ( 
478+         < ConfigHeader 
479+           title = "Rules" 
480+           variant = "sm" 
481+           onAddClick = { ( )  =>  handleAddRule ( ) } 
482+           addButtonTooltip = "Add rules" 
483+         /> 
484+       ) } 
457485
458486      < Card > 
459487        { sortedRules . length  >  0  ? ( 
0 commit comments