You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Hang / Application hang/ Stall / Execution stall/Unresponsive UI / UI freeze ————always thinking but no response after "git, find,searchAuto-compacting context" #24434
appIssues related to the Codex desktop appbugSomething isn't workingcontextIssues related to context management (including compaction)performancetool-callsIssues related to tool calling
thread_count_active: 4但是thread_count_streaming_owner: 3——一个活跃线程没有流所有者
thread_count_streaming_without_role: 1— 流线程未分配任何角色
thread_count_streaming_without_active_runtime: 2-3— 没有活动运行时的流线程
Item not found in turn state: 2— 解决状态查找失败问题
修复——三层方法
第 1 层 — 所有权协调(主要修复):
// In app-server's turn management (Rust)
// When a prompt is accepted, ensure the turn is durably linked to its thread
// BEFORE any streaming begins
fn handle_prompt(thread_id: &str, prompt: Prompt) -> Result {
// 1. Create turn record in the thread's durable store FIRST
let turn = Turn::new(thread_id, prompt);
self.store.save_turn(&turn)?; // Durable write before streaming
// 2. THEN start the backend execution
let turn_id = turn.id.clone();
self.backend.execute(turn_id.clone(), prompt);
// 3. Subscribe the UI to the turn stream
self.ui.subscribe(thread_id, turn_id.clone());
Ok(turn_id)
}
第二层——停止/取消可靠性:
// In the Desktop UI's Stop handler
async handleStop() {
// Get the current turn_id from the durable store, not just in-memory state
const turnId = await this.store.getActiveTurnId(this.threadId);
if (!turnId) {
// Show recovery UI instead of silently failing
this.showRecoveryState("No active turn found. Checking backend state...");
const backendTurn = await this.appServer.findActiveTurn(this.threadId);
if (backendTurn) {
// Re-attach UI to the backend turn
await this.reattachToTurn(backendTurn);
}
return;
}
await this.appServer.cancelTurn(turnId);
}
第 3 层 — 恢复/重新连接状态:
// When the UI detects it has lost ownership of an active turn
async detectAndRecover() {
const localActive = await this.store.getActiveTurns(this.threadId);
const backendActive = await this.appServer.getActiveTurns(this.threadId);
// Find turns that exist in backend but not in UI
const orphanedTurns = backendActive.filter(
bt => !localActive.some(lt => lt.id === bt.id)
);
for (const orphaned of orphanedTurns) {
// Show a recovery banner
this.showRecoveryBanner({
type: 'orphaned_turn',
turnId: orphaned.id,
message: 'An active turn was found that is not visible in the UI. Click to re-attach.',
action: () => this.reattachToTurn(orphaned)
});
}
appIssues related to the Codex desktop appbugSomething isn't workingcontextIssues related to context management (including compaction)performancetool-callsIssues related to tool calling
Activity
github-actions commentedon May 25, 2026
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
Kinghammer1 commentedon May 25, 2026
@shaofa-ui, @https://github.com/openai/codex/issues/24287,https://github.com/jshaofa-ui。
完整解决方案
根本原因分析
这是Codex Desktop UI(Electron 渲染器)与后端/应用服务器之间的会话/回合状态所有权不同步问题。核心问题:
提示已被接受,但用户界面失去所有权:后端已接受并执行提示,但用户界面的回合订阅未能接收或渲染提示气泡、助手进度和工具轨迹。
停止失败:由于用户界面没有对当前回合的有效引用,因此无法取消停止按钮。
重启后状态不可见:线程的提示/跟踪状态与原始线程没有持久关联,因此重启后显示的历史记录可能具有误导性或缺失。
来自哨兵计划的关键线索:
thread_count_active: 4但是thread_count_streaming_owner: 3——一个活跃线程没有流所有者
thread_count_streaming_without_role: 1— 流线程未分配任何角色
thread_count_streaming_without_active_runtime: 2-3— 没有活动运行时的流线程
Item not found in turn state: 2— 解决状态查找失败问题
修复——三层方法
第 1 层 — 所有权协调(主要修复):
// In app-server's turn management (Rust)
// When a prompt is accepted, ensure the turn is durably linked to its thread
// BEFORE any streaming begins
fn handle_prompt(thread_id: &str, prompt: Prompt) -> Result {
// 1. Create turn record in the thread's durable store FIRST
let turn = Turn::new(thread_id, prompt);
self.store.save_turn(&turn)?; // Durable write before streaming
}
第二层——停止/取消可靠性:
// In the Desktop UI's Stop handler
async handleStop() {
// Get the current turn_id from the durable store, not just in-memory state
const turnId = await this.store.getActiveTurnId(this.threadId);
if (!turnId) {
// Show recovery UI instead of silently failing
this.showRecoveryState("No active turn found. Checking backend state...");
const backendTurn = await this.appServer.findActiveTurn(this.threadId);
if (backendTurn) {
// Re-attach UI to the backend turn
await this.reattachToTurn(backendTurn);
}
return;
}
await this.appServer.cancelTurn(turnId);
}
第 3 层 — 恢复/重新连接状态:
// When the UI detects it has lost ownership of an active turn
async detectAndRecover() {
const localActive = await this.store.getActiveTurns(this.threadId);
const backendActive = await this.appServer.getActiveTurns(this.threadId);
}
测试策略
单元测试:验证在流式传输开始之前,回合数是否已持久存储
集成测试:模拟回合进行中 UI 崩溃,验证重启后是否恢复
特殊情况:验证即使用户界面失去回合所有权,“停止”功能也能正常工作。
回归测试:验证正常的流程(提示→流→响应)是否不受影响
要更改的文件
codex-rs/app-server-daemon/src/turn_manager.rs— 在流媒体播放前添加耐用的旋转存储
app/src/turn-state-manager.ts— 添加恢复/重新连接逻辑
app/src/stop-handler.ts— 使用持久化轮次引用而不是内存中的轮次引用
影响
提示与其起源线程永久关联。
停止按钮能够可靠地取消后端转向或显示恢复状态
孤立回合会被检测到,并且可以在重启后恢复。
没有来自不可见已接受提示的重复提示。
MisterRound commentedon May 25, 2026
This issue is becoming widespread, it matches mine #24260