Repository navigation
fix(platform): refresh connector lists live, warn truthfully, keep focus - #3895
Conversation
A dialog opened from a row's actions menu dropped keyboard focus to <body> when it closed (#3715): on Settings > Connectors and AI providers (Edit credential, Replace, Delete), Members (Edit, Transfer ownership, Remove), Teams, API keys and Projects, and on the rows whose menus were only half wired, such as the Documents row's Delete, Move and Team tags. The menu item that opened the dialog is gone by then, and useRestoreFocus only knew a return point the caller passed as restoreFocusRef, which ten row menus never did. The menu names its own button. Radix's DropdownMenu, like any WAI-ARIA menu button, labels its menu by the button (aria-labelledby) and the button declares the popup (aria-haspopup). useRestoreFocus now reads that button when the dialog opens, while the menu still stands, and returns focus there on close when the opener was a menu item. A caller's restoreFocusRef still wins. A label that opens nothing (a listbox's heading) is never taken, a submenu climbs to the outermost button, and a button that is gone too leaves Radix its default. The dialog, data table and accessibility guides say a menu-opened dialog needs no ref; restoreFocusRef stays for an opener that unmounts or moves.
Once another session's credential write refreshes an open connectors page (#3712, next commit), the list refetches under whatever the admin holds open. #3778 made the shared credential table's columns stable and seeds the edit form when it opens, and tested both on the AI providers page. These tests hold both on the connectors page: - an Edit dialog the admin typed into stays open, with what they typed, through a refetch that changed the list; - an Edit opened after a colleague's rename shows the new name, and its untouched form cannot save the old name back. Each fails with its #3778 change reverted: the first without the stable columns, the second with stable columns but no seed-on-open.
An open Settings > Connectors page never learned about another session's credential changes (#3712). A credential another admin deleted stayed listed and actionable, and one they added stayed hidden, until a reload or a remount after the five-minute freshness window. The same listing feeds the compose Inbox field and a thread's mailbox. Connector credential writes emitted no realtime hint, although the app already keyed every read of the listing under `connector_credential`. - Every write the listing shows now inserts one organization-wide `connector_credential` hint in its own transaction: a create (the settings door and the consent callback's in-transaction seams), an update (rename, rotation, enable or disable, endpoint, config), a delete and the default it hands on, a new default, a grant the refresh found dead, and the mailbox config heal. A silent token renewal and the mail-sync cursor change nothing a listing shows and stay quiet. Both ends name the entity through `CONNECTOR_CREDENTIAL_HINT_ENTITY`. - A refusal that proves the cache stale now refreshes it like a success. An adapter row can declare `refusalInvalidates`, and the shared write hooks then fire its invalidation on such a refusal. The connector and AI provider credential update, delete and set-default rows declare `CREDENTIAL_NOT_FOUND`. A tab that missed a hint (its stream was down) drops the ghost row, and the delete confirm with it, instead of failing the same way on every click. - The hooks' comments no longer describe a Convex reactive query. Tests: the service hint test and the refresh test drive every write against a statement-answering double, including a lost compare-and-swap that announces nothing. The reads test runs the real hooks and adapter rows over a stubbed fetch and hint stream: a hint refetches the shared listing, a NOT_FOUND refusal refetches the connectors or providers listing, and another refusal does not. It also locks #3714's fix (#3806): a refused create or edit on either surface raises no generic toast. Each fails with its change reverted. The manual suite gains CONN-F21 (two sessions) and CONN-B11 (a missed hint). The admin guide (EN/DE/FR) says the table updates while open.
Deleting a connector's default credential showed "Deleting it leaves no default until you pick another one." In the same transaction the server made the oldest remaining active credential the default, and nothing said which account took over (#3713). The promotion has been deliberate since the 0.4 mutation: an invocation that names no credential resolves through the default, so it keeps working. The integration lane pins it. The sentence is the AI providers' rule, where nothing promotes, and connectors inherited it through the shared row menu's fallback. The rule is now one function, `defaultSuccessor`: the oldest active credential of the connector, never a disabled or needs-reauth one, with ties broken by id. The delete applies it under the pair lock (as a new credential's default flag is decided), on siblings read after the lock. The listing names its answer on the default's row, and the connectors delete confirm reads it: - "Deleting it makes "Release bot" the default for calls that name no credential", naming the account that takes over; - or no active credential can take over, so unnamed calls fail until an admin picks one; - or, from a listing that names nothing, the rule itself. AI providers keep their sentence. The admin guide and connector overview (EN/DE/FR) state the hand-over. The manual suite gains CONN-F22; CONN-F13 and CONN-F14 no longer expect no default after deleting the default, and pins.md records why.
The Add credential picker offers fifteen connectors. The connector guides (EN/DE/FR) and the manual suite described thirteen (#3716). GlitchTip (added 2026-09-27) and Jev decisions (#3425) appeared in no catalog page, and the Instance URL guidance named only Confluence and Shopify, although GlitchTip's form asks for one and the automation guide already sends admins to connect it. - The overviews table GlitchTip (token + Instance URL, read-only issue intake for the GlitchTip importer) and Jev decisions (an OpenRouter API key; typed questions answered with calibrated probabilities, read-only, billed to that OpenRouter account). They also say what both read and write. - The Instance URL guidance in the overviews, the admin guides and the connector authoring page names GlitchTip, its origin, and the deployment host policy a self-hosted instance needs. The admin guides' method table names the GlitchTip token scopes and the OpenRouter key. - The screenshot caption no longer counts the connectors, so it cannot drift again. - The GlitchTip form shows its own Instance URL help and placeholder (https://app.glitchtip.com) instead of the generic API example. - The manual suite counts 19 definitions and 15 vendors (CONN-F3), and CONN-F6 covers GlitchTip. A guard keeps them together: `catalog_docs.test.ts` reads the listing the picker serves and fails when a locale's table misses or adds a connector, when a per-credential connector goes unnamed where either guide explains the instance address, or when the manual suite's count or list drifts. It fails 7 of 8 on main's pages. `services/platform/turbo.json` hashes the two docs pages for it, and the turbo-inputs guard lists them.
CONN-A4 and A11Y-A19 judge what #3715's fix owes a keyboard user: a dialog opened from a row's actions menu, closed by Escape or Cancel, returns focus to that row's menu button on every table, never <body>. The automation register names the unit, real-browser and component suites that hold the hook, and pins.md records why the hook, not each call site, finds the button. The suite table counts the five boxes this branch adds (CONN-F21, CONN-F22, CONN-B11, CONN-A4, A11Y-A19).
The checkConnectorCredentialLiveListing lane writes credentials as a second admin over the settings door and reads the outbox the owner's /events stream tails. Five writes (three creates, a disable, a rename) yield five connector_credential hints in commit order, for the owner and the admin alike. A refused write (a gone id, a taken name) yields none. The listing names the oldest active sibling as the default's successor, and the delete makes exactly that credential the default, hinted once. A dead grant the resolve seam finds flips needs-reauth and is hinted in the same commit. Locally, on the itest cluster, with the 19 lanes that write connector credentials: 108/109 on this branch. The one red check is checkChatDeferredAuto's 'answered=0 (want 1)', which fails the same on origin/main c8936c1 (104/109 there; main also fails four of this lane's six checks). CI runs no integration lane.
The GlitchTip guidance now reads like the importer guide it points to: "durch die Host-Richtlinie des Connectors" and "par la politique des hôtes du connecteur", "selbst gehostet" throughout. The French table cell sets its apostrophe as prose, and the German Jev decisions row says who decides.
…s-refresh-and-focus # Conflicts: # services/platform/tests/manual/readme.md
yannickmonney
left a comment
There was a problem hiding this comment.
Independent local review of connector transaction hints/default-successor selection, refusal invalidation, and shared focus restoration found no actionable blocker in that scope.
I ran 11 focused test files / 135 tests, all passing: 63 connector/client tests, 51 service/docs-guard tests, 16 focus-hook unit tests and 5 real Chromium dialog tests. The tested checkout was 6f1ec657a6a115d414a69599148f3fe06b8f33ce. The PR has since advanced to 88e742ab51458930c4f65b76510e42c2da18a541; I checked the intervening merge/wording changes and verified that packages/ui, services/platform/app and services/platform/backend are byte-identical between those commits. These results are fresh local executions, not CI cache replays.
Before treating #3712 and #3715 acceptance as complete, please fill in the after-change two-session and keyboard browser results currently marked pending in this PR. In particular: remote add/delete reaching the owner's open list, an open editor surviving another session's change, a vanished-row refusal refreshing the list, and focus restoration across the affected settings surfaces. The component tests support the implementation but do not observe the complete platform lifecycle.
I did not independently execute the real-PostgreSQL integration lane, the full platform two-session round, or the full repository gate. This is a scoped review comment, not merge approval. All testing was local; no production or provider operations.
The GlitchTip step shows its instance origin (https://app.glitchtip.com) as placeholder and help, in place of the generic API example. The test fails on main's labels.
…s-refresh-and-focus # Conflicts: # services/platform/tests/manual/readme.md
…s-refresh-and-focus The manual readme is recounted on the merged tree (995 boxes). This branch's A11Y-A19 collided with the A11Y-A19 that #3853 adds, so it becomes A11Y-A20 in the suite, pins.md and the automation register.
Repairs the five connector-settings findings from the TALE-78 audit, each with its own acceptance case, test and manual box. I read every issue (including #3712's timing correction and the #3715 sweep comment) against current
mainand the merged #3729 first. What had already landed is verified and locked, not redone.Closes #3712, closes #3713, closes #3714, closes #3715, closes #3716.
What changed
#3712: an open Connectors page follows other sessions
connector_credentialhint inside their own transaction, like provider credentials already do. That covers:needs-reauthflip, now one transaction with its hint;A silent token renewal and the mail-sync cursor stay quiet. Both ends name the entity through
CONNECTOR_CREDENTIAL_HINT_ENTITY(lib/shared/hint-entities.ts). The app already keyed the list, and the compose Inbox / mailbox reads that share it, under that entity; nothing emitted it.CREDENTIAL_NOT_FOUND(the stream was down and another session deleted the row) now refetches the list. The ghost row drops, and the delete confirm closes with it, instead of failing on every click. Adapter rows can now declarerefusalInvalidates, anduseBackendAction/useBackendMutationfire the row's invalidation for such a refusal. The connector and AI-provider credential update, delete and set-default rows opt in.#3713: deleting the default names who takes over
The server's promotion is deliberate and stays: the oldest remaining active credential becomes the default, so unnamed calls keep working. The 0.4 mutation documented this, and the integration lane pins it. The dialog was wrong: it showed the AI providers' "leaves no default" through the shared row menu.
defaultSuccessor, used twice:defaultSuccessor).#3714: one message per refused save
Already fixed on
mainby #3806 (3c30e1bfe). The connector and provider create/update hooks now passerrorToast: false. Nothing locked it, though: the single-toast guard explicitly allows an inline error beside a loud write.connector-reads.test.tsxnow runs the real hooks and adapter rows and asserts that a refused create or edit raises no generic toast on either surface. It fails with #3806's hooks reverted. A browser round confirms one inline message for each refusal on both pages.#3715: row-menu dialogs return focus, fixed once in the design system
The sweep found this wider than the issue. Dialogs opened from a row's actions menu dropped focus to
<body>on Connectors, AI providers, Members, Teams, API keys and Projects. They also did so on rows whose menus were only half wired: Documents' Delete, Move and Team tags pass no ref. The sandboxes pages share one dialog across all rows.Patching ten call sites would leave the next one to forget, so the fix sits in the shared primitive.
useRestoreFocus(@tale/ui) now reads the button that opened the menu when the dialog opens. It finds it through the WAI-ARIA menu-button contract:aria-labelledby/aria-controlsplusaria-haspopup, which Radix'sDropdownMenufollows. It returns focus there on close. Precedence and limits:restoreFocusRefstill wins;The design-system guides (dialog, data table, accessibility) say so. Confirming a delete that removes the row is #3791 and is not covered here.
#3716: the docs describe the picker's 15 connectors
https://app.glitchtip.com) in EN/DE/FR.catalog_docs.test.ts, compares each locale's table, the per-credential connectors named beside the instance guidance, and the manual suite's count and list with the listing the picker serves. It fails 7 of 8 checks onmain's pages.services/platform/turbo.jsonhashes the two docs pages, and the turbo-inputs guard lists them.How I verified
Evidence refers to the final head
a3303542dunless noted;6f1ec657ais the same code before two merges ofmain. All of it is local and synthetic: fresh organizations, and tokens that no vendor ever sees. The backend's egress went to a dead proxy (127.0.0.1:9). There was no production and no provider call.Unit, component and browser suites (each new behaviour test fails with its change reverted):
packages/uiuse-restore-focus.test.ts: 16 tests, 3 fail onmain's hook.dialog.browser.test.tsxin real Chromium: Escape and Cancel on anEntityRowActionsrow with no restore ref. The 3 new cases fail onmain's hook.connectors-settings.test.tsx:connector-reads.test.tsx: the hint refetch, the NOT_FOUND refetch on both surfaces, and no generic toast on a refusal. 4 fail withoutrefusalInvalidates, 4 fail with pre-fix(platform): raise one toast per failed write and guard the rule #3806 hooks.service.hints.test.tsandservice.oauth2-refresh.test.ts: 7 fail onmain's service.service.default-successor.test.tscovers the successor rule.catalog_docs.test.ts: 7 of 8 fail onmain's docs.Suites run around the change:
app/lib/backend. The single-toast guard passes alone (37/37). It timed out once in the parallel batch under a host load average near 100.--testTimeout 30000. The host was saturated, and the typing-heavy add-flow tests exceed 5 s here.lint:manualandcheck-guideon the touched suites.tscon every changed file.Real PostgreSQL (
backend:integration, which CI does not run). The newcheckConnectorCredentialLiveListinglane checks, for one second admin:needs-reauthand hints in one commit.The 19 lanes that write connector credentials pass 108/109 on the branch. On
mainc8936c1d2the result is 104/109: this lane fails 4 of its 6 checks there, andcheckChatDeferredAuto's "answered=0 (want 1)" fails the same on both.Real browser, two sessions and keyboard only. The rounds ran on the local stack, first against
mainfac88dfc2and then against the branch:mainfac88dfc2a3303542d)6f1ec657a)<body>; Contacts (control) returns6f1ec657a)6f1ec657a)Visual gate (visual-aspect-analyzer) on the Connectors page at rest, with the default's delete confirm open, and at Add credential > GlitchTip: 98 on the branch and 98 on
main's frontend, with the same two load-time layout shifts (the OAuth apps region 0.03 and the page 0.01, recorded onmainby TALE-80). No element is affected on the branch only.The integration lanes pass 108/109 on the final head
a3303542dtoo; the one failure is the same deferred-send check.Coordination and limits
main; this PR only adds the connectors-page tests for them.