Files
ScadaBridge/src/ZB.MOM.WW.ScadaBridge.CentralUI/Components/Pages/Deployment/DebugView.razor
T
Joseph Doherty 50ce26f2e6 feat(centralui): DV-5 — Debug View tabbed composition trees (Attributes/Alarms)
Replace the two flat capped tables with a Bootstrap nav-tabs layout, each
tab hosting a TreeView<DebugTreeNode> built from the live latest-per-name
dictionaries via DebugTreeBuilder. Drop the MaxRows cap, auto-scroll locks,
and Clear buttons (change-feed affordances that don't fit a current-status
tree); HandleStreamEvent now does a plain dictionary upsert. Per-tab filters
ExpandAll on change so matches stay visible. Branch nodes surface roll-up
badges (active-count for alarms, bad-quality for attributes); native binding
nodes show active-count or 'no active conditions'. All existing badge helpers
and ValueFormatter reused. Marshalling/dispose/reconnect contract preserved
(SafeInvokeAsync/_disposed/Dispose unchanged; FilteredAttributeValues kept as
the render-thread dict reader the CentralUI-021 race test exercises).

Rework DebugViewAlarmTableTests for the tabbed-tree DOM: tab presence+default,
computed alarm grouped under its Motor1 branch with the active roll-up badge,
and a native condition nested under its source-binding node with the enriched
kind/severity/Unacked/Shelved badge set.
2026-06-17 15:23:49 -04:00

672 lines
30 KiB
Plaintext

