-
Notifications
You must be signed in to change notification settings - Fork 903
fix: restore menu bar icon on macOS 26.4 (#805) #849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
steipete
merged 5 commits into
steipete:main
from
willytop8:wr/805-menu-bar-icon-macos-26
May 6, 2026
+230
−70
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0c5390b
fix: restore menu bar icon on macOS 26.4 (#805)
willytop8 0be7a6e
fix: use completion flag for legacy migration instead of existing == nil
willytop8 86e286d
docs: add changelog entry for #805
willytop8 1e08828
fix: only mark migration complete when clearLegacyStores succeeds
willytop8 1160719
test: cover legacy migration completion flag
steipete File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,153 @@ | ||
| import CodexBarCore | ||
| import Foundation | ||
| import Testing | ||
| @testable import CodexBar | ||
|
|
||
| @Suite(.serialized) | ||
| struct CodexBarConfigMigratorTests { | ||
| @Test | ||
| func `legacy secret migration completion flag skips repeated scans`() throws { | ||
| let suite = "CodexBarConfigMigratorTests-skip-\(UUID().uuidString)" | ||
| let defaults = try #require(UserDefaults(suiteName: suite)) | ||
| defaults.removePersistentDomain(forName: suite) | ||
| defer { defaults.removePersistentDomain(forName: suite) } | ||
|
|
||
| let secrets = CountingLegacySecretStore() | ||
| let accountStore = CountingTokenAccountStore() | ||
| let stores = Self.legacyStores(secrets: secrets, accountStore: accountStore) | ||
| let configStore = testConfigStore(suiteName: suite) | ||
|
|
||
| _ = CodexBarConfigMigrator.loadOrMigrate(configStore: configStore, userDefaults: defaults, stores: stores) | ||
|
|
||
| let firstSecretLoads = secrets.loadCount | ||
| let firstAccountLoads = accountStore.loadCount | ||
| #expect(firstSecretLoads > 0) | ||
| #expect(firstAccountLoads == 1) | ||
| #expect(defaults.bool(forKey: Self.legacyMigrationCompletedKey) == true) | ||
|
|
||
| _ = CodexBarConfigMigrator.loadOrMigrate(configStore: configStore, userDefaults: defaults, stores: stores) | ||
|
|
||
| #expect(secrets.loadCount == firstSecretLoads) | ||
| #expect(accountStore.loadCount == firstAccountLoads) | ||
| } | ||
|
|
||
| @Test | ||
| func `legacy migration completion waits for successful cleanup`() throws { | ||
| let suite = "CodexBarConfigMigratorTests-cleanup-failure-\(UUID().uuidString)" | ||
| let defaults = try #require(UserDefaults(suiteName: suite)) | ||
| defaults.removePersistentDomain(forName: suite) | ||
| defer { defaults.removePersistentDomain(forName: suite) } | ||
|
|
||
| let secrets = CountingLegacySecretStore(token: "legacy-token", throwOnStore: true) | ||
| let accountStore = CountingTokenAccountStore() | ||
| let stores = Self.legacyStores(secrets: secrets, accountStore: accountStore) | ||
| let configStore = testConfigStore(suiteName: suite) | ||
|
|
||
| _ = CodexBarConfigMigrator.loadOrMigrate(configStore: configStore, userDefaults: defaults, stores: stores) | ||
|
|
||
| let firstSecretLoads = secrets.loadCount | ||
| #expect(firstSecretLoads > 0) | ||
| #expect(secrets.clearAttempts > 0) | ||
| #expect(defaults.bool(forKey: Self.legacyMigrationCompletedKey) == false) | ||
|
|
||
| secrets.throwOnStore = false | ||
| _ = CodexBarConfigMigrator.loadOrMigrate(configStore: configStore, userDefaults: defaults, stores: stores) | ||
|
|
||
| #expect(secrets.loadCount > firstSecretLoads) | ||
| #expect(defaults.bool(forKey: Self.legacyMigrationCompletedKey) == true) | ||
| } | ||
|
|
||
| private static let legacyMigrationCompletedKey = "codexbar.legacySecretsMigrationCompleted" | ||
|
|
||
| private static func legacyStores( | ||
| secrets: CountingLegacySecretStore, | ||
| accountStore: CountingTokenAccountStore) -> CodexBarConfigMigrator.LegacyStores | ||
| { | ||
| CodexBarConfigMigrator.LegacyStores( | ||
| zaiTokenStore: secrets, | ||
| syntheticTokenStore: secrets, | ||
| codexCookieStore: secrets, | ||
| claudeCookieStore: secrets, | ||
| cursorCookieStore: secrets, | ||
| opencodeCookieStore: secrets, | ||
| factoryCookieStore: secrets, | ||
| minimaxCookieStore: secrets, | ||
| minimaxAPITokenStore: secrets, | ||
| kimiTokenStore: secrets, | ||
| kimiK2TokenStore: secrets, | ||
| augmentCookieStore: secrets, | ||
| ampCookieStore: secrets, | ||
| copilotTokenStore: secrets, | ||
| tokenAccountStore: accountStore) | ||
| } | ||
| } | ||
|
|
||
| private final class CountingLegacySecretStore: ZaiTokenStoring, SyntheticTokenStoring, CookieHeaderStoring, | ||
| MiniMaxCookieStoring, MiniMaxAPITokenStoring, KimiTokenStoring, KimiK2TokenStoring, CopilotTokenStoring, | ||
| @unchecked Sendable | ||
| { | ||
| private let lock = NSLock() | ||
| private var token: String? | ||
| var throwOnStore: Bool | ||
| private(set) var loadCount = 0 | ||
| private(set) var clearAttempts = 0 | ||
|
|
||
| init(token: String? = nil, throwOnStore: Bool = false) { | ||
| self.token = token | ||
| self.throwOnStore = throwOnStore | ||
| } | ||
|
|
||
| func loadToken() throws -> String? { | ||
| self.lock.lock() | ||
| defer { self.lock.unlock() } | ||
| self.loadCount += 1 | ||
| return self.token | ||
| } | ||
|
|
||
| func storeToken(_ token: String?) throws { | ||
| try self.store(token) | ||
| } | ||
|
|
||
| func loadCookieHeader() throws -> String? { | ||
| self.lock.lock() | ||
| defer { self.lock.unlock() } | ||
| self.loadCount += 1 | ||
| return self.token | ||
| } | ||
|
|
||
| func storeCookieHeader(_ header: String?) throws { | ||
| try self.store(header) | ||
| } | ||
|
|
||
| private func store(_ value: String?) throws { | ||
| self.lock.lock() | ||
| defer { self.lock.unlock() } | ||
| self.clearAttempts += value == nil ? 1 : 0 | ||
| if self.throwOnStore { | ||
| throw TestStoreError.storeFailed | ||
| } | ||
| self.token = value | ||
| } | ||
| } | ||
|
|
||
| private final class CountingTokenAccountStore: ProviderTokenAccountStoring, @unchecked Sendable { | ||
| private let lock = NSLock() | ||
| private(set) var loadCount = 0 | ||
|
|
||
| func loadAccounts() throws -> [UsageProvider: ProviderTokenAccountData] { | ||
| self.lock.lock() | ||
| defer { self.lock.unlock() } | ||
| self.loadCount += 1 | ||
| return [:] | ||
| } | ||
|
|
||
| func storeAccounts(_: [UsageProvider: ProviderTokenAccountData]) throws {} | ||
|
|
||
| func ensureFileExists() throws -> URL { | ||
| FileManager.default.temporaryDirectory.appendingPathComponent("codexbar-empty-accounts.json") | ||
| } | ||
| } | ||
|
|
||
| private enum TestStoreError: Error { | ||
| case storeFailed | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting
legacySecretsMigrationCompletedin thiselsebranch permanently disables future migration attempts even when the current run failed to read legacy data.migrateLegacySecrets/migrateLegacyAccountsusetry?, so transient keychain/file errors (for example, locked keychain returningerrSecInteractionNotAllowed) are treated the same as “no legacy data,” leavingsawLegacy*false and triggering this path. In that case, users can lose one-time migration of existing credentials/accounts because subsequent launches skip migration entirely.Useful? React with 👍 / 👎.