Forge
csharpdeeb25a2
1using CascadeIDE.Cockpit.DataBus;
2using CascadeIDE.Models;
3
4namespace CascadeIDE.Features.Agent.Environment;
5
6/// <summary>Сообщение в чат при <see cref="AgentVerifyEpochStale"/> (ADR 0148 W3).</summary>
7public sealed class AgentEnvironmentEpochStaleChatProjection : IDisposable
8{
9 private readonly IDisposable _subscription;
10
11 public AgentEnvironmentEpochStaleChatProjection(
12 IDataBus dataBus,
13 AgentEnvironmentTimeAccountingSettings settings,
14 Action<string, bool> appendTrace)
15 {
16 if (!settings.ShowInChat)
17 {
18 _subscription = new NoopDisposable();
19 return;
20 }
21
22 _subscription = dataBus.Subscribe<AgentVerifyEpochStale>(evt =>
23 {
24 var glyph = evt.Reason switch
25 {
26 "write_in_epoch" => "⚠",
27 "cancel" => "⊘",
28 "superseded" => "↻",
29 _ => "⚠",
30 };
31 var line = $"{glyph} [AEE] verify epoch устарел ({evt.Reason}) · snapshot {evt.VerifySnapshotId[..8]}…";
32 appendTrace(line, false);
33 });
34 }
35
36 public void Dispose() => _subscription.Dispose();
37
38 private sealed class NoopDisposable : IDisposable
39 {
40 public void Dispose() { }
41 }
42}
43
View only · write via MCP/CIDE