fix(ui): preserve precise audit submissions and adopt delivered secrets

This commit is contained in:
Joseph Doherty
2026-11-13 19:42:53 -05:00
parent 9dbfe7bcaf
commit d370dbd37c
80 changed files with 12778 additions and 77 deletions
@@ -16,8 +16,8 @@
}
.drawer-pre.json {
/* JSON blocks get a faint left rule so they read as quoted material. */
border-left: 3px solid var(--bs-info-border-subtle);
/* JSON blocks retain a thin shared rule without a decorative status bar. */
border-left: 1px solid var(--rule-strong);
}
.drawer-pre code.language-sql {
@@ -8,10 +8,8 @@
<form class="card mb-3" data-test="audit-filter-bar" aria-label="Audit filters" @onsubmit="Apply" @onsubmit:preventDefault>
<div class="card-body py-2">
@* All filters sit in one wrapped row. Kind / Status / Site use compact
MultiSelectDropdown controls; Channel is a single-select because the
Kind options narrow to the chosen channel — so the bar stays a row or
two tall instead of four stacked blocks of chip buttons. *@
@* Common filters stay visible; native More filters retains rare draft inputs.
Submission and query success are separate states owned by their callers. *@
<div class="row g-2 align-items-end">
@* Single-select: one channel at a time, so the Kind options below
narrow cleanly to that channel. "All channels" clears it. *@
@@ -34,7 +32,7 @@
<MultiSelectDropdown TValue="AuditKind"
Items="_model.VisibleKinds()"
Selected="_model.Kinds"
LabelledBy="audit-kind-label" DataTest="filter-kind-ms" />
SelectionChanged="RefreshDraftState" LabelledBy="audit-kind-label" DataTest="filter-kind-ms" />
</div>
</div>
@@ -44,7 +42,7 @@
<MultiSelectDropdown TValue="AuditStatus"
Items="_statuses"
Selected="_model.Statuses"
LabelledBy="audit-status-label" DataTest="filter-status-ms" />
SelectionChanged="RefreshDraftState" LabelledBy="audit-status-label" DataTest="filter-status-ms" />
</div>
</div>
@@ -56,22 +54,7 @@
Selected="_model.SiteIdentifiers"
Display="SiteName"
EmptyText="No sites available"
LabelledBy="audit-site-label" DataTest="filter-site-ms" />
</div>
</div>
@* Node multi-select. Options are the distinct SourceNode values
observed in the AuditLog table; the service-side lookup is cached
for 60s so a render of this bar costs at most one DB hit per
minute per circuit. *@
<div class="col-auto" data-test="filter-node">
<label id="audit-node-label" class="form-label small mb-1">Node</label>
<div>
<MultiSelectDropdown TValue="string"
Items="_sourceNodes"
Selected="_model.SourceNodes"
EmptyText="No nodes available"
LabelledBy="audit-node-label" DataTest="filter-node-ms" />
SelectionChanged="RefreshDraftState" LabelledBy="audit-site-label" DataTest="filter-site-ms" />
</div>
</div>
@@ -119,6 +102,48 @@
}
</div>
<div class="col-auto" data-test="filter-errors-only">
<div class="form-check mb-1">
<input class="form-check-input" type="checkbox" id="audit-errors-only"
@bind="_model.ErrorsOnly" />
<label class="form-check-label small" for="audit-errors-only">Errors only</label>
</div>
</div>
<div class="col-auto ms-auto">
<div class="btn-group btn-group-sm" role="group">
<button type="button" class="btn btn-outline-secondary"
@onclick="ClearFilters" data-test="filter-clear">Clear</button>
<button type="submit" class="btn btn-primary" data-test="filter-apply">Apply</button>
</div>
</div>
</div>
@if (_executionIdError is not null)
{
<p id="audit-execution-id-error" class="field-error s-bad small mt-2 mb-0" role="alert">@_executionIdError</p>
}
@if (_parentExecutionIdError is not null)
{
<p id="audit-parent-execution-id-error" class="field-error s-bad small mt-2 mb-0" role="alert">@_parentExecutionIdError</p>
}
<details class="mt-2" data-test="filter-more">
<summary>More filters (@AdvancedFilterCount @(AdvancedFilterCount == 1 ? "field set" : "fields set"))</summary>
<div class="row g-2 align-items-end mt-1">
@* Node multi-select. Options are the distinct SourceNode values
observed in the AuditLog table; the service-side lookup is cached
for 60s so a render of this bar costs at most one DB hit per
minute per circuit. *@
<div class="col-auto" data-test="filter-node">
<label id="audit-node-label" class="form-label small mb-1">Node</label>
<div>
<MultiSelectDropdown TValue="string"
Items="_sourceNodes"
Selected="_model.SourceNodes"
EmptyText="No nodes available"
SelectionChanged="RefreshDraftState" LabelledBy="audit-node-label" DataTest="filter-node-ms" />
</div>
</div>
<div class="col-auto" data-test="filter-instance">
<label class="form-label small mb-1" for="audit-instance">Instance</label>
<input id="audit-instance" type="text" class="form-control form-control-sm"
@@ -144,40 +169,36 @@
</div>
@* ExecutionId is an exact-match Guid filter — the operator pastes the
universal per-run correlation value. Lax-parsed in ToFilter so a
blank/malformed paste simply drops the constraint. *@
universal per-run correlation value. Validated here before submission; blank remains unconstrained. *@
<div class="col-auto" data-test="filter-execution-id">
<label class="form-label small mb-1" for="audit-execution-id">Execution ID</label>
<input id="audit-execution-id" type="text"
class="form-control form-control-sm font-monospace"
placeholder="paste GUID…" @bind="_model.ExecutionId" />
placeholder="paste GUID…" @bind="_model.ExecutionId"
aria-invalid="@(_executionIdError is not null ? "true" : null)"
aria-describedby="@(_executionIdError is not null ? "audit-execution-id-error" : null)" />
</div>
@* ParentExecutionId is an exact-match Guid filter — the operator pastes
the spawner execution's id to find every run it spawned. Lax-parsed
in ToFilter, exactly like ExecutionId above. *@
the spawner execution's id to find every run it spawned. Validated here before submission, like ExecutionId above. *@
<div class="col-auto" data-test="filter-parent-execution-id">
<label class="form-label small mb-1" for="audit-parent-execution-id">Parent execution ID</label>
<input id="audit-parent-execution-id" type="text"
class="form-control form-control-sm font-monospace"
placeholder="paste GUID…" @bind="_model.ParentExecutionId" />
placeholder="paste GUID…" @bind="_model.ParentExecutionId"
aria-invalid="@(_parentExecutionIdError is not null ? "true" : null)"
aria-describedby="@(_parentExecutionIdError is not null ? "audit-parent-execution-id-error" : null)" />
</div>
<div class="col-auto" data-test="filter-errors-only">
<div class="form-check mb-1">
<input class="form-check-input" type="checkbox" id="audit-errors-only"
@bind="_model.ErrorsOnly" />
<label class="form-check-label small" for="audit-errors-only">Errors only</label>
</div>
</div>
<div class="col-auto ms-auto">
<div class="btn-group btn-group-sm" role="group">
<button type="button" class="btn btn-outline-secondary"
@onclick="ClearFilters" data-test="filter-clear">Clear</button>
<button type="submit" class="btn btn-primary" data-test="filter-apply">Apply</button>
</div>
</div>
</div>
</details>
@if (_lastSubmittedSummary is not null)
{
<p class="small text-break mt-2 mb-0" data-test="filter-submitted-summary" role="status">Last submitted filters: @_lastSubmittedSummary</p>
}
@if (_lastSubmittedSignature is not null && _lastSubmittedSignature != DraftSignature())
{
<p class="small text-muted mb-0" data-test="filter-pending">Unsubmitted changes</p>
}
</div>
</form>
@@ -23,6 +23,38 @@ public partial class AuditFilterBar
private string _customFromText = string.Empty;
private string _customToText = string.Empty;
private string? _customRangeError;
private string? _executionIdError;
private string? _parentExecutionIdError;
private string? _lastSubmittedSignature;
private string? _lastSubmittedSummary;
private int AdvancedFilterCount => (_model.SourceNodes.Count > 0 ? 1 : 0)
+ new[] { _model.InstanceSearch, _model.ScriptSearch, _model.TargetSearch, _model.ActorSearch,
_model.ExecutionId, _model.ParentExecutionId }.Count(value => !string.IsNullOrWhiteSpace(value));
// Existing child selection callbacks refresh the parent after a multiselect mutates its set.
private void RefreshDraftState() { }
private string DraftSignature() => System.Text.Json.JsonSerializer.Serialize(new
{
channels = _model.Channels.Order(), kinds = _model.Kinds.Order(), statuses = _model.Statuses.Order(),
sites = _model.SiteIdentifiers.Order(StringComparer.OrdinalIgnoreCase), nodes = _model.SourceNodes.Order(StringComparer.OrdinalIgnoreCase),
_model.TimeRange, _customFromText, _customToText, _model.InstanceSearch, _model.ScriptSearch,
_model.TargetSearch, _model.ActorSearch, _model.ExecutionId, _model.ParentExecutionId, _model.ErrorsOnly
});
private static string SubmittedSummary(AuditLogQueryFilter filter)
{
var parts = new List<string>();
void List<T>(string label, IReadOnlyList<T>? values) { if (values?.Count > 0) parts.Add(label + ": " + string.Join(", ", values)); }
List("Channel", filter.Channels); List("Kind", filter.Kinds); List("Status", filter.Statuses);
List("Site", filter.SourceSiteIds); List("Node", filter.SourceNodes);
if (filter.Target is not null) parts.Add("Target: " + filter.Target);
if (filter.Actor is not null) parts.Add("Actor: " + filter.Actor);
if (filter.ExecutionId is { } execution) parts.Add("Execution ID: " + execution);
if (filter.ParentExecutionId is { } parent) parts.Add("Parent execution ID: " + parent);
parts.Add("UTC window: " + (filter.FromUtc?.ToString("u") ?? "open start") + " → " + (filter.ToUtc?.ToString("u") ?? "open end"));
return string.Join(" · ", parts);
}
private List<Site> _sites = new();
/// <summary>Channel options — the full enum, fixed for the component's lifetime.</summary>
@@ -158,7 +190,7 @@ public partial class AuditFilterBar
_model.SourceNodes.Clear();
_model.TimeRange = AuditTimeRangePreset.LastHour;
_customFromText = _customToText = string.Empty;
_customRangeError = null;
_customRangeError = _executionIdError = _parentExecutionIdError = null;
_model.CustomFromUtc = null;
_model.CustomToUtc = null;
_model.InstanceSearch = string.Empty;
@@ -173,6 +205,9 @@ public partial class AuditFilterBar
private async Task Apply()
{
_customRangeError = null;
_executionIdError = IsEmptyOrGuid(_model.ExecutionId) ? null : "Execution ID: enter a valid GUID in More filters, or clear the field.";
_parentExecutionIdError = IsEmptyOrGuid(_model.ParentExecutionId) ? null : "Parent execution ID: enter a valid GUID in More filters, or clear the field.";
if (_executionIdError is not null || _parentExecutionIdError is not null) return;
if (_model.TimeRange == AuditTimeRangePreset.Custom)
{
if (!TryUtcInput(_customFromText, out var from) || !TryUtcInput(_customToText, out var to))
@@ -189,9 +224,17 @@ public partial class AuditFilterBar
_model.CustomToUtc = to;
}
var now = NowUtcProvider?.Invoke() ?? DateTime.UtcNow;
await OnFilterChanged.InvokeAsync(_model.ToFilter(now));
var filter = _model.ToFilter(now);
var signature = DraftSignature();
// Capture submission order before awaiting the caller: an earlier slow callback must not
// overwrite a later submission. Submitted never claims the grid query succeeded.
_lastSubmittedSignature = signature;
_lastSubmittedSummary = SubmittedSummary(filter);
await OnFilterChanged.InvokeAsync(filter);
}
private static bool IsEmptyOrGuid(string text) => string.IsNullOrWhiteSpace(text) || Guid.TryParse(text, out _);
private static bool TryUtcInput(string raw, out DateTime? value)
{
value = null;
@@ -74,7 +74,6 @@
::deep .fsd-exc {
border: 1px solid var(--bad, var(--bs-danger, #e03131));
border-left-width: 4px;
border-radius: 4px;
background: var(--bad-bg, rgba(var(--bs-danger-rgb, 220, 53, 69), 0.08));
padding: 8px 12px;
@@ -6,7 +6,7 @@
.ft-row { cursor: pointer; }
.ft-row:hover, .ft-row:focus-visible { background: var(--active-bg); }
.ft-row.selected { background: var(--active-bg); box-shadow: inset 3px 0 0 var(--accent); }
.ft-row.failed { box-shadow: inset 3px 0 0 var(--bs-danger, #c0392b); }
.ft-row.failed { box-shadow: inset 1px 0 0 var(--bad-border); }
.ft-title { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 0.8rem; }
.ft-pill { font-size: 0.7rem; border: 1px solid var(--rule-strong); border-radius: 10px; padding: 0 6px; }
.ft-pill.ok { color: var(--ok-ink, #2e7d32); }