Skip to content

Commit 7d99cdc

Browse files
committed
fix: prevent false-positive item relocation when control items first appear
When control items first appear (e.g., after app restart), the previous window IDs might be empty or not reflect the actual visible section state. The code was falling back to checking item identity, which caused items already in the visible section to be treated as 'new' and incorrectly relocated. Fix by only moving items when we have previous window IDs to compare against - if previousIDs is empty, we can't reliably determine which items are new to the visible section, so don't move any. Signed-off-by: Toni Förster <toni.foerster@icloud.com>
1 parent 4a3dd24 commit 7d99cdc

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Thaw/MenuBar/MenuBarItems/MenuBarItemManager.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2688,12 +2688,16 @@ extension MenuBarItemManager {
26882688
savedSectionForIdentifier[item.uniqueIdentifier] != nil
26892689
guard !hasSavedSection else { return false }
26902690

2691-
let isNewIdentity = !knownItemIdentifiers.contains(identifier)
2692-
let isNewID = previousIDs.isEmpty ? isNewIdentity : !previousIDs.contains(item.windowID)
2691+
// Only move items that are new to this section (window ID not seen before).
2692+
// Don't fall back to identity check when previousIDs is empty - that causes
2693+
// false positives where items already in visible section get moved.
2694+
let isNewID = !previousIDs.isEmpty && !previousIDs.contains(item.windowID)
2695+
guard isNewID else { return false }
2696+
26932697
let notPlacedHidden = !hiddenTags.contains(item.tag) && !alwaysHiddenTags.contains(item.tag)
26942698
let bundle = bundleID(for: item)
26952699
let notPinnedHidden = bundle.map { !pinnedHiddenBundleIDs.contains($0) && !pinnedAlwaysHiddenBundleIDs.contains($0) } ?? true
2696-
return notPlacedHidden && notPinnedHidden && (isNewID || isNewIdentity)
2700+
return notPlacedHidden && notPinnedHidden
26972701
}
26982702
guard let candidate else {
26992703
if !leftmostItems.isEmpty && savedSectionForIdentifier.isEmpty == false {

0 commit comments

Comments
 (0)