csharpcf25d736 | 1 | using CascadeIDE.Contracts.Experimental.Capabilities; |
| 2 | using CascadeIDE.Features.UiChrome; |
| 3 | |
| 4 | namespace CascadeIDE.Services.Capabilities; |
| 5 | |
| 6 | /// <summary> |
| 7 | /// Проверка согласованности <see cref="UiSurfaceCapabilityDescriptor.PrimaryAttentionZoneId"/> и |
| 8 | /// <see cref="UiSurfaceCapabilityDescriptor.HostAttentionPanelId"/> с текущей картой |
| 9 | /// <see cref="AttentionZonePanelRuntime"/> (дефолты + overlay из workspace TOML). |
| 10 | /// </summary> |
| 11 | public static class CapabilityAttentionConsistency |
| 12 | { |
| 13 | /// <summary> |
| 14 | /// Если заданы оба поля, возвращает сообщение при неизвестной панели или рассинхроне зоны с рантайм-картой; иначе <see langword="null"/>. |
| 15 | /// </summary> |
| 16 | public static string? TryGetUiSurfaceIssue(UiSurfaceCapabilityDescriptor d) |
| 17 | { |
| 18 | if (string.IsNullOrWhiteSpace(d.HostAttentionPanelId) || string.IsNullOrWhiteSpace(d.PrimaryAttentionZoneId)) |
| 19 | return null; |
| 20 | |
| 21 | var panelId = d.HostAttentionPanelId.Trim(); |
| 22 | var zoneId = d.PrimaryAttentionZoneId.Trim(); |
| 23 | |
| 24 | if (!AttentionZonePanelRuntime.TryGetZone(panelId, out var zone)) |
| 25 | { |
| 26 | return |
| 27 | $"UiSurface '{d.Id}': host panel '{panelId}' is not in AttentionZonePanelRuntime (add default map entry or fix id)."; |
| 28 | } |
| 29 | |
| 30 | var canonical = zone.ToCanonicalId(); |
| 31 | if (canonical != zoneId) |
| 32 | { |
| 33 | return |
| 34 | $"UiSurface '{d.Id}': PrimaryAttentionZoneId '{zoneId}' does not match AttentionZonePanelRuntime for panel '{panelId}' (expected '{canonical}')."; |
| 35 | } |
| 36 | |
| 37 | return null; |
| 38 | } |
| 39 | } |
| 40 | |
View only · write via MCP/CIDE