Skip to content

fix(renderer): 读不到所属 Agent 的对话不再让 Composer 循环重画 / stop Threads with an unreadable owner from looping Composer renders - #1165

Merged
iruriQ merged 1 commit into
BytePioneer-AI:mainfrom
sduhantao-maker:fix/composer-indicator-flicker
Nov 25, 2026
Merged

iruriQ merged 1 commit into
BytePioneer-AI:mainfrom
sduhantao-maker:fix/composer-indicator-flicker

Conversation

@sduhantao-maker

Copy link
Copy Markdown
Contributor

Summary

中文

  • 问题:如果一个对话的所属 Agent 读不出来(例如 Harness 已删除它的原生 Session,codexhost/thread/inspect 返回 -32079),它的 Composer 会一直停在默认的 Codex 草稿阶段,同时又绑定着这个对话。
  • refreshDraftUsage 不处理绑定了对话的 Composer,但 reconcileHarnessAvailabilityHost 只检查阶段,所以每次扫描都会调用 loadCodexAccountsForHost。
  • 加载完成后,它会重画所有 Composer,并刷新每个 Codex Composer 的草稿额度。重画会改动 DOM,DOM 改动又安排下一次扫描。只要这样的 Composer 还挂载着,循环就约每秒 10 次一直运行。Desktop 会把访问过的对话保留为隐藏的 Composer,所以离开这个对话后循环也不会停。
  • 此时打开一个新的 Codex 草稿,额度 chip(例如 ○ 93%)每一轮都会先被清空再填回,看起来就是持续闪烁。
  • 实机数据(macOS,Codex Desktop 26.1120.50957,codexhost 0.26.1,修复前,用只读探针测量):
    • 录屏 3.16 秒内,额度 chip 消失 32 次,每次多为 1 帧。
    • 当前可见 Composer 的 DOM 变动约 2200 次/秒,期间页面没有任何操作。
    • 7 个挂载的 Composer 里,只有那个对话的 Composer 处于 codex / draft;91 次重画中有 90 次来自 loadCodexAccountsForHost 的回调。
  • 改动:新增 isDraftUsageComposer,让扫描和 refreshDraftUsage(包括其中的 isCurrent)使用同一个草稿额度判断。真正的新对话草稿行为不变。

English

  • Problem: If the owner of a Thread cannot be read (for example, the Harness has deleted its native Session and codexhost/thread/inspect returns -32079), its Composer stays in the default Codex draft phase while it is bound to that Thread.
  • refreshDraftUsage refuses a Composer that is bound to a Thread, but reconcileHarnessAvailabilityHost checked only the phase, so every scan called loadCodexAccountsForHost.
  • When the load finishes, it rerenders every Composer and refreshes draft usage for every Codex Composer. The rerender changes the DOM, and the DOM change schedules the next scan. The loop runs about ten times a second for as long as such a Composer stays mounted. Desktop keeps visited Threads as hidden Composers, so the loop continues after the user leaves that Thread.
  • A new Codex draft opened during the loop clears and restores its account limit chip (for example ○ 93%) on every pass, so the chip flickers.
  • Measurements on a real machine (macOS, Codex Desktop 26.1120.50957, codexhost 0.26.1, before the fix, read-only probes):
    • In a 3.16-second recording, the account limit chip disappeared 32 times, mostly for one frame each.
    • The visible Composer had about 2,200 DOM mutations per second while the page was idle.
    • Of 7 mounted Composers, only the Composer of that Thread was in codex / draft; 90 of 91 rerenders came from the loadCodexAccountsForHost callback.
  • Change: Add isDraftUsageComposer, so the scan and refreshDraftUsage (including its isCurrent) use one draft usage eligibility check. Genuine new-Thread drafts behave as before.

Related issues

无 / N/A

UI Demo

中文:没有新增或修改任何界面元素和样式。修复前的现象是上面描述的额度 chip 闪烁。修复后的实机录屏未录制,原因是换上修复版需要重启 Desktop 和 Host。

English: No UI element or style is added or changed. Before the fix, the account limit chip flickers as described above. No recording after the fix was made, because running the fixed build needs a restart of Desktop and the Host.

Test plan

中文

  • 自动测试:npx vitest run --config tests/vitest.config.js packages/renderer-extension/test/renderer-binding-probe-host-catalog.test.ts
    • 新用例在修复前失败:3 次空闲扫描让 codexhost/account/list 请求从 1 次变成 4 次。
    • 修复后该文件 50/50 通过。
  • 自动测试:同一配置运行上述文件以及 renderer-model-client、renderer-binding-probe、renderer-usage-notifications、renderer-main-process-draft、draft-selection-order、renderer-native-thread-ownership 共 7 个文件,180/180 通过(基于当前 main)。
  • 类型检查:npx tsc -b packages/renderer-extension 通过。
  • 实机:只在修复前确认了循环和触发它的 Composer(数据见 Summary)。修复后没有做实机验证,原因同 UI Demo。