@page "/deployment/debug-view"
@using ZB.MOM.WW.ScadaBridge.Security
@using ZB.MOM.WW.ScadaBridge.Commons.Entities.Instances
@using ZB.MOM.WW.ScadaBridge.Commons.Entities.Sites
@using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Repositories
@using ZB.MOM.WW.ScadaBridge.Commons.Messages.DebugView
@using ZB.MOM.WW.ScadaBridge.Commons.Messages.Streaming
@using ZB.MOM.WW.ScadaBridge.Commons.Types
@using ZB.MOM.WW.ScadaBridge.Commons.Types.Enums
@using ZB.MOM.WW.ScadaBridge.Communication
@attribute [Authorize(Policy = AuthorizationPolicies.RequireDeployment)]
@inject ITemplateEngineRepository TemplateEngineRepository
@inject ISiteRepository SiteRepository
@inject ZB.MOM.WW.ScadaBridge.CentralUI.Auth.SiteScopeService SiteScope
@inject DebugStreamService DebugStreamService
@inject IJSRuntime JS
@implements IDisposable
<div class="container-fluid mt-3">
<h4 class="mb-3">Debug View</h4>
<ToastNotification @ref="_toast" />
@if (_loading)
{
<LoadingSpinner IsLoading="true" />
}
else
{
@* Status strip — connection state, instance, last snapshot. *@
<div class="alert alert-light py-2 mb-3 d-flex justify-content-between align-items-center small flex-wrap gap-2">
<div class="d-flex align-items-center gap-2">
<strong>
@if (_connected)
{
var inst = _siteInstances.FirstOrDefault(i => i.Id == _selectedInstanceId);
@(inst?.UniqueName ?? "Connected")
}
else
{
<span class="text-muted">Not connected</span>
}
</strong>
@if (_connected)
{
<span class="badge bg-success" aria-label="Connection state: Live">
<span class="spinner-grow spinner-grow-sm me-1" style="width: 0.5rem; height: 0.5rem;" aria-hidden="true"></span>
Live
</span>
}
else
{
<span class="badge bg-secondary" aria-label="Connection state: Disconnected">Disconnected</span>
}
</div>
<div class="d-flex align-items-center gap-2">
@if (_snapshot != null)
{
<span class="text-muted">
Last snapshot: @_snapshot.SnapshotTimestamp.LocalDateTime.ToString("HH:mm:ss")
</span>
}
@if (_connected && _connectedFromStorage)
{
<button class="btn btn-outline-secondary btn-sm" @onclick="StartFresh"
aria-label="Clear persisted selection and disconnect">Start fresh</button>
}
</div>
</div>
<div class="row mb-3 g-2">
<div class="col-md-3">
<label class="form-label small">Site</label>
<select class="form-select form-select-sm" data-test="debug-site-select"
@bind="_selectedSiteId" @bind:after="LoadInstancesForSite" disabled="@_connected">
<option value="0">Select site...</option>
@foreach (var site in _sites)
{
<option value="@site.Id">@site.Name (@site.SiteIdentifier)</option>
}
</select>
</div>
<div class="col-md-4">
<label class="form-label small">Instance</label>
<select class="form-select form-select-sm" data-test="debug-instance-select"
@bind="_selectedInstanceId" @bind:after="OnInstanceSelectionChanged" disabled="@_connected">
<option value="0">Select instance...</option>
@foreach (var inst in _siteInstances)
{
<option value="@inst.Id">@inst.UniqueName (@inst.State)</option>
}
</select>
</div>
<div class="col-md-3 d-flex align-items-end gap-2">
@if (!_connected)
{
<button class="btn btn-primary btn-sm" @onclick="Connect"
disabled="@(_selectedInstanceId == 0 || _selectedSiteId == 0 || _connecting)">
@if (_connecting) { <span class="spinner-border spinner-border-sm me-1" role="status" aria-label="Connecting"></span> }
Connect
</button>
}
else
{
<button class="btn btn-outline-danger btn-sm" @onclick="Disconnect">Disconnect</button>
}
</div>
</div>
@if (_connected && _snapshot != null)
{
<div class="card">
@* Tabbed layout — Attributes / Alarms, each a composition tree. *@
<div class="card-header py-0 px-0">
<ul class="nav nav-tabs card-header-tabs mx-2 mt-2" role="tablist">
<li class="nav-item" role="presentation">
<button type="button" role="tab"
class="nav-link @(_activeTab == "attributes" ? "active" : "")"
data-test="debug-tab-attributes"
aria-selected="@(_activeTab == "attributes" ? "true" : "false")"
@onclick='() => _activeTab = "attributes"'>
Attributes
</button>
</li>
<li class="nav-item" role="presentation">
<button type="button" role="tab"
class="nav-link @(_activeTab == "alarms" ? "active" : "")"
data-test="debug-tab-alarms"
aria-selected="@(_activeTab == "alarms" ? "true" : "false")"
@onclick='() => _activeTab = "alarms"'>
Alarms
</button>
</li>
</ul>
</div>
<div class="card-body">
@* ── Attributes tab ── *@
<div class="@(_activeTab == "attributes" ? "" : "d-none")"
data-test="debug-pane-attributes" role="tabpanel">
<div class="mb-2">
<input type="text" class="form-control form-control-sm"
style="max-width: 280px;"
placeholder="Filter by attribute…"
@bind="_attrFilter" @bind:event="oninput" @bind:after="OnAttrFilterChanged"
aria-label="Filter attributes" />
</div>
<TreeView TItem="DebugTreeNode" @ref="_attrTree"
Items="AttributeForest"
ChildrenSelector="n => n.Children"
HasChildrenSelector="n => n.HasChildren"
KeySelector="n => n.Key"
InitiallyExpanded="n => true"
StorageKey="debugview.attrTree">
<NodeContent Context="node">
@if (node.Attribute is not null)
{
@* Leaf — one attribute value. *@
<span class="me-2">@node.Segment</span>
<span class="font-monospace me-2"><strong>@ValueFormatter.FormatDisplayValue(node.Attribute.Value)</strong></span>
<span class="badge @GetQualityBadge(node.Attribute.Quality) me-2"
aria-label="@($"Quality: {node.Attribute.Quality}")">@node.Attribute.Quality</span>
<span class="text-muted small"
title="@node.Attribute.Timestamp.LocalDateTime.ToString("HH:mm:ss.fff")">
@node.Attribute.Timestamp.LocalDateTime.ToString("HH:mm:ss")
</span>
}
else
{
@* Branch — composition member. *@
<span class="fw-semibold">@node.Segment</span>
@if (node.HasBadQuality)
{
<span class="badge bg-warning text-dark ms-2"
aria-label="Contains bad-quality attributes"
title="One or more descendant attributes are off-Good quality">⚠ bad quality</span>
}
}
</NodeContent>
<EmptyContent>
<div class="text-muted small p-2">No attributes.</div>
</EmptyContent>
</TreeView>
</div>
@* ── Alarms tab ── *@
<div class="@(_activeTab == "alarms" ? "" : "d-none")"
data-test="debug-pane-alarms" role="tabpanel">
<div class="mb-2">
<input type="text" class="form-control form-control-sm"
style="max-width: 280px;"
placeholder="Filter by alarm…"
@bind="_alarmFilter" @bind:event="oninput" @bind:after="OnAlarmFilterChanged"
aria-label="Filter alarms" />
</div>
<TreeView TItem="DebugTreeNode" @ref="_alarmTree"
Items="AlarmForest"
ChildrenSelector="n => n.Children"
HasChildrenSelector="n => n.HasChildren"
KeySelector="n => n.Key"
InitiallyExpanded="n => true"
StorageKey="debugview.alarmTree">
<NodeContent Context="node">
@if (node.Alarm is not null)
{
@* Leaf — computed alarm or native condition. *@
<span class="me-2"
title="@BuildAlarmTooltip(node.Alarm)">@node.Segment</span>
@if (!string.IsNullOrEmpty(node.Alarm.Message))
{
<span class="text-info me-1" aria-label="Has operator message">💬</span>
}
<span class="badge @GetAlarmStateBadge(node.Alarm.State) me-1"
aria-label="@($"Alarm state: {node.Alarm.State}")">@node.Alarm.State</span>
<span class="badge @GetKindBadge(node.Alarm.Kind) me-1"
aria-label="@($"Alarm kind: {node.Alarm.Kind}")">@FormatKind(node.Alarm.Kind)</span>
@if (node.Alarm.Kind != AlarmKind.Computed)
{
@if (node.Alarm.Condition.Active && !node.Alarm.Condition.Acknowledged)
{
<span class="badge bg-warning text-dark me-1" aria-label="Unacknowledged">Unacked</span>
}
@if (node.Alarm.Condition.Shelve != AlarmShelveState.Unshelved)
{
<span class="badge bg-info text-dark me-1" title="@node.Alarm.Condition.Shelve"
aria-label="@($"Shelved: {node.Alarm.Condition.Shelve}")">Shelved</span>
}
@if (node.Alarm.Condition.Suppressed)
{
<span class="badge bg-info text-dark me-1" aria-label="Suppressed">Suppressed</span>
}
}
<span class="font-monospace small text-muted me-1"
aria-label="@($"Severity: {node.Alarm.Condition.Severity}")">sev @node.Alarm.Condition.Severity</span>
@if (node.Alarm.Level != AlarmLevel.None)
{
<span class="badge @GetAlarmLevelBadge(node.Alarm.Level) me-1"
aria-label="@($"Alarm level: {node.Alarm.Level}")">@FormatLevel(node.Alarm.Level)</span>
}
}
else if (node.IsNativeBinding)
{
@* Native source binding branch. *@
<span class="fw-semibold me-2">@node.Segment</span>
@if (node.ActiveCount > 0)
{
<span class="badge @GetAlarmStateBadge(node.WorstState)"
aria-label="@($"{node.ActiveCount} active conditions")">@node.ActiveCount active</span>
}
else if (!node.HasChildren)
{
<span class="text-muted small">no active conditions</span>
}
}
else
{
@* Generic composition branch. *@
<span class="fw-semibold me-2">@node.Segment</span>
@if (node.WorstState == AlarmState.Active)
{
<span class="badge bg-danger"
aria-label="@($"{node.ActiveCount} active alarms")">@node.ActiveCount active</span>
}
}
</NodeContent>
<EmptyContent>
<div class="text-muted small p-2">No alarms.</div>
</EmptyContent>
</TreeView>
</div>
</div>
</div>
}
else if (_connected)
{
<LoadingSpinner IsLoading="true" Message="Waiting for snapshot..." />
}
}
</div>
@code {
[SupplyParameterFromQuery] public int? SiteId { get; set; }
[SupplyParameterFromQuery] public int? InstanceId { get; set; }
private List<Site> _sites = new();
private List<Instance> _siteInstances = new();
private int _selectedSiteId;
private int _selectedInstanceId;
private bool _loading = true;
private bool _connected;
private bool _connecting;
private bool _connectedFromStorage;
// Which tab pane is visible — "attributes" (default) or "alarms".
private string _activeTab = "attributes";
private DebugViewSnapshot? _snapshot;
// Keyed dictionaries hold the latest value per attribute/alarm — the
// current-status source of truth the composition trees are built from.
private Dictionary<string, AttributeValueChanged> _attributeValues = new();
private Dictionary<string, AlarmStateChanged> _alarmStates = new();
// Per-tab name-contains filters.
private string _attrFilter = string.Empty;
private string _alarmFilter = string.Empty;
private TreeView<DebugTreeNode>? _attrTree;
private TreeView<DebugTreeNode>? _alarmTree;
/// <summary>
/// Current-status enumeration of the live attribute dictionary. Read only on
/// the render thread (CentralUI-021) — see <see cref="HandleStreamEvent"/>.
/// The trees render from <see cref="AttributeForest"/>; this ordered view is
/// the single render-thread reader of the raw dictionary.
/// </summary>
private IReadOnlyList<AttributeValueChanged> FilteredAttributeValues =>
string.IsNullOrWhiteSpace(_attrFilter)
? _attributeValues.Values.OrderBy(a => a.AttributeName).ToList()
: _attributeValues.Values
.Where(a => a.AttributeName.Contains(_attrFilter, StringComparison.OrdinalIgnoreCase))
.OrderBy(a => a.AttributeName)
.ToList();
/// <summary>Attribute composition forest, rebuilt from the live latest-per-name dictionary.</summary>
private IReadOnlyList<DebugTreeNode> AttributeForest =>
DebugTreeBuilder.BuildAttributeTree(_attributeValues.Values, _attrFilter);
/// <summary>Alarm composition forest, rebuilt from the live latest-per-name dictionary.</summary>
private IReadOnlyList<DebugTreeNode> AlarmForest =>
DebugTreeBuilder.BuildAlarmTree(_alarmStates.Values, _alarmFilter);
private DebugStreamSession? _session;
private ToastNotification _toast = default!;
private string? _initError;
// CentralUI-009: the stream callbacks (onEvent/onTerminated) run on an
// Akka/gRPC thread and capture `this` and `_toast`. Once the component is
// disposed, an in-flight callback must no-op rather than touch a disposed
// component (InvokeAsync would throw ObjectDisposedException) or a disposed
// ToastNotification.
private volatile bool _disposed;
protected override async Task OnInitializedAsync()
{
try
{
// Site scoping (CentralUI-002): a scoped Deployment user may only
// debug sites they are permitted on.
_sites = await SiteScope.FilterSitesAsync(await SiteRepository.GetAllSitesAsync());
}
catch (Exception ex)
{
_initError = $"Failed to load sites: {ex.Message}";
}
_loading = false;
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (!firstRender) return;
if (_initError != null)
{
_toast.ShowError(_initError);
_initError = null;
}
if (SiteId is > 0 && InstanceId is > 0)
{
_selectedSiteId = SiteId.Value;
await LoadInstancesForSite();
if (_siteInstances.Any(i => i.Id == InstanceId.Value))
{
_selectedInstanceId = InstanceId.Value;
await Connect();
}
else
{
_toast.ShowError("Requested instance is not available for debug streaming.");
}
StateHasChanged();
return;
}
var storedSiteId = await JS.InvokeAsync<string>("localStorage.getItem", "debugView.siteId");
var storedInstanceId = await JS.InvokeAsync<string>("localStorage.getItem", "debugView.instanceId");
if (!string.IsNullOrEmpty(storedSiteId) && int.TryParse(storedSiteId, out var siteId)
&& !string.IsNullOrEmpty(storedInstanceId) && int.TryParse(storedInstanceId, out var instanceId))
{
_selectedSiteId = siteId;
await LoadInstancesForSite();
_selectedInstanceId = instanceId;
_connectedFromStorage = true;
StateHasChanged();
await Connect();
// Auto-reconnect notice — the user didn't initiate this connection.
var inst = _siteInstances.FirstOrDefault(i => i.Id == instanceId);
_toast.ShowInfo(
$"Auto-reconnected to {inst?.UniqueName ?? "instance"} from previous session.",
autoDismissMs: 8000);
}
}
private async Task LoadInstancesForSite()
{
_siteInstances.Clear();
_selectedInstanceId = 0;
if (_selectedSiteId == 0) return;
// Site scoping (CentralUI-002): re-check the claim server-side — a query
// string or stale localStorage value could name a site outside the grant.
if (!await SiteScope.IsSiteAllowedAsync(_selectedSiteId))
{
_selectedSiteId = 0;
_toast.ShowError("You are not permitted to debug instances on that site.");
return;
}
try
{
_siteInstances = (await TemplateEngineRepository.GetInstancesBySiteIdAsync(_selectedSiteId))
.Where(i => i.State == InstanceState.Enabled)
.ToList();
}
catch (Exception ex)
{
_toast.ShowError($"Failed to load instances: {ex.Message}");
}
}
private void OnInstanceSelectionChanged()
{
// No-op; selection is tracked via _selectedInstanceId binding
}
/// <summary>
/// When the attribute filter changes, expand the tree so any branches holding
/// freshly-matched leaves are visible (the builder already prunes non-matches).
/// </summary>
private void OnAttrFilterChanged() => _attrTree?.ExpandAll();
/// <summary>As <see cref="OnAttrFilterChanged"/>, for the alarm tree.</summary>
private void OnAlarmFilterChanged() => _alarmTree?.ExpandAll();
private async Task Connect()
{
if (_selectedInstanceId == 0 || _selectedSiteId == 0) return;
_connecting = true;
try
{
var session = await DebugStreamService.StartStreamAsync(
_selectedInstanceId,
onEvent: HandleStreamEvent,
onTerminated: () =>
{
_connected = false;
_session = null;
// CentralUI-009: skip the toast/render if already disposed.
if (_disposed) return;
_ = SafeInvokeAsync(() =>
{
if (_disposed) return;
_toast.ShowError("Debug stream terminated (site disconnected).");
StateHasChanged();
});
});
// M2.11: the site returns InstanceNotFound=true when the instance is
// not deployed there (e.g. deployment not yet pushed, or wrong site).
if (session.InitialSnapshot.InstanceNotFound)
{
DebugStreamService.StopStream(session.SessionId);
_toast.ShowError(
"Instance not found on the selected site — check the deployment target.");
_connecting = false;
return;
}
_session = session;
// Populate initial state from snapshot
_attributeValues.Clear();
foreach (var av in session.InitialSnapshot.AttributeValues)
_attributeValues[av.AttributeName] = av;
_alarmStates.Clear();
foreach (var al in session.InitialSnapshot.AlarmStates)
_alarmStates[al.AlarmName] = al;
_snapshot = session.InitialSnapshot;
_connected = true;
// Persist selection to localStorage for auto-reconnect on refresh
await JS.InvokeVoidAsync("localStorage.setItem", "debugView.siteId", _selectedSiteId.ToString());
await JS.InvokeVoidAsync("localStorage.setItem", "debugView.instanceId", _selectedInstanceId.ToString());
var instance = _siteInstances.FirstOrDefault(i => i.Id == _selectedInstanceId);
_toast.ShowSuccess($"Streaming {instance?.UniqueName ?? "instance"}");
}
catch (Exception ex)
{
_toast.ShowError($"Connect failed: {ex.Message}");
}
_connecting = false;
}
private async Task Disconnect()
{
if (_session != null)
{
DebugStreamService.StopStream(_session.SessionId);
_session = null;
}
// Clear persisted selection — user explicitly disconnected
await JS.InvokeVoidAsync("localStorage.removeItem", "debugView.siteId");
await JS.InvokeVoidAsync("localStorage.removeItem", "debugView.instanceId");
_connected = false;
_connectedFromStorage = false;
_snapshot = null;
_attributeValues.Clear();
_alarmStates.Clear();
}
/// <summary>
/// Disconnect and forget the persisted selection. Surfaces in the status
/// strip whenever the page auto-reconnects from localStorage so the user
/// can opt out of the carry-over session.
/// </summary>
private async Task StartFresh()
{
await Disconnect();
_selectedSiteId = 0;
_selectedInstanceId = 0;
_siteInstances.Clear();
_toast.ShowInfo("Cleared previous session — select a site and instance to begin.", autoDismissMs: 5000);
}
/// <summary>
/// Handles one debug-stream event. The callback is invoked on an Akka/gRPC
/// thread, but <see cref="_attributeValues"/>/<see cref="_alarmStates"/> are
/// <see cref="Dictionary{TKey,TValue}"/> instances also enumerated by the
/// render thread (the tree forests + <see cref="FilteredAttributeValues"/> are
/// built from them). <c>Dictionary</c> is not thread-safe (CentralUI-021): a
/// write racing an enumeration can throw or corrupt the buckets. The mutation
/// is therefore marshalled onto the renderer's dispatcher via
/// <see cref="SafeInvokeAsync"/> so every access to the dictionaries — read
/// and write — happens on the render thread.
/// </summary>
private void HandleStreamEvent(object evt)
{
// CentralUI-009: the component may have been disposed while this event
// was in flight on the Akka/gRPC thread.
if (_disposed) return;
_ = SafeInvokeAsync(() =>
{
if (_disposed) return;
switch (evt)
{
case AttributeValueChanged av:
_attributeValues[av.AttributeName] = av;
break;
case AlarmStateChanged al:
_alarmStates[al.AlarmName] = al;
break;
default:
return;
}
StateHasChanged();
});
}
private static string GetQualityBadge(string quality) => quality switch
{
"Good" => "bg-success",
"Bad" => "bg-danger",
"Uncertain" => "bg-warning text-dark",
_ => "bg-secondary"
};
private static string GetAlarmStateBadge(AlarmState state) => state switch
{
AlarmState.Active => "bg-danger",
AlarmState.Normal => "bg-success",
_ => "bg-secondary"
};
/// <summary>
/// Severity-tinted badge class for HiLo alarm levels. The critical bands
/// (HighHigh / LowLow) get the danger class; warning bands get amber.
/// </summary>
private static string GetAlarmLevelBadge(AlarmLevel level) => level switch
{
AlarmLevel.HighHigh or AlarmLevel.LowLow => "bg-danger",
AlarmLevel.High or AlarmLevel.Low => "bg-warning text-dark",
_ => "bg-secondary"
};
/// <summary>Badge class distinguishing computed (neutral) from native (info) alarms.</summary>
private static string GetKindBadge(AlarmKind kind) => kind switch
{
AlarmKind.Computed => "bg-secondary",
_ => "bg-info text-dark"
};
/// <summary>Short display label for the alarm kind.</summary>
private static string FormatKind(AlarmKind kind) => kind switch
{
AlarmKind.NativeOpcUa => "OPC UA",
AlarmKind.NativeMxAccess => "MxAccess",
_ => "Computed"
};
/// <summary>
/// Builds the row tooltip from the alarm's operator message plus native
/// metadata (type, category, operator, raise time, current/limit value).
/// Returns null when there is nothing extra to show.
/// </summary>
private static string? BuildAlarmTooltip(AlarmStateChanged a)
{
var parts = new List<string>();
if (!string.IsNullOrEmpty(a.Message)) parts.Add(a.Message);
if (!string.IsNullOrEmpty(a.AlarmTypeName)) parts.Add($"Type: {a.AlarmTypeName}");
if (!string.IsNullOrEmpty(a.Category)) parts.Add($"Category: {a.Category}");
if (!string.IsNullOrEmpty(a.OperatorUser)) parts.Add($"By: {a.OperatorUser}");
if (!string.IsNullOrEmpty(a.OperatorComment)) parts.Add($"Comment: {a.OperatorComment}");
if (a.OriginalRaiseTime.HasValue) parts.Add($"Raised: {a.OriginalRaiseTime.Value.LocalDateTime:HH:mm:ss}");
if (!string.IsNullOrEmpty(a.CurrentValue)) parts.Add($"Value: {a.CurrentValue}");
if (!string.IsNullOrEmpty(a.LimitValue)) parts.Add($"Limit: {a.LimitValue}");
return parts.Count == 0 ? null : string.Join(" · ", parts);
}
private static string FormatLevel(AlarmLevel level) => level switch
{
AlarmLevel.HighHigh => "HiHi",
AlarmLevel.High => "Hi",
AlarmLevel.Low => "Lo",
AlarmLevel.LowLow => "LoLo",
_ => "—"
};
/// <summary>
/// Runs <paramref name="action"/> on the render thread, guarded against the
/// component being disposed mid-flight (CentralUI-009): <c>InvokeAsync</c>
/// throws <see cref="ObjectDisposedException"/> once the circuit is gone.
/// </summary>
private async Task SafeInvokeAsync(Action action)
{
if (_disposed) return;
try
{
await InvokeAsync(action);
}
catch (ObjectDisposedException)
{
// Component disposed between the guard and the dispatch — ignore.
}
}
public void Dispose()
{
// CentralUI-009: mark disposed first so any in-flight stream callback
// sees the flag and no-ops, then stop the stream synchronously.
_disposed = true;
if (_session != null)
{
DebugStreamService.StopStream(_session.SessionId);
}
}
}