Skip to content

fix(renderer): pick the visible composer for the current thread id - #755

Merged
BytePioneer-AI merged 1 commit into
BytePioneer-AI:mainfrom
zhou199604:fix/renderer-visible-composer-thread-id
Nov 7, 2026
Merged

BytePioneer-AI merged 1 commit into
BytePioneer-AI:mainfrom
zhou199604:fix/renderer-visible-composer-thread-id

Conversation

@zhou199604

Copy link
Copy Markdown
Contributor

目的

Renderer 探针 currentThreadId() 要求 connected composer root 恰好一个,但应用 DOM 常态保留多个已连接的 composer root(含隐藏残留;实测一次会话后即 3 个,随使用增长)。函数在这种常态下恒返回 null,需要账号验证时本地验证页因此无法打开(报 "Open a Codex task before starting verification" → "Could not open the ZCode verification page")。排查 ZCode Start Plan 请求被网关拦截(#754 的根因修复)时实测撞到。

关联 Issue:N/A

实现范围

packages/renderer-extension/src/renderer-binding-probe.ts:currentThreadId() 优先取唯一可见的 composer(可见性判定与同文件 questions 流程一致:rects 非空、visibility 可见、无 hidden/inert/aria-hidden 祖先);仅一个连接 root 时保持原有行为不变;多个可见或零可见时仍返回 null,不做猜测。

实际执行的验证

macOS 15、ZCode Desktop 3.17.2、codexhost CLI 0.17.3:

  • 修复前:4 个已连接 composer(1 可见 + 3 隐藏)下 currentThreadId() 恒为 null,验证页打开失败。
  • 修复后:同状态下正确返回当前会话 id,验证页正常打开并完成无感验证(traceless_passed);单 composer 场景行为与修复前一致。

Copilot AI balanced review requested due to automatic review settings November 6, 2026 00:44

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@coderabbitai

coderabbitai Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug 修复
    • 同时连接多个编辑器时,当前对话的识别会优先依据唯一可见的编辑器;若无法确定唯一目标,则避免错误地返回对话标识。

currentThreadId() 现在优先从唯一可见的 Composer 根获取 Thread ID。若可见根不唯一,则仅在连接的 Composer 根恰好一个时回退,否则返回 null。

Changes: 当前 Thread 选择

Layer / File(s) Summary
按可见性选择 Composer 根
packages/renderer-extension/src/renderer-binding-probe.ts
currentThreadId() 先筛选有可见布局且未处于隐藏祖先中的根。可见根唯一时使用该根;否则仅在连接根唯一时回退。

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

Suggested reviewers: lpmasser, bytepioneer-ai

Merge Risk: Minimal · up to 86343

The change selects the sole visible composer when multiple roots are connected. No merge-blocking issue is established.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed 标题准确概括了选择可见 composer 以确定当前线程 ID 的主要变更。
Description check Passed 描述说明了问题、实现范围和验证结果,与变更内容相关。
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Tip

🎯 Customize your risk assessments

Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.

✅ Automatic approvals, with your rules

Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 39c9565 and 86343e8.

Files selected for processing: 1

  • packages/renderer-extension/src/renderer-binding-probe.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

Recent review details

Context from checks skipped due to timeout: 5

  • GitHub Check: CodeRabbit
  • GitHub Check: Check macos-26
  • GitHub Check: Check ubuntu-22.04
  • GitHub Check: Check Linux ARM64
  • GitHub Check: Check windows-latest
Additional context used

Code guidelines: 2

CLAUDE.md — auto-discovered
AGENTS.md — auto-discovered
Path-based instructions: 2

Source excerpt: `renderer-extension` must not import Node.js built-ins, Electron private APIs, or Harness SDKs.

CodeRabbit inference engine (CLAUDE.md)

Files:

  • packages/renderer-extension/src/renderer-binding-probe.ts
Source excerpt: `codexhost` runs external Agent Harnesses as independent Threads inside Codex Desktop, preserving the official shell and native Codex path.

CodeRabbit inference engine (AGENTS.md)

Files:

  • packages/renderer-extension/src/renderer-binding-probe.ts
Additional comments: 1

packages/renderer-extension/src/renderer-binding-probe.ts: 1

3376-3387: LGTM!

@BytePioneer-AI
BytePioneer-AI merged commit 264d57a into BytePioneer-AI:main Nov 7, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants