fix(central-ui): LogsTruncated clears once a refresh merges in more log rows; badge reworded (Task 13 review)

This commit is contained in:
Joseph Doherty
2026-09-09 12:48:00 -04:00
parent 032598607e
commit 25c6e9ca8a
3 changed files with 115 additions and 6 deletions
@@ -199,7 +199,7 @@
}
@if (_graph?.LogsTruncated == true)
{
<span class="badge bg-warning text-dark" data-test="flow-logs-truncated">log lines truncated inline — Replay is complete</span>
<span class="badge bg-warning text-dark" data-test="flow-logs-truncated">inline log lines capped — refresh outcomes pulls the rest</span>
}
@if (_graph?.UnattachedLogLines > 0)
{
@@ -685,14 +685,22 @@ public partial class FlowDebugger : ComponentBase, IDisposable
var selectedId = _selected?.EventId;
var merged = MergeEvents(_raw.Events, outcome.Raw?.Events);
var truncated = _raw.Truncated || outcome.Raw?.Truncated == true;
// Truncation is sticky across a refresh, exactly as the event-list flag is: the Live run's
// inline copy stays the incomplete one whatever the re-read brought back (D7).
var logsTruncated = _raw.LogsTruncated || outcome.Raw?.LogsTruncated == true;
// D7: the inline copy's cap is only worth reporting while the page still holds that
// incomplete copy. A refresh MERGES rows, so the moment it brings back even one ScriptLog
// row the run did not already have, the page is no longer short of lines and the flag
// clears. Until then it stays: the site's rows reach central's audit store by telemetry
// 5-30 s later, so a refresh that adds nothing proves nothing.
var logsTruncated = (_raw.LogsTruncated || outcome.Raw?.LogsTruncated == true)
&& CountLogRows(merged) <= CountLogRows(_raw.Events);
_raw = _raw with { Events = merged, Truncated = truncated, LogsTruncated = logsTruncated };
_graph = FlowGraphBuilder.Build(merged, truncated, logsTruncated);
_selected = selectedId is { } id ? _graph.Steps.FirstOrDefault(s => s.EventId == id) ?? _selected : _selected;
}
/// <summary>Number of <c>ScriptTrace.ScriptLog</c> rows in <paramref name="events"/> — the log lines a refresh can add to.</summary>
private static int CountLogRows(IReadOnlyList<AuditEvent>? events)
=> events?.Count(FlowStepProjector.IsLogLine) ?? 0;
/// <summary>Union of two audit-row lists by <see cref="AuditEvent.EventId"/>; a row present in both takes the fresh copy.</summary>
internal static IReadOnlyList<AuditEvent> MergeEvents(IReadOnlyList<AuditEvent>? known, IReadOnlyList<AuditEvent>? fresh)
{