@@ -17,6 +17,7 @@ describe('reloadPluginsRuntime', () => {
1717 const refreshTools = vi . fn ( ) ;
1818 const reloadCommands = vi . fn ( ) ;
1919 const config = {
20+ isSafeMode : ( ) => false ,
2021 getExtensionManager : ( ) => ( {
2122 refreshCache,
2223 refreshTools,
@@ -63,6 +64,27 @@ describe('reloadPluginsRuntime', () => {
6364 lspServerCount : 1 ,
6465 } ) ;
6566 } ) ;
67+
68+ it ( 'rejects without refreshing extensions in safe mode' , async ( ) => {
69+ const refreshCache = vi . fn ( ) ;
70+ const refreshTools = vi . fn ( ) ;
71+ const reloadCommands = vi . fn ( ) ;
72+ const config = {
73+ isSafeMode : ( ) => true ,
74+ getExtensionManager : ( ) => ( {
75+ refreshCache,
76+ refreshTools,
77+ } ) ,
78+ } as unknown as Config ;
79+
80+ await expect (
81+ reloadPluginsRuntime ( { config, reloadCommands } ) ,
82+ ) . rejects . toThrow ( 'Extension reload is disabled in safe mode.' ) ;
83+
84+ expect ( refreshCache ) . not . toHaveBeenCalled ( ) ;
85+ expect ( refreshTools ) . not . toHaveBeenCalled ( ) ;
86+ expect ( reloadCommands ) . not . toHaveBeenCalled ( ) ;
87+ } ) ;
6688} ) ;
6789
6890describe ( 'refreshExtensionContentRuntime' , ( ) => {
@@ -72,6 +94,7 @@ describe('refreshExtensionContentRuntime', () => {
7294 const refreshSubagentCache = vi . fn ( ) ;
7395 const reloadCommands = vi . fn ( ) ;
7496 const config = {
97+ isSafeMode : ( ) => false ,
7598 getExtensionManager : ( ) => ( { refreshCache } ) ,
7699 getSkillManager : ( ) => ( { refreshCache : refreshSkillCache } ) ,
77100 getSubagentManager : ( ) => ( { refreshCache : refreshSubagentCache } ) ,
@@ -93,6 +116,7 @@ describe('refreshExtensionContentRuntime', () => {
93116 const refreshSubagentCache = vi . fn ( ) ;
94117 const reloadCommands = vi . fn ( ) ;
95118 const config = {
119+ isSafeMode : ( ) => false ,
96120 getExtensionManager : ( ) => ( { refreshCache } ) ,
97121 getSkillManager : ( ) => ( { refreshCache : refreshSkillCache } ) ,
98122 getSubagentManager : ( ) => ( { refreshCache : refreshSubagentCache } ) ,
@@ -113,6 +137,7 @@ describe('refreshExtensionContentRuntime', () => {
113137 const refreshSkillCache = vi . fn ( ) ;
114138 const reloadCommands = vi . fn ( ) ;
115139 const config = {
140+ isSafeMode : ( ) => false ,
116141 getExtensionManager : ( ) => ( { refreshCache } ) ,
117142 getSkillManager : ( ) => ( { refreshCache : refreshSkillCache } ) ,
118143 getSubagentManager : ( ) => undefined ,
@@ -126,4 +151,20 @@ describe('refreshExtensionContentRuntime', () => {
126151 expect ( refreshSkillCache ) . toHaveBeenCalledOnce ( ) ;
127152 expect ( reloadCommands ) . toHaveBeenCalledOnce ( ) ;
128153 } ) ;
154+
155+ it ( 'skips content refresh in safe mode' , async ( ) => {
156+ const refreshCache = vi . fn ( ) ;
157+ const reloadCommands = vi . fn ( ) ;
158+ const config = {
159+ isSafeMode : ( ) => true ,
160+ getExtensionManager : ( ) => ( { refreshCache } ) ,
161+ } as unknown as Config ;
162+
163+ await expect (
164+ refreshExtensionContentRuntime ( { config, reloadCommands } ) ,
165+ ) . resolves . toBeUndefined ( ) ;
166+
167+ expect ( refreshCache ) . not . toHaveBeenCalled ( ) ;
168+ expect ( reloadCommands ) . not . toHaveBeenCalled ( ) ;
169+ } ) ;
129170} ) ;
0 commit comments