Skip to content

Commit ba66515

Browse files
committed
fix(codex): 统一版本查询与原生更新的渠道环境
- 将有效的发布版本与安装渠道设置传入原生更新动作,保留空字符串覆盖。 - 继续使用可执行文件所属的 CODEX_HOME,不导出无关实例或主机配置。 - 六项失败回归修复后通过;check:changed 通过 114 项测试及相关类型与静态检查。
1 parent ec8727a commit ba66515

2 files changed

Lines changed: 57 additions & 4 deletions

File tree

‎apps/server/src/provider/Drivers/CodexDriver.test.ts‎

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -587,15 +587,49 @@ it.layer(layerTest)("CodexDriver", (it) => {
587587
tag: "rust-v0.164.0",
588588
status: 200,
589589
expected: null,
590+
requestsChannel: false,
590591
env: { CODEX_RELEASE: "0.162.0" },
591592
},
592593
{
593594
name: "an alternative installer channel",
594595
tag: "rust-v0.164.0",
595596
status: 200,
596597
expected: null,
598+
requestsChannel: false,
597599
env: { CODEX_INSTALLER_USE_RELEASES_OPENAI_COM: "false" },
598600
},
601+
{
602+
name: "an inherited explicit release",
603+
tag: "rust-v0.164.0",
604+
status: 200,
605+
expected: null,
606+
requestsChannel: false,
607+
hostEnv: { CODEX_RELEASE: "0.162.0" },
608+
},
609+
{
610+
name: "an inherited alternative installer channel",
611+
tag: "rust-v0.164.0",
612+
status: 200,
613+
expected: null,
614+
requestsChannel: false,
615+
hostEnv: { CODEX_INSTALLER_USE_RELEASES_OPENAI_COM: "false" },
616+
},
617+
{
618+
name: "instance settings overriding the host's pinned alternative channel",
619+
tag: "rust-v0.164.0",
620+
status: 200,
621+
expected: "0.164.0",
622+
hostEnv: { CODEX_RELEASE: "0.162.0", CODEX_INSTALLER_USE_RELEASES_OPENAI_COM: "false" },
623+
env: { CODEX_RELEASE: "latest", CODEX_INSTALLER_USE_RELEASES_OPENAI_COM: "true" },
624+
},
625+
{
626+
name: "empty instance settings restoring the default channel",
627+
tag: "rust-v0.164.0",
628+
status: 200,
629+
expected: "0.164.0",
630+
hostEnv: { CODEX_RELEASE: "0.162.0", CODEX_INSTALLER_USE_RELEASES_OPENAI_COM: "false" },
631+
env: { CODEX_RELEASE: "", CODEX_INSTALLER_USE_RELEASES_OPENAI_COM: "" },
632+
},
599633
]) {
600634
it.effect.skipIf(windowsHost)(`checks the standalone channel for ${fixture.name}`, () =>
601635
Effect.gen(function* () {
@@ -646,14 +680,22 @@ it.layer(layerTest)("CodexDriver", (it) => {
646680
}).pipe(Effect.provideService(HttpClient.HttpClient, http));
647681
const capabilities = yield* instance.snapshot.resolveMaintenance();
648682
expect(requests).toEqual([]);
649-
if (fixture.env) {
683+
expect(capabilities.update?.env).toEqual({
684+
CODEX_HOME: home,
685+
...fixture.hostEnv,
686+
...fixture.env,
687+
});
688+
if (fixture.requestsChannel === false) {
650689
const stable = yield* CodexDriver.create({
651690
instanceId: ProviderInstanceId.make("codex-stable-channel"),
652691
displayName: "Codex stable channel",
653692
enabled: false,
654693
environment: [],
655694
config: { ...CodexDriver.defaultConfig(), binaryPath, homePath: home },
656-
}).pipe(Effect.provideService(HttpClient.HttpClient, http));
695+
}).pipe(
696+
Effect.provideService(HttpClient.HttpClient, http),
697+
Effect.provideService(HostProcess.Environment, {}),
698+
);
657699
const stableCapabilities = yield* stable.snapshot.resolveMaintenance();
658700
expect(
659701
yield* resolveLatestProviderVersion(stableCapabilities).pipe(
@@ -670,7 +712,9 @@ it.layer(layerTest)("CodexDriver", (it) => {
670712
);
671713
expect(latest).toBe(fixture.expected);
672714
expect(requests).toEqual(
673-
fixture.env ? [] : ["https://releases.openai.com/codex/channels/latest"],
715+
fixture.requestsChannel === false
716+
? []
717+
: ["https://releases.openai.com/codex/channels/latest"],
674718
);
675719
expect(
676720
createProviderVersionAdvisory({
@@ -688,7 +732,10 @@ it.layer(layerTest)("CodexDriver", (it) => {
688732
);
689733
}).pipe(
690734
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, noSpawn),
691-
Effect.provideService(HostProcess.Environment, {}),
735+
Effect.provideService(HostProcess.Environment, {
736+
UNRELATED_HOST_SETTING: "not part of the update action",
737+
...fixture.hostEnv,
738+
}),
692739
Effect.scoped,
693740
),
694741
);

‎apps/server/src/provider/Drivers/CodexDriver.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,12 @@ function makeCodexMaintenanceResolver(
136136
isCommandPath: (commandPath) => codexStandaloneHome(commandPath) !== null,
137137
requiresCommandPath: true,
138138
env: (context) => ({
139+
...(env.CODEX_RELEASE === undefined ? {} : { CODEX_RELEASE: env.CODEX_RELEASE }),
140+
...(env.CODEX_INSTALLER_USE_RELEASES_OPENAI_COM === undefined
141+
? {}
142+
: {
143+
CODEX_INSTALLER_USE_RELEASES_OPENAI_COM: env.CODEX_INSTALLER_USE_RELEASES_OPENAI_COM,
144+
}),
139145
CODEX_HOME:
140146
codexStandaloneHome(context.realCommandPath) ??
141147
codexStandaloneHome(context.resolvedCommandPath) ??

0 commit comments

Comments
 (0)