Skip to content

refactor: extract PaginationCoordinator and RowEditingCoordinator#1127

Merged
datlechin merged 4 commits into
mainfrom
refactor/phase4-step4-coordinators
May 9, 2026
Merged

refactor: extract PaginationCoordinator and RowEditingCoordinator#1127
datlechin merged 4 commits into
mainfrom
refactor/phase4-step4-coordinators

Conversation

@datlechin

Copy link
Copy Markdown
Member

Summary

Phase 4 step 4. Two more focused coordinators extracted from MainContentCoordinator's 5 extension files (~903 LOC moved). Same pattern as PR #1125 (FilterCoordinator + QueryExecutionCoordinator). State stays on tabManager.tabs and is mutated via the mutate(tabId:) API from PR #1124.

Extracted

PaginationCoordinator (Core/Coordinators/PaginationCoordinator.swift, 221 LOC)

RowEditingCoordinator (Core/Coordinators/, 3 files, 682 LOC)

  • Main file (241 LOC) plus +SaveChanges.swift (314 LOC) and +Discard.swift (127 LOC).
  • Split into extension files because combined would cross the 1100-line type_body warning.
  • 4 Task closures, all capture [weak self, parent] or [parent].

Forwarders

22 thin forwarders kept on existing extension files so views and tests compile unchanged:

  • 7 in +Pagination.swift, 2 in +LoadMore.swift (cancelCurrentQuery, fetchAllRows)
  • 10 in +RowOperations.swift, 1 in +SaveChanges.swift (saveChanges with inout), 2 in +Discard.swift

Out of scope

  • MainContentCoordinator+TabSwitch.swift (audit score -10, undo manager coupling). Stays for now.
  • Central query entry points (runQuery, executeQueryInternal, etc.) stay on MainContentCoordinator.
  • assemblePendingStatements and fkEnableStatements stay on parent — RowEditingCoordinator+SaveChanges accesses via parent.X. Tests reference them directly, not in scope to relocate.

Verification

  • xcodebuild Debug builds (BUILD SUCCEEDED).
  • swiftlint clean across all 7 touched files.
  • All 5 Task closures verified: grep -nE "Task \\{|Task\\(" TablePro/Core/Coordinators/Pagination*.swift TablePro/Core/Coordinators/RowEditing*.swift shows every Task uses [parent] capture.
  • Pre-existing test failure in TableProTests/Core/Storage/QueryHistoryManagerTests.swift (type 'NSNotification.Name?' has no member 'queryHistoryDidUpdate') is unrelated to this refactor — file unchanged vs main.

Commits

  1. 6f193e9 - extract PaginationCoordinator
  2. 501dca5 - extract RowEditingCoordinator (with SaveChanges + Discard sub-files)

Test plan

  • Build clean (verified)
  • Pagination: next/prev page, page size change, total row count populates
  • Load More: fetch all rows on a paginated table, observe progress
  • Cancel an in-flight COUNT(*) or fetch-all
  • Insert row, edit cell, delete row, save changes, verify SQL preview
  • Discard pending changes, verify undo state cleared
  • FK toggle on save (truncate + re-enable order preserved)

@datlechin datlechin changed the title refactor: phase 4 step 4 — extract PaginationCoordinator and RowEditingCoordinator refactor: extract PaginationCoordinator and RowEditingCoordinator May 8, 2026
@datlechin datlechin merged commit 269e5e7 into main May 9, 2026
2 checks passed
@datlechin datlechin deleted the refactor/phase4-step4-coordinators branch May 9, 2026 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant