Skip to content

Commit 8091fa5

Browse files
committed
Plugins page: only show the loading skeleton on an actual tenant change
The reload-key restructure from the previous commit made every imperative reload (a connect/disconnect panel's onChanged, the error screen's Retry) re-run the fetch effect, which unconditionally set status: "loading" and tore the page down to the full skeleton — a regression from main, where an imperative reload just fetched and swapped in the result. Each effect now tracks the tenant it last fetched for in a ref and only shows the loading state when selectedTenantId actually changed; a same-tenant reload keeps whatever is on screen until the fresh data (or a new error) lands. Fixes CL-7138.
1 parent 671564f commit 8091fa5

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

‎apps/web/src/pages/plugins-page.tsx‎

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424
import type { ResolvedPlugin } from "@workbench/connections/plugins";
2525
import { listPluginsForTenant } from "@workbench/connections/plugins";
2626
import { Plus, SquaresFour, Warning } from "@corbits/icons";
27-
import { useCallback, useEffect, useState } from "react";
27+
import { useCallback, useEffect, useRef, useState } from "react";
2828

2929
import { useBench } from "../bench-context";
3030
import { SKILLS_PATH_PREFIX } from "../path-ids";
@@ -105,11 +105,21 @@ export function PluginsRoute({
105105

106106
// Guarded by `cancelled` (same pattern as settings-ui's `people-section`)
107107
// so a tenant switch mid-flight can't have the previous tenant's late
108-
// response overwrite the newly selected tenant's state.
108+
// response overwrite the newly selected tenant's state. The loading
109+
// skeleton only shows for a tenant this page hasn't fetched yet — an
110+
// imperative reload (a connect/disconnect's `onChanged`, the error
111+
// screen's Retry) keeps whatever is already on screen and swaps in the
112+
// fresh data once it lands, the same way it worked before cancellation
113+
// was added.
114+
const pluginsLoadedTenantRef = useRef<string | null>(null);
115+
const skillsLoadedTenantRef = useRef<string | null>(null);
116+
109117
useEffect(() => {
110118
if (selectedTenantId === null) return;
111119
let cancelled = false;
112-
setPluginsState({ status: "loading" });
120+
const isTenantChange = pluginsLoadedTenantRef.current !== selectedTenantId;
121+
pluginsLoadedTenantRef.current = selectedTenantId;
122+
if (isTenantChange) setPluginsState({ status: "loading" });
113123
listPluginsForTenant(selectedTenantId)
114124
.then((plugins) => {
115125
if (!cancelled) setPluginsState({ status: "ready", plugins });
@@ -126,7 +136,9 @@ export function PluginsRoute({
126136
useEffect(() => {
127137
if (selectedTenantId === null) return;
128138
let cancelled = false;
129-
setSkillsState({ status: "loading" });
139+
const isTenantChange = skillsLoadedTenantRef.current !== selectedTenantId;
140+
skillsLoadedTenantRef.current = selectedTenantId;
141+
if (isTenantChange) setSkillsState({ status: "loading" });
130142
listSkills(selectedTenantId)
131143
.then((skills) => {
132144
if (!cancelled) setSkillsState({ status: "ready", skills });

0 commit comments

Comments
 (0)