Forge
csharpdeeb25a2
1using CascadeIDE.Cockpit.DataBus;
2using CascadeIDE.Models;
3
4namespace CascadeIDE.Features.Agent.Environment;
5
6/// <summary>Inject verify trace into chat on AgentRunCompleted (ADR 0148 W3).</summary>
7public sealed class AgentEnvironmentChatProjection : IDisposable
8{
9 private readonly IDisposable _subscription;
10 private readonly AgentEnvironmentTimeAccountingSettings _settings;
11 private readonly Action<string, bool> _appendTrace;
12
13 public AgentEnvironmentChatProjection(
14 IDataBus dataBus,
15 AgentEnvironmentTimeAccountingSettings settings,
16 Action<string, bool> appendTrace)
17 {
18 _settings = settings;
19 _appendTrace = appendTrace;
20 _subscription = dataBus.Subscribe<AgentRunCompleted>(OnCompleted);
21 }
22
23 private void OnCompleted(AgentRunCompleted evt)
24 {
25 if (!_settings.ShowInChat)
26 return;
27
28 _appendTrace(AgentVerifyEpochFormatter.FormatCompletedChatTrace(evt), evt.Green);
29 }
30
31 public void Dispose() => _subscription.Dispose();
32}
33
View only · write via MCP/CIDE