refactor(core): remove no-confusing-void-expression suppressions#174
refactor(core): remove no-confusing-void-expression suppressions#174gabrypavanello wants to merge 6 commits intomainfrom
Conversation
…SK-037-02) Replace all raw console.log/warn/error calls across 17 inspector/src files with scoped logger instances using createLogger(). Each module gets a descriptive source name for log filtering. - 17 files migrated to structured logger - Stale eslint-disable no-console comments removed - Tests updated to match new console.info output format - bin/mcp-inspector.ts and widget-server-templates.ts untouched - proxy-resources.ts skipped (console call is in client-side template)
…efineMiddleware Remove 3 eslint-disable comments for @typescript-eslint/no-confusing-void-expression in defineMiddleware.ts. The next() function returns Promise<void>, so capturing or returning the void result was unnecessary. Now we simply await next() without capturing the result. Kaizen: daily tech debt reduction
📝 WalkthroughSummary by CodeRabbitRelease Notes
WalkthroughThis PR introduces a centralized, level-gated logger utility with ISO timestamps and source prefixes across multiple packages, replacing direct console calls. A new logger module supports configurable log levels via MCP_APPS_LOG_LEVEL environment variable. Additionally, middleware implementations are simplified to await next() without capturing or returning the result. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Comment |
Code Review - PR #174: refactor(core): remove no-confusing-void-expression suppressionsSummaryThis PR does three things:
Positives
Issues and Suggestions1. Log level is resolved once at module load time (cold-read bug)createLogger calls resolveLevel() at call time, which reads process.env.MCP_APPS_LOG_LEVEL once and captures the result in a closure. Loggers created before the env var is set (e.g. at module-import time, before test setup changes the env) will use the wrong level. The test suite works around this with beforeEach restores, but it is fragile. Suggestion: Re-read the env var on every log call, or accept an explicit level option so callers can override. 2. Inline IIFE loggers in codegen, testing, and ui-react duplicate logicThree separate packages each copy-paste the same IIFE pattern. The comment says it mirrors inspector's createLogger and avoids cross-package dep, but this creates exactly the kind of drift the inspector logger was designed to prevent. If you change the level semantics or add a new level in logger.ts, these copies won't update. Options:
3. dual-server.ts import order breaks conventionImports after statements are hoisted by the JS engine so runtime behaviour is fine, but this violates the imports-at-top-of-file convention and may trigger lint. The const logger = createLogger('dual-server') declaration appears before the import block for createConnectTool etc. Move the imports above it. 4. Potential page.evaluate context bug in mcp-host.ts (HIGH PRIORITY)Several logger.info calls in mcp-host.ts appear to be inside multiline template strings or closures passed to Playwright's page.evaluate. The logger object is a Node-side closure -- it does not exist in the browser context and will throw ReferenceError at runtime if serialised into a page.evaluate call. Please verify: Are the logger.info calls at (e.g.) the ui/initialize response block and the display-mode-changed block inside page.evaluate(...) closures? If so, they must remain as console.log (which the browser has). 5. Same page.evaluate concern in session-renderer.ts (HIGH PRIORITY)The same issue applies to logger.info calls in deliverToolCallResponse, updateMcpGlobals, and updateOpenAIGlobals. These are inside await page.evaluate(...) blocks -- the Node-side logger instance will not be available in the serialised browser context. 6. preset-config.ts -- user-facing OAuth URL suppressed by log levelThe Open this URL in your browser to authorize prompt is now routed through logger.info, which means it will be suppressed if MCP_APPS_LOG_LEVEL=warn or higher -- silently breaking the OAuth flow. Consider keeping this as a direct console.log / stdout write outside the log-level system. 7. Minor: codegen logger has an unnecessary browser guardpackages/codegen is a Node-only build-time Vite plugin. The typeof process !== 'undefined' guard it copies from the inspector logger is unnecessary here. VerdictThe core fix (3 removed suppressions in defineMiddleware.ts) is correct and ready to merge. The logger infrastructure in inspector is a solid improvement, but items 4 and 5 are potential runtime bugs if the identified page.evaluate calls reference the Node-side logger. Those should be confirmed or fixed before merge. Items 1, 2, 3, and 6 are lower-priority follow-ups. Recommended action: Confirm items 4 and 5 are not inside page.evaluate closures (or fix them if they are), then merge. |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
packages/inspector/src/session/session-renderer.ts (1)
206-218:⚠️ Potential issue | 🔴 CriticalFix logger usage inside
page.evaluate(browser context).The
loggervariable is undefined in browser contexts wherepage.evaluateexecutes. Calls tologger.info()will throw a ReferenceError at runtime and break tool response handling and globals delivery. Useconsole.info()instead, which is available in all browser contexts.✅ Suggested fix (replace logger with console in page context)
- logger.info("[MCP Host] Sent ui/notifications/host-context-changed", ctx); + console.info("[MCP Host] Sent ui/notifications/host-context-changed", ctx); ... - logger.info("[OpenAI Host] Sent globals sync:", message.data); + console.info("[OpenAI Host] Sent globals sync:", message.data); ... - logger.info("[MCP Host] Tool response is not a valid object:", responseData); + console.info("[MCP Host] Tool response is not a valid object:", responseData); ... - logger.info("[MCP Host] Tool response missing valid name/toolName string:", responseData); + console.info("[MCP Host] Tool response missing valid name/toolName string:", responseData); ... - logger.info("[MCP Host] No pending calls for tool:", toolName); + console.info("[MCP Host] No pending calls for tool:", toolName); ... - logger.info("[MCP Host] Delivered synced tool response:", toolName, call.messageId); + console.info("[MCP Host] Delivered synced tool response:", toolName, call.messageId);Lines: 206-218, 250-256, 282-333
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/inspector/src/session/session-renderer.ts` around lines 206 - 218, Inside session-renderer.ts the page.evaluate callback uses the Node logger (logger.info) which is undefined in the browser context and will throw; locate the page.evaluate(...) call(s) that accept hostContext and replace any browser-side logger.* calls with the global console equivalents (e.g., logger.info -> console.info, logger.warn -> console.warn, logger.error -> console.error) so the iframe postMessage block (where iframe, message, and hostContext are used) and other evaluate callbacks use console instead of logger.packages/inspector/src/widget-session-manager.ts (1)
401-413:⚠️ Potential issue | 🔴 CriticalReplace
logger.info()calls withconsole.info()insidepage.evaluateblocks.
page.evaluate()runs in the browser context where the Node-sideloggeris undefined. These calls will throw ReferenceError at runtime, aborting host-context updates and event delivery. Useconsole.info()instead within the evaluated function.Suggested fix
- logger.info("[MCP Host] Sent ui/notifications/host-context-changed", ctx); + console.info("[MCP Host] Sent ui/notifications/host-context-changed", ctx); - logger.info("[OpenAI Host] Sent globals sync:", message.data); + console.info("[OpenAI Host] Sent globals sync:", message.data); - logger.info("[MCP Host] Stored hostContext update for ui/initialize:", p); + console.info("[MCP Host] Stored hostContext update for ui/initialize:", p); - logger.info("[MCP Host] Sent synced event:", m, p); + console.info("[MCP Host] Sent synced event:", m, p); - logger.info("[OpenAI Host] Sent synced event:", message.syncType, message.data); + console.info("[OpenAI Host] Sent synced event:", message.syncType, message.data);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/inspector/src/widget-session-manager.ts` around lines 401 - 413, Inside the page.evaluate block that posts the host-context message (the anonymous function passed to page.evaluate where you reference hostContext, iframe, iframe.contentWindow.postMessage and build the message with method "ui/notifications/host-context-changed"), replace any Node-side logger.* calls (e.g. logger.info) with browser-safe console.* calls (e.g. console.info) so they run in the page context without throwing ReferenceError; search for logger.info (and other logger usages) inside page.evaluate blocks in widget-session-manager.ts and change them to console.info (or console.warn/error as appropriate) while leaving the postMessage and message construction unchanged.packages/inspector/src/hosts/mcp-host.ts (1)
220-281:⚠️ Potential issue | 🔴 CriticalReplace logger with console in Playwright init script.
The
getPlaywrightInitScript()method returns code executed in the browser context wherelogger(a Node.js module) is undefined. The 4 logger.info() calls will throw ReferenceError and break message handling. Useconsole.info()instead.Fix all 4 occurrences
- logger.info('[MCP Host Emulator] Received ui/initialize, responding...'); + console.info('[MCP Host Emulator] Received ui/initialize, responding...'); ... - logger.info('[MCP Host Emulator] Sent ui/initialize response'); + console.info('[MCP Host Emulator] Sent ui/initialize response'); ... - logger.info('[MCP Host Emulator] Sending ui/notifications/tool-result...'); + console.info('[MCP Host Emulator] Sending ui/notifications/tool-result...'); ... - logger.info('[MCP Host Emulator] Display mode changed to:', requestedMode, 'sizing:', sizing); + console.info('[MCP Host Emulator] Display mode changed to:', requestedMode, 'sizing:', sizing);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/inspector/src/hosts/mcp-host.ts` around lines 220 - 281, The injected Playwright browser script generated by getPlaywrightInitScript() uses Node-only logger (logger.info) which is undefined in the browser; update the script to use console.info for all logger.info calls inside the generated code (the ui/initialize handling block, the delayed tool-result dispatch, and the display-mode handling messages) so the browser-side message handlers don't throw ReferenceError — search for logger.info within the string produced by getPlaywrightInitScript() and replace each occurrence with console.info.
🧹 Nitpick comments (4)
packages/core/src/middleware/defineMiddleware.ts (1)
185-187: Stale comment: result is no longer captured or returned.The comment mentions returning the result from
next()forMiddlewareChain<TResult>compatibility, but the code now awaits without capturing or returning. Consider updating or removing this comment to match the new behavior.📝 Suggested comment update
- // Note: We return the result from next() even though Middleware type says Promise<void>. - // This allows void-based middleware to work seamlessly with MiddlewareChain<TResult>. - // The type assertion is safe because JavaScript doesn't enforce return types at runtime. + // Note: We await next() without capturing or returning its result since Middleware + // returns Promise<void>. The withResult pattern should be used when result access is needed.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/core/src/middleware/defineMiddleware.ts` around lines 185 - 187, The comment in defineMiddleware.ts referencing "We return the result from next()" is stale because the implementation now awaits next() without capturing or returning its value; update or remove that comment to reflect current behavior (no result is captured/returned). Locate the comment near the MiddlewareChain<TResult> discussion in defineMiddleware (search for "Note: We return the result from next()" or references to MiddlewareChain<TResult> / next()) and either change the wording to explain that next() is awaited and its return value is not propagated, or delete the note entirely so the comment accurately matches the implementation.packages/inspector/src/widget-server.ts (1)
432-436: Minor: Redundant prefix in log output.Similar to other files, the logger already adds
[widget-server]prefix. The manual[WidgetServer]prefix creates slightly redundant output. Consider removing the manual prefix or using it only if the casing distinction serves a specific purpose.📝 Remove redundant prefix
private log(message: string): void { if (this.options.debug) { - logger.info(`[WidgetServer] ${message}`); + logger.info(message); } }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/inspector/src/widget-server.ts` around lines 432 - 436, The private log method in widget-server.ts currently prepends a manual “[WidgetServer]” prefix which is redundant because the global logger already adds a “[widget-server]” tag; update the log method (private log(message: string)) to stop adding the manual prefix and call logger.info with just the message when this.options.debug is true (i.e., replace logger.info(`[WidgetServer] ${message}`) with logger.info(message)), keeping the conditional on this.options.debug unchanged.packages/inspector/src/oauth/wellknown-proxy.ts (1)
81-85: Redundant prefix in log message.The logger already prefixes output with
[wellknown-proxy]viaformatPrefix(). The manual[oauth:wellknown-proxy]prefix creates redundant output like:
"2026-02-17T... [INFO] [wellknown-proxy] [oauth:wellknown-proxy] Upstream changed..."📝 Remove redundant prefix
function log(message: string): void { if (debug) { - logger.info(`[oauth:wellknown-proxy] ${message}`); + logger.info(message); } }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/inspector/src/oauth/wellknown-proxy.ts` around lines 81 - 85, The log function in wellknown-proxy.ts is adding a redundant manual prefix ("[oauth:wellknown-proxy]") even though logger.formatPrefix() already emits "[wellknown-proxy]"; update the log(message: string) implementation to stop prepending "[oauth:wellknown-proxy]" and instead call logger.info(message) (or include only the additional context beyond the existing prefix) so messages are not duplicated; modify any callers of log if they relied on that manual prefix to preserve clarity.packages/codegen/src/watcher.ts (1)
20-46: Consider consolidating logger utilities to avoid duplication.There’s already a
defaultLoggerinpackages/codegen/src/utils/logger.ts. To keep behavior consistent and avoid drift, consider moving this structured logger there and importing it here.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/codegen/src/watcher.ts` around lines 20 - 46, This file defines a duplicate structured logger (defaultLogger, PluginLogger) that should be consolidated with the existing logger in packages/codegen/src/utils/logger.ts; replace the in-file logger with an import from that module, remove the duplicated defaultLogger implementation, and ensure the watcher.ts uses the shared logger API (info, warn, error) so behavior remains identical and avoids drift.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/inspector/src/hosts/openai-host.ts`:
- Around line 248-249: In the Playwright init script template string the
browser-side call logger.info('[OpenAI Host] requestDisplayMode:', mode,
'sizing:', sizing) will throw because logger is undefined; update the template
to use console.info instead (replace logger.info(...) with console.info(...))
where the inline function/requestDisplayMode handler is defined in the
Playwright init template in openai-host.ts so the script runs in browser context
without ReferenceError.
In `@packages/ui-react/src/hooks.ts`:
- Around line 22-40: The build fails because TypeScript can't find the global
"process" symbol used in uiReactLogger (see envLevel and threshold calculation).
Fix by removing direct typed access to process: either add `@types/node` as a
devDependency and enable it via "types":["node"] in the ui-react tsconfig, or
(recommended) replace the direct reference to process.env with a type-safe
runtime accessor (e.g., read process via globalThis or a small helper that
checks typeof process !== "undefined" and returns process.env as any) and use
that helper in the envLevel computation inside uiReactLogger so TypeScript no
longer needs Node types.
---
Outside diff comments:
In `@packages/inspector/src/hosts/mcp-host.ts`:
- Around line 220-281: The injected Playwright browser script generated by
getPlaywrightInitScript() uses Node-only logger (logger.info) which is undefined
in the browser; update the script to use console.info for all logger.info calls
inside the generated code (the ui/initialize handling block, the delayed
tool-result dispatch, and the display-mode handling messages) so the
browser-side message handlers don't throw ReferenceError — search for
logger.info within the string produced by getPlaywrightInitScript() and replace
each occurrence with console.info.
In `@packages/inspector/src/session/session-renderer.ts`:
- Around line 206-218: Inside session-renderer.ts the page.evaluate callback
uses the Node logger (logger.info) which is undefined in the browser context and
will throw; locate the page.evaluate(...) call(s) that accept hostContext and
replace any browser-side logger.* calls with the global console equivalents
(e.g., logger.info -> console.info, logger.warn -> console.warn, logger.error ->
console.error) so the iframe postMessage block (where iframe, message, and
hostContext are used) and other evaluate callbacks use console instead of
logger.
In `@packages/inspector/src/widget-session-manager.ts`:
- Around line 401-413: Inside the page.evaluate block that posts the
host-context message (the anonymous function passed to page.evaluate where you
reference hostContext, iframe, iframe.contentWindow.postMessage and build the
message with method "ui/notifications/host-context-changed"), replace any
Node-side logger.* calls (e.g. logger.info) with browser-safe console.* calls
(e.g. console.info) so they run in the page context without throwing
ReferenceError; search for logger.info (and other logger usages) inside
page.evaluate blocks in widget-session-manager.ts and change them to
console.info (or console.warn/error as appropriate) while leaving the
postMessage and message construction unchanged.
---
Nitpick comments:
In `@packages/codegen/src/watcher.ts`:
- Around line 20-46: This file defines a duplicate structured logger
(defaultLogger, PluginLogger) that should be consolidated with the existing
logger in packages/codegen/src/utils/logger.ts; replace the in-file logger with
an import from that module, remove the duplicated defaultLogger implementation,
and ensure the watcher.ts uses the shared logger API (info, warn, error) so
behavior remains identical and avoids drift.
In `@packages/core/src/middleware/defineMiddleware.ts`:
- Around line 185-187: The comment in defineMiddleware.ts referencing "We return
the result from next()" is stale because the implementation now awaits next()
without capturing or returning its value; update or remove that comment to
reflect current behavior (no result is captured/returned). Locate the comment
near the MiddlewareChain<TResult> discussion in defineMiddleware (search for
"Note: We return the result from next()" or references to
MiddlewareChain<TResult> / next()) and either change the wording to explain that
next() is awaited and its return value is not propagated, or delete the note
entirely so the comment accurately matches the implementation.
In `@packages/inspector/src/oauth/wellknown-proxy.ts`:
- Around line 81-85: The log function in wellknown-proxy.ts is adding a
redundant manual prefix ("[oauth:wellknown-proxy]") even though
logger.formatPrefix() already emits "[wellknown-proxy]"; update the log(message:
string) implementation to stop prepending "[oauth:wellknown-proxy]" and instead
call logger.info(message) (or include only the additional context beyond the
existing prefix) so messages are not duplicated; modify any callers of log if
they relied on that manual prefix to preserve clarity.
In `@packages/inspector/src/widget-server.ts`:
- Around line 432-436: The private log method in widget-server.ts currently
prepends a manual “[WidgetServer]” prefix which is redundant because the global
logger already adds a “[widget-server]” tag; update the log method (private
log(message: string)) to stop adding the manual prefix and call logger.info with
just the message when this.options.debug is true (i.e., replace
logger.info(`[WidgetServer] ${message}`) with logger.info(message)), keeping the
conditional on this.options.debug unchanged.
| logger.info('[OpenAI Host] requestDisplayMode:', mode, 'sizing:', sizing); | ||
| return { mode: mode }; |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
cat -n packages/inspector/src/hosts/openai-host.ts | sed -n '240,260p'Repository: AndurilCode/mcp-apps-kit
Length of output: 787
🏁 Script executed:
cat -n packages/inspector/src/hosts/openai-host.ts | sed -n '210,260p'Repository: AndurilCode/mcp-apps-kit
Length of output: 2204
🏁 Script executed:
cat -n packages/inspector/src/hosts/openai-host.ts | sed -n '1,80p'Repository: AndurilCode/mcp-apps-kit
Length of output: 2902
🏁 Script executed:
cat -n packages/inspector/src/hosts/openai-host.ts | sed -n '170,250p'Repository: AndurilCode/mcp-apps-kit
Length of output: 3305
🏁 Script executed:
cat -n packages/inspector/src/hosts/openai-host.ts | sed -n '130,180p'Repository: AndurilCode/mcp-apps-kit
Length of output: 2083
🏁 Script executed:
cat -n packages/inspector/src/hosts/openai-host.ts | sed -n '100,135p'Repository: AndurilCode/mcp-apps-kit
Length of output: 2086
🏁 Script executed:
cat -n packages/inspector/src/hosts/openai-host.ts | sed -n '128,300p' | grep -n "logger"Repository: AndurilCode/mcp-apps-kit
Length of output: 165
🏁 Script executed:
cat -n packages/inspector/src/hosts/openai-host.ts | sed -n '300,330p'Repository: AndurilCode/mcp-apps-kit
Length of output: 1723
🏁 Script executed:
cat -n packages/inspector/src/hosts/openai-host.ts | sed -n '280,310p'Repository: AndurilCode/mcp-apps-kit
Length of output: 1477
🏁 Script executed:
cat -n packages/inspector/src/hosts/openai-host.ts | sed -n '330,450p'Repository: AndurilCode/mcp-apps-kit
Length of output: 4689
Replace logger.info with console.info in Playwright init script.
Line 248 is inside the Playwright init script template string (lines 128-297) which runs in browser context, where logger is undefined and will throw a ReferenceError at runtime. Use console.info instead.
Suggested fix
- logger.info('[OpenAI Host] requestDisplayMode:', mode, 'sizing:', sizing);
+ console.info('[OpenAI Host] requestDisplayMode:', mode, 'sizing:', sizing);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| logger.info('[OpenAI Host] requestDisplayMode:', mode, 'sizing:', sizing); | |
| return { mode: mode }; | |
| console.info('[OpenAI Host] requestDisplayMode:', mode, 'sizing:', sizing); | |
| return { mode: mode }; |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/inspector/src/hosts/openai-host.ts` around lines 248 - 249, In the
Playwright init script template string the browser-side call
logger.info('[OpenAI Host] requestDisplayMode:', mode, 'sizing:', sizing) will
throw because logger is undefined; update the template to use console.info
instead (replace logger.info(...) with console.info(...)) where the inline
function/requestDisplayMode handler is defined in the Playwright init template
in openai-host.ts so the script runs in browser context without ReferenceError.
| // Lightweight scoped logger (mirrors inspector's createLogger, avoids cross-package dep) | ||
| const uiReactLogger = (() => { | ||
| const source = "ui-react:hooks"; | ||
| const ts = () => new Date().toISOString(); | ||
| const LEVELS: Record<string, number> = { debug: 0, info: 1, warn: 2, error: 3, silent: 4 }; | ||
| // eslint-disable-next-line no-undef, @typescript-eslint/no-unnecessary-condition | ||
| const envLevel = | ||
| typeof process !== "undefined" | ||
| ? ((process.env?.MCP_APPS_LOG_LEVEL as string | undefined) ?? "").toLowerCase() | ||
| : ""; | ||
| const threshold: number = LEVELS[envLevel] ?? 1; // 1 = info | ||
| const ok = (l: string): boolean => (LEVELS[l] ?? 1) >= threshold; | ||
| return { | ||
| // eslint-disable-next-line no-console | ||
| warn: (...args: unknown[]) => { | ||
| if (ok("warn")) console.warn(`${ts()} [WARN] [${source}]`, ...args); | ||
| }, | ||
| }; | ||
| })(); |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Find tsconfig files in ui-react
echo "=== tsconfig files in ui-react ==="
find packages/ui-react -name 'tsconfig*.json' -type f 2>/dev/null | head -20
# Check the main tsconfig content
echo -e "\n=== ui-react tsconfig.json content ==="
cat packages/ui-react/tsconfig.json 2>/dev/null || echo "Not found"
# Check for Node types in tsconfig
echo -e "\n=== Checking for 'types' in ui-react tsconfig ==="
grep -A5 '"types"' packages/ui-react/tsconfig.json 2>/dev/null || echo "No types field found"
# Check for process declarations in .d.ts files
echo -e "\n=== Global process declarations in packages/ui-react ==="
find packages/ui-react -name '*.d.ts' -type f -exec grep -l 'declare.*process' {} \; 2>/dev/null || echo "No process declarations found"
# Check entire hooks.ts file around line 22-40
echo -e "\n=== Full context of hooks.ts (lines 15-50) ==="
sed -n '15,50p' packages/ui-react/src/hooks.ts 2>/dev/null || echo "File not found"
# Check if there are any eslint overrides or similar
echo -e "\n=== Check for eslintignore or similar configs ==="
find packages/ui-react -maxdepth 2 -name '.*' -type f | grep -E '(eslint|ts)' 2>/dev/null || echo "None found"Repository: AndurilCode/mcp-apps-kit
Length of output: 2356
🏁 Script executed:
#!/bin/bash
# Check the base tsconfig that ui-react extends
echo "=== tsconfig.base.json content ==="
cat packages/ui-react/../../tsconfig.base.json 2>/dev/null || cat tsconfig.base.json 2>/dev/null || echo "Not found"
# Check if there's a lib field in base
echo -e "\n=== Checking for types/lib in base tsconfig ==="
grep -A10 '"lib"\|"types"' tsconfig.base.json 2>/dev/null || echo "Not checked"
# Double check what process actually is in the current TypeScript context
echo -e "\n=== Check if process would cause TS error by looking at actual TS behavior ==="
cd packages/ui-react && npx tsc --noEmit 2>&1 | grep -i "process\|ReferenceError" || echo "No TypeScript errors related to process"Repository: AndurilCode/mcp-apps-kit
Length of output: 2541
TypeScript compilation fails on process access—add Node types to ui-react or use type-safe accessor.
The code fails to compile with error TS2580: Cannot find name 'process' at lines 29–30. The lib configuration in ui-react's tsconfig includes only ["ES2020", "DOM", "DOM.Iterable"] and does not include Node types. While the runtime check typeof process !== "undefined" is safe, TypeScript requires type definitions to resolve process.
Either:
- Add
@types/nodeto dev dependencies and include it via"types": ["node"]in tsconfig (if Node types are acceptable), or - Use the type-safe accessor below to avoid depending on Node typing:
Type-safe process.env accessor (recommended)
- // eslint-disable-next-line no-undef, `@typescript-eslint/no-unnecessary-condition`
- const envLevel =
- typeof process !== "undefined"
- ? ((process.env?.MCP_APPS_LOG_LEVEL as string | undefined) ?? "").toLowerCase()
- : "";
+ const envLevel = (
+ (globalThis as { process?: { env?: Record<string, string> } }).process?.env
+ ?.MCP_APPS_LOG_LEVEL ?? ""
+ ).toLowerCase();📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // Lightweight scoped logger (mirrors inspector's createLogger, avoids cross-package dep) | |
| const uiReactLogger = (() => { | |
| const source = "ui-react:hooks"; | |
| const ts = () => new Date().toISOString(); | |
| const LEVELS: Record<string, number> = { debug: 0, info: 1, warn: 2, error: 3, silent: 4 }; | |
| // eslint-disable-next-line no-undef, @typescript-eslint/no-unnecessary-condition | |
| const envLevel = | |
| typeof process !== "undefined" | |
| ? ((process.env?.MCP_APPS_LOG_LEVEL as string | undefined) ?? "").toLowerCase() | |
| : ""; | |
| const threshold: number = LEVELS[envLevel] ?? 1; // 1 = info | |
| const ok = (l: string): boolean => (LEVELS[l] ?? 1) >= threshold; | |
| return { | |
| // eslint-disable-next-line no-console | |
| warn: (...args: unknown[]) => { | |
| if (ok("warn")) console.warn(`${ts()} [WARN] [${source}]`, ...args); | |
| }, | |
| }; | |
| })(); | |
| // Lightweight scoped logger (mirrors inspector's createLogger, avoids cross-package dep) | |
| const uiReactLogger = (() => { | |
| const source = "ui-react:hooks"; | |
| const ts = () => new Date().toISOString(); | |
| const LEVELS: Record<string, number> = { debug: 0, info: 1, warn: 2, error: 3, silent: 4 }; | |
| const envLevel = ( | |
| (globalThis as { process?: { env?: Record<string, string> } }).process?.env | |
| ?.MCP_APPS_LOG_LEVEL ?? "" | |
| ).toLowerCase(); | |
| const threshold: number = LEVELS[envLevel] ?? 1; // 1 = info | |
| const ok = (l: string): boolean => (LEVELS[l] ?? 1) >= threshold; | |
| return { | |
| // eslint-disable-next-line no-console | |
| warn: (...args: unknown[]) => { | |
| if (ok("warn")) console.warn(`${ts()} [WARN] [${source}]`, ...args); | |
| }, | |
| }; | |
| })(); |
🧰 Tools
🪛 ESLint
[error] 30-30: 'process' is not defined.
(no-undef)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/ui-react/src/hooks.ts` around lines 22 - 40, The build fails because
TypeScript can't find the global "process" symbol used in uiReactLogger (see
envLevel and threshold calculation). Fix by removing direct typed access to
process: either add `@types/node` as a devDependency and enable it via
"types":["node"] in the ui-react tsconfig, or (recommended) replace the direct
reference to process.env with a type-safe runtime accessor (e.g., read process
via globalThis or a small helper that checks typeof process !== "undefined" and
returns process.env as any) and use that helper in the envLevel computation
inside uiReactLogger so TypeScript no longer needs Node types.
Kaizen 2026-02-17
Removes 3
eslint-disable @typescript-eslint/no-confusing-void-expressioncomments fromdefineMiddleware.ts.What:
next()returnsPromise<void>, so capturing the result in a variable or explicitly returning it is unnecessary and triggers the lint rule. Fixed by simply awaitingnext()without capturing/returning.Risk: None —
voidreturn is unchanged, all 827 core tests pass.Debt score impact: -3 suppressions