From f71f8fc55aaf0a7f1aae4102a3312d2ee4651b8c Mon Sep 17 00:00:00 2001 From: Arietids <69024461+ArietidsZ@users.noreply.github.com> Date: Sun, 18 Oct 2026 20:59:41 +0800 Subject: [PATCH 1/2] fix(opencodego): honor configured source in app and report actual source --- .../OpenCodeGoProviderImplementation.swift | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Sources/CodexBar/Providers/OpenCodeGo/OpenCodeGoProviderImplementation.swift b/Sources/CodexBar/Providers/OpenCodeGo/OpenCodeGoProviderImplementation.swift index 16a4a2a75f7..b93c29db0e5 100644 --- a/Sources/CodexBar/Providers/OpenCodeGo/OpenCodeGoProviderImplementation.swift +++ b/Sources/CodexBar/Providers/OpenCodeGo/OpenCodeGoProviderImplementation.swift @@ -6,7 +6,19 @@ struct OpenCodeGoProviderImplementation: ProviderImplementation { @MainActor func presentation(context _: ProviderPresentationContext) -> ProviderPresentation { - ProviderPresentation { _ in "web" } + ProviderPresentation { context in + context.store.sourceLabel(for: context.provider) + } + } + + @MainActor + func defaultSourceLabel(context: ProviderSourceLabelContext) -> String? { + context.settings.providerConfig(for: .opencodego)?.source?.rawValue + } + + @MainActor + func sourceMode(context: ProviderSourceModeContext) -> ProviderSourceMode { + context.settings.providerConfig(for: .opencodego)?.source ?? .auto } @MainActor From 702ae14f32b02bb8663c57bd1d1151c8819d4036 Mon Sep 17 00:00:00 2001 From: Arietids <69024461+ArietidsZ@users.noreply.github.com> Date: Sun, 18 Oct 2026 20:59:55 +0800 Subject: [PATCH 2/2] test(opencodego): cover app source routing and header labels --- .../OpenCodeGoAppSourceTests.swift | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Tests/CodexBarTests/OpenCodeGoAppSourceTests.swift diff --git a/Tests/CodexBarTests/OpenCodeGoAppSourceTests.swift b/Tests/CodexBarTests/OpenCodeGoAppSourceTests.swift new file mode 100644 index 00000000000..c48d5157584 --- /dev/null +++ b/Tests/CodexBarTests/OpenCodeGoAppSourceTests.swift @@ -0,0 +1,49 @@ +import CodexBarCore +import Testing +@testable import CodexBar + +@MainActor +@Suite(.serialized) +struct OpenCodeGoAppSourceTests { + @Test(arguments: [ProviderSourceMode.auto, .api, .web]) + func `app honors configured source even when manual cookies exist`(source: ProviderSourceMode) async throws { + let fixture = try ProviderSettingsDescriptorTests().makeSettingsFixture( + suite: "OpenCodeGoAppSourceTests-\(source.rawValue)") + fixture.settings.updateProviderConfig(provider: .opencodego) { config in + config.source = source + config.cookieSource = .manual + config.cookieHeader = "Cookie: invalid" + config.apiKey = "fixture-api-key" + } + + let resolved = ProviderRegistry.resolvedSourceMode( + provider: .opencodego, settings: fixture.settings, account: nil) + #expect(resolved == source) + let spec = try #require(fixture.store.providerSpecs[.opencodego]) + let fetchContext = spec.makeFetchContext() + #expect(fetchContext.sourceMode == source) + #expect(fetchContext.settings?.opencodego?.cookieSource == .manual) + let strategies = await spec.descriptor.fetchPlan.pipeline.resolveStrategies(fetchContext) + if source == .api { + #expect(strategies.map(\.id) == ["opencodego.api"]) + } else if source == .web { + #expect(strategies.map(\.id) == ["opencodego.web"]) + } else { + #expect(strategies.map(\.id) == ["opencodego.web", "opencodego.local", "opencodego.api"]) + } + } + + @Test + func `settings header shows configured or last successful source instead of web`() throws { + let fixture = try ProviderSettingsDescriptorTests().makeSettingsFixture( + suite: "OpenCodeGoAppSourceTests-header") + fixture.settings.updateProviderConfig(provider: .opencodego) { $0.source = .api } + let context = fixture.presentationContext( + provider: .opencodego, metadata: OpenCodeGoProviderDescriptor.descriptor.metadata) + let presentation = OpenCodeGoProviderImplementation().presentation(context: context) + + #expect(presentation.detailLine(context) == "api") + fixture.store.lastSourceLabels[.opencodego] = "local+api" + #expect(presentation.detailLine(context) == "local+api") + } +}