fix(runtime): isolate Electron Node mode from user commands - #4835
Draft
sunheyi6 wants to merge 1 commit into
Draft
fix(runtime): isolate Electron Node mode from user commands#4835sunheyi6 wants to merge 1 commit into
sunheyi6 wants to merge 1 commit into
Conversation
Remove inherited ELECTRON_RUN_AS_NODE at foreground, background, PTY and direct-argv user-command boundaries, preserving the Runtime Host environment and unrelated variables. Validation: incremental compilation and real SunCode startup passed. Four focused assertions passed, but the Windows runner did not exit cleanly; the full shell suite also has Windows shell/PTY failures. This is not an all-green claim. Isolate this general runtime fix for a separate PR. No local executables, profiles or artifact pins are included. <details> <summary>中文翻译</summary> 在前台、后台、PTY 和直接 argv 用户命令边界移除继承的 ELECTRON_RUN_AS_NODE,保留 Runtime Host 自身环境和其他变量,避免 Maka 启动的 Electron 项目丢失 Electron API。 验证:增量编译和真实 SunCode 启动通过。四项专项断言通过,但 Windows 测试进程未正常退出,完整 shell 测试也有 Windows shell/PTY 失败,不宣称测试全绿。 此通用修复独立提交,便于另开 PR。不包含本地执行器、测试配置或制品绑定。 </details>
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.
Summary
Prevent Maka's internal Electron Node-mode environment from leaking into user commands. This is a general runtime correctness fix, not a Computer Use test workaround.
When the Runtime Host has
ELECTRON_RUN_AS_NODE=1, its user-command children can inherit it. An Electron project that launches normally withbun run devfrom a regular terminal can then run in Node mode when launched through Maka, losing Electron APIs such asBrowserWindow.Build a fresh child environment at the foreground shell, direct-argv, background pipe, and PTY boundaries, removing this one variable while preserving other entries and leaving the parent environment untouched. Fixing the shared boundary avoids requiring every Electron project or generated command to know about Maka's internal launch mode.
Refs #2142. Discovered while validating #4668, but deliberately independent of that Computer Use integration and its foreground/background interaction policy.
Compatibility and scope
envobject. Callers intentionally relying on passing Node mode through that object will observe a behavior change. A command may still explicitly set the variable inside its shell/script before launching its own child; this is environment hygiene, not a sandbox or a prohibition on Electron Node mode.Verification
Prior local validation of this patch on Windows (before cherry-picking it onto the separate current-main branch):
05895cd7a1e446b9906bc77e972300498f15fc57, andgit diff --checkpassed. Compilation and runtime tests were not rerun on this cherry-picked branch. macOS/Linux, clean-machine, and packaged release validation remain unverified.Before marking ready
envcompatibility boundary during review.Generated-byattribution in the affected commit history/final squash commit before merge (the currently published commit lacks that trailer).AI use
Tool(s) and scope: OpenAI Codex, including Luna (
gpt-5.6-luna, high reasoning), assisted with implementation and tests; Codex assisted with review, local validation, commit preparation, and this PR description.Checklist
Does this PR entail a change in behavior?
中文翻译
概要
防止 Maka 内部用于 Electron Node 模式的环境变量泄漏到用户命令。这是通用运行时正确性修复,不是 Computer Use 测试专用绕过。
Runtime Host 带有
ELECTRON_RUN_AS_NODE=1时,用户命令的子进程可能继承该值。因此,在普通终端执行bun run dev正常的 Electron 项目,通过 Maka 启动时可能变成 Node 模式,失去BrowserWindow等 Electron API。在前台 shell、直接 argv、后台管道及 PTY 边界创建新的子进程环境,仅移除这个变量,保留其他条目,不修改父进程环境。在共享边界修复,可避免要求每个 Electron 项目或生成的命令了解 Maka 内部的启动模式。
关联 #2142,但不关闭该 Windows 支持总议题。问题在验证 #4668 时发现,本 PR 刻意独立于 Computer Use 集成及其前后台交互策略。
兼容性与范围
env对象中的同名变量也会被移除。依赖这种传参方式主动启用 Node 模式的调用方会受到行为变化影响。命令仍可在自己的 shell/脚本内部主动设置该变量,再启动自己的子进程;这是环境隔离,不是沙箱,也不是禁止使用 Electron Node 模式。验证
以下为该补丁在 Windows 本地的先前验证,发生在将其摘取到独立的当前 main 分支之前:
05895cd7a1e446b9906bc77e972300498f15fc57一致,git diff --check通过。没有在摘取后的独立分支重新运行编译和运行时测试。macOS/Linux、干净机器及打包发行验证仍未完成。转为待合并状态前
env的预期兼容性边界。Generated-by署名(当前已发布提交缺少该 trailer)。AI 使用
工具及范围:OpenAI Codex,包括 Luna(
gpt-5.6-luna,high 思考强度),协助实现及测试;Codex 协助审查、本地验证、提交准备和本 PR 说明。检查清单
本 PR 是否改变行为?