Skip to content

Commit e5ae93d

Browse files
fix(console): the loose-items banner counts only items its links can move into a package (#38818)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} --> _Requested by **Yibo Wang** · [project thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwB7Un8hgmYaC4XFXQuvaosiq)_ Fixes #38776 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:管理员在设置的软件包页上,不再看到「数据源(1)」这类散落项提示;横幅只数能移入软件包的项,每个链接打开的列表都能直接移入。 - 为什么做:散落项移入软件包的入口这周刚上线,横幅把平台自带的默认数据源也算进去了,点进去却没法移,这次让横幅和移入入口说同一句话。 - 出错会怎样:最坏是横幅少数或多数几项,不影响任何数据和保存;撤回这次改动即恢复原样。 - 要你做什么:无。 ## What changes The Packages page banner ("N items belong to no package") read every metadata type that takes a runtime write and counted every row with no `_packageId`. On a fresh showcase that counted the platform's `default` datasource: `DefaultDatasourcePlugin.registerVisibility` registers it in memory with no package, and its "Datasources (1)" link (`/studio/~all/metadata/datasource?source=loose`) is routed by the Studio area to Setup's Datasources page, which has no Loose list and no move. - `LooseItemsBanner.tsx`: `looseCountTypes` keeps only a type whose Studio list offers the "Loose" value. Not `SETUP_KEPT_METADATA_TYPE` (the datasource: every Studio address of it opens Setup's Datasources page, ADR-0146 D1, and ADR-0084 as amended 2026-11-26, decision 12, keeps connections in Setup as environment configuration), and not a type that registers its own `ListPage`, which replaces the default list that draws the Loose value. The datasource is not read at all any more. - `looseMove.ts`: `isLooseRow`, the one predicate the banner and the list's Loose value share, also leaves out a package-less record stamped `_provenance: 'platform'`. That is the move door's own judgement (`protocol-package-move-in.ts`: loose rows are package-less and not `isPlatformRecordRow`), so neither surface offers a move the door answers `NOT_LOOSE`. Same defect class as the datasource count, same predicate, so it is fixed in place. - `ResourceListPage.tsx` is not edited: it already reads `isLooseRow`. - `.changeset/38776-loose-banner-movable-items.md`: `@object-ui/app-shell` patch. Ruling kept: a selection of loose items still moves into a package (ruling 7184753035, question 3). Every package-less row of a listable type with no platform mark is still counted and still offers the move. Files to read first, riskiest first: 1. `ui/packages/app-shell/src/views/metadata-admin/looseMove.ts`: the `isLooseRow` hunk; it changes the list's Loose filter too. 2. `ui/packages/app-shell/src/views/metadata-admin/LooseItemsBanner.tsx`: `offersLooseList` and `looseCountTypes`. 3. `ui/packages/app-shell/src/views/metadata-admin/LooseItemsBanner-38150.test.tsx`: the new describe block for this card. ## Tests New top-level describe blocks in the two existing harness files (AGENTS.md: a new pin for a component with a shared harness file goes into that file): - `LooseItemsBanner-38150.test.tsx`: the fixture now declares `datasource` as the registry does (`allowRuntimeCreate: true`) and serves the `default` row as `GET /meta/datasource` does. Pinned: the datasource type is neither read nor linked; a platform record is not counted; control: a package-less row with no platform mark is still counted. - `looseMove-38150.test.ts`: `isLooseRow` is false for a package-less platform record; control: true for a package-less row without the mark, false for a packaged row; the Loose list (`applyListState`) keeps no platform record. Red on the source at the base, green on the fix: see Verification. ## Acceptance notes - The link half of the card holds structurally: every type the banner still links has a Studio list that draws the Loose value, because the only type with its own `ListPage` on main is the datasource. - A runtime datasource created in Setup with no package is no longer counted either. Its only home is Setup's Datasources page, which offers no move, and ADR-0084 decision 12 manages connections there alone. If datasources should ever be moved into packages from Setup, that is a new door, not this banner. - The platform-record exclusion has no producer in this repository (only `MetadataManager.register` with `origin: 'platform'` stamps it; the hosted runtime registers its AI skills, agents and tools that way). It is pinned at unit level only. - No real-app reading was taken; the reproduction is the unit fixture of the served `default` row. ## Verification Two-minute check: boot showcase, open Setup, Packages. Expected: no "Datasources" entry in the loose-items banner (and no banner at all when nothing else is loose); a loose flow, if one exists, still shows with a link to the Loose list of flows, where it can be selected and moved. Readings at `c3634143` (the branch head: the fix commits merged with origin/main `d97aaaea`, which touched no file under `ui/`). Vitest from `ui/`, `--maxWorkers=2`, through the shared verify lock. <details><summary>Red at the base, green on the fix</summary> - Red: the two harness files with `LooseItemsBanner.tsx` and `looseMove.ts` restored from base `0fc9eab9` (working tree only, put back from HEAD afterwards): `Tests 7 failed | 12 passed (19)`. Failing: the two new `isLooseRow` pins, both new banner pins, and three existing banner tests that now see the datasource read (`counts the loose rows…` total 4, the not-read control, the nothing-loose control). The two new controls passed on the base. - Green: the same two files plus `studioOrgScopeRetired.test.ts` (imports `looseListPath`): `Test Files 3 passed (3)`, `Tests 30 passed (30)`. - The loose surfaces' consumer tests (`ResourceListPage.looseMove-38150`, `ResourceListPage.authoredPackageSource-38150`, `LooseMoveDialog-38150`, `LooseItemsBanner-38150`, `looseMove-38150`, `studioOrgScopeRetired`, `studioScope`, `PackagesPage.moduleDisable-28118`): `Test Files 8 passed (8)`, `Tests 80 passed (80)`. - `pnpm --filter @object-ui/app-shell type-check` (both programs, `tsconfig.json` and `tsconfig.test.json`): exit 0, 0 errors. - NOT MEASURED: app-shell's whole `metadata-admin/` and `studio-design/` test directories (timed out at 530 s under the lock on a shared box). That is `Test UI`'s, in CI. </details> <details><summary>Targeted gates (dispatch-gates --commands on this diff)</summary> - 38 families derived from tree `c3634143`; `dispatch-gates --ran`: 38 run, 0 NOT-MEASURED, every line carrying its exit code. - 37 exited 0 on the first run. `pnpm --dir ui exec vitest run scripts/` was killed (SIGKILL) when it ran unlocked beside other work. Re-run through the lock with `--maxWorkers=2`: exit 0, `Test Files 172 passed | 2 skipped (174)`, `Tests 5159 passed | 2 skipped (5161)`. - `check:nul-bytes`: exit 0. `overlap-check`: clean against origin/main. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01WGufzfcCk7a8bQdgyaxzu7)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 8456562 commit e5ae93d

5 files changed

Lines changed: 130 additions & 8 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
---
4+
5+
fix(app-shell): the Packages page's loose-items banner counts only items its links can move into a package
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
The banner "N items belong to no package" on Setup → Packages counted every row with no package of every type that takes a runtime write. It counted the platform's `default` datasource, and its "Datasources (1)" link opened Setup's Datasources page, which has no "Loose" list and no way to move a datasource into a package.
11+
12+
- The banner reads only a type whose Studio list offers the "Loose" value. The datasource is not one: every Studio address of a datasource opens Setup's Datasources page, where connections are managed as environment configuration (ADR-0084, amended 2026-11-26, decision 12). Nor is a type that registers its own list page in place of the default list.
13+
- A record the platform registered (served with `_provenance: 'platform'` and no package) is no longer read as loose, by the banner or by the "Loose" list: the move door leaves it out of what it moves and answers `NOT_LOOSE`. Every other package-less item still counts, and still offers the move.

‎ui/packages/app-shell/src/views/metadata-admin/LooseItemsBanner-38150.test.tsx‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ const ENTRIES = [
4141
{ type: 'report', allowRuntimeCreate: true },
4242
{ type: 'agent', allowRuntimeCreate: false, allowEnvironmentOverlay: false },
4343
{ type: 'package', allowRuntimeCreate: true },
44+
// The registry's own declaration (`DEFAULT_METADATA_TYPE_REGISTRY`): it takes
45+
// a runtime create, and its Studio address opens Setup's Datasources page.
46+
{ type: 'datasource', allowRuntimeCreate: true },
4447
];
4548

4649
vi.mock('./useMetadata', async (importOriginal) => ({
@@ -61,6 +64,9 @@ beforeEach(() => {
6164
report: new Error('read failed'),
6265
agent: [{ name: 'a1' }],
6366
package: [{ name: 'p1' }],
67+
// What `GET /meta/datasource` serves for the platform's `default`
68+
// datasource (`DefaultDatasourcePlugin.registerVisibility`): no package.
69+
datasource: [{ name: 'default', label: 'Default', driver: 'sqlite', config: {}, origin: 'code' }],
6470
};
6571
});
6672
afterEach(cleanup);
@@ -111,3 +117,41 @@ describe('the Packages page banner (objectstack#38150)', () => {
111117
expect(screen.queryByTestId('loose-items-banner')).toBeNull();
112118
});
113119
});
120+
121+
/**
122+
* objectstack#38776 — the banner counts only what the admin can move into a
123+
* package, and each of its links opens a list where that move is offered.
124+
* Pinned, each with its control:
125+
*
126+
* - a datasource is never read nor linked: its Studio address opens Setup's
127+
* Datasources page (ADR-0146 D1; ADR-0084, amended 2026-11-26, decision
128+
* 12), which draws no Loose list and offers no move, so the platform's
129+
* `default` datasource, served with no package, is not a loose item here;
130+
* - a record the platform registered (`_provenance: 'platform'`, no package)
131+
* is not counted: the move door refuses it as not loose (`isPlatformRecordRow`);
132+
* a package-less row of the same type with no such mark still counts.
133+
*/
134+
describe('only movable items are counted (objectstack#38776)', () => {
135+
it('does not read or link the datasource type, whose list cannot move an item', async () => {
136+
mount();
137+
const banner = await screen.findByTestId('loose-items-banner');
138+
expect(banner).toHaveTextContent('3 items belong to no package');
139+
expect(within(banner).queryByTestId('loose-items-banner-datasource')).toBeNull();
140+
expect(listCalls).not.toContain('datasource');
141+
});
142+
143+
it('does not count a record the platform registered', async () => {
144+
rows.flow = [{ name: 'f1' }, { name: 'builtin', _provenance: 'platform' }, { item: { name: 'builtin2', _provenance: 'platform' } }];
145+
mount();
146+
const banner = await screen.findByTestId('loose-items-banner');
147+
expect(within(banner).getByTestId('loose-items-banner-flow')).toHaveTextContent('(1)');
148+
expect(banner).toHaveTextContent('2 items belong to no package');
149+
});
150+
151+
it('control: a package-less row the platform did not register is still counted', async () => {
152+
rows.flow = [{ name: 'f1' }, { name: 'f4', _provenance: 'org' }];
153+
mount();
154+
const banner = await screen.findByTestId('loose-items-banner');
155+
expect(within(banner).getByTestId('loose-items-banner-flow')).toHaveTextContent('(2)');
156+
});
157+
});

‎ui/packages/app-shell/src/views/metadata-admin/LooseItemsBanner.tsx‎

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,16 @@
1111
* is above zero.
1212
* - The count is the list's own reading: one `GET /meta/:type` per type that
1313
* takes runtime writes (a type that takes none holds no loose item), the
14-
* type's own hide hook applied, `isPackageLessItem` on each row. No new
15-
* server read: the list the link opens counts the same rows.
14+
* type's own hide hook applied, `isLooseRow` on each row. No new server
15+
* read: the list the link opens counts the same rows.
16+
* - objectstack#38776 — it counts only what the admin can move from the list
17+
* its link opens. A type whose Studio list draws no "Loose" value is not
18+
* read: the datasource, whose every Studio address opens Setup's
19+
* Datasources page (ADR-0146 D1; ADR-0084, amended 2026-11-26, decision
20+
* 12: a connection is environment configuration, managed in Setup alone),
21+
* and any type that registers a list page of its own in place of the
22+
* default list. So the platform's `default` datasource, served with no
23+
* package, is never counted as a loose item.
1624
* - A type whose read fails is left out of the count, and the banner says
1725
* some types could not be counted, never a smaller number as if it were all.
1826
*/
@@ -22,15 +30,30 @@ import { Link } from 'react-router-dom';
2230
import { Inbox } from 'lucide-react';
2331
import { useCanAuthorMetadata } from '../../hooks/useCanAuthorMetadata.js';
2432
import { useMetadataClient, useMetadataTypes, type RichMetadataTypeEntry } from './useMetadata.js';
25-
import { resolveResourceConfig } from './registry.js';
33+
import { getMetadataResource, resolveResourceConfig } from './registry.js';
2634
import { t, tFormat, translateMetadataType } from './i18n.js';
2735
import { isLooseRow } from './looseMove.js';
2836
import { LIST_LOOSE_SOURCE, LIST_SOURCE_PARAM } from './metadataListState.js';
2937
import { STUDIO_ALL_PACKAGES_SEGMENT, studioMetadataAreaAddress } from '../studio-design/studioAddress.js';
38+
import { SETUP_KEPT_METADATA_TYPE } from '../studio-design/setupMetadataRedirect.js';
3039

31-
/** The types whose loose rows are counted: those that take a runtime write. */
40+
/**
41+
* Whether a type's Studio list offers the "Loose" value, and with it the move
42+
* (objectstack#38776): not the type the area sends to Setup, and not a type
43+
* whose own list page replaces the default list, which draws that value.
44+
*/
45+
function offersLooseList(type: string): boolean {
46+
return type !== SETUP_KEPT_METADATA_TYPE && !getMetadataResource(type)?.ListPage;
47+
}
48+
49+
/**
50+
* The types whose loose rows are counted: those that take a runtime write and
51+
* whose list the banner's link opens offers the move.
52+
*/
3253
export function looseCountTypes(entries: readonly RichMetadataTypeEntry[]): RichMetadataTypeEntry[] {
33-
return entries.filter((e) => e.type !== 'package' && (e.allowRuntimeCreate || e.allowEnvironmentOverlay));
54+
return entries.filter(
55+
(e) => e.type !== 'package' && (e.allowRuntimeCreate || e.allowEnvironmentOverlay) && offersLooseList(e.type),
56+
);
3457
}
3558

3659
/** A type's "Loose" list on Studio's cross-package leg. */

‎ui/packages/app-shell/src/views/metadata-admin/looseMove-38150.test.ts‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,28 @@ describe('the selection (objectstack#38150)', () => {
125125
expect(withLooseItems(items, items)).toEqual(items);
126126
});
127127
});
128+
129+
/**
130+
* objectstack#38776 — the list's "Loose" reading and the banner's count are
131+
* one predicate (`isLooseRow`), and it reads loose as the move door does
132+
* (`protocol-package-move-in.ts`: package-less and not `isPlatformRecordRow`):
133+
* a record the platform registered is not loose, so the list offers no move
134+
* the door would refuse as `NOT_LOOSE`.
135+
*/
136+
describe('a record the platform registered is not loose (objectstack#38776)', () => {
137+
it('reads a package-less platform record as not loose', () => {
138+
expect(isLooseRow({ _provenance: 'platform' })).toBe(false);
139+
});
140+
141+
it('control: a package-less row with no platform mark is loose; a packaged one is not', () => {
142+
expect(isLooseRow({})).toBe(true);
143+
expect(isLooseRow({ _provenance: 'org' })).toBe(true);
144+
expect(isLooseRow({ _packageId: 'app.alpha', _provenance: 'package' })).toBe(false);
145+
});
146+
147+
it('the Loose list keeps no platform record', () => {
148+
const rows: Row[] = [...ROWS, { item: { name: 'p', _provenance: 'platform' } }];
149+
const kept = applyListState(rows, { ...DEFAULT_LIST_STATE, source: 'loose' }, { ...base, loose: (r) => isLooseRow(r.item) }, 'en-US');
150+
expect(kept.map((r) => r.item.name)).toEqual(['a', 'b']);
151+
});
152+
});

