Skip to content

feat(code): prompt to reconnect when leaving /mcp with pending toggles - #5211

Merged
Mason Daugherty (mdrxy) merged 5 commits into
mainfrom
open-swe/mcp-viewer-disable-reconnect-prompt
Jul 31, 2026
Merged

feat(code): prompt to reconnect when leaving /mcp with pending toggles#5211
Mason Daugherty (mdrxy) merged 5 commits into
mainfrom
open-swe/mcp-viewer-disable-reconnect-prompt

Conversation

@mdrxy

@mdrxy Mason Daugherty (mdrxy) commented Jul 30, 2026

Copy link
Copy Markdown
Member

/mcp: closing the viewer after disabling/enabling servers now offers to reconnect so the change takes effect.


F2 disable/enable toggles in the /mcp viewer only take effect after a server restart, but closing the viewer with Esc left them silently unapplied unless the user remembered Ctrl+R. Closing the viewer after a toggle now schedules a MCPDisableReconnectPromptScreen action modal: Enter reconnects via the same detached-task path as Ctrl+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 reconnect rather than stacking on top and stealing Enter/Esc. Toggles are persisted to config.toml either way, so they apply on next launch even when the reconnect never happens.

Both prompts in mcp_reconnect.py now share a _ReconnectPromptScreen base holding the bindings, layout, styling, and the reconnect/defer dismissal contract, following the existing update_confirm.py pattern. Subclasses supply only their title and body copy, so the two dialogs cannot drift apart visually or behaviorally.

Made by Open SWE

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>
@github-actions github-actions Bot added dcode Related to `deepagents-code` feature New feature/enhancement or request for one internal User is a member of the `langchain-ai` GitHub organization open-swe size: M 200-499 LOC labels Jul 30, 2026
@mdrxy
Mason Daugherty (mdrxy) marked this pull request as ready for review July 30, 2026 23:53
Mason Daugherty (mdrxy) and others added 2 commits July 30, 2026 19: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.
@github-actions github-actions Bot added size: L 500-999 LOC and removed size: M 200-499 LOC labels Jul 31, 2026
@mdrxy
Mason Daugherty (mdrxy) merged commit 53d1fb8 into main Jul 31, 2026
69 checks passed
@mdrxy
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dcode Related to `deepagents-code` feature New feature/enhancement or request for one internal User is a member of the `langchain-ai` GitHub organization open-swe size: L 500-999 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant