Skip to content

fix(mcp-panel): sanitize multiline text and make Keep & Close apply changes#14

Open
gpmarques wants to merge 1 commit intonicobailon:mainfrom
gpmarques:fix/mcp-panel-sanitize-keep-close
Open

fix(mcp-panel): sanitize multiline text and make Keep & Close apply changes#14
gpmarques wants to merge 1 commit intonicobailon:mainfrom
gpmarques:fix/mcp-panel-sanitize-keep-close

Conversation

@gpmarques
Copy link
Copy Markdown

What

This PR applies a minimal, targeted fix to mcp-panel.ts for two UX/rendering issues in the /mcp TUI panel.

Changes included

  1. Sanitize display text

    • Added sanitizeDisplayText(...) to normalize external metadata used in rendering.
    • Strips ANSI escape sequences and control characters.
    • Collapses newlines/tabs/whitespace into single-line display text.
  2. Keep discard behavior

    • In discard confirmation, selecting Keep on Enter now closes the panel and applies changes (done(buildResult())) instead of only leaving confirmation mode.
  3. Clarify button label

    • Renamed confirmation button from Keep to Keep & Close to match behavior.
  4. Protect row rendering from multiline content

    • Updated row(...) to force one-line content before truncation, preventing box/layout corruption from multiline/control characters.
  5. Use sanitized values in server/tool rows

    • renderServerRow(...): sanitize server.name and server.importKind.
    • renderToolRow(...): sanitize tool.name and tool.description.
    • Width/truncation now use sanitized text, improving stable alignment.

Why

Two user-facing issues were reproducible in the current panel behavior:

  1. Layout breaks with multiline tool descriptions

    • Some MCP metadata (e.g., descriptions with line breaks/args blocks or control chars) can spill across lines and break bordered row rendering.
    • Sanitizing + enforcing single-line row rendering makes the TUI robust against untrusted/irregular metadata.
  2. “Keep” in discard confirm is misleading

    • Previously, Keep only closed the confirmation prompt, not the panel, which is unexpected and easy to misinterpret.
    • Updating the action to “keep changes and close” plus renaming to Keep & Close aligns behavior with user expectation and label semantics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant