refactor: rename sandbox_iframe directory to mcp_apps_inner_iframe#988
refactor: rename sandbox_iframe directory to mcp_apps_inner_iframe#988sugoi-yuzuru merged 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request renames the sandbox_iframe directory and all associated file paths and references to mcp_apps_inner_iframe across the Angular and Lit client applications. The changes include updates to .gitignore, package.json build scripts, URL construction in mcp-app.ts, shared constants in shared-constants.ts, and an alias in vite.config.ts. Feedback suggests improving URL construction in mcp-app.ts for robustness and readability, addressing naming inconsistencies by fully refactoring constants and filenames to align with the new directory name, and making the node_modules path in vite.config.ts more robust by avoiding hardcoding.
| let sandboxUrl = `${currentOrigin}/mcp_apps_inner_iframe/sandbox.html`; | ||
| if (disableSecuritySelfTest) { | ||
| sandboxUrl += '?disable_security_self_test=true'; | ||
| } |
There was a problem hiding this comment.
To make the URL construction more robust and readable, you could use the URL and URLSearchParams APIs. This avoids manual string concatenation for query parameters and handles encoding correctly.
const url = new URL(`${currentOrigin}/mcp_apps_inner_iframe/sandbox.html`);
if (disableSecuritySelfTest) {
url.searchParams.set('disable_security_self_test', 'true');
}
const sandboxUrl = url.toString();| export const SANDBOX_BASE_PATH = "shared/mcp_apps_inner_iframe/"; | ||
| export const SANDBOX_ENTRY_NAME = `${SANDBOX_BASE_PATH}sandbox`; | ||
| export const SANDBOX_IFRAME_PATH = `/${SANDBOX_ENTRY_NAME}.html`; |
There was a problem hiding this comment.
While the directory has been renamed to mcp_apps_inner_iframe, these constants and the files they point to (sandbox.ts, sandbox.html) still use the SANDBOX name. This creates some inconsistency. For a more complete refactoring, consider renaming the files and these constants to align with the new directory name. For example, SANDBOX_BASE_PATH could become MCP_APPS_INNER_IFRAME_BASE_PATH. This would improve clarity and consistency across the codebase. Note that this would require updating all usages of these constants and filenames.
| alias: { | ||
| "@a2ui/markdown-it": resolve(__dirname, "../../../../renderers/markdown/markdown-it/dist/src/markdown.js"), | ||
| "sandbox.js": resolve(__dirname, "../../" + SANDBOX_ENTRY_NAME + ".ts"), | ||
| "@modelcontextprotocol/ext-apps/app-bridge": resolve(__dirname, "../node_modules/@modelcontextprotocol/ext-apps/dist/src/app-bridge.js"), |
There was a problem hiding this comment.
This hardcoded relative path to node_modules can be brittle. If dependencies are hoisted to a root node_modules directory (common in monorepos) or the project structure changes, this path will break. A more robust approach would be to use a resolution algorithm to find the package path programmatically. For example, you could use a library like resolve for this purpose.
Description
Rename
sandbox_iframetomcp_apps_inner_iframePre-launch Checklist
If you need help, consider asking for advice on the discussion board.