I'd like to display a list of items to disambiguate for a fulltext search intent. Using the Apple AppIntentsSampleApp, I added TrailSearch.swift
:
import AppIntents
@AssistantIntent(schema: .system.search)
struct TrailSearch: AppIntent {
static let title: LocalizedStringResource = "Search Trail"
static let description = IntentDescription("Search trail by name.",
categoryName: "Discover",
resultValueName: "Trail")
@Parameter(title: "Trail")
var criteria: StringSearchCriteria
func perform() async throws -> some IntentResult & ReturnsValue<TrailEntity> {
if criteria.term.isEmpty {
throw $criteria.needsValueError(IntentDialog("need value"))
}
let trails = TrailDataManager.shared.trails { trail in
trail.name.contains(criteria.term)
}
if trails.count > 1 {
throw $criteria.needsDisambiguationError(among: trails.map { StringSearchCriteria(term: $0.name) })
} else if let firstTrail = trails.first {
return .result(value: TrailEntity(trail: firstTrail))
}
throw $criteria.needsValueError(IntentDialog("Nothing found"))
}
}
Now when I type "trail" which matches several trails and thus lets us enter the disambiguation code path, the Shortcut app just displays the dialog title but no disambiguation items to pick from.
Is this by design or a bug?
(filed as FB17412220)