added typeaheead and introspetion

This commit is contained in:
Mark Gregory
2026-10-18 17:24:28 +01:00
parent 8e5515afc0
commit d1cd3c2004
3 changed files with 106 additions and 2 deletions
+38 -2
View File
@@ -6563,6 +6563,7 @@ private struct DBSynDataCompareView: View {
@State private var table = ""
@State private var isComparing = false
@State private var report: DatabaseModel.DataComparisonReport?
@State private var syncPreview: DatabaseModel.DataSyncPreview?
@State private var errorMessage: String?
private var commonTables: [String] {
@@ -6602,6 +6603,30 @@ private struct DBSynDataCompareView: View {
Spacer()
Button("Compare") { compare() }
.disabled(table.isEmpty || targetDatabase.isEmpty || isComparing)
Button("Preview Missing-Row Sync…") { previewSync() }
.disabled(table.isEmpty || targetDatabase.isEmpty || isComparing)
}
if let syncPreview {
VStack(alignment: .leading, spacing: 8) {
Label("SQL preview — nothing has been executed", systemImage: "exclamationmark.shield")
.font(.headline)
Text(syncPreview.explanation).foregroundStyle(.secondary)
HStack {
Spacer()
Button("Copy SQL") {
NSPasteboard.general.clearContents()
NSPasteboard.general.setString(syncPreview.sql, forType: .string)
}
}
ScrollView {
Text(syncPreview.sql)
.font(.system(.body, design: .monospaced))
.textSelection(.enabled)
.frame(maxWidth: .infinity, alignment: .leading)
}.frame(minHeight: 170)
}
.padding(12)
.background(Color(nsColor: .textBackgroundColor))
}
if isComparing { ProgressView("Comparing table samples…") }
if let errorMessage {
@@ -6641,8 +6666,19 @@ private struct DBSynDataCompareView: View {
targetDatabase = model.databases.first(where: { $0 != sourceDatabase }) ?? ""
}
}
.onChange(of: targetDatabase) { _, _ in table = ""; report = nil }
.onChange(of: table) { _, _ in report = nil }
.onChange(of: targetDatabase) { _, _ in table = ""; report = nil; syncPreview = nil }
.onChange(of: table) { _, _ in report = nil; syncPreview = nil }
}
private func previewSync() {
errorMessage = nil
report = nil
syncPreview = nil
do {
syncPreview = try model.previewMissingRowsSync(source: sourceDatabase, target: targetDatabase, table: table)
} catch {
errorMessage = error.localizedDescription
}
}
private func compare() {