WidgetConfiguration with AppEnum and When clausole on AppIntent

Hi there,

I'm trying to use an enum as a @Parameter for my Widget configuration:

enum InteractivePlacesWidgetMode: Int, CaseIterable, AppEnum, Comparable, Equatable {
	typealias RawValue = Int

	case favourites = 0, recents, nearbyCategory, collections

	static var typeDisplayRepresentation: TypeDisplayRepresentation = TypeDisplayRepresentation(name: LocalizedStringResource("Mode"))

	static var caseDisplayRepresentations: [InteractivePlacesWidgetMode: DisplayRepresentation] = [
		.favourites: DisplayRepresentation(title: LocalizedStringResource("Favorites")),
		.recents: DisplayRepresentation(title: LocalizedStringResource("Recents")),
		.nearbyCategory: DisplayRepresentation(title: LocalizedStringResource("Categories")),
		.collections: DisplayRepresentation(title: LocalizedStringResource("Collections"))
	]

	static func < (lhs: InteractivePlacesWidgetMode, rhs: InteractivePlacesWidgetMode) -> Bool {
		lhs.rawValue < rhs.rawValue
	}
	static func == (lhs: InteractivePlacesWidgetMode, rhs: InteractivePlacesWidgetMode) -> Bool {
		lhs.rawValue == rhs.rawValue
	}
}

Then on the ConfigurationAppIntent I would like to show some more option only for specific cases, with the following:

struct ConfigurationAppIntent: WidgetConfigurationIntent {
	static var title: LocalizedStringResource = "Configuration"
	static var description = IntentDescription("Choose what to show")

	@Parameter(title: LocalizedStringResource("Show"), default: .favourites)
	var widgetMode: InteractivePlacesWidgetMode

	@Parameter (title: "Category")
	var category: CategoryDetail?

	static var parameterSummary: some ParameterSummary {
		When(\.$widgetMode, .equalTo, .nearbyCategory) {
			Summary {
				\.$widgetMode
				\.$category
			}
		} otherwise: {
			Summary {
				\.$widgetMode
			}
		}
	}
}

But the widget seems to ignore the When clausole at all. Is this a limitation of the When clausole? Is there something wrong with my approach? I already used that with standard types in previous work and it seems to work quite well.

Thanks in advance for your help.

c.

Update: As a last resort, I tried a totally different approach involving the use of a custom AppEntity type, like follow:

struct WidgetMode: AppEntity, Equatable {
	var id: Int
	static var defaultQuery = WidgetQuery()

	static var typeDisplayRepresentation: TypeDisplayRepresentation = TypeDisplayRepresentation(name: LocalizedStringResource("Mode"))

	var displayRepresentation: DisplayRepresentation {
		switch id {
		case 0:
			return DisplayRepresentation(title: LocalizedStringResource("Favorites"))
		case 1:
			return DisplayRepresentation(title: LocalizedStringResource("Recents"))
		case 2:
			return DisplayRepresentation(title: LocalizedStringResource("Categories"))
		case 3:
			return DisplayRepresentation(title: LocalizedStringResource("Collections"))
		default:
			return DisplayRepresentation(title: LocalizedStringResource("Unknown"))
		}
	}
}

struct WidgetQuery: EntityQuery {
	func entities(for identifiers: [Int]) async throws -> [WidgetMode] {
		[0, 1, 2, 3].map({ WidgetMode(id: $0)})
	}
	func suggestedEntities() async throws -> [WidgetMode] {
		[0, 1, 2, 3].map({ WidgetMode(id: $0)})
	}
}

struct ConfigurationAppIntent: WidgetConfigurationIntent {
	static var title: LocalizedStringResource = "Configuration"
	static var description = IntentDescription("Choose what to show")

	@Parameter(title: LocalizedStringResource("Show"))
	var widgetMode: WidgetMode

	@Parameter (title: "Category")
	var category: CategoryDetail?

	static var parameterSummary: some ParameterSummary {
		When(\.$widgetMode, .equalTo, WidgetMode(id: 2)) {
			Summary {
				\.$widgetMode
				\.$category
			}
		} otherwise: {
			Summary {
				\.$widgetMode
			}
		}
	}
}

But result is always the same: the widget changes the widgetMode option according to the AppEntity custom type, but the When clausole is never honoured.

Please, anyone can help us into the right direction? Is it a bug on iOS17?

WidgetConfiguration with AppEnum and When clausole on AppIntent
 
 
Q