feat(code): prompt to reconnect when leaving /mcp with pending toggles - #5211
Merged
Mason Daugherty (mdrxy) merged 5 commits intoJul 31, 2026
Merged
Conversation
Disable/enable toggles made with F2 in the `/mcp` viewer only take effect after a server restart. Closing the viewer with Esc left those changes silently unapplied unless the user remembered Ctrl+R, so offer the reconnect in a follow-up action modal instead. Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
Mason Daugherty (mdrxy)
marked this pull request as ready for review
July 30, 2026 23:53
Follow-up hardening for the prompt shown when the `/mcp` viewer closes with pending `F2` toggles. Correctness: - Guard against stacking. `_prompt_mcp_disable_reconnect` runs from `call_after_refresh`, so an unrelated modal can own the screen by then. `push_screen` stacks rather than raising, so the prompt would mount on top and steal Enter/Esc; defer to the recovery toast instead, matching `_open_update_available_modal`. The `except Exception` is now described as what it is — a net for unexpected mount faults. - Stop stranding a toggle when login is refused. Activating an unauthenticated row dismisses the viewer before `_start_mcp_login` runs its guards, so a rejected login (MCP off, remote server, agent switching) left the toggle unapplied with no further nudge. `_start_mcp_login` now reports whether it started and the caller falls through to the prompt when it did not. - Log instead of silently dropping the prompt when `call_after_refresh` reports a closing message pump, and when the detached reconnect finds nothing pending. Structure: - Extract `_ReconnectPromptScreen`, following the `update_confirm.py` pattern, so the two prompts no longer duplicate their bindings, a 34-line CSS block, and three actions. Shared styling is now structural rather than kept in sync by hand. - Drop the empty-`server_names` fallback: the caller only opens the modal with a non-empty pending set, so the generic copy was unreachable. Tests: - Chat input stays responsive while the prompt's reconnect is in flight, mirroring the Ctrl+R guard. - Re-enabling a server disabled in a prior session also prompts. - Multiple pending servers render in sorted order. - A programmatic dismiss stays quiet; only an explicit defer toasts. - An open modal gets the toast rather than a stacked prompt. - A rejected login still surfaces the pending toggle. - Both prompts share one style contract. Docs: correct the reset points for `_mcp_viewer_disable_toggled`, the reconnect race window, the `None` outcome on `ReconnectChoice`, the force-confirm exception in the module docstring, and several test docstrings that overstated what they proved.
Mason Daugherty (mdrxy)
deleted the
open-swe/mcp-viewer-disable-reconnect-prompt
branch
July 31, 2026 02:44
Mason Daugherty (mdrxy)
pushed a commit
that referenced
this pull request
Jul 31, 2026
> [!CAUTION] > Merging this PR will automatically publish to **PyPI** and create a **GitHub release**. For the full release process, see [`.github/RELEASING.md`](https://github.com/langchain-ai/deepagents/blob/main/.github/RELEASING.md). --- _Release notes preview: keep this section in sync with the package `CHANGELOG.md`. Publish reads the merged CHANGELOG via `release.yml`, not this PR description — keep them aligned anyway so the PR stays an accurate historical record for reviewers and anyone returning later._ --- ## [0.1.51](deepagents-code==0.1.50...deepagents-code==0.1.51) (2026-07-31) ### Features - The status bar and usage view now show the running session cost. ([#5036](#5036)) - Removed redundant `shell` and `web_search` prompt guidance. ([#5213](#5213)) - After switching threads, Deep Agents now points back to the previous thread. ([#5172](#5172)) - Leaving `/mcp` with pending toggles now prompts you to reconnect. ([#5211](#5211)) - `dcode config get` now accepts configuration sections. ([#5134](#5134)) ### Fixes - Kept the `/goal` criteria prompt responsive. ([#5142](#5142)) - Improved goal handling so underspecified objectives can be resolved from conversation context. ([#5201](#5201)) - Released the turn when an interrupted worker never starts. ([#5196](#5196)) - Hid timestamp footers together with their associated rows. ([#5167](#5167)) - Fixed editable SDK detection by scanning and correlating SDK locations more accurately. ([#5199](#5199)) - Improved `doctor` output to explain why it may not have a latest-version answer. ([#5209](#5209)) _End release notes preview._ --- > [!NOTE] > A **New Contributors** section is appended to the GitHub release notes automatically at publish time (see [Release Pipeline](https://github.com/langchain-ai/deepagents/blob/main/.github/RELEASING.md#release-pipeline), step 2). --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: langchain-oss-automated-triage[bot] <248757908+langchain-oss-automated-triage[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
/mcp: closing the viewer after disabling/enabling servers now offers to reconnect so the change takes effect.F2disable/enable toggles in the/mcpviewer only take effect after a server restart, but closing the viewer with Esc left them silently unapplied unless the user rememberedCtrl+R. Closing the viewer after a toggle now schedules aMCPDisableReconnectPromptScreenaction modal: Enter reconnects via the same detached-task path asCtrl+R, Esc defers with a reminder toast.The prompt is scoped to toggles that are actually still pending, so it stays quiet on a plain close, on a toggle that was undone, and on a pending login (that flow has its own post-login modal). If another modal already owns the screen by the time it fires, it degrades to a toast pointing at
/mcp reconnectrather than stacking on top and stealing Enter/Esc. Toggles are persisted toconfig.tomleither way, so they apply on next launch even when the reconnect never happens.Both prompts in
mcp_reconnect.pynow share a_ReconnectPromptScreenbase holding the bindings, layout, styling, and the reconnect/defer dismissal contract, following the existingupdate_confirm.pypattern. Subclasses supply only their title and body copy, so the two dialogs cannot drift apart visually or behaviorally.Made by Open SWE