Repository navigation
fix(traex): 终态晚于输入框重画时立即复核终态后输入闸,修复会话卡死 - #1883
Merged
Merged
Conversation
TraeX 先重画输入框并静止、task_complete 随后才进 rollout 时,终态后输入闸撤回已 发布的 prompt-ready;空闲检测器已处于 idle 使 fireIdle 空转,bridge 轮询又只在就绪 时发出终态,于是本轮终态永不发出、后续消息全部滞留,直到 web 终端产生新输出。 新增 schedulePostTerminalFenceRecheck:在闸撤回已发布就绪、以及 markPromptReady 因闸被拒时,等渲染落定后先发出结构化终态,再对当前屏幕复核输入框,通过即恢复就绪; 仍为忙碌则保持原有「等下一次 PTY 重画」契约。 Co-Authored-By: Claude Opus 5.5 <[email protected]>
用例放在 cases-traex/,经 FEISHU_E2E_CASES=traex-ambient 显式选择,需要配置 FEISHU_TRAEX_AMBIENT_CHAT_NAME / FEISHU_TRAEX_BOT_NAME,不进入 CI 默认用例集。 Co-Authored-By: Claude Opus 5.5 <[email protected]>
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
October 13, 2026 14:51
TraeX 仅内部分发,GitHub CI 装不上。新增 scripts/record-traex-tape.ts 在本机驱动 真 traex(160x50 PTY)录制 PTY 字节、rollout 与 history 追加及其相对时间;rollout 仅保留 bridge 消费的记录(白名单),账号名/模型名等宽替换并在写出前做残留校验。 test/helpers/traex-tape-player.mjs 作为假 traex 回放录像(提交时写 history 回执、 type-ahead 排队、空闲时持续回放 logo 眨眼字节),TRAEX_TAPE_TERMINAL_DELAY_MS 可将 task_complete 推迟到输入框静止之后。新增集成测试按原始时序与终态延后 4s 各跑两轮 durable IM:master 上后者卡死,修复后两者均通过(vitest 与 bun test)。 Co-Authored-By: Claude Opus 5.5 <[email protected]>
markPromptReady 因闸被拒时会 reset() 空闲检测器,同时清掉 busyTransitionArmed;复核通过后 若直接 markPromptReady,只恢复了 worker 就绪,检测器未重新武装,之后在 web 终端本地开始的 一轮无法把就绪翻回忙碌,可能放行 durable 输入进入进行中的本地轮次。改为检测器不处于空闲时 走 fireIdle()(markIdle 先武装忙碌边沿,onIdle 再次核对输入框后标记就绪),否则沿用直接 标记。IdleDetector 新增只读 isIdleNow()。复现测试补充恢复后本地开工须触发忙碌翻转的断言。 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🚀 Released in v3.44.0 |
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.
背景
TraeX 会话在「免 @,让位」等高消息量群里偶发卡死:飞书消息再也进不去,直到有人在 web 终端里输入、跑一轮,之前排队的消息才全部进去。
根因
postTerminalPromptFence(#1681 引入,目前只有 traex 开启)的一条时序漏洞:task_complete才进 rollout,ingest 调armPostTerminalInputFence()把已发布的isPromptReady撤回;fireIdle()空转;bridge 1s 轮询器只在isPromptReady时emitReadyCodexTurns();turn_terminal永不发出,durableTurnInFlight一直为真,后续 IM 消息(带dispatchAttempt,不能 type-ahead)全部滞留;另一个同类入口:屏幕 idle 内
drainBridges()读到终态并上闸,紧接着markPromptReady()因闸拒绝并reset(),同样再无人复核。改动
src/worker.ts新增schedulePostTerminalFenceRecheck:等渲染落定 → 先发出结构化终态(与 external-idle 路径同序)→ 对当前屏幕跑postTerminalPromptFenceHolds,确认输入框比 busy 标记新才markPromptReady();仍忙时保持原契约(等下一次 PTY 重画),不放宽闸的语义。armPostTerminalInputFence撤回了已发布的就绪时;markPromptReady因闸被拒时。带 pending 去重与 backend/generation 校验。test/traex-post-terminal-fence-wedge.repro.integration.test.ts。scripts/record-traex-tape.ts:本机驱动真 traex 0.209.1(160x50 PTY)录制 PTY 字节、rollout / history 追加与相对时间;rollout 只保留 bridge 消费的记录(白名单,丢弃 session_meta / world_state / 含系统提示的 thread_settings_applied / 模型侧 items),账号名与模型名等宽替换,写出前做残留校验。test/helpers/traex-tape-player.mjs:回放器作为假 traex(提交时写 history 回执、type-ahead 排队、空闲期持续回放 logo 眨眼字节);TRAEX_TAPE_TERMINAL_DELAY_MS可把 task_complete 推迟到输入框静止之后。test/traex-tape-replay.integration.test.ts:按「原始时序」与「终态延后 4s」各跑两轮 durable IM。test/e2e-browser/feishu-traex-ambient.e2e.ts(cases-traex/,需FEISHU_E2E_CASES=traex-ambient及FEISHU_TRAEX_AMBIENT_CHAT_NAME/FEISHU_TRAEX_BOT_NAME,不进入 CI 默认用例集;该时序在真机上无法强制触发,定位为回归冒烟)。影响面
cliAdapter.postTerminalPromptFence === true的适配器(当前只有 traex),且仅在屏幕证据权威的后端(PTY/tmux,非 ZMX)上上闸;其它 CLI、其它后端路径不变。测试验证
timed out waiting for structured terminal for the first turn),修复后通过(约 8s)。bun x vitest run test/traex-*.test.ts test/raw-input-followup-atomicity.test.ts等相关套件:235 passed(含 修复 TraeX 终态后仍向未就绪 PTY 注入后续消息 #1681 的终态/隔离复现测试,忙时闸仍拦截)。bun run test全量:失败的文件在 master 上单独重跑失败集完全一致(12 个 root 权限 / Linux 隔离类环境用例),无新增失败。timed out waiting for second turn terminal),「原始时序」通过;修复后两者均通过,连跑 3 次稳定;bun test下同样通过。⋄◇✦◈❖✧、busy 行◈ Working… (4s • esc to interrupt)(esc to interrupt不在行首,且部分帧拼作interupt),现有busyPattern在 0.209 上基本不命中——不在本 PR 范围,另行跟进。bun run build通过;test/midscene-suite.test.ts(场景注册 18 个)通过。🤖 Generated with Claude Code