From 5f2194445d654d33dd4755b09b977e024946649a Mon Sep 17 00:00:00 2001 From: OfficialAbhinavSingh Date: Mon, 20 Jul 2026 18:33:18 +0530 Subject: [PATCH] fix: allow Alibaba/Qwen Token Plan usage on Linux with a manual cookie sourceModeRequiresWebSupport blanket-rejects web-source providers off macOS, but carries per-provider escape hatches for opencodego, commandcode, cursor, and qoder when their cookie source is manual - the fetch is plain URLSession + cookies, only browser auto-import needs macOS. alibabatokenplan was missing this exemption, so codexbar usage --provider alibaba-token-plan failed on Linux even with a manually configured cookie header. Add the same exemption. Part of #2328. --- Sources/CodexBarCLI/CLIUsageCommand.swift | 7 +++++ TestsLinux/AlibabaTokenPlanLinuxTests.swift | 30 +++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 TestsLinux/AlibabaTokenPlanLinuxTests.swift diff --git a/Sources/CodexBarCLI/CLIUsageCommand.swift b/Sources/CodexBarCLI/CLIUsageCommand.swift index 56be5c3144..b3e07a8f34 100644 --- a/Sources/CodexBarCLI/CLIUsageCommand.swift +++ b/Sources/CodexBarCLI/CLIUsageCommand.swift @@ -694,6 +694,13 @@ extension CodexBarCLI { { return false } + if provider == .alibabatokenplan, + settings?.alibabaTokenPlan?.cookieSource == .manual + { + // The Alibaba/Qwen Token Plan fetch is plain URLSession + cookies; only browser + // cookie auto-import needs macOS, so a manual cookie header works off macOS too. + return false + } #if os(Linux) if provider == .cursor, settings?.cursor?.cookieSource != .off diff --git a/TestsLinux/AlibabaTokenPlanLinuxTests.swift b/TestsLinux/AlibabaTokenPlanLinuxTests.swift new file mode 100644 index 0000000000..b39915de44 --- /dev/null +++ b/TestsLinux/AlibabaTokenPlanLinuxTests.swift @@ -0,0 +1,30 @@ +#if os(Linux) +import Foundation +import Testing +@testable import CodexBarCLI +@testable import CodexBarCore + +struct AlibabaTokenPlanLinuxTests { + @Test + func `manual cookie source does not require macOS web support`() { + // The Alibaba/Qwen Token Plan fetch is plain URLSession + cookies, so a manually + // configured cookie header must be usable off macOS (matches qoder/commandcode). + #expect(!CodexBarCLI.sourceModeRequiresWebSupport( + .web, + provider: .alibabatokenplan, + settings: ProviderSettingsSnapshot.make( + alibabaTokenPlan: .init( + cookieSource: .manual, + manualCookieHeader: "login_qwencloud_ticket=t")))) + } + + @Test + func `auto cookie source still requires web support off macOS`() { + #expect(CodexBarCLI.sourceModeRequiresWebSupport( + .web, + provider: .alibabatokenplan, + settings: ProviderSettingsSnapshot.make( + alibabaTokenPlan: .init(cookieSource: .auto, manualCookieHeader: nil)))) + } +} +#endif