702fafc1 by Ean Schuessler

Enhance screen rendering with CustomScreenTestImpl and improved WebFacadeStub

- Add CustomScreenTestImpl for better screen path handling
- Fix WebFacadeStub to use actual screenPath instead of hardcoded '/test'
- Improve screen discovery and execution in McpServices
- Support standalone screens and proper root screen detection
- Add timeout protection for screen rendering
1 parent 5618521e
...@@ -33,6 +33,7 @@ class WebFacadeStub implements WebFacade { ...@@ -33,6 +33,7 @@ class WebFacadeStub implements WebFacade {
33 protected final Map<String, Object> parameters 33 protected final Map<String, Object> parameters
34 protected final Map<String, Object> sessionAttributes 34 protected final Map<String, Object> sessionAttributes
35 protected final String requestMethod 35 protected final String requestMethod
36 protected final String screenPath
36 37
37 protected HttpServletRequest httpServletRequest 38 protected HttpServletRequest httpServletRequest
38 protected HttpServletResponse httpServletResponse 39 protected HttpServletResponse httpServletResponse
...@@ -54,11 +55,12 @@ class WebFacadeStub implements WebFacade { ...@@ -54,11 +55,12 @@ class WebFacadeStub implements WebFacade {
54 boolean skipJsonSerialize = false 55 boolean skipJsonSerialize = false
55 56
56 WebFacadeStub(ExecutionContextFactoryImpl ecfi, Map<String, Object> parameters, 57 WebFacadeStub(ExecutionContextFactoryImpl ecfi, Map<String, Object> parameters,
57 Map<String, Object> sessionAttributes, String requestMethod) { 58 Map<String, Object> sessionAttributes, String requestMethod, String screenPath = null) {
58 this.ecfi = ecfi 59 this.ecfi = ecfi
59 this.parameters = parameters ?: [:] 60 this.parameters = parameters ?: [:]
60 this.sessionAttributes = sessionAttributes ?: [:] 61 this.sessionAttributes = sessionAttributes ?: [:]
61 this.requestMethod = requestMethod ?: "GET" 62 this.requestMethod = requestMethod ?: "GET"
63 this.screenPath = screenPath
62 64
63 // Create mock HTTP objects 65 // Create mock HTTP objects
64 createMockHttpObjects() 66 createMockHttpObjects()
...@@ -111,11 +113,23 @@ class WebFacadeStub implements WebFacade { ...@@ -111,11 +113,23 @@ class WebFacadeStub implements WebFacade {
111 } 113 }
112 114
113 @Override 115 @Override
114 String getPathInfo() { return "/test" } 116 String getPathInfo() {
117 // For standalone screens, return empty path to render the screen itself
118 // For screens with subscreen paths, return the relative path
119 return screenPath ? "/${screenPath}" : ""
120 }
115 121
116 @Override 122 @Override
117 ArrayList<String> getPathInfoList() { 123 ArrayList<String> getPathInfoList() {
118 return new ArrayList<String>(["test"]) 124 // IMPORTANT: Don't delegate to WebFacadeImpl - it expects real HTTP servlet context
125 // Return mock path info for MCP screen rendering based on actual screen path
126 def pathInfo = getPathInfo()
127 if (pathInfo && pathInfo.startsWith("/")) {
128 // Split path and filter out empty parts
129 def pathParts = pathInfo.substring(1).split("/") as List
130 return new ArrayList<String>(pathParts.findAll { it && it.toString().length() > 0 })
131 }
132 return new ArrayList<String>() // Empty for standalone screens
119 } 133 }
120 134
121 @Override 135 @Override
......