Skip to content

Commit aa6fa0f

Browse files
mattleibowCopilot
andcommitted
Address round 3 review comments
- Add CancelPendingSearch to LandmarksViewModel, called from OnDisappearing to dispose the debounce timer and cancel any in-flight search when navigating away - Fix TaggingService tag parsing: drop the SelectMany space-split that fragmented multi-word hashtags; instead treat each comma/newline-separated item as a single tag and reject entries with whitespace - Use Background instead of BackgroundColor on LandmarkListItemView and LandmarkFeaturedItemView for consistency with the rest of the BackgroundColor-to-Background migration - Fix WorkflowModels comment to match actual JSON property names (place/days/language not dest/days/lang) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 2035b1a commit aa6fa0f

6 files changed

Lines changed: 13 additions & 6 deletions

File tree

src/AI/samples/Essentials.AI.Sample/AI/WorkflowModels.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace Maui.Controls.Sample.AI;
55

66
/// <summary>
77
/// Result from the Travel Planner Agent - raw extraction of user intent.
8-
/// Short JSON names (dest/days/lang) prevent misspelling by small language models.
8+
/// Short JSON names (place/days/language) reduce misspelling by small language models.
99
/// </summary>
1010
public record TravelPlanResult(
1111
[property: JsonPropertyName("place")]

src/AI/samples/Essentials.AI.Sample/Pages/LandmarksPage.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ protected override void OnAppearing()
5353

5454
protected override void OnDisappearing()
5555
{
56+
_viewModel.CancelPendingSearch();
5657
_chatViewModel.ChatService.NavigateToTripRequested -= OnNavigateToTrip;
5758
base.OnDisappearing();
5859
}

src/AI/samples/Essentials.AI.Sample/Services/TaggingService.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ Return ONLY a comma-separated list of 5 hashtags. No explanations.
3636

3737
return responseText
3838
.Split([',', '\n', '\r'], StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)
39-
.SelectMany(tag => tag.Split(' ', StringSplitOptions.RemoveEmptyEntries))
40-
.Select(tag => tag.TrimStart('#', '-', '•').Trim())
41-
.Where(tag => tag.Length > 1 && !tag.Contains(' ', StringComparison.Ordinal))
39+
.Select(tag => tag.TrimStart('#', '-', '•', '*').Trim())
40+
.Where(tag => tag.Length > 1 && !tag.Any(char.IsWhiteSpace))
4241
.Distinct()
4342
.Take(5)
4443
.ToList();

src/AI/samples/Essentials.AI.Sample/ViewModels/LandmarksViewModel.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ public partial class LandmarksViewModel(
4040
/// <summary>All continent groups (unfiltered).</summary>
4141
List<ContinentGroup> _allGroups = [];
4242

43+
public void CancelPendingSearch()
44+
{
45+
_debounceTimer?.Dispose();
46+
_debounceTimer = null;
47+
_searchCts?.Cancel();
48+
}
49+
4350
public ObservableCollection<ContinentGroup> ContinentGroups => field ??= [];
4451

4552
partial void OnSearchQueryChanged(string? value)

src/AI/samples/Essentials.AI.Sample/Views/Landmarks/LandmarkFeaturedItemView.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
Padding="0"
1111
StrokeShape="RoundRectangle 16"
1212
StrokeThickness="0"
13-
BackgroundColor="Transparent"
13+
Background="Transparent"
1414
Shadow="{Shadow Brush=Black, Offset='0,2', Radius=8, Opacity=0.3}">
1515
<Border.GestureRecognizers>
1616
<TapGestureRecognizer Tapped="OnFeaturedLandmarkTapped" />

src/AI/samples/Essentials.AI.Sample/Views/Landmarks/LandmarkListItemView.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
Padding="0"
1313
StrokeShape="RoundRectangle 16"
1414
StrokeThickness="0"
15-
BackgroundColor="Transparent"
15+
Background="Transparent"
1616
Shadow="{Shadow Brush=Black, Offset='0,2', Radius=8, Opacity=0.3}">
1717
<Border.GestureRecognizers>
1818
<TapGestureRecognizer Tapped="OnLandmarkTapped" />

0 commit comments

Comments
 (0)