Display solution load and diagnostics progress

This commit is contained in:
Matt Parker
2025-11-24 22:51:40 +10:00
parent 6eaea8ca52
commit 329cc057c4
6 changed files with 122 additions and 2 deletions

View File

@@ -13,6 +13,7 @@ using SharpIDE.Application.Features.Nuget;
using SharpIDE.Application.Features.Run;
using SharpIDE.Application.Features.Search;
using SharpIDE.Application.Features.Testing;
using SharpIDE.Godot.Features.ActivityListener;
namespace SharpIDE.Godot;
@@ -48,6 +49,7 @@ public partial class DiAutoload : Node
services.AddScoped<IdeFileOperationsService>();
services.AddScoped<SharpIdeSolutionModificationService>();
services.AddScoped<SharpIdeSolutionAccessor>();
services.AddScoped<ActivityMonitor>();
services.AddHttpClient();
services.AddLogging(builder =>

View File

@@ -0,0 +1,24 @@
using System.Diagnostics;
using SharpIDE.Application;
using SharpIDE.Application.Features.Events;
namespace SharpIDE.Godot.Features.ActivityListener;
public class ActivityMonitor
{
public EventWrapper<Activity, Task> ActivityStarted { get; } = new(_ => Task.CompletedTask);
public EventWrapper<Activity, Task> ActivityStopped { get; } = new(_ => Task.CompletedTask);
public ActivityMonitor()
{
var listener = new System.Diagnostics.ActivityListener
{
ShouldListenTo = source => source == SharpIdeOtel.Source,
Sample = (ref ActivityCreationOptions<ActivityContext> _) => ActivitySamplingResult.PropagationData,
ActivityStarted = activity => ActivityStarted.InvokeParallelFireAndForget(activity),
ActivityStopped = activity => ActivityStopped.InvokeParallelFireAndForget(activity),
};
ActivitySource.AddActivityListener(listener);
}
}

View File

@@ -0,0 +1 @@
uid://bj7cmmfhf41ry

View File

@@ -0,0 +1,79 @@
using System.Diagnostics;
using Godot;
using SharpIDE.Application.Features.Analysis;
using SharpIDE.Godot.Features.ActivityListener;
namespace SharpIDE.Godot.Features.BottomBar;
public partial class RunningTasksDisplay : HBoxContainer
{
[Inject] private readonly ActivityMonitor _activityMonitor = null!;
private bool _isSolutionLoading;
private bool _isSolutionDiagnosticsBeingRetrieved;
private Label _solutionLoadingLabel = null!;
private Label _solutionDiagnosticsLabel = null!;
public override void _Ready()
{
_solutionLoadingLabel = GetNode<Label>("SolutionLoadingLabel");
_solutionDiagnosticsLabel = GetNode<Label>("SolutionDiagnosticsLabel");
Visible = false;
_activityMonitor.ActivityStarted.Subscribe(OnActivityStarted);
_activityMonitor.ActivityStopped.Subscribe(OnActivityStopped);
}
public override void _ExitTree()
{
_activityMonitor.ActivityStarted.Unsubscribe(OnActivityStarted);
}
private async Task OnActivityStarted(Activity activity)
{
if (activity.DisplayName == $"{nameof(RoslynAnalysis)}.{nameof(RoslynAnalysis.UpdateSolutionDiagnostics)}")
{
_isSolutionDiagnosticsBeingRetrieved = true;
}
else if (activity.DisplayName == "OpenSolution")
{
_isSolutionLoading = true;
}
else
{
return;
}
var visible = _isSolutionDiagnosticsBeingRetrieved || _isSolutionLoading;
await this.InvokeAsync(() =>
{
_solutionLoadingLabel.Visible = _isSolutionLoading;
_solutionDiagnosticsLabel.Visible = _isSolutionDiagnosticsBeingRetrieved;
Visible = visible;
});
}
private async Task OnActivityStopped(Activity activity)
{
if (activity.DisplayName == $"{nameof(RoslynAnalysis)}.{nameof(RoslynAnalysis.UpdateSolutionDiagnostics)}")
{
_isSolutionDiagnosticsBeingRetrieved = false;
}
else if (activity.DisplayName == "OpenSolution")
{
_isSolutionLoading = false;
}
else
{
return;
}
var visible = _isSolutionDiagnosticsBeingRetrieved || _isSolutionLoading;
await this.InvokeAsync(() =>
{
_solutionLoadingLabel.Visible = _isSolutionLoading;
_solutionDiagnosticsLabel.Visible = _isSolutionDiagnosticsBeingRetrieved;
Visible = visible;
});
}
}

View File

@@ -0,0 +1 @@
uid://t26ae82ia2cj

View File

@@ -1,4 +1,6 @@
[gd_scene load_steps=3 format=3 uid="uid://cnla64hcar6dr"]
[gd_scene load_steps=4 format=3 uid="uid://cnla64hcar6dr"]
[ext_resource type="Script" uid="uid://t26ae82ia2cj" path="res://Features/BottomBar/RunningTasksDisplay.cs" id="1_ytjpp"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_5swca"]
content_margin_left = 2.0
@@ -34,14 +36,25 @@ offset_bottom = 11.5
grow_horizontal = 2
grow_vertical = 2
size_flags_vertical = 4
script = ExtResource("1_ytjpp")
[node name="ProgressLabel" type="Label" parent="."]
[node name="SolutionLoadingLabel" type="Label" parent="."]
unique_name_in_owner = true
layout_mode = 2
theme_override_colors/font_color = Color(0.67058825, 0.67058825, 0.67058825, 1)
theme_override_font_sizes/font_size = 14
text = "Loading Solution"
vertical_alignment = 1
[node name="SolutionDiagnosticsLabel" type="Label" parent="."]
unique_name_in_owner = true
visible = false
layout_mode = 2
theme_override_colors/font_color = Color(0.67058825, 0.67058825, 0.67058825, 1)
theme_override_font_sizes/font_size = 14
text = "Updating Solution Diagnostics"
vertical_alignment = 1
[node name="ProgressBar" type="ProgressBar" parent="."]
custom_minimum_size = Vector2(150, 0)
layout_mode = 2