Archive completed meeting assistant changes
PR and Push Build/Test / build-and-test (push) Successful in 9m19s

This commit is contained in:
2026-06-26 13:15:47 +02:00
parent 7d16b0cad7
commit aecef30627
72 changed files with 2914 additions and 406 deletions
@@ -3,6 +3,7 @@ using System.Text;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.RegularExpressions;
using MeetingAssistant.MeetingNotes;
namespace MeetingAssistant.Screenshots;
@@ -104,41 +105,69 @@ public sealed partial class LiteLlmScreenshotOcrClient : IScreenshotOcrClient
private static ScreenshotOcrResult ParseOcrResult(string text)
{
ScreenshotCropCoordinates? crop = null;
IReadOnlyList<string> attendees = [];
var cleaned = JsonCodeBlockRegex().Replace(text, match =>
{
if (TryParseCrop(match.Groups["json"].Value, out var parsedCrop))
if (TryParseMetadata(match.Groups["json"].Value, out var parsedCrop, out var parsedAttendees))
{
crop = parsedCrop;
attendees = parsedAttendees;
return "";
}
return match.Value;
}).Trim();
return new ScreenshotOcrResult(cleaned, crop);
return new ScreenshotOcrResult(cleaned, crop, attendees);
}
private static bool TryParseCrop(string json, out ScreenshotCropCoordinates? crop)
private static bool TryParseMetadata(
string json,
out ScreenshotCropCoordinates? crop,
out IReadOnlyList<string> attendees)
{
crop = null;
attendees = [];
try
{
using var document = JsonDocument.Parse(json);
if (!document.RootElement.TryGetProperty("crop", out var cropElement) ||
cropElement.ValueKind == JsonValueKind.Null)
{
return true;
}
if (cropElement.ValueKind != JsonValueKind.Object ||
!TryGetInt(cropElement, "x", out var x) ||
!TryGetInt(cropElement, "y", out var y) ||
!TryGetInt(cropElement, "width", out var width) ||
!TryGetInt(cropElement, "height", out var height))
if (document.RootElement.ValueKind != JsonValueKind.Object)
{
return false;
}
crop = new ScreenshotCropCoordinates(x, y, width, height);
var hasMetadata = false;
if (document.RootElement.TryGetProperty("attendees", out var attendeesElement))
{
hasMetadata = true;
if (attendeesElement.ValueKind == JsonValueKind.Array)
{
attendees = MeetingAttendeeNames.NormalizeDistinct(attendeesElement
.EnumerateArray()
.Where(element => element.ValueKind == JsonValueKind.String)
.Select(element => element.GetString() ?? ""));
}
}
if (!document.RootElement.TryGetProperty("crop", out var cropElement))
{
return hasMetadata;
}
hasMetadata = true;
if (cropElement.ValueKind == JsonValueKind.Null)
{
return true;
}
if (cropElement.ValueKind == JsonValueKind.Object &&
TryGetInt(cropElement, "x", out var x) &&
TryGetInt(cropElement, "y", out var y) &&
TryGetInt(cropElement, "width", out var width) &&
TryGetInt(cropElement, "height", out var height))
{
crop = new ScreenshotCropCoordinates(x, y, width, height);
}
return true;
}
catch (JsonException)