Improved progress display

Previously, the progress bar updated only after completing an entire table.

For large tables such as LIBARC, this could make the application appear to have stopped responding.

Phase 10 updates the interface while rows are being exported.
This commit is contained in:
Mark Gregory
2026-10-16 22:09:43 +01:00
parent 7618294b16
commit 3c0b2b2ae5
21 changed files with 101 additions and 92 deletions
+8
View File
@@ -0,0 +1,8 @@
# Phase 10 — Live export progress
- Updates export progress while each streamed table is being written, rather than only after the table completes.
- Displays current-table row count, expected row count, and total exported rows.
- Throttles UI updates to every 500 rows (and at the last row) to reduce overhead.
- Retains Phase 9's single-result streaming, InnoDB snapshot, row count verification and SHA-256 sidecars.
Limitations: Large individual values remain constrained by MySQL packet sizes. Progress updates are best effort and may be delayed by networking. Export consistency excludes concurrent DDL and non-InnoDB data. This source has not been built with Xcode or tested against a live server.
+35 -1
View File
@@ -1569,6 +1569,9 @@ struct WorkbenchDatabaseTransferView: View {
@State private var database = ""
@State private var isWorking = false
@State private var progress = 0.0
@State private var transferredRows: Int64 = 0
@State private var currentTableRows: Int64 = 0
@State private var currentTableExpected: Int64 = 0
@State private var status = "Ready"
@State private var operationTask: Task<Void, Never>?
@State private var showingImportConfirmation = false
@@ -1707,6 +1710,12 @@ struct WorkbenchDatabaseTransferView: View {
.font(.caption)
.foregroundStyle(.secondary)
.textSelection(.enabled)
if isWorking && selectedMode == 0 && currentTableExpected > 0 {
ProgressView(value: Double(currentTableRows), total: Double(currentTableExpected))
Text("Current table: \(currentTableRows.formatted()) / \(currentTableExpected.formatted()) rows · Total exported: \(transferredRows.formatted())")
.font(.caption.monospacedDigit())
.foregroundStyle(.secondary)
}
}
}
}
@@ -1975,6 +1984,9 @@ struct WorkbenchDatabaseTransferView: View {
exportSession = dedicatedProfile
isWorking = true
progress = 0
transferredRows = 0
currentTableRows = 0
currentTableExpected = 0
let tables = availableTables.filter { selectedTables.contains($0) }
let tempURL = url.deletingLastPathComponent().appendingPathComponent(".\(UUID().uuidString).sql.tmp")
var handle: FileHandle?
@@ -2090,12 +2102,18 @@ struct WorkbenchDatabaseTransferView: View {
let expectedCount = Int64(countText) else {
throw WorkbenchTransferError.message("Cannot count rows in \(table)")
}
currentTableRows = 0
currentTableExpected = expectedCount
try write("-- Streamed snapshot: \(expectedCount) rows; order: \(usableIndex ?? "server scan")\n")
let select = "SELECT CONCAT('(', CONCAT_WS(',', \(expressions)), ')') FROM \(qualified)" +
(orderBy.map { " ORDER BY " + $0 } ?? "")
let outputHandle = handle!
let prefix = Data("INSERT INTO \(qualified) (\(names)) VALUES ".utf8)
let suffix = Data(";\n".utf8)
let completedBeforeTable = transferredRows
let completedTables = index
let totalUnits = max(tables.count + views.count, 1)
var streamedInTable: Int64 = 0
let written = try await NativeMySQLRunner.stream(
profile: dedicatedProfile,
database: database,
@@ -2105,7 +2123,21 @@ struct WorkbenchDatabaseTransferView: View {
try outputHandle.write(contentsOf: prefix)
try outputHandle.write(contentsOf: Data(literal.utf8))
try outputHandle.write(contentsOf: suffix)
streamedInTable += 1
if streamedInTable % 500 == 0 || streamedInTable == expectedCount {
let completed = streamedInTable
DispatchQueue.main.async {
currentTableRows = completed
transferredRows = completedBeforeTable + completed
progress = (Double(completedTables) +
Double(completed) / Double(max(expectedCount, 1))) /
Double(totalUnits)
status = "Exporting \(table): \(completed.formatted()) / \(expectedCount.formatted()) rows"
}
}
}
currentTableRows = written
transferredRows = completedBeforeTable + written
guard written == expectedCount else {
throw WorkbenchTransferError.message(
"Table \(table): expected \(expectedCount) rows, streamed \(written). Backup discarded."
@@ -2113,6 +2145,8 @@ struct WorkbenchDatabaseTransferView: View {
}
status = "Exported \(table): \(written) rows"
}
currentTableExpected = 0
currentTableRows = 0
progress = Double(index + 1) / Double(max(tables.count + views.count, 1))
}
// Views are exported after base tables so dependencies exist on restore.
@@ -2199,7 +2233,7 @@ struct WorkbenchDatabaseTransferView: View {
do {
try WorkbenchBackupIntegrity.createSidecar(for: url)
progress = 1
status = "Export complete and SHA-256 verified: \(tables.count) tables, \(views.count) views"
status = "Export complete and SHA-256 verified: \(tables.count) tables, \(views.count) views, \(transferredRows.formatted()) rows"
} catch {
progress = 1
status = "SQL export complete, but checksum creation failed: \(error.localizedDescription)"
@@ -327,7 +327,7 @@
"key": "Import SQL into %@?",
"location": {
"startingColumn": 13,
"startingLine": 1780
"startingLine": 1789
}
},
{
@@ -335,7 +335,7 @@
"key": "Operation",
"location": {
"startingColumn": 20,
"startingLine": 1600
"startingLine": 1603
}
},
{
@@ -343,7 +343,7 @@
"key": "Data Export",
"location": {
"startingColumn": 22,
"startingLine": 1601
"startingLine": 1604
}
},
{
@@ -351,7 +351,7 @@
"key": "Data Import / Restore",
"location": {
"startingColumn": 22,
"startingLine": 1602
"startingLine": 1605
}
},
{
@@ -359,7 +359,7 @@
"key": "MySQL Connection",
"location": {
"startingColumn": 26,
"startingLine": 1609
"startingLine": 1612
}
},
{
@@ -367,7 +367,7 @@
"key": "Export Options",
"location": {
"startingColumn": 30,
"startingLine": 1633
"startingLine": 1636
}
},
{
@@ -375,7 +375,7 @@
"key": "Import Options",
"location": {
"startingColumn": 30,
"startingLine": 1689
"startingLine": 1692
}
},
{
@@ -383,7 +383,7 @@
"key": "Progress",
"location": {
"startingColumn": 26,
"startingLine": 1701
"startingLine": 1704
}
},
{
@@ -391,7 +391,7 @@
"key": "Connection",
"location": {
"startingColumn": 36,
"startingLine": 1611
"startingLine": 1614
}
},
{
@@ -399,7 +399,7 @@
"key": "Database",
"location": {
"startingColumn": 28,
"startingLine": 1615
"startingLine": 1618
}
},
{
@@ -407,7 +407,7 @@
"key": "Select Database",
"location": {
"startingColumn": 30,
"startingLine": 1616
"startingLine": 1619
}
},
{
@@ -415,7 +415,7 @@
"key": "Refresh Databases",
"location": {
"startingColumn": 32,
"startingLine": 1624
"startingLine": 1627
}
},
{
@@ -423,7 +423,7 @@
"key": "No tables found. Select a database or refresh the list.",
"location": {
"startingColumn": 34,
"startingLine": 1655
"startingLine": 1658
}
},
{
@@ -431,7 +431,7 @@
"key": "InnoDB data is exported using a consistent snapshot and a single streamed query per table. Tables without unique indexes are supported.",
"location": {
"startingColumn": 30,
"startingLine": 1684
"startingLine": 1687
}
},
{
@@ -439,7 +439,7 @@
"key": "Table structure",
"location": {
"startingColumn": 32,
"startingLine": 1635
"startingLine": 1638
}
},
{
@@ -447,7 +447,7 @@
"key": "Table data",
"location": {
"startingColumn": 32,
"startingLine": 1636
"startingLine": 1639
}
},
{
@@ -455,7 +455,7 @@
"key": "Add DROP TABLE IF EXISTS",
"location": {
"startingColumn": 32,
"startingLine": 1637
"startingLine": 1640
}
},
{
@@ -463,7 +463,7 @@
"key": "Include views (definitions)",
"location": {
"startingColumn": 32,
"startingLine": 1639
"startingLine": 1642
}
},
{
@@ -471,7 +471,7 @@
"key": "Include triggers",
"location": {
"startingColumn": 32,
"startingLine": 1641
"startingLine": 1644
}
},
{
@@ -479,7 +479,7 @@
"key": "Include stored procedures and functions",
"location": {
"startingColumn": 32,
"startingLine": 1643
"startingLine": 1646
}
},
{
@@ -487,7 +487,7 @@
"key": "Loading tables…",
"location": {
"startingColumn": 57,
"startingLine": 1653
"startingLine": 1656
}
},
{
@@ -495,7 +495,7 @@
"key": "Tables (%lld selected)",
"location": {
"startingColumn": 34,
"startingLine": 1646
"startingLine": 1649
}
},
{
@@ -503,7 +503,7 @@
"key": "All",
"location": {
"startingColumn": 36,
"startingLine": 1648
"startingLine": 1651
}
},
{
@@ -511,7 +511,7 @@
"key": "None",
"location": {
"startingColumn": 36,
"startingLine": 1649
"startingLine": 1652
}
},
{
@@ -519,7 +519,7 @@
"key": "Refresh",
"location": {
"startingColumn": 36,
"startingLine": 1650
"startingLine": 1653
}
},
{
@@ -527,7 +527,7 @@
"key": "Views (%lld selected)",
"location": {
"startingColumn": 38,
"startingLine": 1669
"startingLine": 1672
}
},
{
@@ -535,7 +535,7 @@
"key": "All",
"location": {
"startingColumn": 40,
"startingLine": 1671
"startingLine": 1674
}
},
{
@@ -543,7 +543,7 @@
"key": "None",
"location": {
"startingColumn": 40,
"startingLine": 1672
"startingLine": 1675
}
},
{
@@ -551,7 +551,7 @@
"key": "Import SQL statements into the selected database.",
"location": {
"startingColumn": 30,
"startingLine": 1691
"startingLine": 1694
}
},
{
@@ -559,7 +559,15 @@
"key": "Supports MySQL DELIMITER directives, triggers and stored routines. Import is not transactional; use a verified backup before restoring.",
"location": {
"startingColumn": 30,
"startingLine": 1694
"startingLine": 1697
}
},
{
"comment": "",
"key": "Current table: %@ / %@ rows · Total exported: %@",
"location": {
"startingColumn": 30,
"startingLine": 1715
}
},
{
@@ -567,7 +575,7 @@
"key": "Close",
"location": {
"startingColumn": 24,
"startingLine": 1720
"startingLine": 1729
}
},
{
@@ -575,7 +583,7 @@
"key": "Verify Backup…",
"location": {
"startingColumn": 28,
"startingLine": 1728
"startingLine": 1737
}
},
{
@@ -583,7 +591,7 @@
"key": "Verify an SQL file against its SHA-256 checksum sidecar",
"location": {
"startingColumn": 27,
"startingLine": 1731
"startingLine": 1740
}
},
{
@@ -591,7 +599,7 @@
"key": "Cancel",
"location": {
"startingColumn": 28,
"startingLine": 1735
"startingLine": 1744
}
},
{
@@ -599,7 +607,7 @@
"key": "Export SQL…",
"location": {
"startingColumn": 31,
"startingLine": 1742
"startingLine": 1751
}
},
{
@@ -607,7 +615,7 @@
"key": "Import SQL…",
"location": {
"startingColumn": 31,
"startingLine": 1743
"startingLine": 1752
}
},
{
@@ -615,7 +623,7 @@
"key": "Import SQL",
"location": {
"startingColumn": 20,
"startingLine": 1783
"startingLine": 1792
}
},
{
@@ -623,7 +631,7 @@
"key": "Cancel",
"location": {
"startingColumn": 20,
"startingLine": 1791
"startingLine": 1800
}
},
{
@@ -631,7 +639,7 @@
"key": "SQL files can modify or delete existing database objects and data. Ensure you have a backup before continuing.",
"location": {
"startingColumn": 17,
"startingLine": 1796
"startingLine": 1805
}
},
{
@@ -639,7 +647,7 @@
"key": "Database Import / Export",
"location": {
"startingColumn": 22,
"startingLine": 1808
"startingLine": 1817
}
},
{
@@ -647,7 +655,7 @@
"key": "Built-in native MySQL database tools",
"location": {
"startingColumn": 22,
"startingLine": 1811
"startingLine": 1820
}
}
]
@@ -15,3 +15,4 @@
/Volumes/Developer/Applications/WorkbenchReplacement/build/Build/Products/Debug/WorkbenchReplacement.app
/Volumes/Developer/Applications/WorkbenchReplacement/build/Build/Products/Debug/WorkbenchReplacement.app
/Volumes/Developer/Applications/WorkbenchReplacement/build/Build/Products/Debug/WorkbenchReplacement.app
/Volumes/Developer/Applications/WorkbenchReplacement/build/Build/Products/Debug/WorkbenchReplacement.app
@@ -19,7 +19,7 @@
<dict>
<key>cdhash</key>
<data>
lD7vQzFdLMorMrk09F1ArmxtEu4=
6S/w6SxP3rEIpQZE9rYcyy4Jl84=
</data>
<key>requirement</key>
<string>identifier "WorkbenchReplacement.debug" and anchor apple generic and certificate leaf[subject.CN] = "Apple Development: Mark Gregory (FLBRJ3BYDD)" and certificate 1[field.1.2.840.113635.100.6.2.1] /* exists */</string>
+5 -47
View File
@@ -6,48 +6,6 @@
<integer>13</integer>
<key>logs</key>
<dict>
<key>32E9EC2D-B9B8-4CD2-8B3D-CD693A4CBD97</key>
<dict>
<key>className</key>
<string>IDECommandLineBuildLog</string>
<key>documentTypeString</key>
<string>&lt;nil&gt;</string>
<key>domainType</key>
<string>Xcode.IDEActivityLogDomainType.BuildLog</string>
<key>fileName</key>
<string>32E9EC2D-B9B8-4CD2-8B3D-CD693A4CBD97.xcactivitylog</string>
<key>hasPrimaryLog</key>
<true/>
<key>primaryObservable</key>
<dict>
<key>highLevelStatus</key>
<string>S</string>
<key>totalNumberOfAnalyzerIssues</key>
<integer>0</integer>
<key>totalNumberOfErrors</key>
<integer>0</integer>
<key>totalNumberOfTestFailures</key>
<integer>0</integer>
<key>totalNumberOfWarnings</key>
<integer>0</integer>
</dict>
<key>schemeIdentifier-containerName</key>
<string>WorkbenchReplacement project</string>
<key>schemeIdentifier-schemeName</key>
<string>WorkbenchReplacement</string>
<key>schemeIdentifier-sharedScheme</key>
<integer>1</integer>
<key>signature</key>
<string>Building project WorkbenchReplacement with scheme WorkbenchReplacement and configuration Debug</string>
<key>timeStartedRecording</key>
<real>813876968.59599304</real>
<key>timeStoppedRecording</key>
<real>813876981.606776</real>
<key>title</key>
<string>Building project WorkbenchReplacement with scheme WorkbenchReplacement and configuration Debug</string>
<key>uniqueIdentifier</key>
<string>32E9EC2D-B9B8-4CD2-8B3D-CD693A4CBD97</string>
</dict>
<key>68955E3A-0B2E-4614-AC89-290DCD28B6D0</key>
<dict>
<key>className</key>
@@ -90,7 +48,7 @@
<key>uniqueIdentifier</key>
<string>68955E3A-0B2E-4614-AC89-290DCD28B6D0</string>
</dict>
<key>921D995A-6441-4831-9E4E-3283B2F38B89</key>
<key>B2C949DC-0503-4157-BC15-F74641625B50</key>
<dict>
<key>className</key>
<string>IDECommandLineBuildLog</string>
@@ -99,7 +57,7 @@
<key>domainType</key>
<string>Xcode.IDEActivityLogDomainType.BuildLog</string>
<key>fileName</key>
<string>921D995A-6441-4831-9E4E-3283B2F38B89.xcactivitylog</string>
<string>B2C949DC-0503-4157-BC15-F74641625B50.xcactivitylog</string>
<key>hasPrimaryLog</key>
<true/>
<key>primaryObservable</key>
@@ -124,13 +82,13 @@
<key>signature</key>
<string>Building project WorkbenchReplacement with scheme WorkbenchReplacement and configuration Debug</string>
<key>timeStartedRecording</key>
<real>813877067.82482302</real>
<real>813877672.07052696</real>
<key>timeStoppedRecording</key>
<real>813877081.68267095</real>
<real>813877685.02004802</real>
<key>title</key>
<string>Building project WorkbenchReplacement with scheme WorkbenchReplacement and configuration Debug</string>
<key>uniqueIdentifier</key>
<string>921D995A-6441-4831-9E4E-3283B2F38B89</string>
<string>B2C949DC-0503-4157-BC15-F74641625B50</string>
</dict>
<key>EB994874-BDA8-4BAC-BAF2-6EB6F20E2468</key>
<dict>
@@ -1 +1 @@
1792184713.510244: Module build session file for module cache at Path(str: "/Volumes/Developer/Applications/WorkbenchReplacement/build/ModuleCache.noindex")
1792184872.486644: Module build session file for module cache at Path(str: "/Volumes/Developer/Applications/WorkbenchReplacement/build/ModuleCache.noindex")
+1 -1
View File
@@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>LastAccessedDate</key>
<date>2026-10-16T21:05:13Z</date>
<date>2026-10-16T21:07:52Z</date>
<key>WorkspacePath</key>
<string>/Volumes/Developer/Applications/WorkbenchReplacement/WorkbenchReplacement.xcodeproj</string>
</dict>