fix: notify on new Xcode version identity, not array-count growth - #842
Open
YuriNachos wants to merge 1 commit into
Open
fix: notify on new Xcode version identity, not array-count growth#842YuriNachos wants to merge 1 commit into
YuriNachos wants to merge 1 commit into
Conversation
The "New Xcode version available" notification was triggered by an array-count increase rather than by the appearance of a genuinely new version identity (AvailableXcode.xcodeID). This caused two user-visible bugs: - False negative: when a new version is added and an old one removed in the same refresh (count unchanged, or even shrunk), no notification fired, so a genuinely new version landed silently. - False positive: when the array grew without a new identity (a duplicate row, or a data-source switch returning an already-known xcodeID), a spurious "new version" banner appeared. Extract the decision into a pure static helper AppState.newlyAvailableXcodes(oldXcodes:newXcodes:) that computes the xcodeID set difference, and notify iff it is non-empty. The empty-old guard is preserved so the initial cache load (empty -> populated) does not notify; the scheduleNotification arguments are unchanged. Adds XcodesTests/NewVersionNotificationTests.swift with a red-before-green regression suite (the false-negative and false-positive cases fail against a buggy count-based mirror and pass against the identity-based body). Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The "New Xcode version available" notification fired whenever the
availableXcodesarray count grew (newValue.count > availableXcodes.count), not when a genuinely new version identity appeared. This caused two user-visible bugs:Solution
Extract a pure helper that compares version identity, not array length:
availableXcodes.willSetnow notifies only when the helper's result is non-empty:AvailableXcode.xcodeID(alreadyHashable) is the identity, so the same version with a different architecture correctly stays distinct and does NOT re-notify.oldXcodes.isEmpty→[], so first-run does not banner every Xcode.Localizable.xcstringschange (title/body keys unchanged).Testing
New
XcodesTests/NewVersionNotificationTests.swift(own file to avoid theAppStateTests.swiftconflict with PR #840) asserts directly on the pure helper:[]);[A]→[A, A]→[], no spurious notify);Real red-before-green: on
main's count predicate, the equal-count cases (new+removed) notify nothing, so the test expecting the new version's identity fails; after the fix it passes.xcodebuild test -scheme Xcodes -destination 'platform=macOS' CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO -only-testing:XcodesTests/NewVersionNotificationTests→ TEST SUCCEEDED.Checklist
AppState.swift(predicate) + newNewVersionNotificationTests.swift+project.pbxproj(test-target registration only).AppState+Install.swift) or fix: rebind Create Symbolic Link shortcut to Cmd+Opt+L to resolve Make Active collision #841 (XcodeCommands.swift).Localizable.xcstringsbyte-identical tomain.Authored by
@YuriNachos. Implementation written by acccc(Claude Code, GLM-5.2) worker under orchestrator acceptance; an independent adversarial review returned APPROVE with no blocking findings.