refactor(terminal): refactor terminal shell startup logic with fault-tolerant fallback - #2737
Merged
Merged
Conversation
liushikuan63
commented
Aug 22, 2026
Contributor
- 新增resolveShellCandidates方法,支持按系统返回可用shell候选列表
- 修改create方法,按候选列表依次尝试启动shell,启动失败则自动尝试下一个
- 新增单元测试验证shell候选解析和异常场景
- 针对企业安全软件拦截默认shell的场景做了兼容处理
…tolerant fallback 1. Add `resolveShellCandidates` method to return available shell candidates based on the operating system 2. Modify `create` method to sequentially try starting shells from the candidate list, automatically falling back to the next on failure 3. Add unit tests to verify shell candidate resolution and exception scenarios 4. Add compatibility handling for scenarios where enterprise security software blocks the default shell
…igurable default shell and improved shell candidate resolution - Introduce DEFAULT_SHELL_PROPERTY configuration property for setting the default shell - Add processFactory factory method to support custom process creation logic - Refactor create method to accept pre-resolved shell candidate list - Extract PtyProcess startup logic into a separate startProcess method - Add proper argument configuration for PowerShell and CMD commands (-NoLogo, -NoExit, -Command, etc.) - Improve shell candidate resolution order on Windows (pwsh → PowerShell → cmd) - Add support for zsh and bash colored prompts - Add test helper methods to reset factory and event publisher state - Add comprehensive unit tests covering shell configuration and failover scenarios - Change inner classes and enums to public to support external access - Add command parser interface to support custom command lookup logic
auenger
previously approved these changes
Aug 25, 2026
auenger
left a comment
Contributor
There was a problem hiding this comment.
代码审查结论:允许合并。
本次改动为 JCEF 内置终端增加 Windows Shell 启动容错。在 system 模式下,会按 PowerShell 7、Windows PowerShell、Command Prompt 的顺序尝试启动;失败候选不会写入 Session,也没有发现命令注入、进程泄漏、数据损坏或 JCEF 接口不兼容问题。
已确认:
- 原有 sessionId、cwd、shell、shellId 响应结构保持不变。
- Shell 配置仍通过固定 ID 解析,不接受任意命令。
- 进程成功启动后才注册 Terminal Session。
- macOS 和 Linux 的默认 Shell 逻辑基本保持不变。
- 改动范围集中在 JCEF 终端模块,没有引入新依赖或存储迁移。
非阻塞关注点:
- 自动回退目前只对 shellId=system 生效。用户显式选择 pwsh 或 powershell 时,启动失败仍不会回退到 CMD。建议在 PR 描述中明确这一行为边界;如果产品目标包含显式 Shell,也可以后续补充候选回退。
- 当前 GitHub Checks 只有项目同步和通知,没有 Java 编译、JCEF 测试或 Windows runner 验证。新增的 Windows 实际启动测试在非 Windows 环境会跳过,建议合并前或后续补充 Windows 实机/JCEF 回归。
- 新增的 chat2db.community.terminal.default-shell JVM 属性暂未在设置 UI、桌面启动参数或文档中暴露;如果作为正式配置使用,建议后续补充入口说明。
以上问题均不作为本次合并阻塞项。整体实现方向合理,可以合并。
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.