English

  • Automated: npx vitest run --config tests/vitest.config.js packages/renderer-extension/test/renderer-binding-probe-host-catalog.test.ts
    • The new case fails before the fix: 3 idle scans raise the codexhost/account/list requests from 1 to 4.
    • After the fix, this file passes 50/50.
  • Automated: the same config on that file plus renderer-model-client, renderer-binding-probe, renderer-usage-notifications, renderer-main-process-draft, draft-selection-order and renderer-native-thread-ownership, 7 files in total: 180/180 pass (on current main).
  • Type check: npx tsc -b packages/renderer-extension passes.
  • Real machine: only the state before the fix was checked (the loop and the Composer that drives it, see Summary). The fix was not verified on a real machine, for the reason given under UI Demo.

…poser renders

A Thread Composer starts in the draft phase and leaves it only after its
owner is read. When that read fails (for example, the Harness has deleted
the Thread's native Session), the Composer stays a Codex draft that is bound
to a Thread.

refreshDraftUsage refuses such a Composer, but reconcileHarnessAvailabilityHost
checked only the phase. Every scan therefore reloaded Codex Accounts, and the
reload rerendered every Composer and refreshed draft usage. The rerender
changed the DOM, which scheduled the next scan, so the loop ran about ten
times a second while the Composer stayed mounted. A visible new Codex draft
cleared and restored its account limit chip on every pass, so the chip
flickered.

Share one draft usage eligibility check between the scan and
refreshDraftUsage.
@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug 修复
    • 改善 Codex 草稿状态下账户列表的加载表现:即使线程信息暂不可用,仍可在首次请求时加载账户列表;后续界面更新不会重复触发请求。
    • 统一草稿用量的刷新条件,保持现有刷新行为一致。

本次变更集中草稿用量的资格判断,并在刷新、异步结果检查和 Host 协调中复用该判断。新增回归测试,验证 Thread 检查失败后,后续 DOM 扫描不会重复请求 Codex 账户列表。

Changes: 草稿用量资格判断与回归测试

Layer / File(s) Summary
统一资格判断并验证账户加载行为
packages/renderer-extension/src/renderer-binding-probe.ts, packages/renderer-extension/test/renderer-binding-probe-host-catalog.test.ts
新增 isDraftUsageComposer,集中判断草稿阶段、Agent 切换状态、提交等待状态和 Thread 关联状态。刷新逻辑、异步结果有效性检查和 Host 协调复用该判断。新增测试覆盖 Thread 检查失败后首次请求账户列表,以及后续三轮 DOM 扫描中请求次数保持不变。

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

Change: Bug fix

Possibly related PRs

  • BytePioneer-AI/codex-host#910:处理 Thread 保持 draft 阶段时账户和 quota 重复读取的问题;与本次变更的草稿刷新资格判断直接相关。

Suggested labels: 类型:缺陷修复, 范围:桌面界面

Suggested reviewers: bytepioneer-ai

Merge Risk: Minimal · up to baa8f

This change stops Thread-bound Composers from repeatedly reloading Codex accounts when the Thread owner cannot be read. Genuine new-Thread drafts keep their existing behavior, and a regression test covers the repeated-scan case. I found no remaining merge-blocking risk.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed 标题描述了主要变更:读不到所属 Agent 的对话不再让 Composer 循环重画。这与 raw_summary 和 pr_objectives 中的 isDraftUsageComposer 扫描与 refreshDraftUsage 共享判断的改动一致。标题同时包含中英文,较长,但主要变更清楚。
Description check Passed 描述与改动直接相关。它说明问题原因(无法读取所属 Agent 时 Composer 停留在 codex draft 阶段,扫描反复调用 loadCodexAccountsForHost)、新增的 isDraftUsageComposer 判断、测试计划和实机数据。描述内容完整,与变更集一致。
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

Warning

Tools execution failed with the following error:

Failed to run tools: 14 UNAVAILABLE: Connection dropped

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 6e68167 and baa8fd8.

Files selected for processing: 2

  • packages/renderer-extension/src/renderer-binding-probe.ts
  • packages/renderer-extension/test/renderer-binding-probe-host-catalog.test.ts

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

Recent review details

Context from checks skipped due to timeout: 8

  • GitHub Check: CodeRabbit
  • GitHub Check: Check Linux ARM64
  • GitHub Check: Check ubuntu-22.04
  • GitHub Check: Check windows-latest
  • GitHub Check: Static checks
  • GitHub Check: Web Host tests
  • GitHub Check: Check macos-26
  • GitHub Check: Vitest
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
  • packages/renderer-extension/test/renderer-binding-probe-host-catalog.test.ts
Source excerpt: Use package public exports for cross-package dependencies.

CodeRabbit inference engine (AGENTS.md)

Files:

  • packages/renderer-extension/src/renderer-binding-probe.ts
  • packages/renderer-extension/test/renderer-binding-probe-host-catalog.test.ts

@iruriQ
iruriQ merged commit 6adb9c4 into BytePioneer-AI:main Nov 25, 2026
6 of 8 checks passed
@iruriQ

iruriQ commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

感谢贡献!改动干净聚焦,真实入口单测在修复前稳定复现循环并在修复后收敛,现已通过 merge commit 合入 main。

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.

2 participants