Skip to content

refactor(database, connections): dedup post-connect setup, extract StoredConnection model#1571

Merged
datlechin merged 2 commits into
mainfrom
refactor/tier1-architecture
Jun 3, 2026
Merged

refactor(database, connections): dedup post-connect setup, extract StoredConnection model#1571
datlechin merged 2 commits into
mainfrom
refactor/tier1-architecture

Conversation

@datlechin

Copy link
Copy Markdown
Member

Summary

Two behavior-preserving Tier-1 architecture refactors. Both build green; the connect/reconnect change was manually verified in the running app (connect + reconnect + startup commands), and the model extraction is covered by the existing ConnectionStorage Codable tests.

1. Shared post-connect setup (DatabaseManager)

The post-connect sequence (apply query timeout, run startup commands; restore schema/database on reconnect) was duplicated across reconnectDriver, reconnectSession, and connectToSession. Extracted into two helpers, applyTimeoutAndStartupCommands and restoreSchemaAndDatabase.

Each call site keeps its own distinct pre-connect orchestration (tunnel rebuild, password prompt, connect error handling) and passes its exact original arguments (for example connectToSession keeps resolvedConnection.startupCommands and connection.name), so behavior is unchanged. Net +42 / -52.

2. Extract StoredConnection model

ConnectionStorage.swift was a 988-line file mixing connection CRUD, 8 kinds of Keychain secret storage, migrations, and the 420-line StoredConnection Codable model. Moved StoredConnection to its own file. ConnectionStorage.swift is now 565 lines, under all SwiftLint limits. Pure move, no logic change.

Verification

  • App build: green.
  • Connect + reconnect + startup-commands flow: manually verified in the running app.
  • Connection list load + save: manually verified; the ConnectionStorage Codable round-trip is covered by existing tests in CI.

Notes

This is the safe, verifiable slice of Tier 1. The remaining items (split the 8 Keychain secret methods into a ConnectionSecretsStore, the DI singleton sweep, and the MainContentCoordinator god-object split) are higher-risk and were deliberately deferred to dedicated work where the running app can be driven to verify password, connection, and UI behavior.

@datlechin datlechin merged commit 0414c0b into main Jun 3, 2026
4 checks passed
@datlechin datlechin deleted the refactor/tier1-architecture branch June 3, 2026 10:20
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