Polish news and personal report phrasing

This commit is contained in:
Jacob Dubin
2026-05-21 06:28:16 -05:00
parent eb509a66e0
commit bedb5d1715
6 changed files with 61 additions and 9 deletions

View File

@@ -2432,7 +2432,11 @@ public sealed class JiboInteractionService(
cancellationToken);
if (snapshot?.Headlines.Count > 0)
return BuildProviderNewsDecision(snapshot, preferredCategories, requestedHeadlineCount);
return BuildProviderNewsDecision(
snapshot,
catalog,
preferredCategories,
requestedHeadlineCount);
var providerStatus = ResolveNewsProviderStatus(snapshot);
var providerMessage = snapshot?.ProviderMessage;
@@ -2522,6 +2526,7 @@ public sealed class JiboInteractionService(
private static JiboInteractionDecision BuildProviderNewsDecision(
NewsBriefingSnapshot snapshot,
JiboExperienceCatalog catalog,
IReadOnlyList<string> preferredCategories,
int requestedHeadlineCount)
{
@@ -2543,7 +2548,8 @@ public sealed class JiboInteractionService(
var leadIn = BuildNewsLeadIn(snapshot.SourceName, preferredCategories);
var joinedHeadlines = string.Join(" ", headlines.Select(static headline => $"{headline.Title}."));
var spokenBriefing = $"{leadIn} {joinedHeadlines}".Trim();
var outroTemplate = ChooseShortestTemplate(catalog.NewsOutroReplies) ?? "And that's the news.";
var spokenBriefing = $"{leadIn} {joinedHeadlines} {outroTemplate}".Trim();
return BuildNewsDecision(
spokenBriefing,
snapshot.SourceName,

View File

@@ -281,12 +281,24 @@ internal static class PersonalReportOrchestrator
}
if (toggles.CalendarEnabled)
reportSections.Add((await buildCalendarDecisionAsync(turn, cancellationToken)).ReplyText);
{
var calendarReply = (await buildCalendarDecisionAsync(turn, cancellationToken)).ReplyText;
if (!string.IsNullOrWhiteSpace(calendarReply))
{
reportSections.Add(calendarReply);
var calendarOutro = ChooseShortestTemplate(catalog.CalendarOutroReplies);
if (!string.IsNullOrWhiteSpace(calendarOutro))
reportSections.Add(RenderPersonalReportTemplate(calendarOutro!, userName));
}
}
if (toggles.CommuteEnabled)
{
var commuteReply = (await buildCommuteDecisionAsync(turn, cancellationToken)).ReplyText;
reportSections.Add(ChooseFirstSentence(commuteReply));
var commuteSnippet = ChooseFirstSentence(commuteReply);
if (!string.IsNullOrWhiteSpace(commuteSnippet))
reportSections.Add(commuteSnippet);
}
if (toggles.NewsEnabled)
@@ -717,6 +729,25 @@ internal static class PersonalReportOrchestrator
return string.IsNullOrWhiteSpace(firstSentence) ? value.Trim() : firstSentence;
}
private static string ChooseFirstTwoSentences(string value)
{
if (string.IsNullOrWhiteSpace(value)) return string.Empty;
var segments = value
.Split(['.', '!', '?'], StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)
.Take(2)
.ToArray();
if (segments.Length == 0) return string.Empty;
var joined = string.Join(". ", segments);
return value.TrimEnd().EndsWith(".", StringComparison.Ordinal) ||
value.TrimEnd().EndsWith("!", StringComparison.Ordinal) ||
value.TrimEnd().EndsWith("?", StringComparison.Ordinal)
? $"{joined}."
: joined;
}
private static string? ChooseShortestTemplate(IEnumerable<string> templates)
{
var selected = templates