Skip to content

refactor(terminal): refactor terminal shell startup logic with fault-tolerant fallback - #2737

Merged
openai0229 merged 5 commits into
OtterMind:mainfrom
liushikuan63:main
Sep 2, 2026
Merged

openai0229 merged 5 commits into
OtterMind:mainfrom
liushikuan63:main

Conversation

@liushikuan63

Copy link
Copy Markdown
Contributor
  1. 新增resolveShellCandidates方法,支持按系统返回可用shell候选列表
  2. 修改create方法,按候选列表依次尝试启动shell,启动失败则自动尝试下一个
  3. 新增单元测试验证shell候选解析和异常场景
  4. 针对企业安全软件拦截默认shell的场景做了兼容处理

@liushikuan63
liushikuan63 requested review from a team and openai0229 as code owners August 22, 2026 09:19
@openai0229 openai0229 moved this to In Review in Chat2DB Community Aug 22, 2026
…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
@liushikuan63 liushikuan63 changed the title refactor(terminal): 重构终端shell启动逻辑,增加容错 fallback 机制 refactor(terminal): refactor terminal shell startup logic with fault-tolerant fallback Aug 22, 2026
auenger
auenger previously approved these changes Aug 25, 2026

@auenger auenger left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

代码审查结论:允许合并。

本次改动为 JCEF 内置终端增加 Windows Shell 启动容错。在 system 模式下,会按 PowerShell 7、Windows PowerShell、Command Prompt 的顺序尝试启动;失败候选不会写入 Session,也没有发现命令注入、进程泄漏、数据损坏或 JCEF 接口不兼容问题。

已确认:

  • 原有 sessionId、cwd、shell、shellId 响应结构保持不变。
  • Shell 配置仍通过固定 ID 解析,不接受任意命令。
  • 进程成功启动后才注册 Terminal Session。
  • macOS 和 Linux 的默认 Shell 逻辑基本保持不变。
  • 改动范围集中在 JCEF 终端模块,没有引入新依赖或存储迁移。

非阻塞关注点:

  1. 自动回退目前只对 shellId=system 生效。用户显式选择 pwsh 或 powershell 时,启动失败仍不会回退到 CMD。建议在 PR 描述中明确这一行为边界;如果产品目标包含显式 Shell,也可以后续补充候选回退。
  2. 当前 GitHub Checks 只有项目同步和通知,没有 Java 编译、JCEF 测试或 Windows runner 验证。新增的 Windows 实际启动测试在非 Windows 环境会跳过,建议合并前或后续补充 Windows 实机/JCEF 回归。
  3. 新增的 chat2db.community.terminal.default-shell JVM 属性暂未在设置 UI、桌面启动参数或文档中暴露;如果作为正式配置使用,建议后续补充入口说明。

以上问题均不作为本次合并阻塞项。整体实现方向合理,可以合并。

@openai0229
openai0229 merged commit edc3222 into OtterMind:main Sep 2, 2026
16 checks passed
@openai0229 openai0229 moved this from In Review to Done in Chat2DB Community Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants