From 47278399f4cb7dce3286265a914e4cdcfc16b56b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 10 Dec 2025 15:26:40 +0000 Subject: [PATCH 1/3] Initial plan From 961dab77a415a706bcdc1d49403f639a6195143b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 10 Dec 2025 15:33:27 +0000 Subject: [PATCH 2/3] Allow searching entities by name, entity ID, and area name Co-authored-by: bgoncal <5808343+bgoncal@users.noreply.github.com> --- .../Extensions/Widgets/HAAppEntityAppIntentEntity.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Sources/Extensions/Widgets/HAAppEntityAppIntentEntity.swift b/Sources/Extensions/Widgets/HAAppEntityAppIntentEntity.swift index b77cb01958..b7b7f596ea 100644 --- a/Sources/Extensions/Widgets/HAAppEntityAppIntentEntity.swift +++ b/Sources/Extensions/Widgets/HAAppEntityAppIntentEntity.swift @@ -50,7 +50,12 @@ struct HAAppEntityAppIntentEntityQuery: EntityQuery, EntityStringQuery { .init(sections: getEntities().map { (key: Server, value: [HAAppEntityAppIntentEntity]) in .init( .init(stringLiteral: key.info.name), - items: value.filter({ $0.displayString.lowercased().contains(string.lowercased()) }) + items: value.filter({ entity in + let searchString = string.lowercased() + return entity.displayString.lowercased().contains(searchString) || + entity.entityId.lowercased().contains(searchString) || + (entity.area?.lowercased().contains(searchString) ?? false) + }) ) }) } From d477ab3b9ff65cc40a97bfbd6a513ffaa55c95b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Pantale=C3=A3o?= <5808343+bgoncal@users.noreply.github.com> Date: Wed, 10 Dec 2025 16:59:19 +0100 Subject: [PATCH 3/3] Improve entity search to be case and diacritic insensitive Updated the entity filtering logic to use case-insensitive and diacritic-insensitive matching for display string, entity ID, and area name. This enhances the search experience by making it more robust to user input variations. --- .../Widgets/HAAppEntityAppIntentEntity.swift | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Sources/Extensions/Widgets/HAAppEntityAppIntentEntity.swift b/Sources/Extensions/Widgets/HAAppEntityAppIntentEntity.swift index b7b7f596ea..1f90a3fd72 100644 --- a/Sources/Extensions/Widgets/HAAppEntityAppIntentEntity.swift +++ b/Sources/Extensions/Widgets/HAAppEntityAppIntentEntity.swift @@ -51,10 +51,22 @@ struct HAAppEntityAppIntentEntityQuery: EntityQuery, EntityStringQuery { .init( .init(stringLiteral: key.info.name), items: value.filter({ entity in - let searchString = string.lowercased() - return entity.displayString.lowercased().contains(searchString) || - entity.entityId.lowercased().contains(searchString) || - (entity.area?.lowercased().contains(searchString) ?? false) + let matchDisplayString = entity.displayString.range( + of: string, + options: [.caseInsensitive, .diacriticInsensitive] + ) != nil + let matchEntityId = entity.entityId.range( + of: string, + options: [.caseInsensitive, .diacriticInsensitive] + ) != nil + let matchAreaName = { + if let area = entity.area { + return area.range(of: string, options: [.caseInsensitive, .diacriticInsensitive]) != nil + } else { + return false + } + }() + return matchDisplayString || matchEntityId || matchAreaName }) ) })