Skip to content

fix: replay pending prompts after stale-turn reconcile (#4474)#4522

Open
CVEngineer66 wants to merge 2 commits into
esengine:main-v2from
CVEngineer66:fix/replay-pending-on-stale-turn-4474
Open

fix: replay pending prompts after stale-turn reconcile (#4474)#4522
CVEngineer66 wants to merge 2 commits into
esengine:main-v2from
CVEngineer66:fix/replay-pending-on-stale-turn-4474

Conversation

@CVEngineer66

Copy link
Copy Markdown
Contributor

Fixes #4474

问题

Plan 模式下,AI 完成规划后弹出执行/修订/退出窗口。如果用户切到其他会话,30s 后 stale-turn watchdog 触发 reconcileTabRuntime,dispatch backend_status 到前端,这行代码清除了 approval 状态:

return { ...s, items: finalized, running: false, turnActive: false, 
  approval: undefined, ask: undefined };

approval modal 消失,但后端 controller 仍在阻塞等待用户审批。用户回来时看不到窗口,只能手动点 stop。

PR #4286 修复了 tab 切换时调用 ReplayPendingPrompts,但未覆盖 stale-turn reconcile 路径。

修复

reconcileTabRuntimebackend_status dispatch 之后也调用 replayPendingPromptsForActiveTab(tabId),确保 approval modal 在任意路径下都能恢复。

测试

新增 replay-pending-prompts.test.ts,6 个 case:

  • 无 active tab 不触发
  • 有效 tab 触发一次
  • 不同 tab 再次触发
  • bridge 错误静默吞掉
  • tabId 正确传递

wufengfan added 2 commits June 15, 2026 19:26
…ayout

Root cause (esengine#4459): configuring custom models on Windows triggered 40%
CPU usage from three compounding issues:
  - ModelPicker re-filtered all refs on every keystroke (no debounce)
  - ProviderEditor reparsed modelNames on every input change (no memo)
  - ModelSwitcher called getBoundingClientRect() in render path

Fixes:
- allRefs(s) → useMemo([s.providers]) in ModelsSection
- providerAccessGroups call → useMemo([s.providers, t]) in ProvidersSection
- modelNames split/trim/filter → useMemo([models])
- ModelChips extracted as standalone memo component
- reload/apply/backgroundApply → useCallback
- uniqueStrings O(n²) → Set-based O(n)
- ModelPicker + ProviderModelDraftPicker search → 150ms debounce
- ModelSwitcher getBoundingClientRect → useEffect + ResizeObserver
reconcileTabRuntime (triggered by the 30s stale-turn watchdog) dispatches
backend_status which can clear the frontend's approval/ask state. Without
a subsequent ReplayPendingPrompts call, the modal disappears and the turn
appears stuck.

Previously only the tab-switch path (activeTabId useEffect) called
ReplayPendingPrompts (esengine#4286). This fix adds it to reconcileTabRuntime as
well, covering the stale-turn case.

Also adds a replay-pending-prompts test suite.
@github-actions github-actions Bot added v2 Go rewrite (1.x) — main-v2 branch, active development desktop Wails desktop app (desktop/**) labels Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

desktop Wails desktop app (desktop/**) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: 后台完成plan后切回来没有弹出执行plan窗口

1 participant