void (Object sessionId) { ApplicationManager.getApplication().invokeLater(() -> { final Project project = myProject; if (!project.isDisposed()) { synchronized (myMessageViewLock) { final NewErrorTreeViewPanel errorTreeView = myErrorTreeView; if (errorTreeView != null && errorTreeView.getErrorViewStructure().isEmpty()) { final ToolWindow tw = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.MESSAGES_WINDOW); if (tw == null || !tw.isVisible()) { // if message view is not visible and current content is empty, remove the content removeTaskContents(project, sessionId); } } } } }); }