@@ -36,7 +36,8 @@ const view = {
3636 toolName : "show" ,
3737 uiResourceUri : "ui://demo/app" ,
3838 html : "<html>demo</html>" ,
39- allowedAppToolNames : undefined as ReadonlySet < string > | undefined ,
39+ allowedAppToolNames : new Set ( [ "shared" , "app-only" ] ) as ReadonlySet < string > | undefined ,
40+ readOnly : undefined as boolean | undefined ,
4041 toolInput : { city : "Paris" } ,
4142 toolResult : { content : [ { type : "text" , text : "ok" } ] } ,
4243 expiresAtMs : Date . now ( ) + 60_000 ,
@@ -108,7 +109,8 @@ describe("MCP App gateway bridge", () => {
108109 view . requestCount = 0 ;
109110 view . toolCallCount = 0 ;
110111 view . activeRequests = 0 ;
111- view . allowedAppToolNames = undefined ;
112+ view . allowedAppToolNames = new Set ( [ "shared" , "app-only" ] ) ;
113+ view . readOnly = undefined ;
112114 mocks . getMcpAppViewLease . mockReset ( ) . mockReturnValue ( view ) ;
113115 mocks . completeDeferredSessionMcpRuntimeRetirement . mockReset ( ) . mockResolvedValue ( false ) ;
114116 mocks . peekSessionMcpRuntime . mockReset ( ) . mockReturnValue ( runtime ( ) ) ;
@@ -135,6 +137,7 @@ describe("MCP App gateway bridge", () => {
135137 toolInput : { city : "Paris" } ,
136138 standaloneUrl : "/__openclaw__/mcp-app#ticket" ,
137139 standaloneExpiresAtMs : 1_800_000_120_000 ,
140+ messageSupported : true ,
138141 } ) ,
139142 ) ;
140143 expect ( mocks . getMcpAppViewLease ) . toHaveBeenCalledWith ( "cv_app" , expect . any ( Object ) ) ;
@@ -178,6 +181,26 @@ describe("MCP App gateway bridge", () => {
178181 } ) ;
179182 } ) ;
180183
184+ it ( "keeps message support disabled without fresh run authority" , async ( ) => {
185+ view . allowedAppToolNames = undefined ;
186+ const respond = await invoke ( "mcp.app.view" , {
187+ sessionKey : "agent:main:main" ,
188+ viewId : "cv_app" ,
189+ } ) ;
190+
191+ expect ( respond . mock . calls [ 0 ] ?. [ 1 ] ) . toMatchObject ( { messageSupported : false } ) ;
192+ } ) ;
193+
194+ it ( "supports messages for a fresh view with no app-callable tools" , async ( ) => {
195+ view . allowedAppToolNames = new Set ( ) ;
196+ const respond = await invoke ( "mcp.app.view" , {
197+ sessionKey : "agent:main:main" ,
198+ viewId : "cv_app" ,
199+ } ) ;
200+
201+ expect ( respond . mock . calls [ 0 ] ?. [ 1 ] ) . toMatchObject ( { messageSupported : true } ) ;
202+ } ) ;
203+
181204 it ( "filters model-only tools from app discovery and execution" , async ( ) => {
182205 const params = { sessionKey : "agent:main:main" , viewId : "cv_app" } ;
183206 const listed = await invoke ( "mcp.app.listTools" , params ) ;
@@ -233,7 +256,12 @@ describe("MCP App gateway bridge", () => {
233256
234257 it ( "restores a transcript-backed view after a Gateway restart" , async ( ) => {
235258 const restoredRuntime = runtime ( ) ;
236- const restoredView = { ...view , runtime : restoredRuntime , allowedAppToolNames : new Set ( ) } ;
259+ const restoredView = {
260+ ...view ,
261+ runtime : restoredRuntime ,
262+ allowedAppToolNames : new Set ( ) ,
263+ readOnly : true ,
264+ } ;
237265 mocks . peekSessionMcpRuntime . mockReturnValue ( undefined ) ;
238266 mocks . restoreMcpAppView . mockResolvedValue ( {
239267 runtime : restoredRuntime ,
@@ -246,6 +274,9 @@ describe("MCP App gateway bridge", () => {
246274 } ) ;
247275
248276 expect ( respond . mock . calls [ 0 ] ?. [ 0 ] ) . toBe ( true ) ;
249- expect ( respond . mock . calls [ 0 ] ?. [ 1 ] ) . toMatchObject ( { html : "<html>demo</html>" } ) ;
277+ expect ( respond . mock . calls [ 0 ] ?. [ 1 ] ) . toMatchObject ( {
278+ html : "<html>demo</html>" ,
279+ messageSupported : false ,
280+ } ) ;
250281 } ) ;
251282} ) ;
0 commit comments