Skip to content

fix(studio): refresh sidebar metadata when switching packages - #1183

Merged
xuyushun441-sys merged 1 commit into
mainfrom
copilot/fix-package-metadata-refresh
Apr 19, 2026
Merged

fix(studio): refresh sidebar metadata when switching packages#1183
xuyushun441-sys merged 1 commit into
mainfrom
copilot/fix-package-metadata-refresh

Conversation

CopilotAI commented Apr 19, 2026

Copy link
Copy Markdown
Contributor

Switching the active package via the Studio sidebar's dropdown did not refresh the left metadata list — it stayed pinned to the previously selected package.

Root cause

apps/studio/src/routes/$package.tsx wired the dropdown's onSelectPackage directly to setSelectedPackage. The same layout also runs a URL→state useEffect that forces selectedPackage to match the $package route param. Because the dropdown never changed the URL, that effect reverted selectedPackage to the old package on the next render, and AppSidebar.loadMetadata (keyed on selectedPackage) never re-ran.

Changes

  • Make the URL the single source of truth for the active package. The dropdown handler now navigates to /$newPackage instead of mutating local state; the existing URL→state sync then updates selectedPackage, invalidating loadMetadata's dependency and refetching metadata for the new package.
  • No-op guard when the target id matches the current $package param, to avoid a redundant navigation.
  • CHANGELOG.md — entry under Unreleased → Fixed.
// apps/studio/src/routes/$package.tsxconsthandleSelectPackage=useCallback((pkg: InstalledPackage)=>{constnextId=pkg.manifest?.id;if(!nextId||nextId===packageId)return;navigate({to: '/$package',params: {package: nextId}});},[navigate,packageId]);<AppSidebar...onSelectPackage={handleSelectPackage}/>

Make the sidebar package dropdown drive the URL instead of local state.
The $package layout already syncs selectedPackage from the URL param, so
the previous setSelectedPackage-only handler was being immediately reverted
by that effect, which kept AppSidebar.loadMetadata from re-running. Now
selecting a package navigates to /$newPackage; the URL->state effect
updates selectedPackage, which invalidates loadMetadata's dependency and
refreshes the left metadata list for the newly selected package.
Agent-Logs-Url: https://github.com/objectstack-ai/framework/sessions/3dce7059-3349-474c-b9c3-aa576806fc14
Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com>
@vercel

vercelBot commented Apr 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentActionsUpdated (UTC)
objectstack-demoReadyReadyPreview, CommentApr 19, 2026 6:36am
specReadyReadyPreview, CommentApr 19, 2026 6:36am

Request Review

Sign up for freeto 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.

2 participants

@xuyushun441-sys