From b9984e1dba9ad70ddd290d2a3a0e30bde874e445 Mon Sep 17 00:00:00 2001 From: Konstantin Aleev Date: Sat, 31 Jan 2026 18:30:30 +0100 Subject: [PATCH] IJPL-230472 services: run dashboard: move content based on managed run configuration types GitOrigin-RevId: edbfe227473da3468aa6a9e686000df240a78bd6 --- .../frontend/FrontendRunDashboardManager.kt | 14 +++-- .../frontend/RunDashboardUiManagerImpl.java | 55 ++++++++++++++----- 2 files changed, 49 insertions(+), 20 deletions(-) diff --git a/platform/execution.dashboard/src/splitApi/frontend/FrontendRunDashboardManager.kt b/platform/execution.dashboard/src/splitApi/frontend/FrontendRunDashboardManager.kt index bff83f909ee5..76c55c51735f 100644 --- a/platform/execution.dashboard/src/splitApi/frontend/FrontendRunDashboardManager.kt +++ b/platform/execution.dashboard/src/splitApi/frontend/FrontendRunDashboardManager.kt @@ -73,9 +73,6 @@ internal class FrontendRunDashboardManager(private val project: Project) : RunDa frontendDtos.value = updatesFromBackend updateDashboard(true) - withContext(Dispatchers.EDT) { - RunDashboardUiManagerImpl.getInstance(project).syncContentsFromBackend() - } } } @@ -123,9 +120,14 @@ internal class FrontendRunDashboardManager(private val project: Project) : RunDa internal suspend fun subscribeToBackendConfigurationTypesUpdates() { RunDashboardServiceRpc.getInstance().getConfigurationTypes(project.projectId()).collect { updateFromBackend -> - // Just update types set on the frontend, - // do not filter frontend DTOs since they are synced via subscribeToBackendServicesUpdates(). - configurationTypes.value = types + configurationTypes.value = updateFromBackend + + updateDashboard(true) + withContext(Dispatchers.EDT) { + if (RunDashboardUiManagerImpl.getInstance(project).syncContentsFromBackend()) { + updateDashboard(true) + } + } } } diff --git a/platform/execution.dashboard/src/splitApi/frontend/RunDashboardUiManagerImpl.java b/platform/execution.dashboard/src/splitApi/frontend/RunDashboardUiManagerImpl.java index 48f87b162786..83432b5a4a01 100644 --- a/platform/execution.dashboard/src/splitApi/frontend/RunDashboardUiManagerImpl.java +++ b/platform/execution.dashboard/src/splitApi/frontend/RunDashboardUiManagerImpl.java @@ -1,7 +1,6 @@ // Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.platform.execution.dashboard.splitApi.frontend; -import com.google.common.collect.Sets; import com.intellij.execution.ExecutionBundle; import com.intellij.execution.Executor; import com.intellij.execution.RunContentDescriptorId; @@ -131,21 +130,49 @@ public final class RunDashboardUiManagerImpl implements RunDashboardUiManager { return Conditions.alwaysFalse(); } - public void syncContentsFromBackend() { + /** + * Synchronizes content between the dashboard content manager and the run content manager + * based on the current set of run configuration types that should be shown in services. + *

+ * Content is moved out of the dashboard when its run configuration type is removed from services. + * Content is moved into the dashboard when its run configuration type is added to services. + */ + public boolean syncContentsFromBackend() { FrontendRunDashboardManager frontendManager = FrontendRunDashboardManager.getInstance(myProject); - List<@NotNull FrontendRunDashboardService> services = frontendManager.getServicePresentations(); - Set actualContents = new HashSet<>( - ContainerUtil.mapNotNull(services, - service -> { - var descriptor = frontendManager.getServiceRunContentDescriptor(service); - return descriptor != null ? descriptor.getAttachedContent() : null; - })); - var managedContents = Set.of(myContentManager.getContents()); + Set types = frontendManager.getTypes(); - var removed = Sets.difference(managedContents, actualContents); - moveRemovedContent(removed); - var added = Sets.difference(actualContents, managedContents); - moveAddedContent(added); + // Find content to remove from dashboard (type no longer in services) + Set managedContents = Set.of(myContentManager.getContents()); + Set toRemove = new HashSet<>(); + for (Content content : managedContents) { + RunContentDescriptor descriptor = RunContentManagerImpl.getRunContentDescriptorByContent(content); + if (descriptor == null) continue; + + String typeId = descriptor.getRunConfigurationTypeId(); + if (typeId != null && !types.contains(typeId)) { + toRemove.add(content); + } + } + moveRemovedContent(toRemove); + + // Find content to add to dashboard (type now in services) + RunContentManager runContentManager = RunContentManager.getInstance(myProject); + Set toAdd = new HashSet<>(); + for (RunContentDescriptor descriptor : runContentManager.getRunContentDescriptors()) { + String typeId = descriptor.getRunConfigurationTypeId(); + if (typeId == null || !types.contains(typeId)) continue; + + Content content = descriptor.getAttachedContent(); + if (content == null || managedContents.contains(content)) continue; + + // Only add content that is not already being managed by the dashboard + if (content.getManager() != myContentManager) { + toAdd.add(content); + } + } + moveAddedContent(toAdd); + + return !toRemove.isEmpty() || !toAdd.isEmpty(); } private void moveRemovedContent(Collection contents) {