mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-18 12:38:00 +00:00
Added the visual briefing assistant (#893)
Build and Release / Determine run mode (push) Has been cancelled
Build and Release / Read metadata (push) Has been cancelled
Build and Release / Sync Flatpak repo (push) Has been cancelled
Build and Release / Collect Flatpak artifacts (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg,app,updater, dmg) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis,updater, nsis) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage,updater, appimage) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg,app,updater, dmg) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis,updater, nsis) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage,updater, appimage) (push) Has been cancelled
Build and Release / Prepare & create release (push) Has been cancelled
Build and Release / Publish release (push) Has been cancelled
Build and Release / Determine run mode (push) Has been cancelled
Build and Release / Read metadata (push) Has been cancelled
Build and Release / Sync Flatpak repo (push) Has been cancelled
Build and Release / Collect Flatpak artifacts (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg,app,updater, dmg) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis,updater, nsis) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage,updater, appimage) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg,app,updater, dmg) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis,updater, nsis) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage,updater, appimage) (push) Has been cancelled
Build and Release / Prepare & create release (push) Has been cancelled
Build and Release / Publish release (push) Has been cancelled
This commit is contained in:
1 parent
df4663fff4
commit
58cc811a58
214 files changed
+18943
-353
No files matched your search
@@ -0,0 +1,71 @@
|
||||
using System.Text;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace AIStudio.Assistants.VisualBriefing;
|
||||
|
||||
/// <summary>
|
||||
/// Compiles interaction state and safe declarative controls.
|
||||
/// </summary>
|
||||
internal static class VisualBriefingInteractionCompiler
|
||||
{
|
||||
/// <summary>
|
||||
/// Compiles controls and formulas into deterministic runtime state.
|
||||
/// </summary>
|
||||
/// <param name="controls">The validated interaction controls.</param>
|
||||
/// <param name="formulas">The validated formula specifications.</param>
|
||||
/// <returns>The declarative interaction data.</returns>
|
||||
internal static JsonElement Compile(IReadOnlyList<VisualBriefingControlSpec> controls, IReadOnlyList<VisualBriefingFormulaSpec> formulas)
|
||||
{
|
||||
var state = controls.ToDictionary(
|
||||
control => control.ControlId,
|
||||
control => control.InitialValue.Clone(),
|
||||
StringComparer.Ordinal);
|
||||
|
||||
var formulaMap = formulas.ToDictionary(
|
||||
formula => formula.OutputSlotId,
|
||||
formula => formula.Formula,
|
||||
StringComparer.Ordinal);
|
||||
|
||||
return JsonSerializer.SerializeToElement(new
|
||||
{
|
||||
controls,
|
||||
state,
|
||||
formulas = formulaMap,
|
||||
}, VisualBriefingJson.Canonical);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compiles safe control markup for one component.
|
||||
/// </summary>
|
||||
/// <param name="componentId">The owning component identifier.</param>
|
||||
/// <param name="controls">All validated briefing controls.</param>
|
||||
/// <returns>The declarative control markup.</returns>
|
||||
internal static string CompileMarkup(string componentId, IReadOnlyList<VisualBriefingControlSpec> controls)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
foreach (var indexed in controls.Select((control, index) => (Control: control, Index: index)).Where(item => item.Control.ComponentId == componentId))
|
||||
{
|
||||
var control = indexed.Control;
|
||||
var id = HtmlEncoder.Default.Encode(control.ControlId);
|
||||
var accessibilityPath = $"accessibility.{HtmlEncoder.Default.Encode(componentId)}";
|
||||
|
||||
builder.Append(control.Kind switch
|
||||
{
|
||||
VisualBriefingControlKind.SELECT or VisualBriefingControlKind.FILTER => $"<select data-mwai-model=\"interactions.state.{id}\" data-mwai-attr-aria-label=\"{accessibilityPath}\"><template data-mwai-each=\"interactions.controls.{indexed.Index}.options\"><option data-mwai-attr-value=\".value\" data-mwai-text=\".label\"></option></template></select>",
|
||||
VisualBriefingControlKind.RANGE => $"<input type=\"range\" data-mwai-model=\"interactions.state.{id}\" data-mwai-attr-aria-label=\"{accessibilityPath}\">",
|
||||
VisualBriefingControlKind.NUMBER => $"<input type=\"number\" data-mwai-model=\"interactions.state.{id}\" data-mwai-attr-aria-label=\"{accessibilityPath}\">",
|
||||
_ => string.Empty,
|
||||
});
|
||||
}
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compiles a deterministic reset action for one simulation component.
|
||||
/// </summary>
|
||||
/// <param name="componentId">The simulation component identifier.</param>
|
||||
/// <returns>The declarative reset button markup.</returns>
|
||||
internal static string CompileResetMarkup(string componentId) => $"<button type=\"button\" data-mwai-reset=\"{HtmlEncoder.Default.Encode(componentId)}\" data-mwai-text=\"labels.reset\"></button>";
|
||||
}
|
||||
Reference in new issue
Block a user