File tree Expand file tree Collapse file tree
CodexBarCore/Providers/Codex Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ extension SettingsStore {
2929 return exact
3030 }
3131 }
32- return override. first ( where: \. isActiveInCodex) ?? override . first
32+ return override. first ( where: \. isActiveInCodex)
3333 }
3434 #endif
3535 return CodexProfileStore . selectedDisplayProfile ( selectedPath: self . selectedCodexProfilePath)
Original file line number Diff line number Diff line change @@ -114,7 +114,9 @@ public enum CodexProfileStore {
114114 }
115115
116116 if let activeProfile,
117- discovered. contains ( where: { $0. fileURL. standardizedFileURL == activeProfile. fileURL. standardizedFileURL } ) == false
117+ discovered. contains ( where: {
118+ $0. fileURL. standardizedFileURL == activeProfile. fileURL. standardizedFileURL
119+ } ) == false
118120 {
119121 discovered. append ( activeProfile)
120122 }
@@ -213,10 +215,10 @@ public enum CodexProfileStore {
213215 }
214216 let authPath = authFileURL. standardizedFileURL. path
215217 if standardizedPath == authPath {
216- return displayed. first ( where: \. isActiveInCodex) ?? displayed . first
218+ return displayed. first ( where: \. isActiveInCodex)
217219 }
218220 }
219- return displayed. first ( where: \. isActiveInCodex) ?? displayed . first
221+ return displayed. first ( where: \. isActiveInCodex)
220222 }
221223
222224 private static func credentials( at url: URL , fileManager: FileManager ) -> CodexOAuthCredentials ? {
Original file line number Diff line number Diff line change @@ -71,6 +71,34 @@ struct CodexProfileStoreTests {
7171 #expect( selected? . isActiveInCodex == true )
7272 }
7373
74+ @Test
75+ func `selected profile stays unset when no active auth exists`() throws {
76+ let root = FileManager . default. temporaryDirectory. appendingPathComponent ( UUID ( ) . uuidString, isDirectory: true )
77+ try FileManager . default. createDirectory ( at: root, withIntermediateDirectories: true )
78+ defer { try ? FileManager . default. removeItem ( at: root) }
79+
80+ let authURL = root. appendingPathComponent ( " auth.json " )
81+ let profilesURL = root. appendingPathComponent ( " profiles " , isDirectory: true )
82+ try FileManager . default. createDirectory ( at: profilesURL, withIntermediateDirectories: true )
83+
84+ try self . writeAuthFile (
85+ to: profilesURL. appendingPathComponent ( " plus-a.json " ) ,
86+ email: " plus-a@example.com " ,
87+ plan: " plus " ,
88+ accountID: " acct-a " )
89+ try self . writeAuthFile (
90+ to: profilesURL. appendingPathComponent ( " plus-b.json " ) ,
91+ email: " plus-b@example.com " ,
92+ plan: " plus " ,
93+ accountID: " acct-b " )
94+
95+ let selected = CodexProfileStore . selectedDisplayProfile (
96+ selectedPath: nil ,
97+ authFileURL: authURL)
98+
99+ #expect( selected == nil )
100+ }
101+
74102 @Test
75103 func `display profiles collapse live auth into matching saved profile`() throws {
76104 let root = FileManager . default. temporaryDirectory. appendingPathComponent ( UUID ( ) . uuidString, isDirectory: true )
You can’t perform that action at this time.
0 commit comments