From cd592c928c77d02648951d62e7eb54aab65fc78d Mon Sep 17 00:00:00 2001 From: Jack Zhuang <277994282+os-zhuang@users.noreply.github.com> Date: Thu, 16 Jul 2026 09:48:52 +0800 Subject: [PATCH] fix(studio): refresh builder top-bar name after a package rename MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Claude Opus 4.8 --- .../studio-design/StudioDesignSurface.tsx | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx b/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx index 01304d60b..1ab1333d1 100644 --- a/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx +++ b/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx @@ -256,15 +256,24 @@ function PackageSwitcher({ packageId, tab }: { packageId: string; tab: string }) React.useEffect(() => { let cancelled = false; - fetchPackages() - .then((parsed) => { - if (!cancelled) setPkgs(parsed); - }) - .catch(() => { - /* leave null — switcher still works for navigation-free display */ - }); + const load = () => { + fetchPackages() + .then((parsed) => { + if (!cancelled) setPkgs(parsed); + }) + .catch(() => { + /* leave null — switcher still works for navigation-free display */ + }); + }; + load(); + // Refresh the switcher list (and thus the top-bar package name) when a + // package is created or its manifest is edited elsewhere — PackageFormDialog + // dispatches `objectui:packages-changed` on create/edit. Without this the + // header showed the OLD name after a rename until a full page reload. + window.addEventListener('objectui:packages-changed', load); return () => { cancelled = true; + window.removeEventListener('objectui:packages-changed', load); }; }, [packageId]);