Skip to content

Commit b02c072

Browse files
os-zhuangclaude
andauthored
fix(studio): refresh builder top-bar name after a package rename (#2554)
The PackageSwitcher loaded the package list once (keyed on packageId) and derived the top-bar name from it, but never listened for `objectui:packages-changed` — which PackageFormDialog dispatches on create/edit. So after renaming the current package via "edit", the header kept showing the OLD name until a full page reload. Re-fetch the switcher list on `objectui:packages-changed` so the top-bar name reflects the rename immediately. Verified: dispatching the event triggers a GET /api/v1/packages refetch, re-deriving the displayed name. Co-authored-by: Jack Zhuang <277994282+os-zhuang@users.noreply.github.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent a56c596 commit b02c072

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

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

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -256,15 +256,24 @@ function PackageSwitcher({ packageId, tab }: { packageId: string; tab: string })
256256

257257
React.useEffect(() => {
258258
let cancelled = false;
259-
fetchPackages()
260-
.then((parsed) => {
261-
if (!cancelled) setPkgs(parsed);
262-
})
263-
.catch(() => {
264-
/* leave null — switcher still works for navigation-free display */
265-
});
259+
const load = () => {
260+
fetchPackages()
261+
.then((parsed) => {
262+
if (!cancelled) setPkgs(parsed);
263+
})
264+
.catch(() => {
265+
/* leave null — switcher still works for navigation-free display */
266+
});
267+
};
268+
load();
269+
// Refresh the switcher list (and thus the top-bar package name) when a
270+
// package is created or its manifest is edited elsewhere — PackageFormDialog
271+
// dispatches `objectui:packages-changed` on create/edit. Without this the
272+
// header showed the OLD name after a rename until a full page reload.
273+
window.addEventListener('objectui:packages-changed', load);
266274
return () => {
267275
cancelled = true;
276+
window.removeEventListener('objectui:packages-changed', load);
268277
};
269278
}, [packageId]);
270279

0 commit comments

Comments
 (0)