Skip to content

Fix build: initialize fadeIn properties in SuggestionSettingsModel.init#763

Merged
FuJacob merged 1 commit into
FuJacob:mainfrom
t-h-tech:fix/settings-init-fadein
Jun 28, 2026
Merged

Fix build: initialize fadeIn properties in SuggestionSettingsModel.init#763
FuJacob merged 1 commit into
FuJacob:mainfrom
t-h-tech:fix/settings-init-fadein

Conversation

@t-h-tech

@t-h-tech t-h-tech commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Summary

SuggestionSettingsModel.init doesn't initialize fadeInSuggestions / fadeInDurationSeconds — the two @Published properties added by the opacity-ramp change (#749). They're assigned in resetToDefaults but not in init, so Swift rejects the initializer ("return from initializer without initializing all stored properties") and main currently fails to compile (the xcodebuild (macOS) CI check is red). This adds the two missing assignments in init, mirroring resetToDefaults.

Validation

xcodebuild build -project Cotabby.xcodeproj -scheme Cotabby \
  -destination 'platform=macOS' CODE_SIGNING_ALLOWED=NO
# ** BUILD SUCCEEDED **   (current main fails to build without this change)

swiftlint lint --config .swiftlint.yml --quiet
# exit 0

The same fix on a feature branch also passes the full suite: xcodebuild test … CODE_SIGNING_ALLOWED=NO** TEST SUCCEEDED **, 1652 tests, 0 failures.

Linked issues

None.

Risk / rollout notes

Two-line change, no behavior difference — these values were already assigned everywhere except init. Restores a green build on main.

Greptile Summary

This PR restores a broken build on main by adding the two missing property initializations (fadeInSuggestions and fadeInDurationSeconds) introduced by PR #749 to SuggestionSettingsModel.init. Swift's definite initialization rules require every stored property to be set before the initializer returns, so the omission caused a compile error.

  • Adds fadeInSuggestions = data.fadeInSuggestions and fadeInDurationSeconds = data.fadeInDurationSeconds to init, mirroring their existing assignments in resetToDefaults.
  • The fix re-establishes the documented invariant that the init assignment list and the resetToDefaults assignment list stay in sync, which is enforced by a dedicated unit test.

Confidence Score: 5/5

Safe to merge — two-line addition that unblocks the build with no behavioral change.

The change adds two property assignments that were clearly supposed to be in init all along — they exist in resetToDefaults and are read everywhere the overlay renderer touches fade settings. The values flow from the same store.load call that populates every other property, so there is no new logic to reason about and no risk of wrong defaults. The init/resetToDefaults parity is tested, meaning the test suite will catch any future drift.

No files require special attention.

Important Files Changed

Filename Overview
Cotabby/Models/SuggestionSettingsModel.swift Adds the two missing init assignments for fadeInSuggestions and fadeInDurationSeconds; restores the init/resetToDefaults parity invariant and fixes the compilation error.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant Caller
    participant SuggestionSettingsModel
    participant SuggestionSettingsStore
    participant SuggestionSettingsData

    Caller->>SuggestionSettingsModel: init(configuration:userDefaults:)
    SuggestionSettingsModel->>SuggestionSettingsStore: load(configuration:)
    SuggestionSettingsStore-->>SuggestionSettingsModel: SuggestionSettingsData
    Note over SuggestionSettingsModel: Assign all @Published properties from data
    Note over SuggestionSettingsModel: (including fadeInSuggestions + fadeInDurationSeconds — added by this PR)
    SuggestionSettingsModel-->>Caller: fully initialized instance

    Caller->>SuggestionSettingsModel: resetToDefaults()
    SuggestionSettingsModel->>SuggestionSettingsStore: resetToDefaults(configuration:)
    SuggestionSettingsStore-->>SuggestionSettingsModel: SuggestionSettingsData (defaults)
    Note over SuggestionSettingsModel: Re-fans all @Published properties (mirrors init)
    SuggestionSettingsModel-->>Caller: settings reset
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"}}}%%
sequenceDiagram
    participant Caller
    participant SuggestionSettingsModel
    participant SuggestionSettingsStore
    participant SuggestionSettingsData

    Caller->>SuggestionSettingsModel: init(configuration:userDefaults:)
    SuggestionSettingsModel->>SuggestionSettingsStore: load(configuration:)
    SuggestionSettingsStore-->>SuggestionSettingsModel: SuggestionSettingsData
    Note over SuggestionSettingsModel: Assign all @Published properties from data
    Note over SuggestionSettingsModel: (including fadeInSuggestions + fadeInDurationSeconds — added by this PR)
    SuggestionSettingsModel-->>Caller: fully initialized instance

    Caller->>SuggestionSettingsModel: resetToDefaults()
    SuggestionSettingsModel->>SuggestionSettingsStore: resetToDefaults(configuration:)
    SuggestionSettingsStore-->>SuggestionSettingsModel: SuggestionSettingsData (defaults)
    Note over SuggestionSettingsModel: Re-fans all @Published properties (mirrors init)
    SuggestionSettingsModel-->>Caller: settings reset
Loading

Reviews (1): Last reviewed commit: "Fix build: initialize fadeIn properties ..." | Re-trigger Greptile

The opacity-ramp change (FuJacob#749) added `fadeInSuggestions` and
`fadeInDurationSeconds` and assigns them in `resetToDefaults`, but `init`
never sets them, so the initializer is rejected ("return from initializer
without initializing all stored properties") and `main` does not compile.
Initialize both from `data` in `init`, mirroring `resetToDefaults`.

@FuJacob FuJacob left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!!

@FuJacob FuJacob merged commit a69a362 into FuJacob:main Jun 28, 2026
4 checks passed
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.

2 participants