Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 23, 2026

DCM Logo

Docker Compose Maker

Type of Change

  • πŸ“¦ New Container Definition
  • πŸ› Bug Fix
  • ✨ New Feature
  • πŸ“ Documentation Update
  • 🎨 UI/Style Improvement
  • ♻️ Code Refactoring
  • πŸ”§ Configuration Changes
  • πŸš€ Performance Improvement
  • βš™οΈ CI/Build Changes
  • πŸ”₯ Breaking Change
  • πŸ§ͺ Test

Description

Port conflict detection now returns structured data and renders with visual indicators showing which services keep/lose ports and their reassignments.

Core Changes

Type System (lib/docker-compose/port-conflicts.ts)

  • New types: PortChange, PortConflict, PortConflictsResult replace string arrays
  • Tracks which service keeps original port, which get reassigned, and the oldβ†’new mappings per service

Regex Bug Fix

  • Previous pattern: [\s\S]*? matched across service boundaries after port replacement
  • Fixed with negative lookahead: (?![^\n]*\n\s{2}[a-zA-Z0-9_-]+:) prevents cross-service matching
  • Removed while loop - each service only has one conflict per port

UI Component (components/compose-modal/PortConflictsAlert.tsx)

  • Port badges: destructive red, monospace
  • Service badges: green (βœ“) for kept, yellow (βœ—) for reassigned
  • Port transitions: red old β†’ green new with arrow icon
  • Grouped by port number in card layout

Example

// Before: string array
conflicts: ["Port 8096 was used by: jellyfin, plex, emby\n  β†’ Changed plex: 8096 β†’ 8097"]

// After: structured data
detailedConflicts: [{
  port: "8096",
  affectedServices: ["jellyfin", "plex", "emby"],
  keptService: "jellyfin",
  changes: [
    { service: "plex", oldPort: "8096", newPort: "8097" },
    { service: "emby", oldPort: "8096", newPort: "8098" }
  ]
}]

Test Coverage

  • 12 new tests: simple/multiple/three-way conflicts, quote variations, cross-service boundary regression

Checklist

  • PR targets the main branch
  • Code builds without warnings or errors
  • Commits follow the conventional commits guideline
  • No shorthand variable names are used
  • Tests have been added for new functionality

This PR is in accordance with the CONTRIBUTING.md guidelines.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • fonts.googleapis.com
    • Triggering command: /usr/local/bin/node node /home/REDACTED/work/dcm/dcm/node_modules/.bin/next build ker/cli-plugins/docker-compose n-meοΏ½οΏ½ config --quiet /usr/libexec/docker/docker-init config --quiet docker-compose /usr/libexec/docker/docker-init --veοΏ½οΏ½ (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Enhance port conflict detection and resolution logic</issue_title>
<issue_description>Problem: The current auto-port conflict resolver works, but further improvements could:

  • Show the user which containers have port conflicts
  • Suggest alternative ports and allow selection
  • Visualize port changes

Context: See ENHANCEMENTS.md and lib/docker-compose/port-conflicts.ts for current implementation.</issue_description>

<agent_instructions>use bun package manager </agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you β€” coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 5 commits January 23, 2026 14:11
- Added structured types for port conflicts (PortChange, PortConflict, PortConflictsResult)
- Enhanced detectAndFixPortConflicts to return detailed conflict information
- Redesigned PortConflictsAlert component with improved UI:
  - Shows which containers have conflicts with visual badges
  - Clear indication of which service port is kept vs changed
  - Better visualization of port changes with color-coded old/new ports
  - Grouped conflict information by port
- Added comprehensive test suite for port conflict scenarios
- All 127 tests passing

Co-authored-by: ajnart <49837342+ajnart@users.noreply.github.com>
The regex was matching across service boundaries when a service's port had already been changed. The pattern would match from the target service through to the next service that still had the conflicting port. Fixed by using a negative lookahead to prevent matching across service definitions.

Also removed the while loop since each service should only have one port conflict per port number, simplifying the logic.

- All 128 tests passing including new detailed conflict tracking test
- Verified fix with manual demonstration script

Co-authored-by: ajnart <49837342+ajnart@users.noreply.github.com>
Addressed code review feedback by adding comprehensive comments explaining:
- The purpose of the regex pattern
- Each part of the complex pattern including lookaheads
- Why modifying result during iteration is safe in this context

All tests still passing.

Co-authored-by: ajnart <49837342+ajnart@users.noreply.github.com>
Comprehensive documentation covering:
- Overview of all changes made
- Detailed explanation of new types and functionality
- Bug fix explanation with technical details
- UI enhancement documentation with visual structure
- Complete test coverage summary
- Regex pattern explanation
- Future enhancement suggestions

All 128 tests passing. Ready for final review.

Co-authored-by: ajnart <49837342+ajnart@users.noreply.github.com>
Created detailed documentation showing:
- Before/After comparison of UI
- Visual examples of different conflict scenarios
- Color scheme and styling details
- Component structure and data flow
- Accessibility considerations
- Future enhancement suggestions

This provides maintainers and reviewers with clear understanding of the UI improvements.

Co-authored-by: ajnart <49837342+ajnart@users.noreply.github.com>
Copilot AI changed the title [WIP] Enhance port conflict detection and resolution logic Enhance port conflict detection with structured data and visual UI Jan 23, 2026
Copilot AI requested a review from ajnart January 23, 2026 14:24
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.

Enhance port conflict detection and resolution logic

2 participants