Skip to content

Centralize adjustment reset logic in the model - #1

Open
yingwang wants to merge 1 commit into
mainfrom
claude/luma-project-improvements-KDC4t
Open

yingwang wants to merge 1 commit into
mainfrom
claude/luma-project-improvements-KDC4t

Conversation

@yingwang

Copy link
Copy Markdown
Owner

Summary

The radial, linear, spot-heal, beauty, and color-mixer reset routines in PhotoLibraryStore each inlined PhotoAdjustments' default values as magic numbers (e.g. radialRadius = 0.35, spotHealRadius = 0.06, linearEndY = 0.65). Those same defaults already live in three other places — the struct's stored-property defaults, the memberwise init, and the Decodable initializer — so a default could silently drift out of sync between the editor's reset buttons and the actual neutral state.

This PR moves the reset behavior onto PhotoAdjustments itself as pure mutating methods that derive their values from PhotoAdjustments.neutral, and has the store delegate to them.

Changes

  • PhotoAsset.swift — add resetRadialAdjustment(), resetLinearAdjustment(), resetSpotHeal(), resetLocalAdjustments(), resetBeautyAdjustments(), and resetColorMixer() on PhotoAdjustments. The local/radial/linear/spot methods source their values from PhotoAdjustments.neutral so there is a single source of truth.
  • PhotoLibraryStore.swift — the six resetSelected… methods now delegate to the new model methods instead of repeating the field-by-field resets (net −48 lines of duplicated magic numbers).
  • LumaModelTests.swift — add 6 tests verifying each reset restores the right fields to their neutral defaults while leaving unrelated edits untouched.

Behavior

No user-facing behavior change — this is a refactor that removes duplication and adds test coverage to logic that was previously only exercised through the Core Image pipeline.

Testing

I could not compile or run swift test in this environment (Linux, no Swift toolchain; the app targets macOS-only AppKit/SwiftUI/Core Image). The change is deliberately scoped to pure value-type logic so it is fully covered by the existing model test target — please run swift test on macOS to confirm.

https://claude.ai/code/session_01KhYaXvEGDKh26h6A5LdoAW


Generated by Claude Code

The radial, linear, spot-heal, beauty, and color-mixer reset routines
duplicated PhotoAdjustments default values inside PhotoLibraryStore.
Those magic numbers also live in the struct defaults, the memberwise
init, and the decoder, so a default could silently drift out of sync
across call sites.

Move the reset behavior onto PhotoAdjustments as pure mutating methods
(resetRadialAdjustment, resetLinearAdjustment, resetSpotHeal,
resetLocalAdjustments, resetBeautyAdjustments, resetColorMixer) that
derive their values from PhotoAdjustments.neutral, and have the store
delegate to them. Add model unit tests covering each reset.
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