Commit 74a6940
[AI] Sample: Detail page, semantic search, streaming, and UI polish (#34576)
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!
## Summary
Major improvements to the Essentials AI sample app: new Landmark Detail
page with AI features, semantic search, streaming response handler
improvements, and comprehensive UI polish across all pages for a modern,
edge-to-edge experience on iOS and MacCatalyst.
### New Features
- **Landmark Detail Page** — New intermediate page between browsing and
trip planning with AI-generated travel tips, similar destinations via
semantic search, animated hashtag tags, language picker, full-bleed hero
image with scrolling gradient overlay, and Plan Trip navigation
- **Semantic Search** — Search bar on Landmarks page filters continent
groups using semantic similarity with `Timer`-based debounce (300ms) and
tracks recent searches for contextual AI descriptions
- **ISemanticSearchService abstraction** — Clean interface backed by
`EmbeddingSearchService` (Apple NL embeddings + cosine similarity +
hybrid keyword boost + sentence chunking)
- **StreamingResponseHandler passthrough mode** — Supports streaming
without buffering, with new device tests
(`DeliversMultipleIncrementalUpdates`, `ConcatenatedText`)
- **PromptBasedSchemaClient** — Prompt-based JSON schema middleware for
Phi Silica compatibility
### UI Polish
- **Edge-to-edge layout** — All pages use `SafeAreaEdges="None"` on root
Grid with back buttons wrapped in `SafeAreaEdges="Container"`
- **Scrolling gradient pattern** — Fixed gradient overlay + scrolling
gradient that transitions to solid background
- **Custom search entry** — Replaced `SearchBar` with borderless `Entry`
in rounded `Border` with native border/focus ring removed on
iOS/MacCatalyst
- **Edge-to-edge horizontal scrollers** — Scroll to screen edges, align
with page content padding at rest
- **Removed broken BoxView global style** — Was breaking gradient
overlays
- **Added missing Gray700 color** — Prevented silent navigation crash
- **Background → Background property migration** — Replaced
`BackgroundColor` with `Background` across all pages
### Code Quality
- **IDispatcher injection** instead of
`MainThread.BeginInvokeOnMainThread`
- **Only-once AI initialization** — Guard against re-entry in
`LandmarkDetailViewModel`
- **Null safety** — Fixed CS8602 warnings in DataService search methods
- **Removed debug logging**
### Navigation Flow
`LandmarksPage` (browse + search) → `LandmarkDetailPage` (details + AI
tips) → `TripPlanningPage` (itinerary generation)
### Deleted Files
- `LandmarkDescriptionView`, `LandmarkTripView` — Replaced by new pages
- `LanguagePreferenceService` — Refactored into inline language array
### New Test Coverage
- `StreamingResponseHandlerTests/Passthrough.cs` — Unit tests for
passthrough streaming mode
- `ChatClientStreamingTestsBase` — Updated device tests for streaming
scenarios
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 148b9aa commit 74a6940
File tree
51 files changed
+9356
-708
lines changed- src/AI
- samples/Essentials.AI.Sample
- AI
- Converters
- Models
- Pages
- Resources
- Fonts
- Raw
- Images
- Backgrounds
- Thumbnails
- Styles
- Services
- ViewModels
- Views
- Itinerary
- Landmarks
- src/Essentials.AI/Platform
- tests
- Essentials.AI.DeviceTests/Tests
- Essentials.AI.UnitTests/Tests/StreamingResponseHandlerTests
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
51 files changed
+9356
-708
lines changedLines changed: 12 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
| 46 | + | |
| 47 | + | |
53 | 48 | | |
54 | | - | |
55 | | - | |
56 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
57 | 53 | | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
63 | 59 | | |
64 | 60 | | |
65 | 61 | | |
| |||
108 | 104 | | |
109 | 105 | | |
110 | 106 | | |
| 107 | + | |
111 | 108 | | |
112 | 109 | | |
113 | 110 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
7 | | - | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | | - | |
11 | | - | |
| 11 | + | |
| 12 | + | |
12 | 13 | | |
13 | | - | |
14 | | - | |
| 14 | + | |
| 15 | + | |
15 | 16 | | |
16 | | - | |
17 | | - | |
| 17 | + | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
24 | | - | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | | - | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
| 11 | + | |
13 | 12 | | |
14 | 13 | | |
15 | 14 | | |
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
0 commit comments