From 576f7b4fde0046d59066029a253c09c0df9cc332 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 31 May 2026 13:06:22 +0100 Subject: [PATCH] Mirror Eve surface trees over CultMesh --- docs/eve-dashboard.md | 4 ++ src/Mimir.EveDashboard/Program.cs | 50 ++++++++++++++++- .../Synchronization/MimirCultMeshContracts.cs | 53 ++++++++++++++++++- 3 files changed, 105 insertions(+), 2 deletions(-) diff --git a/docs/eve-dashboard.md b/docs/eve-dashboard.md index 97d8d66..9046beb 100644 --- a/docs/eve-dashboard.md +++ b/docs/eve-dashboard.md @@ -150,3 +150,7 @@ The old `nodes` array is no longer expected to carry complete UI composition. It is a compatibility/debug/data surface. Clients that understand `surface` should render the composed tree first and use `nodes` only for selection, state-path binding, and fallback. + +The binary CultMesh state document mirrors this ownership: field 7 carries the +optional `surface` tree. Older clients can stop at the node projection; current +Eve clients should prefer `surface.root` whenever it is present. diff --git a/src/Mimir.EveDashboard/Program.cs b/src/Mimir.EveDashboard/Program.cs index 7d96495..be5c39b 100644 --- a/src/Mimir.EveDashboard/Program.cs +++ b/src/Mimir.EveDashboard/Program.cs @@ -311,7 +311,8 @@ internal sealed class EveDashboardServer(int port, EveDashboardProviderCatalog p node.Health, node.ProviderId, node.Command, - node.Endpoint)).ToArray()); + node.Endpoint)).ToArray(), + ToCultMeshSurface(state.Surface)); await SendBinaryFrameAsync(socket.Stream, MessagePackSerializer.Serialize(document)).ConfigureAwait(false); return; } @@ -319,6 +320,53 @@ internal sealed class EveDashboardServer(int port, EveDashboardProviderCatalog p await SendTextFrameAsync(socket.Stream, JsonSerializer.Serialize(state, JsonOptions)).ConfigureAwait(false); } + private static MimirEveDashboardSurfaceSnapshot? ToCultMeshSurface(DashboardSurface? surface) + { + if (surface == null) + { + return null; + } + + return new MimirEveDashboardSurfaceSnapshot( + surface.Schema, + surface.Id, + surface.Title, + ToCultMeshElement(surface.Root), + surface.Assets + .Select(static asset => new MimirEveDashboardSurfaceAssetSnapshot(asset.Id, asset.Kind, asset.Uri)) + .ToArray()); + } + + private static MimirEveDashboardUiElementSnapshot ToCultMeshElement(DashboardUiElement element) + { + return new MimirEveDashboardUiElementSnapshot( + element.Id, + element.Kind, + element.Role, + element.Text, + element.AssetRef, + element.AssetUri, + element.BindNodeId, + element.CommandId, + element.Layout == null + ? null + : new MimirEveDashboardUiLayoutSnapshot( + element.Layout.Direction, + element.Layout.Width, + element.Layout.Height, + element.Layout.Grow, + element.Layout.Gap, + element.Layout.Padding, + element.Layout.Overflow), + element.Style == null + ? null + : new MimirEveDashboardUiStyleSnapshot(element.Style.Variant, element.Style.Tone), + element.Metric == null + ? null + : new MimirEveDashboardUiMetricSnapshot(element.Metric.Label, element.Metric.Value, element.Metric.Tone), + element.Children.Select(ToCultMeshElement).ToArray()); + } + private async Task BroadcastStateAsync() { foreach (var (id, socket) in clients) diff --git a/src/Mimir.Runtime/Synchronization/MimirCultMeshContracts.cs b/src/Mimir.Runtime/Synchronization/MimirCultMeshContracts.cs index 794bb7c..410477d 100644 --- a/src/Mimir.Runtime/Synchronization/MimirCultMeshContracts.cs +++ b/src/Mimir.Runtime/Synchronization/MimirCultMeshContracts.cs @@ -129,7 +129,8 @@ public sealed record MimirEveDashboardStateDocument( [property: Key(3)] string UpdatedAtUtc, [property: Key(4)] string SelectedNodeId, [property: Key(5)] string LutPreset, - [property: Key(6)] MimirEveDashboardNodeSnapshot[] Nodes); + [property: Key(6)] MimirEveDashboardNodeSnapshot[] Nodes, + [property: Key(7)] MimirEveDashboardSurfaceSnapshot? Surface); [MessagePackObject] public sealed record MimirEveDashboardNodeSnapshot( @@ -149,6 +150,56 @@ public sealed record MimirEveDashboardNodeSnapshot( [property: Key(13)] string? Command, [property: Key(14)] string? Endpoint); +[MessagePackObject] +public sealed record MimirEveDashboardSurfaceSnapshot( + [property: Key(0)] string Schema, + [property: Key(1)] string Id, + [property: Key(2)] string Title, + [property: Key(3)] MimirEveDashboardUiElementSnapshot Root, + [property: Key(4)] MimirEveDashboardSurfaceAssetSnapshot[] Assets); + +[MessagePackObject] +public sealed record MimirEveDashboardSurfaceAssetSnapshot( + [property: Key(0)] string Id, + [property: Key(1)] string Kind, + [property: Key(2)] string Uri); + +[MessagePackObject] +public sealed record MimirEveDashboardUiElementSnapshot( + [property: Key(0)] string Id, + [property: Key(1)] string Kind, + [property: Key(2)] string? Role, + [property: Key(3)] string? Text, + [property: Key(4)] string? AssetRef, + [property: Key(5)] string? AssetUri, + [property: Key(6)] string? BindNodeId, + [property: Key(7)] string? CommandId, + [property: Key(8)] MimirEveDashboardUiLayoutSnapshot? Layout, + [property: Key(9)] MimirEveDashboardUiStyleSnapshot? Style, + [property: Key(10)] MimirEveDashboardUiMetricSnapshot? Metric, + [property: Key(11)] MimirEveDashboardUiElementSnapshot[] Children); + +[MessagePackObject] +public sealed record MimirEveDashboardUiLayoutSnapshot( + [property: Key(0)] string Direction, + [property: Key(1)] double? Width, + [property: Key(2)] double? Height, + [property: Key(3)] double? Grow, + [property: Key(4)] double? Gap, + [property: Key(5)] double? Padding, + [property: Key(6)] string? Overflow); + +[MessagePackObject] +public sealed record MimirEveDashboardUiStyleSnapshot( + [property: Key(0)] string Variant, + [property: Key(1)] string? Tone); + +[MessagePackObject] +public sealed record MimirEveDashboardUiMetricSnapshot( + [property: Key(0)] string Label, + [property: Key(1)] double Value, + [property: Key(2)] string Tone); + [CultDocument("mimir.eve_dashboard_command", "mimir.eve_dashboard_command.v1")] [MessagePackObject] public sealed record MimirEveDashboardCommandDocument(