Repository navigation
fix: show the Gateway answer after reconnect - #2379
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: passed. What this changesThis PR automatically retrieves the Gateway’s authoritative question outcome after local expiry or reconnect without resending the answer. Example: The user selects Inspect, submits it, and loses the connection before the acknowledgement arrives.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: current main still has the recovery defect, the maintainer-authored repair is useful, and no definite introduced bug was found. Reviewed head: Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherChatQuestionCoordinator receives question events, connection changes and status responses through the existing authenticated Gateway bridge, then supplies transient state to ReactorQuestionPanel. flowchart LR
A[Gateway question service] --> B[Authenticated Gateway client]
B --> C[ChatQuestionCoordinator]
D[Local expiry timer] --> C
C --> E[Automatic status recovery]
E --> B
C --> F[Native question panel]
Technical reviewBest possible solution: Retain authoritative outcome recovery in the existing coordinator, preserve uncertain-answer submission safeguards, and dismiss questions only when their Gateway outcome is known. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the failure path, and supplied base-app evidence shows the accepted answer alongside stale expiry; this review did not execute a reproduction. Is this the best way to solve the issue? The repair addresses the cause in the established state owner, uses supported status reads, preserves generation and revision safeguards, and corrects the fixture behavior that masked the defect. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d0a9f21b8cee. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall readiness starts with the lower of the proof and patch scores. It is capped at 3/6 if the fix is partial, the change offers little benefit, a product decision is still open, or the PR reverses an earlier decision without saying why. ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed December 1, 2026, 7:59 PM ET / December 2, 2026, 00:59 UTC (Revision 2). |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…iry-investigation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…iry-investigation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Closing the AnimationController returned by
CompositionPathGeometry.TryGetAnimationController("Path") leaves the
native controller linked in the DirectComposition device rebuild list.
The next commit then hits dcompi!purecall in
CRebuildableObjectList::Rebuild and fail-fasts the process (0xC0000409),
which crashed the hosted Tray UI testhost.
Keep the controller unowned. Dispose already stops its Progress binding
and the geometry's Path animation before removing the visual tree.
This replaces the duplicate-playback change from 12c5b32, which did not
address the crash, and restores OnboardingMascot.cs to its base state.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Reject equivalent ways of closing the controller (using, Own, _owned) and require Dispose to stop bindings before clearing visuals. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
When the transport confirms the question.resolve request was not written, restore the prompt to its pre-submit state with a send-failed error instead of locking it until a status refresh. Uncertain outcomes (timeout, lost connection) keep the existing lock. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…s mascot fix Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…wers A question that expires locally while disconnected now shows "expired or disconnected", then "Checking question status." after reconnect, instead of a premature "Expired". The Gateway's recovered status decides the final state. Local expiry drops a submit error that no longer applies, and a question that can no longer be recovered now counts toward the terminal history limit. Adds a mounted UI proof for both reconnect outcomes (answered and expired) and coordinator tests for the error and retention rules. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
- Keep a pending read past its local deadline unconfirmed until the Gateway expires it. - Replace the endless checking notice with a read error after repeated failed reads. - Keep the unsupported-read error through local expiry and trim that history. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
An unsupported list now marks a locally expired question with the read error instead of a final expiry. A pending read keeps the answer-not-confirmed notice, and the read-failure notice only marks questions that were not read in the failing refresh. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
A local expiry bumps a question's revision without reading it, so the revision guard skipped it and delayed the read-error notice by one retry. Track the IDs each refresh actually read instead. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…s the local deadline Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The Gateway's question.list returns pending questions only. The fixture listed every question, which let the old coordinator recover an answered question from the list and masked the stale local expiry. - Make the fixture list pending questions only, like the Gateway, and add an external-resolve helper for answers made on another client. - Add a real-socket regression: answer elsewhere while offline, expire locally, reconnect, and expect the Gateway answer via question.get. - Tighten the connected failed-reply test and lower the timing baseline for the delays this PR removed. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…lost Turn the reconnect repro into a theory. One case has another operator answer while this client is offline. The other intercepts this client's own question.resolve, disconnects before any reply or event, then lets the Gateway apply it. Both expire locally and must show the Gateway answer after reconnect without resending. Scope the question.get assertion to reconnect traffic and wait on a single prompt. Add FixtureGatewayServer.InterceptNextRequest so a test can take a request before the scenario applies it. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
- Wait for the fixture to record the successful question.get, not only the client state, so the reconnect proof cannot race the fixture's completion record. - Cancel unused interceptions on fixture disposal, and fail the connection when an interception would bypass a response gate. - Cover the Gateway grace window: a locally expired question reads the Gateway outcome once, whether it is answered or no longer available. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…aborts An interception never replies, so it could silently skip a held response. The guard checked the gate in one lock section and removed the interception in a later one, so a concurrent registration could bypass it, and held chat.abort outcomes were not guarded at all. Check and take the interception in the same lock section and include the abort gate. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…nnect Add a full-app GatewayFixture test: the answer is accepted while the app loses its reply and the resolved event, the local deadline passes during the outage, and after reconnect the panel shows the Gateway outcome. The test fails on the base build with "Question expired" still showing. Record fixture gate conflicts as unexpected requests and dispose the fixture server when interception test setup fails. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
A submission that is still in flight when the local clock expires the question now stays awaiting resolution, so a later pending read cannot re-enable Submit and send a second answer. Replies that prove nothing was written clear that fence, and other reply failures keep the unconfirmed notice. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
A refresh that reads a past-deadline pending request while an answer is in flight now keeps the answer fenced until the Gateway resolves it. A reconnect that drops an in-flight answer which expired locally now shows the not-confirmed notice instead of an indefinite status check. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
4ce1a5346b49fb47f933b1b0ee8292ef38981f34↑ The full-app reconnect test, the real-socket Gateway client test and the mounted WinUI test each passed 11/11 in hosted CI, including a 10-run soak.
↑ Local
build.ps1, Shared (6,229 passed, 29 skipped) and Tray (7,251 passed) runs passed on this exact tree.↑ Removing any one of the six answer-fence lines fails its named coordinator test.
↑ Round 16 of the dual-model review found nothing in either model.
↓ Not run against a live Gateway or provider.
↓ Local accessibility scan had 2 failures outside question code; hosted accessibility had 0 failed with 14 not run.
↑ Network recovery E2E passed 2 of 2 on the rerun; CI Gate passed and merge state is clean.
↓ The first network E2E attempt hit the 30-minute job limit with no log; the E2E project does not reference changed code, so this is attributed to the runner, but its cause is unproven.
↑ The real-socket test on base shows
question.get=0after reconnect, and reverting the fix fails both cases.↑ The old fixture listed answered questions, unlike the upstream Gateway, which explains why existing tests missed it.
↑ Both possible triggers (a dropped connection, or a failed reply while connected) are covered and recover.
↓ No field log, so the exact trigger in the report is unknown.
What Problem This Solves
When the Gateway connection drops while an agent is asking a question, Companion can show "Question expired" after it reconnects, even though the Gateway already has an answer. This happens when the user answered just before the drop and the reply was lost, or when someone else answered in web chat while Companion was offline. The user is told their answer was lost when it was not, and the only way to see the real outcome is to open web chat.
User Impact
User impact: after a reconnect, Companion checks every question it marked expired on its own and shows the Gateway's real outcome. It does this without a manual Refresh and without sending the answer a second time. While it checks, the question shows "Checking question status."
Visible changes and limits:
question.getkeeps failing with an error other than "not found", the question stays on "Checking question status." and Companion keeps checking every 4 seconds while connected. There is no retry limit, so a later success still shows the real outcome.Why This Change Was Made
Root cause. When the local deadline passed, Companion marked the question expired and stopped tracking it. The Gateway's
question.listreturns pending questions only, so an answered question drops out of the list. Nothing then read the question directly withquestion.get, so the local "expired" stayed on screen. This came in with #1757.Fix. A local expiry is now treated as unconfirmed, not final.
ChatQuestionCoordinatorkeeps such questions in recovery, reads each one withquestion.getafter reconnect and on the retry schedule above, and replaces the local status with the Gateway's. Recovery only reads. It never resends an answer, and a submission whose result is unknown stays blocked from a second submit until the Gateway reports a status. This includes an answer still being sent when the local deadline passes, whether the once-a-second expiry check or a status read notices the deadline first.Test fixture fidelity. The synthetic Gateway's question list used to include answered questions, which hid this bug from the existing tests. It now returns pending questions only, matching the upstream Gateway. The fixture also gains
InterceptNextRequest, so a test can take a request before the Gateway applies it and model a commit whose reply was lost. An interception never replies, so the fixture refuses one for a request whose response is held (a response gate or a heldchat.abort). It checks and takes the interception under one lock, so a concurrent registration cannot slip past that check.Scope: questions only. The setup-mascot crash fix that briefly shared this branch landed separately in #2425.
Evidence
The reported screen, reproduced in the full app and fixed. The new UI test
GatewayFixtureUiTests.InteractiveQuestionAnsweredDuringOutageShowsGatewayOutcomeAfterReconnectdrives the real Companion app, with an isolated profile, against the fixture Gateway over a real WebSocket:It passes only when, after reconnect, the app has read the question with
question.get, the question panel is gone, the composer is back, and the answer was sent exactly once.7b740dbfwith the question code reverted to base9f802c64(local)7b740dbf(local)1f052401(local)4ce1a534(current), hosted CIThe test itself is unchanged since
7b740dbf; later commits change onlyChatQuestionCoordinator.csand its unit tests.Base (local run), after reconnect: connected, and the agent reply says the answer was accepted, but the panel above the composer still says "Question expired". This is the reported screen.
This PR (hosted CI on head
4ce1a534), offline after the local deadline: the question is shown as not confirmed, not as expired.This PR (hosted CI on head
4ce1a534), after reconnect: the app read the Gateway's answer, closed the question and shows the reply.Question before the outage, and run identity
The three screenshots of this PR come from hosted CI 46775158923, attempt 1. It tested head
4ce1a5346b49fb47f933b1b0ee8292ef38981f34merged into main (merge commit206fe35fc6ea247d2755715d12688c392f7d0895). The test captured them from the app's own window withPrintWindow(artifacttest-results-gateway-fixture, fixture run58430fc1). The fixture Gateway recordedconnect,question.list,question.resolve,connect,question.list,question.get: one answer, then a status read after reconnect.The base screenshot comes from a local run on head
7b740dbfb19580d57189dd376fb55ff3a712d640that reverted onlyChatQuestionCoordinator.cs,ReactorQuestionPanel.csand the sixResources.reswfiles to base. The local fixed runs used clean trees.OpenClaw.Tray.WinUI.dllSHA2567b740dbf, question code at baseEE9A44B763F31B0F0CE0795A104855E9B22A0300BECD6069073CDD858C4AA2F27b740dbfC048F520A569CA3A8C90AF20B2E4CDCF1AB875A73961FFA56CB784E6820FA8B11f052401E357F97EDED45E5DD4BF9298C0612C52FAA671A089337D6FAEFD35D7DBE37185206fe35f028A518BB68C9919DA4F15B09071EF8766754F333E91E96B533EAEBDAB08D50FBug reproduced, then fixed, at the Gateway client.
InteractiveGatewayChatTests.QuestionResolvedDuringOutageAndExpiredLocally_ShowsGatewayAnswerAfterReconnectruns the real Companion Gateway client against the fixture Gateway in two cases:answeredHere: true: the user submits an answer. The Gateway takes it, the connection drops before any reply or event, then the Gateway applies it. This is the reported scenario.answeredHere: false: another operator answers while Companion is offline.In both cases the question shows "expired" while offline. After reconnect it must show "answered" with no error. The test also checks that a successful
question.getran after reconnect and that Companion sentquestion.resolveat most once (no resend).9f802c64production codeconnected=True status=expired question.list=1 question.get=0, so Companion never read the question4ce1a534: Tray suite plus the 10-run soakCoordinator regressions.
ChatQuestionCoordinatorTestscover each recovery route: reconnect, a connected reply failure, retries running out, and clock skew.LocallyExpiredQuestion_ReadsGatewayOutcomeWhileConnectedcovers both Gateway answers to a status check while connected: "answered", and "not found" after the grace window, which shows "Question no longer available". Each makes exactly one read. RemovingNeedsRefresh = trueor the recovery arm fromExpirefails both cases. Earlier review rounds mutation-checked the other new tests against the production lines they guard.FailedRefresh_RetriesAtOneTwoFourSeconds_ThenEveryFourUntilRecoveredpins the automatic retry schedule that replaces the Refresh button.The no-second-answer fence has its own tests. On
4ce1a534, removing each production line below fails the named coordinator test:Expirekeeps an in-flight answer awaiting the GatewayLocallyExpiredInFlightSubmission_PendingReadCannotSendSecondAnswer, plus 2 moreStore)InFlightSubmission_ReadPastDeadlineKeepsAnswerFenceOnStatus)LocallyExpiredInFlightSubmission_ReconnectKeepsUnconfirmedNoticeLocallyExpiredInFlightSubmission_FailedReplyRecoversGatewayAnswerWhileConnectedLocallyExpiredUnwrittenAnswer_CanBeSubmittedAfterPendingRead(invalidAnswer: True)LocallyExpiredUnwrittenAnswer_CanBeSubmittedAfterPendingRead(invalidAnswer: False)Mounted WinUI.
ReactorQuestionProofTests.LocallyExpiredQuestion_StaysUnconfirmedUntilReconnectReadsOutcomerenders a locally expired question in the real native panel. It shows the unconfirmed state with no Refresh control, then the Gateway outcome after reconnect, for both "answered" and "expired". Both cases passed 11/11 in hosted CI on4ce1a534. The new and changedChatQuestionCoordinatorTestscases that CI selected for its soak, including the six fence tests above, each passed 10/10.Review. Sixteen rounds of the Hanselman dual-model review (
claude-opus-5.5, andgpt-6-astrawith long context, both at high reasoning effort). Each verified finding was fixed with a regression test. The last three rounds:7b740dbf1f0524017b740dbf..1f0524014ce1a5341f052401..4ce1a534Left as is, by decision: when
question.listfails and Companion knows no question, it retries every 4 seconds without a panel error, which matches web chat. After a local expiry and a "request not sent" reply, "Could not submit your answer. Try again." can show for up to 4 seconds while Submit stays disabled, until the next status read. A reconnect while an answer is in flight, before the local deadline, re-enables Submit once a status read shows the question still pending; this is unchanged from base.Validation commands and counts
Local runs on
4ce1a5346b49fb47f933b1b0ee8292ef38981f34(the validated tree, committed unchanged):.\build.ps1: all builds succeeded.dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore --blame-hang-timeout 10m: 6,229 passed, 29 skipped, 0 failed. The hang guard is there because an earlier run hung inInstalledFileWorkerResolverTests.CancellationBeforeVerificationResumesPreservesItsTokenAndOnlyUnprovenObjects(obstacle: "published-ea"), a FileWorker test this PR does not touch. A dump showed its oplock request failed at once, and its cleanup then waits forever inGetOverlappedResult. It did not hang on this run.dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore: 7,251 passed, 0 failed..\scripts\validate-test-timing-patterns.ps1: passed.git diff --checkagainst base: clean.Earlier, on
740a013b: the SharedInteractive_fixture filter passed 46.Interactive_DisposeCancelsUnusedInterceptionfails at its 20 s deadline when the dispose cancellation is removed.Interactive_InterceptionCannotBypassHeldResponsefails for a heldchat.abortwhen the guard ignores the abort gate, and fails in both cases when the guard is removed. TheReactorQuestionProofTests.cstiming baseline went down from 26 to 23. These fixture tests are part of the full Shared run above, so they also pass on the current head.Hosted CI 46775158923, attempt 1, on head
4ce1a534(merge commit206fe35f). Counts come from the downloaded TRX files. Every file reports 0 failed.CodeQL: success. Network recovery E2E (WSL Latest): attempt 1 was cancelled at the 30-minute job limit without a log or artifact.
OpenClaw.E2ETestsreferences only SetupEngine, Shared and Connection, which this PR does not change. Attempt 2 of the same run passed 2 of 2 tests in about 13 minutes, and CI Gate passed.Earlier local runs on head
2d9d98bbc9ec4ff900facaa046c1668ef8a3b948hit two unrelated first-run failures, each passing on rerun:GatewayFileTransportTests.RejectedFrameInWindowStopsTransferAndLeavesGatewayResponsive(rejected: 0)(HttpListenerException, its listener port was in use) andInteractiveGatewayChatTests.SidebarForkPreservesCompletedHistory(active: True)(the fixture recorded a non-WebSocketINVALID_UPGRADEconnection the test never sends). Neither touches question code.Required proof pools
windows-winui-interactive: Partly verified on head4ce1a534.4ce1a534). This is UI Automation, not a computer-use session.run-accessibility-scan): ran locally on a clean tree, 41 of 43 passed. The evidence validator records the run as blocked because of 2 failures outside question code.MainSearch_OpenPopupEmptyResultsAndAccessibleInputStatusPassAccessibilityfailed because Windows kept another desktop app in the foreground.SessionsRows_ArrowNavigationEntersLaterRowActionsis a stale test: it expects "Open in chat", but the row has said "Open {title} in chat" since3f47e8388. Neither ran in hosted CI, where accessibility had 29 passed, 14 not run and 0 failed.Real Behavior Proof
The reported sequence runs end to end in the real app (Companion UI, production Gateway client and a real WebSocket) against the fixture Gateway, on base and on this head, as shown above. The base build reproduces the reported screen: connected, the answer accepted, and "Question expired".
Limits: this is not a live Gateway or provider run. No field trace from the original report was available, so its exact trigger (a dropped connection, or a failed reply while connected) is unknown. Both triggers are covered by tests. The original report's screenshots are not attached because they contain private chat. They showed web chat with the answer recorded while Companion showed "Question expired".