Skip to content

refactor: move UI-test harnesses out of AppDelegate into extension files - #60

Merged
arzafran merged 1 commit into
mainfrom
refactor/n3-appdelegate-uitest-harness
Jul 8, 2026
Merged

refactor: move UI-test harnesses out of AppDelegate into extension files#60
arzafran merged 1 commit into
mainfrom
refactor/n3-appdelegate-uitest-harness

Conversation

@arzafran

@arzafran arzafran commented Jul 8, 2026

Copy link
Copy Markdown
Member

What this does

AppDelegate.swift had grown to 14,818 lines, and roughly a fifth of that was code that only exists to support XCUITest automation (cmd-click diagnostics, stress-workspace loaders, jump-to-unread/goto-split/bonsplit-drag/multi-window-notification test harnesses). None of it runs in production builds. This moves that instrumentation into three same-type extension files so AppDelegate.swift itself is smaller and easier to navigate, with zero behavior change.

Summary

  • Sources/AppDelegate+UITestCmdClick.swift (726 lines): cmd-click terminal UI test setup, socket sanity check, display-resolution diagnostics. Moved as a single #if DEBUG block (lines 3103–3815 of the original file).
  • Sources/AppDelegate+UITestStressWorkspaces.swift (547 lines): debug-stress-workspace loaders (openDebugStressWorkspacesWithLoadedSurfaces and its helpers). Functions only — the stored properties they depend on stay in the AppDelegate class body (Swift doesn't allow stored properties in extensions), re-wrapped in their own #if DEBUG.
  • Sources/AppDelegate+UITestHarnesses.swift (1,803 lines): jump-unread, goto-split, bonsplit tab-drag, and multi-window-notification test harnesses. Moved as a single #if DEBUG block.
  • Sources/AppDelegate.swift: 14,818 → 11,783 lines. All moved code deleted; no call sites changed.
  • GhosttyTabs.xcodeproj/project.pbxproj: registered the 3 new files (fileRef + buildFile entries, group membership, Sources build phase) mirroring AppDelegate.swift's existing entries.

Visibility widened (private/fileprivate → internal only — no other change) because the split moved code across file boundaries within the same type:

  • MainWindowContext (private final class) → internal
  • Members defined outside the moved clusters, now called from moved code: writeUITestDiagnosticsIfNeeded, socketListenerConfigurationIfEnabled, restartSocketListenerIfEnabled, debugManagerToken, sendTextWhenReady, plus stored properties the compiler flagged during the build pass: mainWindowContexts, didSetupJumpUnreadUITest, jumpUnreadFocusExpectation, jumpUnreadFocusObserver, didSetupTerminalCmdClickUITest, didSetupGotoSplitUITest, didSetupBonsplitTabDragUITest, terminalCmdClickUITestPoller, bonsplitTabDragUITestRecorder, gotoSplitUITestRecorder, gotoSplitUITestObservers, didSetupMultiWindowNotificationsUITest, didSetupDisplayResolutionUITestDiagnostics, displayResolutionUITestObservers, ghosttyGotoSplitLeftShortcut/RightShortcut/UpShortcut/DownShortcut, debugStressWorkspaceCreationInProgress, debugStressLagProbeEnabled, debugStressWorkspaceCount, debugStressPaneCount, debugStressTabsPerPane, debugStressYieldInterval, debugStressSurfaceLoadTimeoutSeconds, debugPerfWorkspaceTitlePrefix.
  • Members defined inside the moved clusters, now called from code that stays in AppDelegate.swift: the six setup...UITestIfNeeded entry points (setupJumpUnreadUITestIfNeeded, setupTerminalCmdClickUITestIfNeeded, setupGotoSplitUITestIfNeeded, setupBonsplitTabDragUITestIfNeeded, setupMultiWindowNotificationsUITestIfNeeded, setupDisplayResolutionUITestDiagnosticsIfNeeded), plus logSlowShortcutMonitorLatencyIfNeeded, recordGotoSplitMoveIfNeeded, recordGotoSplitSplitIfNeeded, recordGotoSplitZoomIfNeeded, recordMultiWindowNotificationFocusIfNeeded, scheduleUITestSocketSanityCheckIfNeeded, writeJumpUnreadTestData, writeMultiWindowNotificationTestData.

Nuclear-review N3/AS2.

Test Plan

  • Local Debug build green: PROGRAMA_SKIP_ZIG_BUILD=1 xcodebuild -project GhosttyTabs.xcodeproj -scheme programa -configuration Debug -destination 'platform=macOS' build** BUILD SUCCEEDED **
  • CI arbiter — this is a pure move with no logic changes, so the key checks are ui-regressions and the UITest-driven jobs (jump-unread, goto-split, bonsplit-drag, multi-window-notification, cmd-click) passing unchanged.

~3,200 lines of XCUITest-only instrumentation (cmd-click diagnostics,
stress-workspace loaders, jump-unread/goto-split/bonsplit-drag/
multi-window-notification harnesses) move to same-type extension files.
Zero call-site change; visibility widened only where the move split a
same-file reference. Nuclear-review N3/AS2.
@arzafran
arzafran merged commit 2125242 into main Jul 8, 2026
8 checks passed
@arzafran
arzafran deleted the refactor/n3-appdelegate-uitest-harness branch July 10, 2026 16:05
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