You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[desktop/macos] APIClient.swift is a 5,750-line god actor with hand-duplicated server models #8844
Desktop/Sources/APIClient.swift is a single 5,750-line file: one actor, 18+ anonymous extension APIClient blocks, 168 functions, plus most server DTOs defined inline (ActionItem at :1040, ConversationPhoto at :1185, ServerMemory at :1444, ActionItemsListResponse at :2163, …). Every feature touches this file, so it is a permanent merge-conflict and review hotspot at ~1190 desktop commits/month.
The DTOs are also hand-duplicated across three codebases with no generated contract:
Python backend models (source of truth for the REST API)
Drift is already visible in the scars: Tests/ServerMemoryV17DecodingTests.swift exists because decoding broke against a server schema change.
Suggested fix (incremental, no rewrite)
Mechanically split APIClient.swift into per-domain files (APIClient+Conversations.swift, APIClient+Memories.swift, APIClient+Tasks.swift, …) and move DTOs into a Models/ directory. Pure file moves, no behavior change — do it in one PR to keep blame useful.
Add a CI ratchet: fail if any Swift file under Desktop/Sources exceeds its current line count high-water mark (or a fixed cap for new files), so god files can only shrink. Same medicine applies to TasksPage.swift (5,394), ChatProvider.swift (4,406), FloatingControlBarWindow.swift (3,636).
Longer term: generate the Swift DTOs from the Python backend's OpenAPI schema (FastAPI already produces one; backend/scripts/openapi_runner.sh exists), or at minimum add contract tests pinning JSON fixtures shared between the Swift and Rust decoders — mirroring the existing desktop-backend-contracts.yml pattern.
Open questions
Which DTOs are desktop-only (Rust backend) vs shared with the Python API? The split determines which contract source to generate from.
Done: APIClient.swift is now 1,103 lines with domain files split out (Services/APIClient/APIClient+Settings.swift, +AuthPolicy.swift), and the god-file ratchet exists as product-file-line-count-ratchet in .github/checks-manifest.yaml.
Activity
refactor: thermo-nuclear quality repayment (macOS + backend) (#9327)
Git-on-my-level commentedon Jul 22, 2026
Done: APIClient.swift is now 1,103 lines with domain files split out (Services/APIClient/APIClient+Settings.swift, +AuthPolicy.swift), and the god-file ratchet exists as
product-file-line-count-ratchetin .github/checks-manifest.yaml.