Skip to content

Commit 4871b3b

Browse files
authored
fix: keyboard shortcuts (#743)
* fix: keyboard shortcuts — remap HIG conflicts, wire dead shortcuts, fix docs * fix: update hardcoded shortcut help text to match new defaults * fix: simplify changelog, remove inaccurate Print suppression claim
1 parent 1dce3e1 commit 4871b3b

File tree

8 files changed

+53
-22
lines changed

8 files changed

+53
-22
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- Fix AI chat hanging the app during streaming, schema fetch, and conversation loading (#735)
1313
- SSH Agent auth: fall back to key file from `~/.ssh/config` or default paths when agent has no loaded identities (#729)
14+
- Wire AI Explain (⌘L), Optimize (⌘⌥L), and Toggle Sidebar (⌘0) shortcuts to menu bar commands
15+
- Keyboard shortcuts follow macOS HIG — remap Quick Switcher to ⌘⇧O, Format Query to ⌘⇧L, fix stale tooltip hints
1416
- SSH-tunneled connections failing to reconnect after idle/sleep — health monitor now rebuilds the tunnel, OS-level TCP keepalive detects dead NAT mappings, and wake-from-sleep triggers immediate validation (#736)
1517
- Composite primary key tables: editing or deleting a row affects all rows sharing the first PK value instead of just the target row
1618
- Structure view saves bypass safe mode on read-only connections

TablePro/Models/UI/KeyboardShortcutModels.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,9 @@ struct KeyCombo: Codable, Equatable, Hashable {
365365
KeyCombo(key: "3", command: true, shift: true), // Screenshot full
366366
KeyCombo(key: "4", command: true, shift: true), // Screenshot area
367367
KeyCombo(key: "5", command: true, shift: true), // Screenshot options
368+
KeyCombo(key: "q", command: true, control: true), // Lock Screen
369+
KeyCombo(key: "f", command: true, control: true), // Full Screen
370+
KeyCombo(key: "d", command: true, option: true), // Toggle Dock
368371
]
369372

370373
/// Check if this combo is reserved by the system
@@ -461,10 +464,10 @@ struct KeyboardSettings: Codable, Equatable {
461464
.closeTab: KeyCombo(key: "w", command: true),
462465
.refresh: KeyCombo(key: "r", command: true),
463466
.explainQuery: KeyCombo(key: "e", command: true, option: true),
464-
.formatQuery: KeyCombo(key: "f", command: true, option: true),
467+
.formatQuery: KeyCombo(key: "l", command: true, shift: true),
465468
.export: KeyCombo(key: "e", command: true, shift: true),
466469
.importData: KeyCombo(key: "i", command: true, shift: true),
467-
.quickSwitcher: KeyCombo(key: "p", command: true),
470+
.quickSwitcher: KeyCombo(key: "o", command: true, shift: true),
468471
.previousPage: KeyCombo(key: "[", command: true),
469472
.nextPage: KeyCombo(key: "]", command: true),
470473

TablePro/TableProApp.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,20 @@ struct AppMenuCommands: Commands {
277277

278278
Divider()
279279

280+
Button(String(localized: "Explain with AI")) {
281+
actions?.aiExplainQuery()
282+
}
283+
.optionalKeyboardShortcut(shortcut(for: .aiExplainQuery))
284+
.disabled(!(actions?.isConnected ?? false) || !(actions?.hasQueryText ?? false))
285+
286+
Button(String(localized: "Optimize with AI")) {
287+
actions?.aiOptimizeQuery()
288+
}
289+
.optionalKeyboardShortcut(shortcut(for: .aiOptimizeQuery))
290+
.disabled(!(actions?.isConnected ?? false) || !(actions?.hasQueryText ?? false))
291+
292+
Divider()
293+
280294
Button(String(localized: "Preview FK Reference")) {
281295
actions?.previewFKReference()
282296
}
@@ -351,6 +365,11 @@ struct AppMenuCommands: Commands {
351365

352366
// View menu
353367
CommandGroup(after: .sidebar) {
368+
Button(String(localized: "Toggle Sidebar")) {
369+
NSApp.sendAction(#selector(NSSplitViewController.toggleSidebar(_:)), to: nil, from: nil)
370+
}
371+
.optionalKeyboardShortcut(shortcut(for: .toggleTableBrowser))
372+
354373
Button("Toggle Inspector") {
355374
actions?.toggleRightSidebar()
356375
}

TablePro/Views/Editor/QueryEditorView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ struct QueryEditorView: View {
9292
.frame(width: 24, height: 24)
9393
}
9494
.buttonStyle(.borderless)
95-
.help(String(localized: "Format Query (⌥⌘F)"))
95+
.help(String(localized: "Format Query (⇧⌘L)"))
9696
.optionalKeyboardShortcut(AppSettingsManager.shared.keyboard.keyboardShortcut(for: .formatQuery))
9797

9898
Divider()

TablePro/Views/Main/Child/MainStatusBarView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ struct MainStatusBarView: View {
114114
}
115115
.toggleStyle(.button)
116116
.controlSize(.small)
117-
.help(String(localized: "Toggle Filters (⌘F)"))
117+
.help(String(localized: "Toggle Filters (⌘F)"))
118118
}
119119

120120
// Pagination controls for table tabs

TablePro/Views/Main/MainContentCommandActions.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,18 @@ final class MainContentCommandActions {
576576
coordinator?.runExplainQuery()
577577
}
578578

579+
func aiExplainQuery() {
580+
guard let query = coordinator?.tabManager.selectedTab?.query, !query.isEmpty else { return }
581+
coordinator?.showAIChatPanel()
582+
coordinator?.aiViewModel?.handleExplainSelection(query)
583+
}
584+
585+
func aiOptimizeQuery() {
586+
guard let query = coordinator?.tabManager.selectedTab?.query, !query.isEmpty else { return }
587+
coordinator?.showAIChatPanel()
588+
coordinator?.aiViewModel?.handleOptimizeSelection(query)
589+
}
590+
579591
func previewFKReference() {
580592
coordinator?.toggleFKPreviewForFocusedCell()
581593
}

TablePro/Views/Toolbar/TableProToolbarView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ struct TableProToolbar: ViewModifier {
125125
} label: {
126126
Label("Quick Switcher", systemImage: "magnifyingglass")
127127
}
128-
.help(String(localized: "Quick Switcher (⌘P)"))
128+
.help(String(localized: "Quick Switcher (⇧⌘O)"))
129129
.disabled(state.connectionState != .connected)
130130

131131
Button {
@@ -142,7 +142,7 @@ struct TableProToolbar: ViewModifier {
142142
} label: {
143143
Label("Filters", systemImage: "line.3.horizontal.decrease.circle")
144144
}
145-
.help(String(localized: "Toggle Filters (⌘F)"))
145+
.help(String(localized: "Toggle Filters (⌘F)"))
146146
.disabled(state.connectionState != .connected || !state.isTableTab)
147147
}
148148

docs/features/keyboard-shortcuts.mdx

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ TablePro is keyboard-driven. Most actions have shortcuts, and most menu shortcut
1717
| New connection | `Cmd+N` |
1818
| Open history | `Cmd+Y` |
1919
| Settings | `Cmd+,` |
20-
| Quick Switcher | `Cmd+P` |
20+
| Quick Switcher | `Cmd+Shift+O` |
2121
| Close window | `Cmd+W` |
2222
| Quit | `Cmd+Q` |
2323

@@ -37,7 +37,7 @@ TablePro is keyboard-driven. Most actions have shortcuts, and most menu shortcut
3737
|--------|----------|-------------|
3838
| Execute query | `Cmd+Enter` | Run query at cursor, or all selected statements sequentially |
3939
| Explain query | `Option+Cmd+E` | Show execution plan for query at cursor |
40-
| Format SQL | `Option+Cmd+F` | Format SQL query |
40+
| Format SQL | `Cmd+Shift+L` | Format SQL query |
4141

4242
### Text Editing
4343

@@ -77,7 +77,7 @@ TablePro is keyboard-driven. Most actions have shortcuts, and most menu shortcut
7777

7878
| Action | Shortcut |
7979
|--------|----------|
80-
| Select word | `Cmd+D` |
80+
| Duplicate line | `Cmd+D` |
8181
| Expand selection | `Cmd+Shift+Right` |
8282
| Shrink selection | `Cmd+Shift+Left` |
8383

@@ -101,7 +101,7 @@ TablePro is keyboard-driven. Most actions have shortcuts, and most menu shortcut
101101

102102
| Action | Shortcut |
103103
|--------|----------|
104-
| Edit cell | `Enter` or `F2` |
104+
| Edit cell | `Enter` |
105105
| Preview FK reference | `Space` |
106106
| Cancel edit | `Escape` |
107107
| Add row | `Cmd+Shift+N` |
@@ -134,7 +134,7 @@ TablePro is keyboard-driven. Most actions have shortcuts, and most menu shortcut
134134
| Action | Shortcut |
135135
|--------|----------|
136136
| Copy selection | `Cmd+C` |
137-
| Copy as CSV | `Cmd+Shift+C` |
137+
| Copy with Headers | `Cmd+Shift+C` |
138138
| Copy as JSON | `Cmd+Option+J` |
139139
| Copy as TSV | Available from context menu |
140140

@@ -147,18 +147,16 @@ TablePro is keyboard-driven. Most actions have shortcuts, and most menu shortcut
147147
| Close window / tab | `Cmd+W` |
148148
| New query tab | `Cmd+T` |
149149
| Switch to tab 1-9 | `Cmd+1` through `Cmd+9` |
150-
| Next tab | `Cmd+Shift+]` or `Cmd+Option+Right` |
151-
| Previous tab | `Cmd+Shift+[` or `Cmd+Option+Left` |
150+
| Next tab | `Cmd+Shift+]` |
151+
| Previous tab | `Cmd+Shift+[` |
152152
| Minimize | `Cmd+M` |
153-
| Zoom | `Cmd+Option+Z` |
154153

155154
### Connections
156155

157156
| Action | Shortcut |
158157
|--------|----------|
159158
| New connection | `Cmd+N` |
160159
| Switch connection | `Cmd+Control+C` |
161-
| Disconnect | `Cmd+D` |
162160
| Refresh connection | `Cmd+R` |
163161
| Delete selected connections | `Cmd+Delete` |
164162

@@ -178,7 +176,6 @@ TablePro is keyboard-driven. Most actions have shortcuts, and most menu shortcut
178176
| Query History | `Cmd+Y` |
179177
| Toggle Cell Inspector | `Cmd+Option+I` |
180178
| Toggle Results | `Cmd+Opt+R` |
181-
| Toggle AI Chat | `Cmd+Shift+L` |
182179
| Settings | `Cmd+,` |
183180

184181
### Results
@@ -193,9 +190,8 @@ TablePro is keyboard-driven. Most actions have shortcuts, and most menu shortcut
193190

194191
| Action | Shortcut | Description |
195192
|--------|----------|-------------|
196-
| Toggle AI Chat | `Cmd+Shift+L` | Open or close the AI chat panel |
197-
| Explain with AI | `Cmd+L` | Send selected SQL (or current query) to AI for explanation |
198-
| Optimize with AI | `Cmd+Option+L` | Send selected SQL (or current query) to AI for optimization |
193+
| Explain with AI | `Cmd+L` | Send current query to AI for explanation |
194+
| Optimize with AI | `Cmd+Option+L` | Send current query to AI for optimization |
199195

200196
## ER Diagram
201197

@@ -309,11 +305,11 @@ Vim mode keybindings only apply in the SQL editor. They don't affect the data gr
309305

310306
## Quick switcher
311307

312-
The Quick Switcher (`Cmd+P`) lets you search and jump to any table, view, database, schema, or recent query. It uses fuzzy matching, so typing `usr` finds `users`, `user_settings`, etc.
308+
The Quick Switcher (`Cmd+Shift+O`) lets you search and jump to any table, view, database, schema, or recent query. It uses fuzzy matching, so typing `usr` finds `users`, `user_settings`, etc.
313309

314310
| Action | Shortcut |
315311
|--------|----------|
316-
| Open Quick Switcher | `Cmd+P` |
312+
| Open Quick Switcher | `Cmd+Shift+O` |
317313
| Navigate results | `Up` / `Down` arrows |
318314
| Open selected item | `Return` |
319315
| Dismiss | `Escape` |
@@ -326,7 +322,6 @@ Results are grouped by type (tables, views, system tables, databases, schemas, r
326322
|--------|----------|
327323
| Quit application | `Cmd+Q` |
328324
| Preferences | `Cmd+,` |
329-
| Search documentation | `Cmd+?` |
330325

331326
## Customizing Shortcuts
332327

0 commit comments

Comments
 (0)