feat(ui): optimize MCP App widgets to reduce chat UI overhead#93
feat(ui): optimize MCP App widgets to reduce chat UI overhead#93jhuang-tw wants to merge 1 commit into
Conversation
Optimize MCP App widget behavior because tool-result cards can keep accumulating in long conversations. This can make the chat page increasingly slow, crowd the conversation with repeated UI surfaces, and make the information the user actually needs harder to find. Behavior: - default MCP App widgets to `off` - add a persisted `widgets` setting with `off`, `changes`, and `full` - add `devspace config set widgets <off|changes|full>` - keep `DEVSPACE_WIDGETS` as the highest-priority temporary override - report the active mode during init, serve, and doctor commands - in `off`, register native MCP tools without MCP App metadata and do not register the App resource - in `changes` and `full`, preserve the existing MCP App registration and presentation behavior Rationale: - prevent embedded tool cards from continuously piling up in chat - reduce rendering and interaction overhead in long conversations - keep tool results readable without hiding important conversation content behind repeated UI containers - allow Owners to explicitly enable partial or full UI when needed Compatibility and security: - Owner-password OAuth is unchanged - the `/mcp` endpoint and tool names are unchanged - existing `DEVSPACE_WIDGETS` deployments remain supported - persisted configuration is overridden by the environment variable - no generated UI assets, helper scripts, workflows, or documentation files are included in the final change Validation: - npm run typecheck - npm test - npm run build Scope: - src/user-config.ts - src/config.ts - src/config.test.ts - src/cli.ts - src/server.ts
📝 WalkthroughWalkthroughChangesWidgets configuration and server behavior
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant ConfigLoader
participant createMcpServer
participant registerAppTool
participant MCPHost
ConfigLoader->>createMcpServer: config.widgets
createMcpServer->>registerAppTool: register tool
registerAppTool->>MCPHost: UI-backed tool or native tool
createMcpServer->>MCPHost: Diff Card resource when widgets are enabled
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/server.ts (1)
160-164: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueSafeguard against accidental array conversion.
While the
definitionandhandlerresults are always plain objects in this context, using object rest spread on an array would inadvertently convert it into an object with numeric keys (e.g.,{ 0: item, 1: item }).As a defensive measure for a generic
<T>function, consider explicitly excluding arrays from being destructured.♻️ Proposed refactor
function stripAppMeta<T>(value: T): T { - if (!value || typeof value !== "object") return value; + if (!value || typeof value !== "object" || Array.isArray(value)) return value; const { _meta: _discardedMeta, ...nativeValue } = value as Record<string, unknown>; return nativeValue as T; }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/server.ts` around lines 160 - 164, Update stripAppMeta so arrays bypass the _meta removal and are returned unchanged, preventing object rest spread from converting them into numeric-keyed objects. Keep the existing primitive/null handling and plain-object metadata stripping behavior intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/server.ts`:
- Around line 160-164: Update stripAppMeta so arrays bypass the _meta removal
and are returned unchanged, preventing object rest spread from converting them
into numeric-keyed objects. Keep the existing primitive/null handling and
plain-object metadata stripping behavior intact.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: c2f29ab8-0f59-43b3-9fd7-70de576f0d04
📒 Files selected for processing (5)
src/cli.tssrc/config.test.tssrc/config.tssrc/server.tssrc/user-config.ts
Optimize MCP App widget behavior because tool-result cards can keep accumulating in long conversations. This can make the chat page increasingly slow, crowd the conversation with repeated UI surfaces, and make the information the user actually needs harder to find.
Behavior:
offwidgetssetting withoff,changes, andfulldevspace config set widgets <off|changes|full>DEVSPACE_WIDGETSas the highest-priority temporary overrideoff, register native MCP tools without MCP App metadata and do not register the App resourcechangesandfull, preserve the existing MCP App registration and presentation behaviorRationale:
Compatibility and security:
/mcpendpoint and tool names are unchangedDEVSPACE_WIDGETSdeployments remain supportedValidation:
Scope:
Summary by CodeRabbit
New Features
off,changes, orfull.devspace config set widgets ...support with validation.Bug Fixes
off.