fix(acp): improve packaged codex startup fallback#1594
fix(acp): improve packaged codex startup fallback#1594piorpua merged 3 commits intoiOfficeAI:mainfrom
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 88d80b9dd2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| function resolveCodexAcpPlatformPackageSpecifier(packageName: string): string { | ||
| return process.platform === 'win32' ? `${packageName}@${CODEX_ACP_BRIDGE_VERSION}` : packageName; |
There was a problem hiding this comment.
Pin direct Codex ACP packages on POSIX
resolveCodexAcpPlatformPackageSpecifier() only appends @${CODEX_ACP_BRIDGE_VERSION} on Windows, so the new Linux/macOS startup path invokes bare @zed-industries/codex-acp-* package names. That means fresh Codex startups on POSIX will install whatever version is currently latest in the registry instead of the bridge version this app is pinned to, and a future upstream release can suddenly change protocol/behavior on one machine while others still run @zed-industries/[email protected]. The direct platform package should stay version-locked on every OS.
Useful? React with 👍 / 👎.
| const stat = await fs.stat(candidatePath); | ||
| if (stat.isFile() && stat.mtimeMs > selectedMtimeMs) { | ||
| selectedBinaryPath = candidatePath; | ||
| selectedMtimeMs = stat.mtimeMs; |
There was a problem hiding this comment.
Reject stale cached Codex binaries from older bridge versions
This cache probe chooses the newest codex-acp binary by mtime and executes it directly, but it never verifies that the cached package version matches CODEX_ACP_BRIDGE_VERSION. After an app upgrade, users who still have an older bridge cached under _npx will keep launching that stale binary and never give npx a chance to fetch the new bridge, so the packaged startup fix in this commit does not actually roll out until they manually purge the cache. Please read each candidate package's version before reusing it.
Useful? React with 👍 / 👎.
| const posixCacheCandidates = [path.join(homeDir, '.npm-cache'), path.join(homeDir, '.npm')]; | ||
| const npmCacheBase = posixCacheCandidates.find((candidate) => existsSync(candidate)) || posixCacheCandidates[0]; |
There was a problem hiding this comment.
Probe the actual
_npx dir before preferring ~/.npm-cache
On POSIX this now prefers the first existing parent cache directory (~/.npm-cache before ~/.npm) without checking which one actually contains _npx. If a machine has a leftover ~/.npm-cache directory but npx is still using the default ~/.npm/_npx, both the new cached-binary lookup and the existing corrupted-cache cleanup paths will inspect/delete the wrong tree, so startup recovery silently stops working for that setup.
Useful? React with 👍 / 👎.
|
感谢提交!在 Linux 上修复 ACP optional dependency 问题的思路很好,fallback 策略覆盖了缓存查找、平台直装和 meta 包回退,考虑得很全面。 提两个小建议: 1. 非 Windows 平台的包建议也锁定版本号目前 function resolveCodexAcpPlatformPackageSpecifier(packageName: string): string {
return process.platform === 'win32' ? `${packageName}@${CODEX_ACP_BRIDGE_VERSION}` : packageName;
}这样 Linux/macOS 上 npx 会安装 latest 版本,如果上游发了不兼容的新版就会出问题。建议统一锁定: function resolveCodexAcpPlatformPackageSpecifier(packageName: string): string {
return `${packageName}@${CODEX_ACP_BRIDGE_VERSION}`;
}2.
|
我的判断是:
我建议你现在的处理顺序是:先修 |
Code Review:fix(acp): improve packaged codex startup fallback (#1594)变更概述本 PR 修复了 Linux 环境下的 Codex ACP 启动失败问题,主要新增了三项机制:(1) 通过扫描 npx 缓存目录直接定位已缓存的平台原生二进制文件;(2) 构建多候选包的顺序重试循环,根据平台优先直接包或元包;(3) 将 Codex 的连接超时从固定 70 秒提升至 150 秒,适配 Linux 上较慢的启动速度。此外同步增强了 方案评估结论:✅ 方案合理 方案通过缓存二进制发现 + 多候选回退的两层机制解决了 Linux 上平台包安装不可靠的根本问题,与项目 ACP 架构一致。回退链路清晰,每次失败后调用 问题清单🟡 MEDIUM — Linux/macOS 平台包缺少版本固定文件: 问题代码: function resolveCodexAcpPlatformPackageSpecifier(packageName: string): string {
return process.platform === 'win32' ? `${packageName}@${CODEX_ACP_BRIDGE_VERSION}` : packageName;
}问题说明:Windows 平台固定了版本(如 修复建议: function resolveCodexAcpPlatformPackageSpecifier(packageName: string): string {
return `${packageName}@${CODEX_ACP_BRIDGE_VERSION}`;
}同步更新相关测试中的期望值。 🔵 LOW — lint:
|
| # | 严重级别 | 文件 | 问题 |
|---|---|---|---|
| 1 | 🟡 MEDIUM | acpConnectors.ts:73 |
Linux/macOS 平台包未固定版本 |
| 2 | 🔵 LOW | acpConnectors.ts:409 |
no-await-in-loop 在缓存扫描循环 |
| 3 | 🔵 LOW | acpConnectors.ts:587,610 |
no-await-in-loop 在重试循环 |
| 4 | 🔵 LOW | acpConnectors.ts:614 |
直接变异候选包数组 |
| 5 | 🔵 LOW | shellEnv.ts:581 |
POSIX 无缓存时默认 ~/.npm-cache 而非 ~/.npm |
结论
本报告由本地 pr-review skill 生成,包含完整项目上下文,无截断限制。
Previously only Windows platform packages were versioned (e.g. [email protected]), while Linux and macOS packages resolved to 'latest', risking protocol mismatch if a newer incompatible version was published. Update resolveCodexAcpPlatformPackageSpecifier to always append @CODEX_ACP_BRIDGE_VERSION regardless of platform, and update tests to expect the versioned package specifier for linux-x64 and darwin-x64. Review follow-up for #1594
PR Fix 验证报告原始 PR: #1594
总结: ✅ 已修复 1 个 | ❌ 未能修复 0 个
|
|
To use Codex here, create a Codex account and connect to github. |
Pull Request
Description
linux中同样有ACP报错问题,进行了修复,现在提交上去。
直接本地bun run start ,尝试发送消息就会报错,原因是ACP通讯问题,所以进行修复
Related Issues
[Bug]: linux运行的ACP通讯会有问题 #1593
Type of Change
Testing
Screenshots
Additional Context
Thank you for contributing to AionUi! 🎉