Skip to content

Commit 24efe13

Browse files
committed
fix: architecture + UIUX review fixes
1. Pin toggle routes through coordinator + bumps resultVersion for SwiftUI reactivity (was mutating class directly, bypassing Equatable) 2. Remove dead onAIFix API from InlineErrorBanner 3. Use NSColor.selectedControlColor for active tab (was wrong .selectedContentBackgroundColor.opacity(0.3), broken in dark mode) 4. ResultTabBar height 28→32pt (HIG minimum), replace deprecated .cornerRadius with RoundedRectangle, localize context menu strings 5. Consolidate dual ResultSuccessView paths into single branch
1 parent 7cece84 commit 24efe13

File tree

3 files changed

+28
-36
lines changed

3 files changed

+28
-36
lines changed

TablePro/Views/Main/Child/MainEditorContentView.swift

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -330,16 +330,16 @@ struct MainEditorContentView: View {
330330
)
331331
} else if tab.resultColumns.isEmpty && tab.errorMessage == nil
332332
&& tab.lastExecutedAt != nil && !tab.isExecuting
333-
&& !tab.resultSets.isEmpty
334333
{
335-
ResultSuccessView(
336-
rowsAffected: tab.rowsAffected,
337-
executionTime: tab.executionTime,
338-
statusMessage: tab.statusMessage
339-
)
340-
} else if tab.resultColumns.isEmpty && tab.resultSets.isEmpty {
341-
// All result tabs closed — empty grid
342-
Spacer()
334+
if tab.resultSets.isEmpty {
335+
Spacer()
336+
} else {
337+
ResultSuccessView(
338+
rowsAffected: tab.rowsAffected,
339+
executionTime: tab.executionTime,
340+
statusMessage: tab.statusMessage
341+
)
342+
}
343343
} else {
344344
// Filter panel (collapsible, above data grid)
345345
if filterStateManager.isVisible && tab.tabType == .table {
@@ -381,7 +381,9 @@ struct MainEditorContentView: View {
381381
coordinator.closeResultSet(id: id)
382382
},
383383
onPin: { id in
384-
tab.resultSets.first { $0.id == id }?.isPinned.toggle()
384+
guard let tabIdx = coordinator.tabManager.selectedTabIndex else { return }
385+
coordinator.tabManager.tabs[tabIdx].resultSets.first { $0.id == id }?.isPinned.toggle()
386+
coordinator.tabManager.tabs[tabIdx].resultVersion += 1
385387
}
386388
)
387389
}

TablePro/Views/Results/InlineErrorBanner.swift

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import SwiftUI
1010
struct InlineErrorBanner: View {
1111
let message: String
1212
var onDismiss: (() -> Void)?
13-
var onAIFix: (() -> Void)?
1413

1514
var body: some View {
1615
HStack(spacing: 8) {
@@ -21,11 +20,6 @@ struct InlineErrorBanner: View {
2120
.lineLimit(3)
2221
.textSelection(.enabled)
2322
Spacer()
24-
if let onAIFix {
25-
Button("Fix with AI") { onAIFix() }
26-
.buttonStyle(.bordered)
27-
.controlSize(.small)
28-
}
2923
if let onDismiss {
3024
Button { onDismiss() } label: {
3125
Image(systemName: "xmark")
@@ -41,16 +35,9 @@ struct InlineErrorBanner: View {
4135
}
4236

4337
#Preview {
44-
VStack {
45-
InlineErrorBanner(
46-
message: "ERROR 1064 (42000): You have an error in your SQL syntax",
47-
onDismiss: {},
48-
onAIFix: {}
49-
)
50-
InlineErrorBanner(
51-
message: "Connection refused",
52-
onDismiss: {}
53-
)
54-
}
38+
InlineErrorBanner(
39+
message: "ERROR 1064 (42000): You have an error in your SQL syntax",
40+
onDismiss: {}
41+
)
5542
.frame(width: 600)
5643
}

TablePro/Views/Results/ResultTabBar.swift

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct ResultTabBar: View {
2222
}
2323
}
2424
}
25-
.frame(height: 28)
25+
.frame(height: 32)
2626
.background(Color(nsColor: .controlBackgroundColor))
2727
}
2828

@@ -31,7 +31,7 @@ struct ResultTabBar: View {
3131
return HStack(spacing: 4) {
3232
if rs.isPinned {
3333
Image(systemName: "pin.fill")
34-
.font(.system(size: 8))
34+
.font(.system(size: 9))
3535
.foregroundStyle(.secondary)
3636
}
3737
Text(rs.label)
@@ -47,22 +47,25 @@ struct ResultTabBar: View {
4747
}
4848
}
4949
.padding(.horizontal, 10)
50-
.padding(.vertical, 4)
51-
.background(isActive ? Color(nsColor: .selectedContentBackgroundColor).opacity(0.3) : Color.clear)
52-
.cornerRadius(4)
50+
.padding(.vertical, 6)
51+
.background(
52+
RoundedRectangle(cornerRadius: 4)
53+
.fill(isActive ? Color(nsColor: .selectedControlColor) : Color.clear)
54+
)
5355
.contentShape(Rectangle())
5456
.onTapGesture { activeResultSetId = rs.id }
5557
.contextMenu {
56-
Button(rs.isPinned ? "Unpin" : "Pin Result") { onPin?(rs.id) }
58+
Button(rs.isPinned ? String(localized: "Unpin") : String(localized: "Pin Result")) {
59+
onPin?(rs.id)
60+
}
5761
Divider()
58-
Button("Close") { onClose?(rs.id) }
62+
Button(String(localized: "Close")) { onClose?(rs.id) }
5963
.disabled(rs.isPinned)
60-
Button("Close Others") {
64+
Button(String(localized: "Close Others")) {
6165
for other in resultSets where other.id != rs.id && !other.isPinned {
6266
onClose?(other.id)
6367
}
6468
}
6569
}
6670
}
6771
}
68-

0 commit comments

Comments
 (0)