Skip to content

Refactor settings into product domains#799

Merged
FuJacob merged 1 commit into
mainfrom
codex/settings-domains
Jul 18, 2026
Merged

Refactor settings into product domains#799
FuJacob merged 1 commit into
mainfrom
codex/settings-domains

Conversation

@FuJacob

@FuJacob FuJacob commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Summary

Group Cotabby's durable suggestion settings into subsystem-owned domain values while preserving the existing SwiftUI properties, generation snapshot, and flat persistence keys. This gives future work cohesive settings boundaries without making a migration part of the refactor.

This is the third PR in the repository-organization stack and is based on #798.

Validation

  • swiftlint lint --strict — 0 violations.
  • xcodegen generate — succeeded and the generated project is committed.
  • xcodebuild -project Cotabby.xcodeproj -scheme Cotabby -destination 'platform=macOS' build-for-testing -derivedDataPath build/DerivedDataTEST BUILD SUCCEEDED.
  • Compatibility inventory — all 61 previous flat SuggestionSettingsData properties remain as bidirectional forwarding accessors.
  • After ad-hoc re-signing the local test host to avoid the repository's Team-ID mismatch, 87 settings domain/model/store tests passed with 0 failures on the final stacked branch.

Linked issues

None.

Risk / rollout notes

No UserDefaults or Keychain key changes are included. SuggestionSettingsSnapshot retains its existing shape and the observable model retains its individual @Published properties, so this should not alter persistence, observation timing, or generation behavior.

Greptile Summary

This PR restructures the flat SuggestionSettingsData struct into eight cohesive domain sub-structs (SuggestionGeneralSettings, SuggestionEngineSettings, SuggestionCompletionSettings, SuggestionContextSettings, SuggestionCorrectionSettings, SuggestionPresentationSettings, SuggestionInlineFeatureSettings, SuggestionShortcutSettings) while keeping all 61 original flat properties as bidirectional forwarding computed properties for backward compatibility. Persistence keys, @Published properties on the model, and SuggestionSettingsSnapshot shape are all unchanged.

  • SuggestionSettingsData.swift: Replaces the single flat struct with eight domain sub-structs plus a compatibility extension that re-exposes every prior property through a forwarding getter/setter pair.
  • SuggestionSettingsModel.swift: Adds a domainSettings computed property that assembles SuggestionSettingsData from the existing @Published properties, and refactors snapshot to go through domainSettings rather than reading individual properties directly.
  • SuggestionSettingsStore.swift and SuggestionSettingsDomainTests.swift: Construction of SuggestionSettingsData in the store updated to use the new nested initialiser; new test file covers domain grouping, flat-accessor round-trips, and model projection.

Confidence Score: 5/5

Safe to merge — purely structural reorganization with no persistence, observation timing, or generation behavior changes.

All 61 flat forwarding accessors are correctly bidirectional, the snapshot computation is semantically identical to before, and UserDefaults keys are untouched. The snapshotPublisher still reads @published properties directly so reactive emission paths are unaffected. New tests cover store-load grouping, flat/domain round-trips, and model projection.

No files require special attention — all changed files are consistent with each other and with the stated refactoring goals.

Important Files Changed

Filename Overview
Cotabby/Models/Settings/SuggestionSettingsData.swift Core refactoring: flat struct split into 8 domain sub-structs with 61 bidirectional forwarding properties; all forwarding paths verified correct
Cotabby/Models/Settings/SuggestionSettingsModel.swift Adds domainSettings computed property and routes snapshot through it; isTemporarilyPaused computation is semantically identical to the previous direct property access
Cotabby/Support/Settings/SuggestionSettingsStore.swift SuggestionSettingsData construction updated to use nested domain initialisers; all resolved values correctly routed to their owning domain
CotabbyTests/Models/Settings/SuggestionSettingsDomainTests.swift New tests cover store-load grouping, flat/domain bidirectional consistency, and model domainSettings projection; adequate coverage for the structural change
Cotabby.xcodeproj/project.pbxproj Adds SuggestionSettingsDomainTests.swift to both the file references and test target sources sections; no other structural changes

Class Diagram

