Forge
csharp4405de34
1using CascadeIDE.Cockpit.DataBus;
2using CascadeIDE.Models;
3
4namespace CascadeIDE.Features.Agent.Environment;
5
6/// <summary>Краткий прогресс environment tasks в чат (ADR 0148 W3).</summary>
7public sealed class AgentEnvironmentChatProgressProjection : IDisposable
8{
9 private readonly IDisposable _subscription;
10
11 public AgentEnvironmentChatProgressProjection(
12 IDataBus dataBus,
13 AgentEnvironmentTimeAccountingSettings settings,
14 Action<string, bool> appendTrace)
15 {
16 if (!settings.ShowTaskProgressInChat)
17 {
18 _subscription = new NoopDisposable();
19 return;
20 }
21
22 _subscription = dataBus.Subscribe<AgentEnvironmentTaskChanged>(evt =>
23 {
24 if (evt.State is not (AgentEnvironmentTaskState.Running or AgentEnvironmentTaskState.Queued))
25 return;
26
27 var line = $"[AEE] {evt.Kind} · {evt.State} · run {evt.RunId[..8]}…";
28 if (!string.IsNullOrWhiteSpace(evt.ProgressMessage))
29 line += $" ({evt.ProgressMessage})";
30 appendTrace(line, true);
31 });
32 }
33
34 public void Dispose() => _subscription.Dispose();
35
36 private sealed class NoopDisposable : IDisposable
37 {
38 public void Dispose() { }
39 }
40}
41
View only · write via MCP/CIDE