Open
Conversation
|
Someone is attempting to deploy a commit to the op7418's projects Team on Vercel. A member of the Team first needs to authorize it. |
从 fix/proxy-auth-subprocess 分支手动移植 electron/main.ts 的代理修复。 v0.31.0 的 claude-client.ts 已大幅重构,不再有 Keychain token 注入问题, 因此只需移植 loadUserShellEnv() 的改进。 改动: - 新增 parseEnvOutput() 辅助函数 - 新增 getSystemProxyFromScutil() 从 macOS System Preferences 读代理 - loadUserShellEnv() 改为三级级联: 1. 非交互式登录 shell(快速,5s 超时) 2. 交互式登录 shell(10s 超时,兼容 oh-my-zsh 等慢启动) 3. scutil --proxy 兜底(不依赖 shell 启动) - 每级在无 HTTPS_PROXY 时额外补充 scutil --proxy 结果 修复场景:从 Dock 启动时 claude 子进程因缺少 HTTPS_PROXY 而 exit code 1。 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
问题:之前的 scutil --proxy 方案只支持 macOS,Windows/Linux 无效。 新方案: - 删除 getSystemProxyFromScutil()(macOS 专用,不跨平台) - 新增 getProxyEnvFromSystem():使用 Electron 内置的 session.resolveProxy() 解析 api.anthropic.com 的系统代理,底层与 Chromium 一致 - 支持 macOS scutil、Windows WinHTTP/IE 设置、Linux gsettings、PAC 文件 - loadUserShellEnv() 简化为两级级联(去掉 scutil 兜底) - app.whenReady() 中在 shell env 无代理时异步调用 getProxyEnvFromSystem() 修复场景:从 Dock/桌面启动时,claude 子进程因缺少 HTTPS_PROXY 而 exit code 1(GFW 封锁 api.anthropic.com)。现在 Windows 用户同样受益。 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- CliSettingsSection: 在 Form 表单顶部新增「代理服务器」输入框 - 读写 ~/.claude/settings.json 的 env.HTTPS_PROXY 字段 - 同时设置大小写两种变量(HTTPS_PROXY / https_proxy) - 清空时移除相关 env 键,避免留下空值 - i18n: en/zh 新增 cli.proxy / cli.proxyDesc / cli.proxyPlaceholder 翻译键 - electron/main.ts: 新增第三级代理回退逻辑 - 顺序:shell env → Chromium resolveProxy → ~/.claude/settings.json env.HTTPS_PROXY - 从 Dock 启动时若前两级均未检测到代理,读取用户在 UI 配置的代理地址 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- 在 streamClaude() 中,将 workingDirectory 传给 SDK 前先用 fs.existsSync 验证,不存在则静默回退到 os.homedir() - 补充 console.warn 方便调试追踪(原因:Node.js spawn 当 cwd 不存在时会以二进制路径为主语抛出 ENOENT,错误信息极具误导性) - 优化 ENOENT 错误提示文案,明确告知也可能是工作目录问题 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
**electron/main.ts — loadUserShellEnv()** - 同时执行 `-lc`(login)和 `-ilc`(interactive login)两种方式 - 合并两者的 PATH,确保 .zshrc 中配置的自定义路径不会丢失 - 之前 -lc 成功即返回,导致 .zshrc 里的 PATH 被跳过 **src/lib/platform.ts — _findClaudeBinaryUncached()** - 优先扫描 process.env.PATH 中的所有目录寻找 claude 二进制 - 解决硬编码候选路径不包含用户自定义安装位置的问题 - 适用于 claude 安装在非标准路径(如 trae nodejs bin 目录)的情况 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
改动摘要
1. 跨平台代理检测(
electron/main.ts)用 Electron
session.resolveProxy()替代原有scutil --proxy,解决 macOS 以外平台(Windows / Linux)无法自动读取系统代理的问题。2. Claude CLI 设置 — 代理服务器 UI(
CliSettingsSection.tsx+ i18n)~/.claude/settings.json的env.HTTPS_PROXY/env.https_proxy(双 case 兼容)settingSources: ['user']实现)3. spawn ENOENT 根因修复(
claude-client.ts)问题: Node.js
spawn当cwd(工作目录)不存在时,错误信息为spawn /path/to/claude ENOENT,看起来像是找不到二进制,实际是工作目录不存在。修复:
fs.existsSync验证工作目录,不存在则静默回退到os.homedir()测试验证
~/.claude/settings.json正确持久化🤖 Generated with Claude Code