%%{init: {'theme': 'neutral'}}%%
classDiagram
    class SuggestionSettingsData {
        +var general: SuggestionGeneralSettings
        +var engine: SuggestionEngineSettings
        +var completion: SuggestionCompletionSettings
        +var context: SuggestionContextSettings
        +var correction: SuggestionCorrectionSettings
        +var presentation: SuggestionPresentationSettings
        +var inlineFeatures: SuggestionInlineFeatureSettings
        +var shortcuts: SuggestionShortcutSettings
        +61 total forwarding accessors
    }
    class SuggestionGeneralSettings {
        +isGloballyEnabled: Bool
        +pauseState: SuggestionPauseState?
        +disabledAppRules: [DisabledApplicationRule]
        +suggestInIntegratedTerminals: Bool
        +isPerformanceTrackingEnabled: Bool
    }
    class SuggestionShortcutSettings {
        +acceptance: SuggestionShortcutBindingSettings
        +fullAcceptance: SuggestionShortcutBindingSettings
        +globalToggle: SuggestionShortcutBindingSettings
    }
    class SuggestionShortcutBindingSettings {
        +keyCode: CGKeyCode
        +modifiers: ShortcutModifierMask
        +label: String
    }
    class SuggestionSettingsModel {
        +61 @Published properties
        +domainSettings: SuggestionSettingsData
        +snapshot: SuggestionSettingsSnapshot
    }
    class SuggestionSettingsStore {
        +load(configuration) SuggestionSettingsData
    }
    SuggestionSettingsData *-- SuggestionGeneralSettings
    SuggestionSettingsData *-- SuggestionShortcutSettings
    SuggestionShortcutSettings *-- SuggestionShortcutBindingSettings
    SuggestionSettingsModel ..> SuggestionSettingsData : domainSettings projection
    SuggestionSettingsStore ..> SuggestionSettingsData : constructs on load
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
classDiagram
    class SuggestionSettingsData {
        +var general: SuggestionGeneralSettings
        +var engine: SuggestionEngineSettings
        +var completion: SuggestionCompletionSettings
        +var context: SuggestionContextSettings
        +var correction: SuggestionCorrectionSettings
        +var presentation: SuggestionPresentationSettings
        +var inlineFeatures: SuggestionInlineFeatureSettings
        +var shortcuts: SuggestionShortcutSettings
        +61 total forwarding accessors
    }
    class SuggestionGeneralSettings {
        +isGloballyEnabled: Bool
        +pauseState: SuggestionPauseState?
        +disabledAppRules: [DisabledApplicationRule]
        +suggestInIntegratedTerminals: Bool
        +isPerformanceTrackingEnabled: Bool
    }
    class SuggestionShortcutSettings {
        +acceptance: SuggestionShortcutBindingSettings
        +fullAcceptance: SuggestionShortcutBindingSettings
        +globalToggle: SuggestionShortcutBindingSettings
    }
    class SuggestionShortcutBindingSettings {
        +keyCode: CGKeyCode
        +modifiers: ShortcutModifierMask
        +label: String
    }
    class SuggestionSettingsModel {
        +61 @Published properties
        +domainSettings: SuggestionSettingsData
        +snapshot: SuggestionSettingsSnapshot
    }
    class SuggestionSettingsStore {
        +load(configuration) SuggestionSettingsData
    }
    SuggestionSettingsData *-- SuggestionGeneralSettings
    SuggestionSettingsData *-- SuggestionShortcutSettings
    SuggestionShortcutSettings *-- SuggestionShortcutBindingSettings
    SuggestionSettingsModel ..> SuggestionSettingsData : domainSettings projection
    SuggestionSettingsStore ..> SuggestionSettingsData : constructs on load
Loading

Reviews (1): Last reviewed commit: "refactor: group settings by product doma..." | Re-trigger Greptile

@FuJacob
FuJacob force-pushed the codex/safe-decomposition branch from a35450d to ee74ba4 Compare July 18, 2026 03:01
@FuJacob
FuJacob deleted the branch main July 18, 2026 03:05
@FuJacob FuJacob closed this Jul 18, 2026
@FuJacob FuJacob reopened this Jul 18, 2026
@FuJacob
FuJacob changed the base branch from codex/safe-decomposition to main July 18, 2026 03:06
@FuJacob
FuJacob force-pushed the codex/settings-domains branch from 7a0bad7 to 9c15593 Compare July 18, 2026 03:06
@FuJacob
FuJacob marked this pull request as ready for review July 18, 2026 03:10
@FuJacob
FuJacob merged commit 5caed55 into main Jul 18, 2026
4 checks passed
@FuJacob
FuJacob deleted the codex/settings-domains branch July 18, 2026 03:10
@FuJacob
FuJacob restored the codex/settings-domains branch July 18, 2026 03:10
@FuJacob
FuJacob deleted the codex/settings-domains branch July 18, 2026 03:10
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