using System.Diagnostics; using MeetingAssistant.Workflow; using Microsoft.Extensions.Options; namespace MeetingAssistant.MacOs; public sealed class MacOsWorkflowRulesEditorWindowService : IWorkflowRulesEditorWindowService { private readonly IOptions options; public MacOsWorkflowRulesEditorWindowService(IOptions options) { this.options = options; } public void Show() { if (!OperatingSystem.IsMacOS()) { return; } var url = $"{options.Value.Api.PublicBaseUrl.TrimEnd('/')}/diagnostics/settings-and-logs"; Process.Start(new ProcessStartInfo { FileName = "/usr/bin/open", ArgumentList = { url }, UseShellExecute = false }); } } public sealed class MacOsWorkflowRulesEditorSession { private readonly WorkflowRulesEditorChatViewModel viewModel; private readonly SemaphoreSlim sendLock = new(1, 1); public MacOsWorkflowRulesEditorSession(WorkflowRulesEditorChatViewModel viewModel) { this.viewModel = viewModel; } public async Task SendAsync( string? message, CancellationToken cancellationToken) { if (string.IsNullOrWhiteSpace(message)) { return Snapshot(); } await sendLock.WaitAsync(cancellationToken); try { viewModel.Draft = message; await viewModel.SendAsync(cancellationToken); return Snapshot(); } finally { sendLock.Release(); } } private MacOsWorkflowRulesEditorChatResponse Snapshot() { return new MacOsWorkflowRulesEditorChatResponse( viewModel.Messages .Where(item => item.Kind == WorkflowRulesEditorConversationItemKind.Message) .Select(item => new MacOsWorkflowRulesEditorMessage( item.Message!.Role.ToString().ToLowerInvariant(), item.Message.Content)) .ToArray()); } } public sealed record MacOsWorkflowRulesEditorChatRequest(string? Message); public sealed record MacOsWorkflowRulesEditorChatResponse( IReadOnlyList Messages); public sealed record MacOsWorkflowRulesEditorMessage(string Role, string Content); public static class MacOsWorkflowRulesEditorPage { public const string Html = """ Meeting Summary Agent

Meeting Summary Agent

"""; }