Repository navigation
fix(dashboard): hide ask-the-agent while the gateway is unreachable - #20223
Conversation
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Check that "Ask the agent" doesn't flicker out from under the cursor during short socket reconnects, since the link now unmounts on every [UX-REVIEWED] 377096d Description read[DESCRIPTION-READ] 0c22872df427bb2ae764d57ea67f15ee1e62a6626c5aa5006606164d4a01866d That sha256 names everything this verdict read: the PR description, plus the 11 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
First Principles Review (Opus 5.5) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS The new connectivity mirror is a second copy of Not justified as shipped
Inventory (5 items) — 2 justifiedIntent: stop offering "Ask the agent" while the gateway is unreachable. FIX.
[FIRST-PRINCIPLES-REVIEWED] 377096d Description read[DESCRIPTION-READ] 441067096039307623b702ce5048e25d6b89dd060bfb4d6a659d394d4e3bc23f That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing to check. Suggestions
[DESIGN-REVIEWED] 377096d Description read[DESCRIPTION-READ] f46f76f5bce05beb72767e913fb019cd138cbf928b0c70a3e637fc6f44deec37 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
|
Closing and reopening to re-run CI against current main (picks up #20212, which fixes main's own ChatEmbed.optimisticSend failure). |
|
Closing and reopening once more: the previous reopen still ran CI on the old merge base (e93ecd0); the merge ref is now current. |
f6df37e to
b083b88
Compare
cruisercohen
left a comment
There was a problem hiding this comment.
Review of b083b88497aee53c9dd0ebc2d7bac1548db14b6f (merge base e4270cfcec).
The fix is right. Both hand-off surfaces named in #20215 now hide while the socket is down and come back on reconnect, and the error text and dismiss button stay. I put the two components and the two socket call sites back to the merge base and kept the new tests: 5 of the 6 new tests fail (the three gate tests in errorToAgent.test.tsx, gatewayConnectivity.test.tsx, and the pairing test). On this head, all 70 tests in the four touched test files pass. All checks are green on this head (87 pass, 0 fail).
Changes requested. Both are comment fixes; neither changes behaviour.
-
website/src/components/AskAgentButton.tsx:37: "even though the component is no longer hook-free" narrates history. The comment rule indocs/system-specs/common/code-style.md("Comments explain the WHY") bans "no longer" in every comment. Comments underwebsite/are held to that rule by review, because the script gate scans only Python. Suggested present-tense wording: "(useSyncExternalStoreneeds no context, so the hook keeps that constraint.)" -
website/src/utils/errorReport.ts:751-754(and the same claim at line 739): the docstring says the writers are inuseWebSocketand keep the mirror and the store flag together "so the two cannot drift". Both parts are wrong:- The writers are in
hooks/websocket/gatewayConnectivity.ts. sseStatus(website/src/store/dashboardSlice.ts:898) setsconnected = trueon its own.
I ran a probe on this head:
markGatewayDisconnected(store.dispatch)followed bystore.dispatch(sseStatus({}))leavesstore.getState().dashboard.connected === truewhileisGatewayConnected() === false. The bootapi.status()call inApp.tsxdispatchessseStatus. So if the socket closes before a successful status reply lands, the two flags disagree until the socket next opens or closes. Two ways to fix it:- Reword the docstring to say what the helpers guarantee, and note that
sseStatuswrites the store flag by itself. - Or extend the pairing test to cover
sseStatustoo.
- The writers are in
Not blocking: whether to keep the mirror or read the store singleton through useSyncExternalStore(store.subscribe, ...) is a design call. The fail-open default before the first connect is a fair reason to keep the mirror.
|
@cruisercohen thanks, both fixed in 434474a (comments and one test case, no behaviour change):
Could you re-review when you have a moment? |
cruisercohen
left a comment
There was a problem hiding this comment.
Re-review of 434474ad3cb047a5aac4a1f3e230c4ef1a656359. Thanks for the quick turn.
Both earlier points are fixed:
AskAgentButton.tsx: the added comment now reads in present tense.errorReport.ts: the section comment and thesetGatewayConnecteddocstring namehooks/websocket/gatewayConnectivity.tsas the writer and say the two flags can differ throughsseStatus, and the new pairing case pins that.
Two things on this head still need a change:
-
website/src/test/gatewayConnectedPairing.test.ts:23importsmarkGatewayDisconnecteddirectly from../hooks/websocket/gatewayConnectivity. That breaks the existing invariant inwebsite/src/test/useWebSocket.ownership.test.ts:178("outside the owner directory, only the facade imports an owner"):cd website && npx vitest run src/test/useWebSocket.ownership.test.ts × one public surface > outside the owner directory, only the facade imports an owner - [] + [ "src/test/gatewayConnectedPairing.test.ts" ]With the pairing test as it was at
b083b88497the same run passes 9/9. Frontend Tests are still running on this head, so CI has not reported it yet. The facade does not export the helper, so the smallest fix may be to move this one case intohooks/websocket/gatewayConnectivity.test.tsx, inside the owner directory where the import is allowed, and leave the source-level scan where it is. -
PR Hygiene fails: "PR must contain 1 or 2 commits (has 3)". Folding the comment commit into one of the two earlier ones clears it.
The first two commits are identical to the head I reviewed before (range-diff), so the fix itself still stands. Happy to approve once these two are addressed and the checks are green.
434474a to
67987b7
Compare
…unreachable While the gateway is down, "Ask the agent" hands the error to a chat composer that cannot send, and the error on screen is usually the connectivity failure itself. Hide the hand-off (AskAgentButton and ErrorNoticeMenuItem) while disconnected; it returns on reconnect. The button must mount outside the store Provider (ErrorBoundary fallbacks), so the store's connected flag is mirrored into a context-free seam in utils/errorReport. The socket layer moves both through markGatewayConnected/markGatewayDisconnected in hooks/websocket/gatewayConnectivity.ts, called from connection.ts (handleClose) and reconnectCatchUp.ts (first connect and reconnect). A source-level test pins that no raw sseConnected/sseDisconnected dispatch exists outside those helpers. Re-ported from #10680 onto the hooks/websocket split from #15082. Fixes #20215 Co-authored-by: Ruben Cuevas <rubencu@amazon.com>
67987b7 to
377096d
Compare
|
Update: the sseStatus case could not live in |
mbriones98
left a comment
There was a problem hiding this comment.
Checks green and readiness passed at 377096d; no behavior change.
cruisercohen
left a comment
There was a problem hiding this comment.
Re-review of 377096d8fea778c04c0a18c8d3d4d4425eb9c192 (2 commits on e4270cfcec).
Both points from the last round are fixed:
- The
sseStatuscase now lives inhooks/websocket/gatewayConnectivity.test.tsx, inside the owner directory, souseWebSocket.ownership.test.tspasses. The pairing test keeps the source-level check, and its header points to the runtime case. - The PR has 2 commits and PR Hygiene passes.
Checked locally on this head: gatewayConnectivity.test.tsx, gatewayConnectedPairing.test.ts, errorToAgent.test.tsx and useWebSocket.ownership.test.ts pass 71/71 on three runs. The whole hooks/websocket/ directory plus those files pass 84/84 in shuffled order. The fix itself is unchanged since the first round, where putting the components and socket call sites back to the merge base made 5 of the 6 new tests fail. Every check from this head's push is green, including PR Readiness, and there are no code-scanning alerts.
Approving. This replaces my earlier change request.
Replaces #10680 by @rubencu — thank you for the fix and its design. This re-ports it onto main's
hooks/websocket/*split (#15082); the fix commit keeps @rubencu as author.Problem / Motivation
Goal: "Ask the agent" is not offered while the gateway is unreachable, and comes back when it reconnects.
While the gateway is down, every error surface still shows Ask the agent (banner links and the menu-item form in kebab/dropdown menus). The agent runs on the gateway, so the hand-off lands in a composer that cannot send ("gateway offline — message will not send"). The error on screen then is usually the connectivity failure itself.
Why it matters
Every user who sees an error during a gateway outage or restart is offered an action that cannot work. A dead call to action next to "Failed to fetch" reads as one more broken thing.
Not a goal
connectedflag is computed (sseStatuskeeps its own write).What changed (motivation → approach → change)
AskAgentButton(components/AskAgentButton.tsx) andErrorNoticeMenuItem(components/ErrorNotice.tsx) only checked for a message/report, never connectivity.Provider(ErrorBoundary fallbacks), so it cannot readdashboardSlice.connected. The flag is mirrored into a context-free seam inutils/errorReport.ts(setGatewayConnected/isGatewayConnected/subscribeGatewayConnected, default connected), the same shape as the existinginstallSoftNavigateseam. Both components subscribe viauseSyncExternalStoreand returnnullwhile disconnected; error text and dismiss stay.hooks/websocket/gatewayConnectivity.tsholdsmarkGatewayConnected/markGatewayDisconnected, which move the store flag and the seam together. They replace the raw dispatches inconnection.ts(handleClose) andreconnectCatchUp.ts(first connect + reconnect).useWebSocket.ownership.test.tslists the new owner and its two edges.useWebSocket.ts.website/scripts/capture-20215-ask-agent-offline.mjs: screenshot harness for the banner scenes below.Backwards compatibility
Compatible: no API, store shape or prop changes; the seam defaults to connected, so surfaces that never mount the socket behave as before.
Reader: website/src/components/AskAgentButton.tsx:AskAgentButton -- chat|crew page|app -- hidden only while the socket is down;
errorToAgent.test.tsx"hides the button while the gateway is unreachable and restores it on reconnect"Reader: website/src/components/ErrorNotice.tsx:ErrorNoticeMenuItem -- chat|crew page -- same gate;
errorToAgent.test.tsx"the menu-item hand-off hides while disconnected too"Reader: website/src/components/ErrorBoundary.tsx (fallback hand-off) -- release -- no socket mounted, seam stays connected;
errorToAgent.test.tsx"defaults to connected"Tests
test/errorToAgent.test.tsx: button,ErrorNoticeand menu item hidden while offline, visible when online, restored on reconnect; defaults to connected.hooks/websocket/gatewayConnectivity.test.tsx: the helpers dispatch the store action and flip the rendered button.test/gatewayConnectedPairing.test.ts: no rawsseConnected/sseDisconnecteddispatch outside the helpers.Manual verification
npm run typecheckclean, eslint clean on touched files.Screenshots / video
Banner: built SPA,
POST /api/channelsfails at the network layer; the/api/wsstub closes (offline) or stays open (online). Harness:website/scripts/capture-20215-ask-agent-offline.mjs.Menu item: the session kebab menu (
capture/mute-sessions-kebab-item.html?scene=error, realSessionActionsMenu+ErrorNoticeMenuItem), offline set through the seam. On main there is no offline state for the item, so it always shows.Related Issues
Fixes #20215
Replaces #10680
Pattern harvest
Not generalizable: a one-off gap in one hand-off control; the seam plus the pairing test already stop the store flag and the mirror drifting.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.