Skip to content

feat(env): manage multiple mutagen sessions and improve sync handling#918

Open
martin-cod wants to merge 5 commits into
wardenenv:mainfrom
martin-cod:feature/resume-multi-mutagen-sessions
Open

feat(env): manage multiple mutagen sessions and improve sync handling#918
martin-cod wants to merge 5 commits into
wardenenv:mainfrom
martin-cod:feature/resume-multi-mutagen-sessions

Conversation

@martin-cod

@martin-cod martin-cod commented Feb 26, 2026

Copy link
Copy Markdown

Check List

  • Matching PR in the documentation repo (replace text with link when it exists)
  • Entry in CHANGELOG.md

Is your feature request related to a problem? Please describe.
Previous versions of the environment management functionality did not support handling multiple Mutagen sessions simultaneously, which led to conflicts and insufficient synchronization handling for more complex development workflows. Users were frustrated by the inability to efficiently manage or monitor multiple live mutagen sync sessions within the same environment.

Describe the solution you've submitted
This PR introduces enhancements for managing multiple Mutagen sessions concurrently within the environment. It improves the sync session resuming logic, monitors several sync sessions in parallel. The changes include robust session tracking, improved error handling, and optimised status reporting for each session.

Mutagen sync session management step-by-step improvements:

  • Get all sessions for the environment. Analyse and categorise Mutagen sync sessions as either matching or mismatched with the current container, improving session management and code clarity
  • Terminate Mutagen sync sessions that reference outdated (mismatched) containers, preventing potential sync issues
  • Resume only paused sessions that match the current container, and to start new sync sessions only if no connected sessions exist for the current container.
  • Get all connected sessions. Re-run $WARDEN_BIN sync list command because statuses were changed after mutagen sessions resumed.
  • Start new sync session only if there are no connected sessions for the current container

Describe alternatives you've considered
Alternatives considered include only supporting a single sync session at a time or using external scripts to manage multiple sessions outside the existing environment tooling. These approaches were disregarded due to their lack of integration and reduced user experience compared to the proposed comprehensive multi-session management.

Additional context
This PR still does not add the full-featured support of multiple mutagen sessions mentioned in #910. I.e. when the environment is created with warden env up, only one mutagen session is still created. But, when parrallel mutagen session was started manually, now it will not be dropped and stopped/resumed correctly

- Get paused sessions: separate matching and mismatched containers
- Terminate sessions with mismatched containers
- Resume all valid paused sessions (warden filters by label automatically)
@martin-cod martin-cod force-pushed the feature/resume-multi-mutagen-sessions branch from 142aaca to 3c8313e Compare February 26, 2026 12:07
- Get all sessions for this environment (warden filters by label)
- Terminate stale connected sessions (pointing to old containers)
- Start sync only if zero connected sessions for current container
@martin-cod martin-cod changed the title fix(env): keep multiple mutagen session running feat(env): manage multiple mutagen sessions and improve sync handling Feb 27, 2026
@martin-cod martin-cod marked this pull request as ready for review February 27, 2026 15:41
@navarr navarr requested a review from Copilot March 6, 2026 20:35
@navarr navarr moved this to 🆕 New in Warden Mar 6, 2026
@navarr navarr added this to the Warden 1.0.0 milestone Mar 6, 2026
@navarr navarr added the bug Something isn't working label Mar 6, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates Warden’s environment lifecycle command to better handle multiple Mutagen sync sessions for the same environment by detecting sessions tied to outdated containers, resuming valid paused sessions, and only starting a new session when none are connected.

Changes:

  • Add categorizeSyncSessions() to classify Mutagen sessions as matching/mismatching the current php-fpm container.
  • On env up/start, terminate mismatched sessions, resume paused matching sessions, and start sync only when no connected matching sessions exist.
  • Document the enhancement in CHANGELOG.md.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
commands/env.cmd Implements multi-session-aware Mutagen termination/resume/start logic during env up/start/down.
CHANGELOG.md Adds an UNRELEASED entry describing the multi-session resume/sync-handling improvement.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread commands/env.cmd
Comment thread commands/env.cmd Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Status: 🆕 New

Development

Successfully merging this pull request may close these issues.

3 participants