Skip to content

fix(platform): refresh connector lists live, warn truthfully, keep focus - #3895

Merged
yannickmonney merged 12 commits into
mainfrom
fix/connector-settings-refresh-and-focus
Sep 29, 2026
Merged

yannickmonney merged 12 commits into
mainfrom
fix/connector-settings-refresh-and-focus

Conversation

@yannickmonney

@yannickmonney yannickmonney commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

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 main and 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

  • Hints. Connector-credential writes now emit one org-wide connector_credential hint inside their own transaction, like provider credentials already do. That covers:
    • create, from the settings door and from the consent callback's in-transaction seams;
    • update (rename, rotation, enable or disable, endpoint, config);
    • delete, together with the default it hands on;
    • set default;
    • the needs-reauth flip, now one transaction with its hint;
    • the mailbox config heal.
      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.
  • Recovery when a hint was missed. A write refused 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 declare refusalInvalidates, and useBackendAction / useBackendMutation fire the row's invalidation for such a refusal. The connector and AI-provider credential update, delete and set-default rows opt in.
  • Open dialogs. A live refetch no longer closes an open dialog, and Edit credential opens with the current name. fix(platform): keep custom provider edits whole and version-checked #3778 (merged while this was open) made the table's columns stable and seeds the form on open. This PR adds the connectors-page tests for both.
  • The hooks' comments no longer describe a Convex reactive query.

#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.

  • The rule is now one function, defaultSuccessor, used twice:
    • the delete applies it, under the pair lock, on siblings read after the lock;
    • the listing names its answer on the default row (defaultSuccessor).
  • The connectors confirm now says one of two things:
    • Deleting it makes "Release bot" the default for calls that name no credential.
    • …no other active credential can take over: calls that name no credential fail until you make one the default.
  • AI providers keep their sentence.
  • Docs (EN/DE/FR) and the manual suite (CONN-F13/F14/F22, pins.md) state the hand-over.

#3714: one message per refused save

Already fixed on main by #3806 (3c30e1bfe). The connector and provider create/update hooks now pass errorToast: false. Nothing locked it, though: the single-toast guard explicitly allows an inline error beside a loud write. connector-reads.test.tsx now 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-controls plus aria-haspopup, which Radix's DropdownMenu follows. It returns focus there on close. Precedence and limits:

  • a caller's restoreFocusRef still wins;
  • a label that opens nothing (a listbox's heading) is never taken;
  • a submenu climbs to its outermost button;
  • if the button is gone too, Radix's default applies.

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

  • The overviews (EN/DE/FR) now table GlitchTip (token + Instance URL; read-only issue intake for its importer) and Jev decisions (an OpenRouter API key; read-only decisions billed to that account).
  • The Instance URL guidance names GlitchTip in the overviews, the admin guides and the developer page. The admin guides' method table names the token scopes and the OpenRouter key.
  • The caption no longer counts connectors. docs(docs): retake every docs screenshot and the README gallery #3817 (merged meanwhile) retook the screenshot, which now shows GlitchTip.
  • The GlitchTip form gets its own Instance URL help and placeholder (https://app.glitchtip.com) in EN/DE/FR.
  • The manual suite counts 19 definitions and 15 vendors.
  • A guard, 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 on main's pages. services/platform/turbo.json hashes the two docs pages, and the turbo-inputs guard lists them.

How I verified

Evidence refers to the final head a3303542d unless noted; 6f1ec657a is the same code before two merges of main. 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/ui use-restore-focus.test.ts: 16 tests, 3 fail on main's hook.
  • dialog.browser.test.tsx in real Chromium: Escape and Cancel on an EntityRowActions row with no restore ref. The 3 new cases fail on main'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 without refusalInvalidates, 4 fail with pre-fix(platform): raise one toast per failed write and guard the rule #3806 hooks.
  • service.hints.test.ts and service.oauth2-refresh.test.ts: 7 fail on main's service. service.default-successor.test.ts covers the successor rule.
  • catalog_docs.test.ts: 7 of 8 fail on main's docs.

Suites run around the change:

  • 58 server files / 778 tests: the connector, credential, OAuth, conversations-shim and i18n suites, the guards, and 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.
  • 49 jsdom files / 400 tests over the connectors, providers, credentials, members, teams, API keys and contacts settings, run with --testTimeout 30000. The host was saturated, and the typing-heavy add-flow tests exceed 5 s here.
  • The docs structural suite (200), the ui-docs content suite, lint:manual and check-guide on the touched suites.
  • Type-aware lint and a scoped tsc on every changed file.

Real PostgreSQL (backend:integration, which CI does not run). The new checkConnectorCredentialLiveListing lane checks, for one second admin:

  • 5 writes produce 5 hints in commit order, for the owner and the admin;
  • a refused write produces none;
  • the listing names the successor, and the delete promotes exactly it;
  • a dead grant flips needs-reauth and hints in one commit.

The 19 lanes that write connector credentials pass 108/109 on the branch. On main c8936c1d2 the result is 104/109: this lane fails 4 of its 6 checks there, and checkChatDeferredAuto'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 main fac88dfc2 and then against the branch:

Case main fac88dfc2 this branch (final round at a3303542d)
#3712 A/B: another admin deletes a row and adds one while the owner's page is open still listed / still hidden after 10 s drops after 1.3 s / appears at once
#3712 D/E: an Edit open during another session's add; Edit opened after a rename (no refresh at all) dialog stays, typed text kept / Name shows the new name
#3712 C: hint stream cut, then Disable / Delete on the vanished row refusal toast; the row and the confirm stay one toast; the row drops within 0.7 s; the confirm closes
#3712 after reload; F (control): Members page follows a role change true list; live after 0.9 s true list; live after 2.7 s
#3713: delete the default with an active sibling / only a disabled one / a non-default "leaves no default", then "Release bot" is promoted names "Release bot", which becomes the default / "no other active credential can take over" / nothing. AI providers keep their sentence.
#3714: taken name / path in the Instance URL / rename, on both surfaces one inline message, no toast (fixed by #3806) same (6f1ec657a)
#3715: keyboard, a row-menu dialog closed with Escape or Cancel 15 of 15 dialogs drop focus to <body>; Contacts (control) returns 18 of 18 return to the row's menu button: Connectors, AI providers, Members, Teams, API keys, Projects, Documents (20 of 20 at 6f1ec657a)
#3716: the picker against the docs picker 15, docs 13 in EN/DE/FR, suite 13 15 = 15 in EN/DE/FR and in the suite (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 on main by TALE-80). No element is affected on the branch only.

The integration lanes pass 108/109 on the final head a3303542d too; the one failure is the same deferred-send check.

Coordination and limits

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 yannickmonney left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

yannickmonney and others added 3 commits September 29, 2026 13:42
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.
@yannickmonney
yannickmonney merged commit 19f18f6 into main Sep 29, 2026
57 checks passed
@yannickmonney
yannickmonney deleted the fix/connector-settings-refresh-and-focus branch September 29, 2026 16:15
yannickmonney added a commit that referenced this pull request Sep 29, 2026
A11Y-A19 (#3853) and A11Y-A20 (#3895) each raised the header from 26 to 27 on their own branch; with both merged the suite holds 28 boxes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment