Skip to content

fix(platform): keep pages up when a membership refresh fails - #5089

Closed
tale-code-bot wants to merge 1 commit into
mainfrom
fix/member-context-refresh-failure
Closed

tale-code-bot wants to merge 1 commit into
mainfrom
fix/member-context-refresh-failure

Conversation

@tale-code-bot

Copy link
Copy Markdown
Collaborator

Closes #4859

Task: TALE-179 (Development board), the plan is posted on the task.

What was wrong

services/platform/app/routes/dashboard/$id.tsx handed every page isLoading = isAuthLoading || isQueryLoading || isError as AbilityLoadingContext. isError joined the flag in #580 (107cdcaf9), when the layout had no error screen. Since then the isError && !memberContext early return owns a failed read with nothing cached. That leaves the term firing only when a refresh failed while react-query kept the last member context: status error, data retained, errorUpdateCount + 1 (@tanstack/query-core 5.97.0, query.ts reducer). Nothing cleared it until a later read succeeded.

The shell and the navigation kept the last known role, but every useAbilityLoading consumer took the failure for access still loading:

  • Knowledge rendered no tab content.
  • Governance and Metrics stayed on their skeleton.
  • Organization, Branding, Connectors, Providers, Data residency, Enterprise SSO, API and Sandboxes stayed skeletonized.

There was no message and no retry.

What changes

  • The flag: isLoading = isAuthLoading || isQueryLoading. A failed refresh over a loaded member context is not loading. The role stands, and the pages render with it. Server-side permission checks are untouched.
  • The notice: refreshFailed = isError && memberContext != null mounts the new AccessRefreshNotice (app/components/layout/access-refresh-notice.tsx). It sits in the shell's alert stack, after the session notice, as a ShellAlert like every dashboard nudge: Couldn't refresh your access — What you see follows your role as it was last loaded. Try again calls refetch. The retry follows CatalogLoadError's rules:
    • it is busy, not disabled, while isFetching;
    • each failure (errorUpdateCount) is announced again;
    • when a successful retry removes the notice, the focus on Try again goes to #main-content (useFocusHandoff) instead of the document body.
  • Unchanged: with nothing cached, the full-page error with Try again. A first load, and a refetch that dropped its data, still report loading.
  • Strings: accessDenied.refreshFailed.{title,body} in en, de and fr. de-CH falls back to de, which has no ß.
  • Sweep: automations-access-gate.tsx (doc comment), its test and automations/route.test.tsx said "a failed membership refetch counts as loading". They now name the case that still holds: a read still loading over the last role. Their assertions are unchanged.
  • Manual layer: new box NAV-B20 (block /members/me, trigger a refresh from a second session, judge the notice, the pages, the busy retry and the recovery). Suite cost 72→73. reference/automation/navigation.md says what the specs own.

How it was tested

Commands were run in services/platform unless noted.

  • bunx vitest --run --config vitest.ui.config.ts app/routes/dashboard/dashboard-layout.test.tsx app/components/layout/access-refresh-notice.test.tsx: 21 passed.
    • The :387 case ("keeps outlet visible when query errors but has previous data") now asserts useAbilityLoading() is false under the outlet, that the shell's only status is the notice, that Try again calls refetch, and that it is busy while isFetching.
    • New: the real Knowledge layout (_knowledge.tsx), mounted under the real shell in the same state, renders its tab. Its control holds the tab back while a first load hydrates from the last role.
    • Controls: no cached data plus an error still shows the full-page error, its Try again refetches, and no notice shows. A first load from the persisted role reports true under the outlet, and so does a refetch that dropped its data (the nav-rail case).
    • The notice's own test covers the real catalog words, Try again, axe, the busy state, re-announcement and the focus handoff.
  • Fails before the fix: the same layout test file against main's $id.tsx gives 2 failed / 15 passed. keeps outlet visible… expected data-ability-loading="false" and received "true". renders a Knowledge tab's content through a failed refresh could not find the tab content.
  • bunx vitest --run --config vitest.ui.config.ts app/features/automations/components/automations-access-gate.test.tsx 'app/routes/dashboard/$id/automations/route.test.tsx': 22 passed.
  • bunx vitest --run --project server lib/i18n/messages.test.ts lib/i18n/topic-references.test.ts: 36 passed (parity and usage enforced; no report-mode finding names the new keys).
  • bunx oxlint --type-aware app/routes/dashboard/ app/components/layout/ …gate files: 0 warnings, 0 errors.
  • bunx oxfmt --check on the changed TS files: clean.
  • From the repo root: bun run lint:manual (all ok), bun run lint:conflicts (clean), and bun services/platform/tests/manual/scripts/check-guide.ts services/platform/tests/manual/suites/navigation.md (OK).
  • NODE_OPTIONS=--max-old-space-size=6144 bunx tsc --noEmit (the platform's frontend, backend and tests as one program, CI's heap): exit 0.

Not tested

  • No real browser and no running stack: NAV-B20 (a blocked /members/me in a live session, the layout of the notice at phone and desktop widths, a screen reader) was not run, and the visual check was not run either. The queue's E2E/UI/Browser jobs run what they own.
  • If the session itself lapsed, a 401 on this refresh shows this notice beside the sign-in notice. Both statements are true, so it is not suppressed.

A failed background refresh of GET /members/me keeps its last member
context, yet the dashboard counted the error as access still loading and
never stopped: Knowledge rendered no tab, and Governance, Metrics and
most settings pages stayed on skeletons, with no message and no retry.

The shell no longer folds isError into AbilityLoadingContext. The last
role stands and every page renders with it, under a shell notice
("Couldn't refresh your access") whose Try again refetches: busy while
it runs, each failure announced again, and the focus handed to the page
when the notice leaves. With nothing cached, the full-page error stays.

Closes #4859

@tale-review-bot tale-review-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review of head d3e1fd4f261ff3e2d20515a6b10fa2bb676d2e66 (base main 9be5cadacb5f59cd6b2cc67c7840e3c0101bdde2), TALE-179. Approve.

Diff (read whole, 12 files):

  • routes/dashboard/$id.tsx: isLoading = isAuthLoading || isQueryLoading, so a failed refresh over a cached member context no longer counts as loading. The role logic keeps the last role, and the pages render with it.
  • The notice: refreshFailed = isError && memberContext != null mounts AccessRefreshNotice, a ShellAlert (role status). Its Try again calls refetch, is busy (not disabled) while fetching, re-announces each failure via errorUpdateCount, and hands the focus to #main-content when a successful retry removes it.
  • Unchanged: with nothing cached, the full-page error stays. not_member and not_found are answers, not errors, so removals are unaffected. Server-side checks are untouched.
  • Sweep: strings in en, de and fr (no ß, so de-CH needs no override); the automations gate comment and test titles are reworded (they set the flag directly, and their assertions are unchanged); manual box NAV-B20 (cost 72→73) plus a register note. Branch and commit follow the contract, and the body says Closes #4859.

Run myself (credentials removed, deps from the lockfile under host lease a68bde4f):

  • Head, 4 UI files (dashboard-layout.test.tsx, access-refresh-notice.test.tsx, automations-access-gate.test.tsx, automations/route.test.tsx): 43/43 passed.
  • Regression: with main's $id.tsx, dashboard-layout.test.tsx gives 2 failed, 15 passed. The :387 case expected data-ability-loading="false" and received "true"; the real Knowledge layout under a failed refresh is missing its outlet. The controls (no cache gives the full-page error, a first load from the last role still loads) pass. Tree restored.
  • i18n parity plus guards (lib/i18n/, error-message-description, single-failure-toast): 13 files, 699/699 passed. lint:manual ok; check-guide.ts tests/manual/suites/navigation.md OK.

Required checks on this head: all 7 CI ready passed: Checks 40920337083, Commitlint 40920337105, SAST 40920337051, E2E 40920337232, CLI 40920337095, Security 40920337183, Build 40920337075.

Not run by me: the full UI shards, Browser and E2E (merge queue only), and NAV-B20 in a live browser (none here).

Notes, not blocking:

  • No user docs sentence for the new notice (docs/*/platform/member/preferences.md describes the sibling session notice). This is a possible follow-up, consistent with #5087, which shipped read-failure notices without one.
  • After a lapsed session, a 401 on this refresh shows this notice beside the sign-in notice. Both are true, as the Coder flagged.

@tale-review-bot
tale-review-bot added this pull request to the merge queue Oct 29, 2026
@yannickmonney
yannickmonney removed this pull request from the merge queue due to a manual request Oct 29, 2026
@yannickmonney yannickmonney reopened this Oct 29, 2026
@tale-review-bot

Copy link
Copy Markdown
Collaborator

Not landing yet. The green CI ready checks on the approved head d3e1fd4f261ff3e2d20515a6b10fa2bb676d2e66 came from the pre-0da08205 workflows. (tale-review-bot, Reviewer run b123c4de, read at 22:32 UTC)

  • The newest runs: they were created by the 20:13–20:15 UTC close/reopen. They checked out the merge into the old base: Checks run 40947316355, job 123705984480, logged HEAD is now at 0d5610a Merge d3e1fd4f261ff3e2d20515a6b10fa2bb676d2e66 into 9be5cadac.
  • What they skipped: in that run, UI (platform n/4) and UI read skipped. So the heavy suites that .github/CI.md ("Landing on main") now requires on the pull request never ran on this head.
  • My approval of d3e1fd4f261ff3e2d20515a6b10fa2bb676d2e66 stands. The head needs a fresh pull_request run first, from a close/reopen or a draft→ready, which now merges into 0da08205. Once every required check finishes green on that run, the Reviewer lands it with --match-head-commit d3e1fd4f261ff3e2d20515a6b10fa2bb676d2e66.

@yannickmonney

yannickmonney commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Reopened so the checks run again. The 20:13–20:15 UTC reopen started its runs from a test merge into 9be5cada (before 0da08205), because GitHub had not refreshed it yet. This reopen's runs start from the test merge 9acac08685, into 0da08205. The head is unchanged (no new commit).

@yannickmonney

Copy link
Copy Markdown
Contributor

Landed on train as fed9a33: squashed at the approved head after the fast gate (formatting, typecheck, build). It reaches main with the merge train's pull request, so this pull request closes without merging.

yannickmonney pushed a commit that referenced this pull request Oct 30, 2026
Reviewed and approved in pull request #5089 at d3e1fd4.

Closes #4859
Task: TALE-179
@yannickmonney
yannickmonney deleted the fix/member-context-refresh-failure branch October 30, 2026 10:32
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.

Bug: a failed member-context refresh blanks Knowledge and leaves Governance, Metrics and most Settings pages on skeletons

3 participants