Repository navigation
engine: a reloaded page is told about a prompt the turn is still waiting on (#130) - #144
Merged
Merged
Conversation
…ing on (#130) The subscription engine announces a blocking TUI prompt once (input_needed) and withdraws it once (input_resolved). A page reloaded in between got a new socket that saw neither frame and a fresh tab state with nothing to redraw the banner from, so the chat showed a running turn and no question. This is the part #143 left open. - The engine reports both edges through an optional onPromptState callback, from wsSendAll, the one place both frames go through. - engine-prompts.js keeps the open prompt per session; all three runInteractiveSingle call sites (chat, Kanban task, Telegram) feed it. - subscribe_session replays it only without noCatchUp (a background tab that never reloaded still has it) and only while isSessionLive(), so a prompt left by a crash between the edges is dropped, not shown. test/engine-prompt-replay.test.js boots a real server whose fake claude draws the trust screen: a foreground subscribe gets the prompt, a noCatchUp one and one after the turn ended do not. It fails on the two positive checks without the replay.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This was referenced Nov 16, 2026
Closed
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.
Follow-up to #130 / #143, the gap stated in the #143 description and in the issue comment: after a full page reload, a pending
input_neededbanner was not re-sent.What was wrong
The subscription engine announces a blocking TUI prompt once (
input_needed) and withdraws it once (input_resolved). A page reloaded while the turn waits gets a new socket that saw neither frame, plus a fresh tab state with nothing to redraw the banner from. The chat showed a running turn and no question.WsProxyreplay does not cover this: it only buffers frames sent while no socket was attached, and this frame went out to the socket that existed then.The fix
runInteractiveSingletakes an optionalonPromptState(frame|null), called fromwsSendAll, the one place both edges go through. It fires only for those two frame types, so a future frame routed through there cannot erase an open prompt. The engine'sfinallyalready sends the closing edge on every exit path.engine-prompts.js(pure, no sockets): keeps the open prompt per session. All three call sites feed it: chat, Kanban task and Telegram.subscribe_sessionreplays it only:noCatchUp, because a background tab that never reloaded still holds the prompt and would just be notified twice;isSessionLive(), so a prompt left behind by a crash between the two edges is dropped rather than shown.tabId(the session id when the engine sent none) andreplayed: true. Theinput_neededshape is otherwise unchanged.Tests
test/engine-prompt-replay.test.js(new, real server and tmux, self-skips without tmux, ~16 s). The fakeclaudedraws the real trust screen, so the turn waits on a prompt. Results:noCatchUpsubscribe does not;With the replay line removed, exactly the two positive checks fail.
test/engine-prompts.test.js(new): drives the store and pins that everyrunInteractiveSinglecall site feeds it, plus the!noCatchUp/isSessionLiveguards.test/claude-firstrun.test.js:onPromptStatehears the prompt open, then close, on a live pane.Mutation checks: removing any one call site's wiring, the
noCatchUpguard, the liveness check, or the engine callback each turns a test red.npm testis green locally (TEST_PORT=4391; another session on this machine was running the suite on the default ports at the same time).An independent review (agy) raised six points. One became the type guard above. The others do not hold here:
d.tabId || activeTabId;isSessionLivereads the turn registries, not session existence;paramsobject carriessessionId;Not covered
The browser rendering of the replayed frame is the existing
input_neededhandler (renderInputNeededCard). The integration test proves the server sends it to a reloaded page, but I did not drive a real browser through a reload.