Skip to content

Commit 3aec00d

Browse files
Copilotbgoncal
andcommitted
Add showAssistView gesture action to open native AssistView
Co-authored-by: bgoncal <5808343+bgoncal@users.noreply.github.com>
1 parent aadc37e commit 3aec00d

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

Sources/App/Resources/en.lproj/Localizable.strings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@
328328
"gestures.value.option.search_devices" = "Search devices";
329329
"gestures.value.option.search_entities" = "Search entities";
330330
"gestures.value.option.servers_list" = "Servers list";
331+
"gestures.value.option.show_assist_view" = "Open Assist (Native)";
331332
"gestures.value.option.show_settings" = "Open App settings";
332333
"gestures.value.option.show_sidebar" = "Show sidebar";
333334
"grdb.config.migration_error.failed_access_grdb" = "Failed to access database (GRDB), error: %@";

Sources/App/WebView/Extensions/WebViewGestureHandler.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ final class WebViewGestureHandler {
1111
switch action {
1212
case .assist:
1313
showAssistThroughKeyEvent()
14+
case .showAssistView:
15+
showAssistView()
1416
case .showSidebar:
1517
showSidebar()
1618
case .backPage:
@@ -106,6 +108,14 @@ final class WebViewGestureHandler {
106108
}
107109
}
108110

111+
private func showAssistView() {
112+
guard let server = webView?.server else {
113+
Current.Log.error("No server available to open AssistView")
114+
return
115+
}
116+
webView?.webViewExternalMessageHandler.showAssist(server: server, pipeline: "", autoStartRecording: false)
117+
}
118+
109119
private func openInBrowser() {
110120
guard let url = webView?.currentURL else { return }
111121
guard var urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false) else { return }

Sources/Shared/AppGesture.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public enum HAGestureAction: String, Codable, CaseIterable {
3131
case searchDevices
3232
case searchCommands
3333
case assist
34+
case showAssistView
3435
// Page
3536
case backPage
3637
case nextPage
@@ -47,7 +48,7 @@ public enum HAGestureAction: String, Codable, CaseIterable {
4748

4849
public var category: HAGestureActionCategory {
4950
switch self {
50-
case .showSidebar, .searchEntities, .searchDevices, .searchCommands, .assist:
51+
case .showSidebar, .searchEntities, .searchDevices, .searchCommands, .assist, .showAssistView:
5152
.homeAssistant
5253
case .backPage, .nextPage, .openInBrowser:
5354
.page
@@ -90,6 +91,8 @@ public enum HAGestureAction: String, Codable, CaseIterable {
9091
L10n.Gestures.Value.Option.searchCommands
9192
case .assist:
9293
L10n.Gestures.Value.Option.assist
94+
case .showAssistView:
95+
L10n.Gestures.Value.Option.showAssistView
9396
}
9497
}
9598

@@ -123,6 +126,8 @@ public enum HAGestureAction: String, Codable, CaseIterable {
123126
nil
124127
case .assist:
125128
nil
129+
case .showAssistView:
130+
nil
126131
}
127132
}
128133
}

Sources/Shared/Resources/Swiftgen/Strings.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,6 +1360,8 @@ public enum L10n {
13601360
public static var searchEntities: String { return L10n.tr("Localizable", "gestures.value.option.search_entities") }
13611361
/// Servers list
13621362
public static var serversList: String { return L10n.tr("Localizable", "gestures.value.option.servers_list") }
1363+
/// Open Assist (Native)
1364+
public static var showAssistView: String { return L10n.tr("Localizable", "gestures.value.option.show_assist_view") }
13631365
/// Open App settings
13641366
public static var showSettings: String { return L10n.tr("Localizable", "gestures.value.option.show_settings") }
13651367
/// Show sidebar

0 commit comments

Comments
 (0)