feat(intents): onscreen entity annotations + App Intents tests
All checks were successful
CI / build-and-deploy (push) Successful in 28s

- bookmarkOnscreen(_:) publishes the viewed bookmark as the on-screen
  entity (NSUserActivity.appEntityIdentifier) so Siri can resolve "this"
  / "summarize this one"; applied to the BrowserView sheets in
  BookmarksView and SearchView
- Add MarksTests (XCTest) covering entity mapping, EntityIdentifier,
  IntentRouter, and the real perform() of SearchMarksIntent and
  OpenBookmarkIntent; wired into the Marks scheme test phase

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Krishna Kumar
2026-06-17 00:16:46 -05:00
parent 389d615c8b
commit a3059f25fc
7 changed files with 256 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
import SwiftUI
import AppIntents
extension View {
/// Marks `bookmark` as the on-screen entity via an `NSUserActivity`, so
/// Siri / Apple Intelligence can resolve references like "summarize this"
/// or "open this one" while the bookmark is being viewed.
///
/// iOS 26.0 ships no SwiftUI `.appEntityIdentifier` modifier, so this uses
/// the supported path: the standard `.userActivity` modifier plus
/// `NSUserActivity.appEntityIdentifier` (from `AppEntityAnnotatable`).
func bookmarkOnscreen(_ bookmark: Bookmark) -> some View {
userActivity("com.magicive.marks.viewBookmark", element: bookmark.id) { id, activity in
activity.title = bookmark.displayTitle
activity.appEntityIdentifier = EntityIdentifier(for: BookmarkEntity.self, identifier: id)
activity.isEligibleForSearch = true
}
}
}

View File

@@ -178,6 +178,7 @@ struct BookmarksView: View {
BrowserView(url: url, title: bookmark.displayTitle, claude: viewModel.claude, podcastPlayer: viewModel.podcastPlayer) {
await viewModel.archive(bookmark)
}
.bookmarkOnscreen(bookmark)
}
}
.onChange(of: browsingBookmark) { _, new in

View File

@@ -52,6 +52,7 @@ struct SearchView: View {
) {
await viewModel.archive(bookmark)
}
.bookmarkOnscreen(bookmark)
}
}
}