Skip to content

Commit 2e03404

Browse files
committed
Support closing tab with Command+W
1 parent 83ee69e commit 2e03404

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

Core/Sources/SuggestionWidget/ChatWindowView.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ struct ChatWindowView: View {
5050
}
5151
.opacity(0)
5252
.keyboardShortcut("M", modifiers: [.command])
53+
54+
Button(action: {
55+
viewStore.send(.closeActiveTabClicked)
56+
}) {
57+
EmptyView()
58+
}
59+
.opacity(0)
60+
.keyboardShortcut("W", modifiers: [.command])
5361
}
5462
.background(.regularMaterial)
5563
.xcodeStyleFrame()

Core/Sources/SuggestionWidget/FeatureReducers/ChatPanelFeature.swift

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public struct ChatPanelFeature: ReducerProtocol {
4040
public enum Action: Equatable {
4141
// Window
4242
case hideButtonClicked
43+
case closeActiveTabClicked
4344
case toggleChatPanelDetachedButtonClicked
4445
case detachChatPanel
4546
case attachChatPanel
@@ -67,7 +68,17 @@ public struct ChatPanelFeature: ReducerProtocol {
6768
return .run { _ in
6869
await activatePreviouslyActiveXcode()
6970
}
70-
71+
72+
case .closeActiveTabClicked:
73+
if let id = state.chatTapGroup.selectedTabId {
74+
return .run { send in
75+
await send(.closeTabButtonClicked(id: id))
76+
}
77+
}
78+
79+
state.isPanelDisplayed = false
80+
return .none
81+
7182
case .toggleChatPanelDetachedButtonClicked:
7283
state.chatPanelInASeparateWindow.toggle()
7384
return .none
@@ -111,6 +122,9 @@ public struct ChatPanelFeature: ReducerProtocol {
111122

112123
case let .closeTabButtonClicked(id):
113124
state.chatTapGroup.tabs.removeAll { $0.id == id }
125+
if state.chatTapGroup.tabs.isEmpty {
126+
state.isPanelDisplayed = false
127+
}
114128
return .none
115129

116130
case .createNewTapButtonClicked:

0 commit comments

Comments
 (0)