Skip to content

fix(elicitation): allow dialog to be closed via X button and on error#1919

Open
nuthalapativarun wants to merge 2 commits intoMCPJam:mainfrom
nuthalapativarun:fix/elicitation-dialog-close
Open

fix(elicitation): allow dialog to be closed via X button and on error#1919
nuthalapativarun wants to merge 2 commits intoMCPJam:mainfrom
nuthalapativarun:fix/elicitation-dialog-close

Conversation

@nuthalapativarun
Copy link
Copy Markdown

Summary

Fixes #1604

The elicitation dialog had two problems that could leave users with an unclosable dialog:

  1. X button did nothingonOpenChange was a no-op (() => {}), so clicking the dialog's X button had no effect. Wired to call cancel so the X button behaves the same as the Cancel button.

  2. Dialog stuck after server-side timeout or API error — When the server-side elicitation times out, activeElicitation on the client is still set. Any subsequent Cancel click would call the API and fail, but the catch block only set the error state without clearing activeElicitation, leaving the dialog permanently open. Fixed by clearing activeElicitation on cancel/decline API errors, and also when activeElicitation is already gone (stale state after server timeout).

Changes

  • ElicitationDialog.tsx: onOpenChange={(open) => { if (!open) handleResponse("cancel"); }}
  • ToolsTab.tsx: Clear activeElicitation on cancel/decline in catch block; clear it when activeElicitation is null at entry

Testing

  1. Connect to an MCP server that triggers elicitation
  2. While the dialog is open, click the X button — dialog should close
  3. Simulate a timeout (wait for the server to expire the elicitation), then click Cancel — dialog should close

Unit tests: 4 new tests in ElicitationDialog.test.tsx, all ToolsTab tests (17) still pass.

The elicitation dialog's onOpenChange was a no-op so the X button had
no effect. Wire it to call cancel so users can always dismiss the
dialog.

Also fixes the case where the dialog stays stuck after a server-side
timeout or API error:
- When activeElicitation is already gone (server timed out), clear it
  so the dialog closes instead of silently returning.
- On cancel/decline API errors, clear activeElicitation so the dialog
  closes rather than leaving users unable to dismiss it.

Fixes MCPJam#1604
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Apr 24, 2026
@chelojimenez
Copy link
Copy Markdown
Contributor

chelojimenez commented Apr 24, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: aba367d8-94a8-40ad-85c4-79348604e4d8

📥 Commits

Reviewing files that changed from the base of the PR and between f30dc05 and 2ac20f3.

📒 Files selected for processing (1)
  • mcpjam-inspector/client/src/components/__tests__/ElicitationDialog.test.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • mcpjam-inspector/client/src/components/tests/ElicitationDialog.test.tsx

Walkthrough

The pull request changes ElicitationDialog so its Dialog onOpenChange calls handleResponse("cancel") when open becomes false. ToolsTab’s elicitation response handler now clears activeElicitation if there is no active request and also ensures activeElicitation is cleared when responding throws an error for "cancel" or "decline". A new test file exercises conditional rendering of the dialog, prompt text display, and that both the dialog close control and the Cancel button invoke onResponse("cancel").


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@mcpjam-inspector/client/src/components/__tests__/ElicitationDialog.test.tsx`:
- Around line 59-71: The test helper makeRequest constructs a DialogElicitation
but sets timestamp to a number (Date.now()) while DialogElicitation.timestamp is
typed as string; change the timestamp to a string (e.g., new
Date().toISOString() or Date.now().toString()) so the return value of
makeRequest matches the DialogElicitation type and avoids TypeScript errors.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 60c2831a-87e2-4284-a9c0-b5a7c9f4c283

📥 Commits

Reviewing files that changed from the base of the PR and between 934c606 and f30dc05.

📒 Files selected for processing (3)
  • mcpjam-inspector/client/src/components/ElicitationDialog.tsx
  • mcpjam-inspector/client/src/components/ToolsTab.tsx
  • mcpjam-inspector/client/src/components/__tests__/ElicitationDialog.test.tsx

`DialogElicitation.timestamp` is typed as `string`; `Date.now()` returns
a number which causes a TypeScript type mismatch under strict mode.
@nuthalapativarun nuthalapativarun force-pushed the fix/elicitation-dialog-close branch from f634a54 to 2ac20f3 Compare April 24, 2026 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] If certain errors occurr during form elicitation, the elicitation dialog is stuck open

2 participants