‎ui/packages/app-shell/src/views/metadata-admin/looseMove.ts‎

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
* - What is loose is `isPackageLessItem` on the served `_packageId`, the one
1212
* reading; never `classifyProvenance`, which also files a `.custom` pair
1313
* item and a served overlay as "runtime".
14+
* - objectstack#38776 — and loose is what the door moves: a record the
15+
* platform registered (`_provenance: 'platform'` with no package, the
16+
* metadata service's `isPlatformOrigin`) is not loose, because the door's
17+
* judgement leaves it out (`isPlatformRecordRow`) and answers `NOT_LOOSE`.
18+
* The list's "Loose" value and the Packages page banner read this one
19+
* predicate, so neither offers a move the door refuses.
1420
* - The answer is the server's. A refusal arrives as a 422 whose details are
1521
* the whole answer (`outcome: 'refused'`, every item's own code and
1622
* sentence), and is returned as that answer, never re-worded here. Any
@@ -35,9 +41,20 @@ export function looseItemKey(item: { type: string; name: string; member?: string
3541
return `${item.type}\u0000${item.name}\u0000${item.member ?? ''}`;
3642
}
3743

38-
/** Whether a served row is loose: bound to no package (`isPackageLessItem`). */
39-
export function isLooseRow(item: { _packageId?: unknown } | null | undefined): boolean {
40-
return isPackageLessItem(item);
44+
/**
45+
* The `_provenance` the platform's own registration stamps
46+
* (`MetadataProvenanceSchema`, `@objectstack/spec/kernel`; the metadata
47+
* service's `PLATFORM_PROVENANCE`).
48+
*/
49+
const PLATFORM_PROVENANCE = 'platform';
50+
51+
/**
52+
* Whether a served row is loose: bound to no package (`isPackageLessItem`),
53+
* and not a record the platform registered, which the move door never moves
54+
* (objectstack#38776).
55+
*/
56+
export function isLooseRow(item: { _packageId?: unknown; _provenance?: unknown } | null | undefined): boolean {
57+
return isPackageLessItem(item) && item?._provenance !== PLATFORM_PROVENANCE;
4158
}
4259

4360
/** `items` with `more` added, each once, in the order first named. */

0 commit comments

Comments
 (0)