Skip to content

Modern Docker Management, Designed for Everyone

fix: project overview shows stale service count after compose edit (#2193)

Giulio Savini419cb9219d65
diff --git a/backend/internal/services/project_service.go b/backend/internal/services/project_service.go
index e0c65e952..e96111a78 100644
--- a/backend/internal/services/project_service.go
+++ b/backend/internal/services/project_service.go
@@ -2185,6 +2185,14 @@ func (s *ProjectService) UpdateProject(ctx context.Context, projectID string, na
return nil, err
}
+ // When compose content changes, recalculate service counts and status so the
+ // overview doesn't show stale values (e.g. ghost services after removal).
+ if composeContent != nil {
+ if err := s.updateProjectStatusandCountsInternal(ctx, proj.ID, proj.Status); err != nil {
+ slog.WarnContext(ctx, "failed to update service counts after compose edit", "projectID", proj.ID, "error", err)
+ }
+ }
+
metadata := models.JSON{
"action": "update",
"projectID": proj.ID,
@@ -2229,6 +2237,11 @@ func (s *ProjectService) ApplyGitSyncProjectFiles(ctx context.Context, projectID
return nil, fmt.Errorf("failed to update project: %w", err)
}
+ // Recalculate service counts and status after compose file sync
+ if err := s.updateProjectStatusandCountsInternal(ctx, proj.ID, proj.Status); err != nil {
+ slog.WarnContext(ctx, "failed to update service counts after git sync", "projectID", proj.ID, "error", err)
+ }
+
metadata := models.JSON{
"action": "git_sync_update",
"projectID": proj.ID,
@@ -2734,6 +2747,11 @@ func (s *ProjectService) UpdateProjectIncludeFile(ctx context.Context, projectID
return fmt.Errorf("failed to update include file: %w", err)
}
+ // Recalculate service counts since include files can define services
+ if err := s.updateProjectStatusandCountsInternal(ctx, proj.ID, proj.Status); err != nil {
+ slog.WarnContext(ctx, "failed to update service counts after include file edit", "projectID", proj.ID, "error", err)
+ }
+
metadata := models.JSON{
"action": "update_include",
"projectID": proj.ID,