Agent/tray UI and reconnect - #1
Conversation
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
📝 WalkthroughWalkthrough新增 Windows 自包含安装包及其构建、安装和启动流程,更新托盘单实例与界面资源处理,并修复 CDP 浏览器身份变化后的会话重连。 ChangesWindows 安装包与托盘运行时
CDP 身份变化后的会话恢复
Estimated code review effort: 5 (Critical) | ~90+ minutes Sequence Diagram(s)sequenceDiagram
participant BuildScript
participant InnoSetup
participant Installer
participant Tray
participant Codex
BuildScript->>InnoSetup: 构建安装包
InnoSetup->>Installer: 安装打包运行时与应用文件
Installer->>Tray: 安装完成后启动托盘
Tray->>Codex: CDP 未发现时触发 Codex 启动
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
PR Summary by QodoWindows installer, faster tray startup, single-instance lock, and CDP reconnect
AI Description
Diagram
High-Level Assessment
Files changed (12)
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTo customize comments, go to the Qodo configuration screen, or learn more in the docs. |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
scripts/start-beauticode-engine.ps1 (1)
101-116: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win注释与实际保护机制不符。
第 109 行注释 "Fail open: the session-host injector lock still rejects duplicate owners." 提到的 "session-host injector lock" 在代码库中并不存在。实际兜底保护是
apps/tray/start-tray.ps1中托盘脚本自身创建的同名互斥量(Local\beautiCode.Engine.Tray.v1,初始持有权$true),而非什么 "injector lock"。建议修正注释以准确描述真正的兜底机制,避免后续排查问题时产生误导。📝 建议修正注释
} catch { - # Fail open: the session-host injector lock still rejects duplicate owners. + # Fail open: apps/tray/start-tray.ps1 owns an authoritative named mutex + # ("Local\beautiCode.Engine.Tray.v1") and will exit immediately if a + # second instance tries to acquire it, so a false negative here is safe. return $false }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@scripts/start-beauticode-engine.ps1` around lines 101 - 116, Update the fallback comment in Test-BcTrayRunningFast to accurately state that apps/tray/start-tray.ps1 creates and initially owns the same Local\beautiCode.Engine.Tray.v1 mutex, rather than referring to a nonexistent session-host injector lock. Keep the mutex handling and fail-open behavior unchanged.apps/tray/start-tray.ps1 (1)
9-24: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win互斥量创建缺少异常保护。
脚本以隐藏窗口方式启动(由
start-beauticode-engine.ps1以WindowStyle Hidden拉起),而第 14-18 行[System.Threading.Mutex]::new(...)若抛出异常(例如极端情况下的权限/命名冲突),将导致整个托盘进程无提示崩溃退出,用户完全不会看到任何反馈。建议对该初始化做一次 try/catch 兜底(即使只是记录日志或回退为“继续启动”),避免静默失败。🛡️ 建议的兜底处理
$script:trayInstanceMutex = $null $script:trayInstanceMutexOwned = $false $createdNew = $false -$script:trayInstanceMutex = [System.Threading.Mutex]::new( - $true, - "Local\beautiCode.Engine.Tray.v1", - [ref]$createdNew -) -if (-not $createdNew) { - $script:trayInstanceMutex.Dispose() - exit 0 +try { + $script:trayInstanceMutex = [System.Threading.Mutex]::new( + $true, + "Local\beautiCode.Engine.Tray.v1", + [ref]$createdNew + ) + if (-not $createdNew) { + $script:trayInstanceMutex.Dispose() + exit 0 + } +} catch { + # Fail open: proceed without single-instance protection rather than a + # silent, unreported crash of a hidden-window process. + $script:trayInstanceMutex = $null + $createdNew = $true } $script:trayInstanceMutexOwned = $true🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/tray/start-tray.ps1` around lines 9 - 24, 在 start-tray.ps1 的 trayInstanceMutex 初始化流程中加入 try/catch 保护,覆盖 [System.Threading.Mutex]::new 调用及相关状态设置;捕获异常后提供可诊断的日志或明确的回退行为,避免隐藏窗口启动时因互斥量创建失败而静默崩溃,同时保持已创建实例的退出逻辑不变。
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/adapter-codex/src/session.ts`:
- Around line 235-240: 同步更新 watchTick() 的身份不匹配恢复路径:重建 host 后清空
detachedVideoKey,再执行重发布,确保重启后的 Chromium 会重新附加本地视频;可抽取并复用 ensureHost()
的共享恢复逻辑。补充覆盖端口、会话数量和 generation 相同场景的视频重连测试。
In `@scripts/build-windows-installer.ps1`:
- Around line 246-247: Update the metadata logic around $commit and
$trackedChanges so installer builds continue when Git or the repository’s .git
metadata is unavailable. Detect whether Git metadata can be queried, use
conservative fallback values such as commit “unknown” and dirty true when it
cannot, and preserve the existing Git-derived values when available.
---
Nitpick comments:
In `@apps/tray/start-tray.ps1`:
- Around line 9-24: 在 start-tray.ps1 的 trayInstanceMutex 初始化流程中加入 try/catch
保护,覆盖 [System.Threading.Mutex]::new
调用及相关状态设置;捕获异常后提供可诊断的日志或明确的回退行为,避免隐藏窗口启动时因互斥量创建失败而静默崩溃,同时保持已创建实例的退出逻辑不变。
In `@scripts/start-beauticode-engine.ps1`:
- Around line 101-116: Update the fallback comment in Test-BcTrayRunningFast to
accurately state that apps/tray/start-tray.ps1 creates and initially owns the
same Local\beautiCode.Engine.Tray.v1 mutex, rather than referring to a
nonexistent session-host injector lock. Keep the mutex handling and fail-open
behavior unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: c5800226-768e-4e52-871d-baaf65af52a9
📒 Files selected for processing (12)
.github/workflows/ci.yml.gitignoreREADME.mdapps/tray/start-tray.ps1docs/windows-installer.mdinstaller/windows/beauticode.isspackage.jsonpackages/adapter-codex/src/session.tspackages/adapter-codex/test/adapter.test.jspackages/adapter-codex/test/mock-cdp.jsscripts/build-windows-installer.ps1scripts/start-beauticode-engine.ps1
| this.onStatus?.(`Codex CDP restarted on :${this.port}; reconnecting…`); | ||
| this.host?.close(); | ||
| this.host = this.createHost(this.port); | ||
| this.detachedVideoKey = ""; | ||
| this.lastPublishSessionKey = ""; | ||
| await connectCurrentHost(); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
同步更新 watch 重连路径的视频重建状态。
Line 238 只覆盖 ensureHost() 的恢复;watchTick() 的身份不匹配恢复会重建 host 后直接重发布,但未清空 detachedVideoKey。当端口、会话数量和 generation 恰好相同时,视频会被判定为无需强制重建,可能无法向重启后的 Chromium 重新附加本地视频。请抽取共享恢复逻辑,或在 watch 路径中同样清空该 key,并补充视频重连测试。
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/adapter-codex/src/session.ts` around lines 235 - 240, 同步更新
watchTick() 的身份不匹配恢复路径:重建 host 后清空 detachedVideoKey,再执行重发布,确保重启后的 Chromium
会重新附加本地视频;可抽取并复用 ensureHost() 的共享恢复逻辑。补充覆盖端口、会话数量和 generation 相同场景的视频重连测试。
| $commit = (& git -C $RepoRoot rev-parse --short=12 HEAD).Trim() | ||
| $trackedChanges = @(& git -C $RepoRoot status --porcelain --untracked-files=no) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
不要让 Git 元数据阻断安装器构建。
第 246-247 行无条件依赖 git,但文档前置条件未包含 Git;从源码 ZIP 构建或未安装 Git 时会失败。请在 Git 或 .git 不可用时写入如 commit: "unknown"、dirty: true 的保守值,或明确将 Git 加入前置条件。
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@scripts/build-windows-installer.ps1` around lines 246 - 247, Update the
metadata logic around $commit and $trackedChanges so installer builds continue
when Git or the repository’s .git metadata is unavailable. Detect whether Git
metadata can be queried, use conservative fallback values such as commit
“unknown” and dirty true when it cannot, and preserve the existing Git-derived
values when available.
Summary by CodeRabbit
新功能
改进
问题修复
测试