Repository navigation
fix(chat): bound the /-menu slash-command fetch so a slow gateway fails visibly - #7418
Conversation
7c51ea9 to
1af3bab
Compare
GPT 5.6 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
Design Review (Fable 5, fork) — ✅ PASSDesign-level review of All claims verified against the base tree: Design-Verdict: PASS Faithfully extends the proven #7062 pattern to the next composer menu; every trade-off (fallback-row scoping, two keys, deferred [DESIGN-REVIEWED] f250736 |
First Principles Review (Fable 5, fork) — ✅ PASSPremise-level review of All claims verified against the base. The pre-state matches ( First-Principles-Verdict: PASS A real composer deadlock gets a bound, a named wait, and honest failure copy — every item traces to the reported defect or a documented invariant. What this change shipsIntent: stop a wedged
Watch
[FIRST-PRINCIPLES-REVIEWED] f250736 |
Opus 4.8 Review (fork) — ✅ no blocking findingsReviewed Review detailsI've traced the full component logic and the diff. Let me evaluate the single candidate. Candidate 1 — the in-flight "Loading commands…" Verifying against the render code (
This is a minor a11y polish item, ambiguous as to whether it's even a defect, and does not reach the 80+ bar for a concrete wrong outcome. Dropped. Step 2: I traced the surrounding logic for new defects — the release-gate ( No findings. [OPUS-REVIEWED] f250736 |
UX Review (Fable 5, fork) — ✅ PASSUX-level review of UX-Verdict: PASS The failure now names itself in the user's vocabulary, the wait is visible, and every string mirrors the shipped Suggestions
[UX-REVIEWED] f250736 |
1af3bab to
e6b9192
Compare
019b352 to
a4e2acc
Compare
a7487ea to
c78c8b2
Compare
…ls visibly Give api.slashCommands an AbortSignal and a 15s deadline, and render a failed load as a failure so a wedged gateway stops swallowing Enter in the composer.
c78c8b2 to
f250736
Compare
| // a newline); role="status" so screen-reader users hear the flip too. | ||
| ? <div role="status" className="px-3 py-3 text-[12px] text-muted">{i18nT(sendOnEnter === 'ctrl-enter' ? 'components.slashCommandMenu.no_matching_commands_ctrl_enter_sends' : 'components.slashCommandMenu.no_matching_commands_enter_sends')}</div> | ||
| ? (isFetching | ||
| ? <div className="px-3 py-3 text-[12px] text-muted">{i18nT('components.slashCommandMenu.loading_commands')}</div> |
There was a problem hiding this comment.
🟡 The new loading row is silent to screen readers, while your own open sibling PR #7668 exists precisely to announce the $-picker's loading hold.
? <div className="px-3 py-3 text-[12px] text-muted">{i18nT('components.slashCommandMenu.loading_commands')}</div>Cause → mechanism → consequence: the loading row carries no role="status"/live-region semantics → a screen-reader user typing /xyz hears nothing while Enter stays preventDefaulted for up to 15s → the exact silent-held-Enter confusion this PR fixes visually persists aurally. Today this mirrors SkillPickerMenu's shipped loading row exactly (verified at head), so it is consistent — but #7668 ("announce that Enter is held while the $skill picker loads") will make that sibling announce, leaving this menu the odd one out the day it merges.
Suggestion: either add role="status" here now (matching the settled-empty row two lines down), or note in the PR that this row inherits whatever announcement pattern #7668 lands, as a named follow-up. Non-blocking either way.
[code-review-sage]
bolichen97
left a comment
There was a problem hiding this comment.
Approving on the strength of a full readiness audit of every open PR against main, not a
line-by-line reading of this diff — recording that plainly so the next reader knows what this
stamp does and does not cover.
Verified against this exact head SHA:
readiness: passedpresent, andPR Readiness— the one required status context onmain
(rulesetprotected-branches) — issuccesson this head.- No check run on this head is
failure,cancelled,timed_outor still in flight. Skipped
jobs are path-filtered conditionals, none of them required. mergeable: true, and the head is not far enough behindmainfor its green CI to describe a
base that no longer exists.- No surviving reviewer
CHANGES_REQUESTED: any such review is on an older commit and therefore
already dismissed bydismiss_stale_reviews_on_push. - Every issue comment, inline review comment and review thread was read and classified. Nothing
left is an unresolved human change request — the remainder is bot review-lane output, resolved
or outdated threads, explicitly non-blocking suggestions, and author status notes.
Auto-merge (squash) is armed, so this lands once every other ruleset requirement is met.
Problem / Motivation
At
78cc85a83the/-menu's command fetch has no deadline and noAbortSignal:A wedged
/api/slash-commandstherefore never settles, andisFetchingneverclears. That matters because the menu's key-release gate reads it:
So on a slash prefix that matches nothing yet —
/xyz, or any server-onlycommand the offline fallback does not list — the menu takes the
displayed.length === 0 && !releaseKeysWhenEmptybranch and rendersnullwhile
useListKeyboardNav's document listener stays attached. Enter ispreventDefaulted by an element that is not on screen. The user cannot send,and there is nothing to explain why.
This is the same defect class as the
$-skills menu, fixed in #7062(
62c20a17e). That PR is the template here; this is the next menu along.Why it matters
The failure is a composer deadlock, and it is silent. The
$-menu at leastheld a visible "Loading skills…" up; this menu rendered nothing at all, so the
only symptom was that Enter stopped working — indistinguishable, from the user's
side, from the app having frozen. The one escape was to backspace out of the
slash prefix, which is not discoverable. This PR closes that gap as well as
bounding the fetch: the in-flight window now names itself.
It also mis-reports once the fetch does fail.
datadefaults toFALLBACK_COMMANDS, so a settled error still shows the offline list, and azero-match against that list rendered "No matching commands". That asserts the
live list was read and did not hold the prefix. It was never read, and the
served list is provider-aware, so a command it would have offered may simply
never have arrived.
What changed
Bound inside
api.slashCommands, not at the call site. Onereact-query initiator exists today (verified by grep with a fabricated-token
control), so this is not yet about losing a dedupe race — it is about the next
caller of
['slash-commands']inheriting the bound rather than having toremember it. Reuses
lib/withDeadline.tsas shipped by #7062; no second helper.fetchis kept rather than switched to thegethelper deliberately:getadds the
X-Session-Keyplaceholder header, and this endpoint isprovider-aware, so that would be a behaviour change smuggled in beside a
timeout fix.
The in-flight window is named, not merely bounded. The zero-match branch
rendered
nullwhile the fetch was outstanding, so for up to 15s the composerlooked frozen with Enter held. It now renders a
Loading commands…row — newkey
loading_commandsacross 13 catalogs — mirroringSkillPickerMenu.tsx:237.Enter is still held there on purpose: a half-typed command must not send.
On the 15s value, stated plainly: it is the sibling constant's value, chosen
for consistency. I did not measure this endpoint, so the comment on the constant
claims no measurement of its own — the two menus are the same kind of composer
affordance blocking Enter on the same gateway, and a second, differently-derived
number here would only be another thing to explain.
No per-query
retry:. #7062 foldedisDeadlineErrorinto the app-wideretryPolicy(queryClient.ts:37), and this component sets noretry, so italready inherits "never retry a deadline". Adding one here would re-introduce
exactly the per-site threading that PR removed. Pinned by test, not by comment.
Failure rendered as failure.
SlashCommandMenu.tsxnow threads({ signal })through and readsisError, and the zero-row copy branches on itahead of the empty-state text:
Two points a reviewer comparing against #7062 will want:
skills_load_failedplus the twosend-binding variants because its menu renders an empty state while still
unreleased. Here a settled error with zero rows ALWAYS releases Enter —
releaseKeysWhenEmptyis!isFetching && filtered.length === 0, andisErrorimplies
!isFetching— so the bare variant is structurally unreachable andwould be dead copy for 13 translators. The existing
no_matching_commands_*pair omits it for the same reason.
isError && items.length === 0.When the fallback does yield rows they stay listed and usable; the failure copy
is for the case where the menu would otherwise have made a false claim.
Real per-locale translations across all 13 catalogs, each composed from that
locale's own shipped halves — its
skills_load_failedverb phrase and itsno_matching_commands_*send clause — so separator (—/:/——), keynaming (
EntervsInvio) and register match what already ships there.en-XAregenerated withnpm run i18n:pseudo.Two call-site consequences, both deliberate:
slashCommandsjoinsHAND_TESTEDinApiClient.coverage.test.tsx. Thatsweep passes positional junk, which now lands on the signal parameter and
would throw inside
withDeadline— the same reasonskillswas excluded.The URL/no-body coverage it provided is re-asserted directly in the new
api test.
filtering to /tan …drove the errorpath and expected "No matching commands"; it now expects the failed-load
copy. Its actual intent — never render an inert
/tangentrow — is unchangedand still asserted.
Deferred, and named here because leaving it unnamed is the real defect.
api.fileSearchis the same class and is not bounded by this PR. It accepts andforwards an
AbortSignal(client.ts:3167) but carries no deadline, andFilePickerMenusits behind the same!isFetchingrelease gate(
FilePickerMenu.tsx:160), so the@-menu can swallow Enter exactly as the/-menudid. It is deliberately not touched here because #7068 already implements it: that PR
is open and non-draft, and carries its own
website/src/lib/fileSearchDeadline.ts, abounded
FolderPanel, and a 240-line timeout suite. Bounding it here would duplicate alive sibling and collide in
FilePickerMenu.tsx,queryClient.tsand these samelocale catalogs. If #7068 is abandoned, this is the follow-up to pick up.
Tests
src/test/apiSlashCommandsDeadline.test.ts(new, 5 tests) — the client-layerbound, against a gateway that settles only if the signal aborts: rejects with
TimeoutErrorgiven no signal (the pre-fix shape); relays an outer signal soreact-query unmount/cancel still aborts; asks for
SLASH_COMMANDS_TIMEOUT_MS;and the two that must pass either way — a healthy fetch resolves untouched, and
the URL is exactly
/api/slash-commandswith no body.src/test/SlashCommandMenu.timeout.test.tsx(new, 6 tests) — what the menuowes: the
AbortSignalreachesapi.slashCommands; a timeout names the failureand Enter passes through un-prevented (
fireEvent.keyDownreturnstrue) withonSelectuntouched; it does not claim "no matching commands";ctrl-entermode names Ctrl+Enter; the fetch runs once under the production
retryPolicy; and, as the negative control on the copy's scope, a bare/still lists the fallback with no failure text.
Negative controls, run in two stages rather than asserted. With only
SlashCommandMenu.tsxreverted tomain, 6 tests fail — 5 on the absentfailure copy and one on
expected undefined to be an instance of AbortSignal—while the fallback-rows control still passes. With only the
withDeadlinewrapremoved from
client.ts(the constant left in place, so the failure isbehavioural and not a missing symbol), the 3 deadline tests hang and time out at
15000ms, which is the defect itself; the healthy-resolve and URL tests still
pass. Both files were restored and re-diffed byte-identical afterwards.
Local gates, all green:
npx tsc -b;npx eslint src/ --max-warnings 659(0 errors, 657 warnings — the same count a clean
78cc85a83tree produces,measured by stashing this change and re-running, so the diff adds none);
npx jscpd .(0 clones);node scripts/i18n-check.mjswithI18N_BASE_REF=78cc85a83…— includingcheck-unit-literalsreporting 0number+unit literals on added lines,
check-i18n-keysresolving the new ternarystatically with no new dynamic site, and
check-untranslated-valuesflaggingnone of the 26 new values as passthrough; and
npx vitest run src/.Screenshot evidence
Captured against the REAL built SPA by
website/scripts/capture-slash-command-fetch-timeout.mjs,which asserts as well as photographs: the two timeout scenes let
/api/slash-commandsHANG, so theproduction
withDeadlinetimer is what fires rather than a simulated rejection, and the scriptexits non-zero unless the expected copy rendered inside a
role="status"live region. Nothing inCI runs that file — the CI-enforced half is
SlashCommandMenu.timeout.test.tsxandapiSlashCommandsDeadline.test.ts.Pattern harvest
Rule candidate: semgrep
Pattern: a react-query
queryFnthat drops the injectedsignal—queryFn: () => api.foo()instead ofqueryFn: ({ signal }) => api.foo(..., signal)— leaving the fetch unbounded, so a wedged gateway latches the component's in-flight state forever.Third instance of this class here, which is what makes it a candidate rather than a one-off: #7062 (
api.skills, the$-menu, merged), #7068 (file search, the@-menu, open), and this one (api.slashCommands, the/-menu). All three are composer menus whose in-flight state gates a key binding, so an unbounded fetch does not merely spin — it swallows Enter and the message cannot be sent.Only the dropped-
signalhalf is mechanically detectable. The other half belongs in a review prompt rather than a rule: a settled error must not render as a confident empty state. Heredatadefaulted to an offline fallback list, so a failed load was indistinguishable from a successful one, and a zero-match against that fallback still claimed "No matching commands".