a9e8f5abfe
I-1 - a non-C# paste produced thousands of Roslyn markers. The Problems-list report sent them all as one JS->.NET message, which could exceed the 1 MB hub limit and kill the circuit. The JS now sends at most MaxReportedMarkers (200) markers, errors first, each message cut to 300 chars, plus the total. ScriptProblemReport.FromEditor clamps again on arrival, and the Problems list shows "showing N of Total" / "+N more". The diagnostics endpoint also bounds its response: Distinct, errors first, MaxDiagnosticMarkers (1000), messages cut to 1000 chars. An error is always kept, so editor-accepts == publish-accepts. M-1 - drop the per-instance compilation lineage; analyses derive from BaseCompilation. M-2 - the VirtualTag modal clears its problems (and editor ref) on close and on a script reload. M-5 - an over-limit text is announced at blur (OnSyncRefused), not only at Save. Refs #745 Claude-Session: https://claude.ai/code/session_01Ub9hGmYLQvn9XETzw7CMsT
61 lines
2.9 KiB
Plaintext
61 lines
2.9 KiB
Plaintext
@namespace ZB.MOM.WW.OtOpcUa.AdminUI.Components.Shared
|
|
@using ZB.MOM.WW.OtOpcUa.AdminUI.ScriptAnalysis
|
|
@* The script editor's Problems list. Fed by MonacoEditor.MarkersChanged; clicking a row calls OnSelect, which the
|
|
host wires to MonacoEditor.RevealLineAsync so the caret jumps to the problem. Ordering and wording live in
|
|
ScriptProblems (unit-tested). *@
|
|
|
|
@{
|
|
var report = Report ?? ScriptProblemReport.Empty;
|
|
var ordered = ScriptProblems.Order(report.Markers);
|
|
}
|
|
<div class="script-problems mt-2 small" role="region" aria-label="Problems">
|
|
<div class="d-flex align-items-center gap-2 text-muted mb-1">
|
|
<span class="fw-semibold">Problems</span>
|
|
<span>@ScriptProblems.Summary(report with { Markers = ordered })</span>
|
|
</div>
|
|
@if (ordered.Count > 0)
|
|
{
|
|
<ul class="list-group list-group-flush border rounded" style="max-height: 10rem; overflow-y: auto;">
|
|
@foreach (var m in ordered.Take(MaxRows))
|
|
{
|
|
<li class="list-group-item list-group-item-action py-1 px-2 d-flex gap-2 align-items-baseline"
|
|
role="button" tabindex="0" style="cursor: pointer;"
|
|
title="Go to line @m.StartLineNumber, column @m.StartColumn"
|
|
@onclick="() => OnSelect.InvokeAsync(m)"
|
|
@onkeydown="e => OnKeyAsync(e, m)">
|
|
<span class="badge @BadgeClass(m.Severity)">@ScriptProblems.SeverityLabel(m.Severity)</span>
|
|
<span class="mono text-muted">@m.StartLineNumber:@m.StartColumn</span>
|
|
<span class="flex-grow-1">@m.Message</span>
|
|
<span class="mono text-muted">@m.Code</span>
|
|
</li>
|
|
}
|
|
</ul>
|
|
@if (report.Total > Math.Min(ordered.Count, MaxRows))
|
|
{
|
|
@* The editor reports at most ScriptEditorLimits.MaxReportedMarkers problems (one circuit message); the
|
|
rest are still squiggled in the editor. *@
|
|
<div class="text-muted mt-1">+@(report.Total - Math.Min(ordered.Count, MaxRows)) more — fix the problems above, or scroll the editor to see them all.</div>
|
|
}
|
|
}
|
|
</div>
|
|
|
|
@code {
|
|
private const int MaxRows = ScriptEditorLimits.MaxReportedMarkers;
|
|
|
|
/// <summary>The report the editor last sent (null before the first diagnostics pass).</summary>
|
|
[Parameter] public ScriptProblemReport? Report { get; set; }
|
|
|
|
/// <summary>Raised when the author picks a problem; wire it to <c>MonacoEditor.RevealLineAsync</c>.</summary>
|
|
[Parameter] public EventCallback<DiagnosticMarker> OnSelect { get; set; }
|
|
|
|
private Task OnKeyAsync(KeyboardEventArgs e, DiagnosticMarker m)
|
|
=> e.Key is "Enter" or " " ? OnSelect.InvokeAsync(m) : Task.CompletedTask;
|
|
|
|
private static string BadgeClass(int severity) => severity switch
|
|
{
|
|
ScriptProblems.Error => "text-bg-danger",
|
|
ScriptProblems.Warning => "text-bg-warning",
|
|
_ => "text-bg-secondary",
|
|
};
|
|
}
|