Skip to content

Commit a432ff6

Browse files
Merge pull request #1154 from objectstack-ai/copilot/fix-object-list-change
fix(objectql): respect packageId filter when merging MetadataService items
2 parents 22a6454 + 402ad5e commit a432ff6

3 files changed

Lines changed: 15 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2626
- Preserved skill independence — Each skill remains independently installable/referenceable (no global routing required)
2727

2828
### Fixed
29+
- **Studio: Package switcher not filtering object list** — Fixed a bug where switching packages in the Studio left sidebar did not change the displayed object list. The root cause was in `ObjectStackProtocolImplementation.getMetaItems()`: after filtering items by `packageId` via `SchemaRegistry.listItems()`, the code merged in ALL runtime items from MetadataService without respecting the `packageId` filter, effectively overriding the filtered results. The same issue existed in `HttpDispatcher.handleMetadata()` where the MetadataService fallback path also ignored `packageId`. Both paths now correctly filter MetadataService items by `_packageId` when a package scope is requested.
2930
- **MetadataPlugin driver bridging fallback** — Fixed `MetadataPlugin.start()` so the driver service scan fallback (`driver.*`) is reached when ObjectQL returns `null` (not just when it throws). Previously, `setDatabaseDriver` was never called in environments where ObjectQL was not loaded.
3031
- **Auth trustedOrigins test alignment** — Updated `plugin-auth` tests to match the auto-default `http://localhost:*` behavior added in PR #1152 for better-auth CORS support. When no `trustedOrigins` are configured, the implementation correctly defaults to trusting all localhost ports for development convenience.
3132
- **Docs build: lucide-react module resolution** — Added Turbopack `resolveAlias` in `apps/docs/next.config.mjs` so MDX content files in `content/docs/` (outside the app directory) can resolve `lucide-react`. Turbopack starts module resolution from the file's directory, which doesn't have access to the app's `node_modules/`.

packages/objectql/src/protocol.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,14 @@ export class ObjectStackProtocolImplementation implements ObjectStackProtocol {
253253
const services = this.getServicesRegistry?.();
254254
const metadataService = services?.get('metadata');
255255
if (metadataService && typeof metadataService.list === 'function') {
256-
const runtimeItems = await metadataService.list(request.type);
256+
let runtimeItems = await metadataService.list(request.type);
257+
// When filtering by packageId, only include runtime items that
258+
// belong to the requested package. MetadataService.list() returns
259+
// items from ALL packages, so we must filter here to respect the
260+
// package scope requested by the caller (e.g., Studio sidebar).
261+
if (packageId && runtimeItems && runtimeItems.length > 0) {
262+
runtimeItems = runtimeItems.filter((item: any) => item?._packageId === packageId);
263+
}
257264
if (runtimeItems && runtimeItems.length > 0) {
258265
// Merge, avoiding duplicates by name
259266
const itemMap = new Map<string, any>();

packages/runtime/src/http-dispatcher.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,12 @@ export class HttpDispatcher {
534534
const metadataService = await this.getService(CoreServiceName.enum.metadata);
535535
if (metadataService && typeof (metadataService as any).list === 'function') {
536536
try {
537-
const items = await (metadataService as any).list(typeOrName);
537+
let items = await (metadataService as any).list(typeOrName);
538+
// Respect package filter: MetadataService.list() returns ALL items,
539+
// so filter by _packageId when a specific package is requested.
540+
if (packageId && items && items.length > 0) {
541+
items = items.filter((item: any) => item?._packageId === packageId);
542+
}
538543
if (items && items.length > 0) {
539544
return { handled: true, response: this.success({ type: typeOrName, items }) };
540545
}

0 commit comments

Comments
 (0)