Skip to content

Commit 02ece7b

Browse files
committed
fix(app-shell): Studio asks the listed ids only when the switcher has no entry for the package
A switcher entry is an installed package, so the not-found check reads the full id list only for an id the switcher lacks; both reads still share the one package-list request. Claude-Session: https://claude.ai/code/session_01FEkQ5nhhuhjVQJ8R3qK9UB Co-authored-by: Claude <noreply@anthropic.com>
1 parent f714cf0 commit 02ece7b

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

‎ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx‎

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,9 +1294,10 @@ export function StudioDesignSurface({ aiSlot }: StudioDesignSurfaceProps): React
12941294
// this id: the surface renders "package not found" instead of a builder
12951295
// whose every save the server refuses. Only a positive answer sets it — a
12961296
// read still in flight or one that failed leaves the builder as it was, the
1297-
// same fail direction as the writability gate above. Read from the ids the
1298-
// list serves (`fetchListedPackageIds`, the same request), not from the
1299-
// switcher's entries, which hide the kernel packages that ARE installed.
1297+
// same fail direction as the writability gate above. A switcher entry is
1298+
// installed; an id with none is then looked up in every id the list serves
1299+
// (`fetchListedPackageIds`, the same request), because the switcher's
1300+
// entries hide the kernel packages that ARE installed.
13001301
const [pkgMissing, setPkgMissing] = React.useState(false);
13011302
React.useEffect(() => {
13021303
// objectui#11553 — the package-less scope has no package to look up; its
@@ -1305,19 +1306,23 @@ export function StudioDesignSurface({ aiSlot }: StudioDesignSurfaceProps): React
13051306
let cancelled = false;
13061307
setPkgWritable(undefined);
13071308
setPkgMissing(false);
1308-
fetchListedPackageIds().then(
1309-
(ids) => {
1310-
if (!cancelled) setPkgMissing(!ids.has(packageId));
1311-
},
1312-
// The failure is reported once, by the entries read below (one request).
1313-
() => {},
1314-
);
1309+
// Asked beside the entries read, so both share its one request. A failure
1310+
// is reported once, by the entries read below.
1311+
const listedIds = fetchListedPackageIds();
1312+
listedIds.catch(() => {});
13151313
fetchPackages()
13161314
.then((list) => {
13171315
if (cancelled) return;
13181316
const entry = list.find((p) => p.id === packageId) ?? null;
13191317
setPkgWritable(entry?.writable ?? null);
13201318
setPkgEntry(entry);
1319+
if (entry) return;
1320+
listedIds.then(
1321+
(ids) => {
1322+
if (!cancelled) setPkgMissing(!ids.has(packageId));
1323+
},
1324+
() => {},
1325+
);
13211326
})
13221327
.catch((e: unknown) => {
13231328
// Staying ungated is still right — the server gate is the authority

0 commit comments

Comments
 (0)