Skip to content

Surface expired gatekeeper connections in app chrome and live reconnect notice - #1337

Draft
ryanrasti wants to merge 4 commits into
mainfrom
rrasti/sidebar-expired-accounts-indicator
Draft

ryanrasti wants to merge 4 commits into
mainfrom
rrasti/sidebar-expired-accounts-indicator

Conversation

@ryanrasti

Copy link
Copy Markdown

Surfaces expired gatekeeper connections across both UIs without making any gatekeeper RPCs for healthy accounts:

  1. Backend (workshop-shared, workshop-backend): Adds expiredOnly?: boolean to ConnectedAccountsFilter in subscribeConnectedAccounts(). Healthy accounts short-circuit synchronously from User DO storage (0 gatekeeper RPCs), emitting add() only for expired accounts and remove(id) on recovery.
  2. Classic UI (workshop-frontend):
    • Single app-wide ExpiredAccountsProvider in routes/__root.tsx subscribed with { expiredOnly: true }.
    • Red indicator dot + hover tooltip naming expired connections on the sidebar Gatekeepers <Plug /> button (SidebarUtilityStrip).
    • Top-bar <ExpiredGatekeepersButton /> in workspace/gadget views (GadgetEditor, GadgetUseView) where no sidebar is visible (renders nothing when all accounts are healthy).
    • Live-expiry Kumo toast with an in-place Reconnect button (openConnectWindow(reconnectAccount(id))) that fires only for healthy → expired transitions after ready() (quiet on initial page load) and auto-closes on recovery.
  3. Experimental UI (workshop-frontend-experimental):
    • useExpiredAccounts() hook subscribed with { expiredOnly: true }.
    • Red indicator dot + tooltip on the sidebar Connections button (ConnectButton and collapsed-rail Sidebar button).
    • Live-expiry notice in ConnectionIsland (<Service> disconnected + Reconnect action), quiet on initial load and auto-dismissed on recovery.

@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown

Preview: pr1337-rrasti-sideb-e23d807b

https://pr1337-rrasti-sideb-e23d807b-router.cloudflare-os-previews.workers.dev

Dashboard · deleted when this PR closes

let credentialsValid = areCredentialsValid(record);
if (filter?.expiredOnly && credentialsValid) {
if (seenIds.has(record.id)) {
subscriber.remove(record.id);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

A recovery can be lost while the expired notification is still looking up vendor metadata. If markCredentialsRestored() runs while notifyAdd() is awaiting vendor.describe() or getSupportedResources(), this branch sees no seenIds entry and skips the removal. The older call then resumes and adds the now-healthy account, leaving a red dot or reconnect notice with no later event to clear it. Invalidate in-flight adds for the ID on update/delete and check before sending, or recheck the current record after the awaits. The backend test currently waits for the expired add() before restoring; please also cover restoration with the lookup still pending.

if (disabledGatekeeperSet.has(record.vendorId)) {
return; // Whole gatekeeper disabled by admin.
}
let credentialsValid = areCredentialsValid(record);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This makes a healthy Slack connection show as disconnected across the app once its first rotating access token expires. Slack sends grant.accessToken.expires on connect and reconnect (slack.ts:541–547), but successfully refreshes the token without updating the Workshop deadline (slack.ts:631–644). GatekeeperConnectCallback.complete() in packages/workshop-shared/src/gatekeeper.ts:871–876 explicitly distinguishes refreshability from access-token expiry. Before using this deadline for an app-wide warning, handle the legacy Slack timestamps already in storage and make refreshable grants rely on the terminal expiry notification.

if (!cancelled) setLiveExpired((cur) => (cur?.id === id ? undefined : cur))
},
() => {
ready = true

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

If the last expired account is reconnected in another tab while this tab’s WebSocket is down, the replacement subscription sends only ready(). No callback publishes the empty map, so the red dot persists indefinitely; this hook also retains an actionable notice for the recovered account. The classic provider at ExpiredAccountsProvider.tsx:143 has the same empty-snapshot bug. Publish the full snapshot at ready(), including [], and clear any live notice whose ID is absent. This follows the experimental AGENTS.md reconnect pattern: “showing the last account snapshot until the new snapshot arrives.”

onReconnect: () => {
const id = liveExpired.id
dismissLiveExpired(id)
void api.reconnectAccount(id).then((flow) => openConnectWindow(flow)).catch(() => {})

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

A blocked popup or a failed reconnect RPC makes the island disappear without telling the user what went wrong or letting them retry there. openConnectWindow() explicitly throws when the popup is blocked; the Connections page already keeps its dialog open and shows that error. Guard this action with connection.blocked() (see the lost-connection rule in packages/workshop-frontend-experimental/AGENTS.md:118–120), and keep the notice actionable with an error on failure, or take the user to the existing reconnect dialog.

<span className="relative inline-flex">
<Button
aria-label={expired > 0 ? `Connect an app (${expired} ${expired === 1 ? 'connection needs' : 'connections need'} reconnection)` : 'Connect an app'}
title={expired > 0 ? expiredTitle : undefined}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The service names are only in a native title, so a sighted keyboard user can focus the button but cannot reliably see which services expired. The accessible label conveys only the count. Use the shared Tooltip on the button in both variants, as WorkspaceRailItem does, so the summary is available on focus as well as hover.

@ask-bonk

ask-bonk Bot commented Dec 3, 2026

Copy link
Copy Markdown

Review: 5 findings.

Posted all five as inline comments on PR #1337.

github run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant