Skip to content

Commit ea82c96

Browse files
feat(app-shell): select loose items on Studio's cross-package list and move them into a package; the Packages page counts them (#38150 PR-A2) (#38389)
repo:objectstack#3 · os-tesla · session_01L9qibyHmxFV4bTFZ5BKnUz <!-- claude-projects-attribution: {"github_login":"os-tesla"} --> _Requested by **Tesla** · [project thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6JaoLMbEWhC18gy3jFR6wzDkuz)_ Part of #38150. This is PR-A2, the console's half of the move door, by the seat's claim (comment 7234216673) and its branch ruling of 16:02Z: PR-A1 (#38185, the server door) is merged, and #38149 (#38204, the package ask this PR reuses) merged at 16:01Z. PR-B1 (the retirement of `adopt-orphans` and its two console entries, parked as #38364 at head `1852bb898`) lands after this PR, so no prerelease ships a console with no way to move loose items. PR-B2 (Studio `~org`, the redirects to `?source=loose`, the Q-f E classifier #38061, the ADR marks) follows. Clause-②: yes (widening) Metadata-protocol: none Skills-docs: none — no skill under `skills/**` or `.claude/skills/**` teaches the console's lists or loose items; the `objectstack-platform` passage on package-less Setup rows is about overlays of shipped items, which are not loose (searched at this head) **Size: 1,380 lines** (additions + deletions, generated files included: 1,369 added, 11 deleted, 15 files; `git diff --numstat eef1cbf be8e0d5`, base main `eef1cbfe4`). With A1's 1,947 and B1's 3,123 the card is past 3,000 (#38280's per-card line), so this PR is Tier H. ## 维护者速读 - 用户能看到什么变化:在应用工作室的跨软件包列表(`/studio/~all/metadata/<类型>`)里,来源下拉多了「散落项」。选它后,有编辑权限的人可以逐行勾选或全选,点「移入软件包…」,选好软件包后先看一次试运行:每一项移入后地址怎么变,或者为什么被拒。确认后整批移入。设置的「软件包」页上会提示「有 N 个散落项,不属于任何软件包」,按类型列出,点进去就是那种类型的散落项列表。 - 为什么做:App Studio 改版专题(#38150)。你裁定散落项原地保留,由一个按勾选移动的入口负责移入。服务端接口已在 A1 合并,这个 PR 做控制台入口。 - 出错会怎样:只改控制台。移入整批进行,要么全部移入,要么一项不动;被拒时逐项给出服务端原话。最坏情况是横幅计数不准,或某个入口不显示,可以直接撤回。 - 要你做什么:这张卡总行数超过 3000 行,属于 Tier H,需要你经 os-zhuang 批准。 ## What changes **The "Loose" source value** (`metadataListState.ts`, `ResourceListPage.tsx`, `useListOrderedNames.ts`). - `?source=loose` joins the list's address state. On the cross-package leg (`allLeg`: an area host with no package, outside the environment scope) the list offers it, as "Loose (N)" in both the Studio and the Setup toolbars. - A row is loose by `isPackageLessItem` on its served `_packageId` (absent, `''`, or the `sys_metadata` sentinel), the card's "never `classifyProvenance`": that classifier also files a `.custom` pair item and a served overlay as runtime, so "Modified and new" holds them and "Loose" does not. - The row reader gains an optional `loose` member. Absent, as on a package's own leg, `source=loose` reads as every source, the way an unoffered filter does. The detail's ‹ › order reads the same member, so prev and next agree with the list. **Select and move** (`ResourceListPage.tsx`, `looseMove.ts`, `LooseMoveDialog.tsx`). - Under "Loose", a person who may author (`useCanAuthorMetadata`, and not walled) gets a select column first in the table and a selection bar above it: "Select all (N)" over the rows the filter shows, the count selected, and "Move into package…". A reader who may not author sees the loose rows with no select box and no bar. - "Move into package…" opens #38149's ask with nothing pre-selected, with the move's own question and explanation (`PackageCreateAsk` takes an optional `title` and `description`; the create's are unchanged). "New package…" in the ask works as it does for a create. - The confirm step asks the door's dry run (`POST /api/v1/packages/:id/move-in` with `dryRun: true`) and draws its answer: - `would_move`: each item, `(draft only)` where only a draft moves, the address change (`_env/NAME` → `NAMESPACE/NAME`) and the AI face name change where the door reports them. Two notes follow. The first is the dry-run caveat: some save checks run only on the real move, and if one refuses, nothing moves. The second is L2's N4 (record 7236830081): reverting the move's package commit takes the items out of the package and does not make them loose again. - `refused`: each refused item with the door's own code and sentence. For `REFERENCE_LEFT_BEHIND`, "Add the loose items they use and check again" adds the `references` to the selection, which may be of other types, and asks the dry run again. - Move makes the real call. A refusal there is drawn as "The move was refused, and nothing moved". `moved` closes the dialog, says "Moved into PACKAGE: N." and re-reads the list. - The door's 422 arrives as a thrown envelope. `moveLooseItems` resolves it as the door's answer (`error.details` with `outcome: 'refused'`), and every other failure throws with the server's sentence, which the dialog draws with Try again. **The Packages page banner** (`LooseItemsBanner.tsx`, `PackagesPage.tsx`). - "N items belong to no package", drawn on both faces for a person who may author, while N is above zero. Each type with loose items is listed as a link to its "Loose" list, `/studio/~all/metadata/TYPE?source=loose`. That is the acceptance's "from the Setup → Packages banner, a person reaches a flow's Loose list in the UI, with no typed address". - **The count's cost, measured.** No new server read. One `GET /meta/:type` per type that takes a runtime write (`allowRuntimeCreate` or `allowEnvironmentOverlay`; a type that takes none holds no loose item), with the type's own hide hook applied, the same rows its list counts. On the showcase boot that is 30 of the 40 served types, and the 30 reads in parallel took 366 ms. A type whose read fails is named as not counted, never folded into a smaller total. - The count is keyed on the types it reads and reaches the client through a ref. A first version keyed it on the client's identity, and the PackagesPage tests' per-call mock client then looped the effect and hung the app-shell suite. **i18n.** 31 keys in `@object-ui/i18n`'s studio namespace, en and zh: `engine.list.sourceFilter.loose`, `engine.looseMove.*`, `engine.looseItems.*`. No other locale carries the studio namespace. **Changeset.** `38150-move-loose-items-console.md`: `@object-ui/app-shell` and `@object-ui/i18n` patch, `Clause-②: yes (widening)`, `Metadata-protocol: none`, as #38204 declared for the same kind of console widening. ## Tests New, each with its control: | file | pins | |:--|:--| | `ResourceListPage.looseMove-38150.test.tsx` (7) | `?source=loose` on `~all` lists exactly the package-less rows (none, `''`, `sys_metadata`), never a `.custom` pair item or an overlay; with no filter every row is listed. The select column and bar appear for an author, not for a reader who may not author. Select all → the ask opens with nothing picked and the move's question → the dry run carries the three items, `dryRun: true` → the confirm names the package by its name and shows the address change → Move resends the same items without `dryRun`. One row selected moves that row alone. A package's own leg ignores `?source=loose` and draws no selection. | | `LooseMoveDialog-38150.test.tsx` (5) | The address change, the caveat and the undo note, then Move. `REFERENCE_LEFT_BEHIND` offers to add the dataset, the next check carries it, and Move moves both. A refusal with no `references` offers nothing to add. A refusal on the real move reads as nothing moved, and `onMoved` is not called. A failure that is not an answer shows its sentence and Try again. | | `looseMove-38150.test.ts` (8) | The `source=loose` codec round-trips, and an unknown value reads as all. `loose` keeps package-less rows where `runtime` also keeps the `.custom` row. With no `loose` member every row is kept. The 422 resolves as the answer; a 403 throws the server's sentence; the body carries `dryRun` only on a dry run. References are added once each. | | `LooseItemsBanner-38150.test.tsx` (5) | Per-type counts and links (`/studio/~all/metadata/flow?source=loose`). A type with no runtime write, and `package`, are not read. A failed read is named. Nothing is drawn or read for a non-author, and nothing is drawn at zero. | **Ablation.** With the list's `loose` reader set to `row.source === 'runtime'` (the classifier the card forbids), two cases of `ResourceListPage.looseMove-38150` go red: the exact-rows case and the select-all move (its dry run then carried the pair item and the overlay). Restored, 7 of 7 pass. ## Verification Local, on this branch, after a declaration build of `./packages/**` and `@object-ui/app-shell`'s dependencies: - `@object-ui/app-shell` and `@object-ui/i18n` (`pnpm --dir ui exec vitest run packages/app-shell packages/i18n`), before the merge of main: 2,570 files, 2,569 passed and 1 skipped; 25,917 tests passed and 22 skipped. After the two display fixes, the touched files (every `ResourceListPage*`, the four new files, `PackageCreateAsk*`, all of `packages/i18n`) passed: 132 files, 2,048 tests passed and 13 skipped. After the merge of main and the collection imports, the four new files pass 25 of 25. - `@object-ui/app-shell` `type-check` (`tsc --noEmit` and `tsc -p tsconfig.test.json`) passes after the merge of main. The first run failed on `looseMove-38150.test.ts`'s untyped `vi.fn` tuple, and that was fixed. - **Derived gates.** `node scripts/pm/dispatch-gates.mjs --commands` derives 39 families for this tree, the same 39 before and after the merge of main. 38 passed on the first run. `check:test-source-alias` failed on three of the new test files, which reached `celAuthoring`'s dynamic `@objectstack/lint` import through `packageActions.tsx`. Each now has the module-top import, and the gate passes. After the merge, the four gates that read the diff against `origin/main` (`check-adr-0087-registration`, `check-changeset-no-major`, `check-empty-changeset`, `check:test-source-alias`) and `check:undeclared-dep-imports` and `check:type-check-coverage` were run again and pass. `dispatch-gates --ran`: 39 derived, 39 run, 0 NOT-MEASURED. - `overlap-check.mjs` before the first push: `origin/main` conflicted in `ResourceListPage.tsx` (the lucide import, beside #38357's `X`) and `metadataListState.ts` (beside #38357's `targetObject` filter). Both are resolved in the merge, keeping both sides. #38318 shares the two i18n files and merges cleanly. ## Walkthrough (a real stack) At `c27f9ab24` (the two display fixes in; the merge of main after it touches neither surface), `pnpm console:build`, then the showcase booted with `objectstack dev --ui --seed-admin` on a fresh database. Through the API: an installed writable package `com.probe.zeta` (name Zeta, namespace `zeta`), two loose flows (`probe_loose_flow`, `probe_loose_flow2`) and a loose object `probe_widget`, each saved with no package. Then, in the browser (Playwright, 1400×900): 1. Setup → Packages (`?face=admin`) draws "4 items belong to no package" with Flow (2), Object (1), Datasource (1). The datasource is the showcase's own loose row. 2. Flow (2) opens `/_console/studio/~all/metadata/flow?source=loose`: two rows, the select column, "Select all (2)". 3. Select all, then Move into package…: the ask, Zeta picked by hand. 4. The confirm, "Move into Zeta": each flow `_env/probe_loose_flow` → `zeta/probe_loose_flow`, the caveat and the undo note. 5. Move: the dialog closes and the list is re-read. The API then reads both flows `_packageId: com.probe.zeta`, `GET /meta/flow/zeta/probe_loose_flow` answers 200 and `GET /meta/flow/_env/probe_loose_flow` 409, with no restart. 6. The object list's Loose value, `probe_widget` into Zeta: refused `NAMESPACE_PREFIX`, "Object 'probe_widget' is missing the package namespace prefix. Rename it to 'zeta_probe_widget' (namespace = 'zeta').", Move disabled. 7. Back on Setup → Packages: "2 items belong to no package", Object (1) and Datasource (1). Screenshots, at device scale 2: in the project files under `card-38150/a2-walkthrough/`, `1-packages-banner.png` … `7-banner-after.png`. ## Owed before landing - One CONTRACT_REVIEW_TIER review (the seat's). - Tier H: Tesla's approval via os-zhuang. - PR-B1 lands after this PR, restarted on a new PR from `1852bb898`'s commits. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01L9qibyHmxFV4bTFZ5BKnUz --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 2de276c commit ea82c96

15 files changed

Lines changed: 1369 additions & 11 deletions
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/i18n': patch
4+
---
5+
6+
feat(app-shell): select loose items on Studio's cross-package list and move them into a package; the Packages page counts them
7+
8+
Clause-②: yes (widening)
9+
Metadata-protocol: none
10+
11+
The console's half of the move door (`POST /api/v1/packages/:id/move-in`, ADR-0084's amendment of 2026-11-26: "Loose items stay where they are, and one door moves them").
12+
13+
- Studio's cross-package list of a type (`/studio/~all/metadata/TYPE`) offers a "Loose" source value (`?source=loose`): the items bound to no package, and only those. An item of a package's `.custom` pair and an overlay of a shipped item are not loose, though the list's "Modified and new" value holds them.
14+
- Under "Loose", a person who may author metadata gets a select box per row, "Select all", and "Move into package…". The package is picked in the create's ask (the packages the server says they may write, or a new one), with nothing pre-selected.
15+
- The confirm step reads the door's dry run. It shows each item and what its addresses become (`_env/NAME` → `NAMESPACE/NAME`, the name AI clients list it under), or each refused item with the door's own code and sentence. When a moved item uses a loose item the selection leaves behind, it offers to add that item and check again. Move makes the move, whole or nothing. The confirm says that a save check that runs only on the real move can still refuse an item, and that reverting the move's package commit takes the items out of the package rather than making them loose again.
16+
- The Packages page (Setup → Packages, and its development face) shows "N items belong to no package" while there are any, counted per type, each count a link to that type's "Loose" list. It is drawn for a person who may author metadata.
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* objectstack#38150 PR-A2 — the Packages page's "N loose items" banner. Pinned,
5+
* each with its control:
6+
*
7+
* - it counts the package-less rows of each type that takes a runtime write,
8+
* one list read per such type, and links each count to that type's "Loose"
9+
* list on Studio's cross-package leg (`?source=loose`), so the list is
10+
* reached with no typed address;
11+
* - a type that takes no runtime write is not read;
12+
* - a type whose read fails is named as not counted, never folded into a
13+
* smaller total;
14+
* - nothing is drawn, and nothing read, for a reader who may not author; and
15+
* nothing is drawn while no item is loose.
16+
*/
17+
import { describe, it, expect, vi, afterEach, beforeEach } from 'vitest';
18+
import { render, cleanup, screen, waitFor, within } from '@testing-library/react';
19+
import '@testing-library/jest-dom';
20+
import * as React from 'react';
21+
import { MemoryRouter } from 'react-router-dom';
22+
// The source reaches `celAuthoring`'s dynamic `@objectstack/lint` import; its
23+
// first load is paid here, at collection (`check:test-source-alias`).
24+
import '@objectstack/lint';
25+
26+
let canAuthor = true;
27+
let rows: Record<string, unknown[] | Error> = {};
28+
const listCalls: string[] = [];
29+
30+
const CLIENT = {
31+
list: async (type: string) => {
32+
listCalls.push(type);
33+
const r = rows[type];
34+
if (r instanceof Error) throw r;
35+
return r ?? [];
36+
},
37+
};
38+
const ENTRIES = [
39+
{ type: 'flow', allowRuntimeCreate: true },
40+
{ type: 'dataset', allowEnvironmentOverlay: true },
41+
{ type: 'report', allowRuntimeCreate: true },
42+
{ type: 'agent', allowRuntimeCreate: false, allowEnvironmentOverlay: false },
43+
{ type: 'package', allowRuntimeCreate: true },
44+
];
45+
46+
vi.mock('./useMetadata', async (importOriginal) => ({
47+
...(await importOriginal<Record<string, unknown>>()),
48+
useMetadataClient: () => CLIENT,
49+
useMetadataTypes: () => ({ loading: false, error: null, entries: ENTRIES }),
50+
}));
51+
vi.mock('../../hooks/useCanAuthorMetadata', () => ({ useCanAuthorMetadata: () => canAuthor }));
52+
53+
import { LooseItemsBanner } from './LooseItemsBanner';
54+
55+
beforeEach(() => {
56+
canAuthor = true;
57+
listCalls.length = 0;
58+
rows = {
59+
flow: [{ name: 'f1' }, { name: 'f2', _packageId: 'sys_metadata' }, { name: 'f3', _packageId: 'app.alpha' }],
60+
dataset: [{ item: { name: 'ds1', _packageId: '' } }, { name: 'ds2', _packageId: 'app.alpha.custom' }],
61+
report: new Error('read failed'),
62+
agent: [{ name: 'a1' }],
63+
package: [{ name: 'p1' }],
64+
};
65+
});
66+
afterEach(cleanup);
67+
68+
const mount = () =>
69+
render(
70+
<MemoryRouter>
71+
<LooseItemsBanner locale="en-US" />
72+
</MemoryRouter>,
73+
);
74+
75+
describe('the Packages page banner (objectstack#38150)', () => {
76+
it('counts the loose rows per writable type and links each to its Loose list', async () => {
77+
mount();
78+
const banner = await screen.findByTestId('loose-items-banner');
79+
expect(banner).toHaveTextContent('3 items belong to no package');
80+
const flow = within(banner).getByTestId('loose-items-banner-flow');
81+
expect(flow).toHaveTextContent('(2)');
82+
expect(flow).toHaveAttribute('href', '/studio/~all/metadata/flow?source=loose');
83+
expect(within(banner).getByTestId('loose-items-banner-dataset')).toHaveTextContent('(1)');
84+
});
85+
86+
it('control: a type that takes no runtime write, and the package type, are not read', async () => {
87+
mount();
88+
await screen.findByTestId('loose-items-banner');
89+
expect([...listCalls].sort()).toEqual(['dataset', 'flow', 'report']);
90+
expect(screen.queryByTestId('loose-items-banner-agent')).toBeNull();
91+
});
92+
93+
it('names a type whose read failed as not counted', async () => {
94+
mount();
95+
expect(await screen.findByTestId('loose-items-banner-unread')).toHaveTextContent('report');
96+
});
97+
98+
it('control: draws nothing and reads nothing for a reader who may not author', async () => {
99+
canAuthor = false;
100+
mount();
101+
await new Promise((r) => setTimeout(r, 20));
102+
expect(screen.queryByTestId('loose-items-banner')).toBeNull();
103+
expect(listCalls).toEqual([]);
104+
});
105+
106+
it('control: draws nothing while no item is loose', async () => {
107+
rows = { flow: [{ name: 'f3', _packageId: 'app.alpha' }], dataset: [], report: [] };
108+
mount();
109+
await waitFor(() => expect(listCalls.length).toBe(3));
110+
await new Promise((r) => setTimeout(r, 20));
111+
expect(screen.queryByTestId('loose-items-banner')).toBeNull();
112+
});
113+
});
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* objectstack#38150 — the Packages page's "N loose items" banner (ADR-0084's
5+
* amendment of 2026-11-26; decision 12's placement, kept for the move door):
6+
* how many items of this environment belong to no package, counted per type,
7+
* each count a link to that type's "Loose" list on Studio's cross-package leg,
8+
* where they are selected and moved into a package.
9+
*
10+
* - Drawn only for a person who may author metadata, and only while the count
11+
* is above zero.
12+
* - The count is the list's own reading: one `GET /meta/:type` per type that
13+
* 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.
16+
* - A type whose read fails is left out of the count, and the banner says
17+
* some types could not be counted, never a smaller number as if it were all.
18+
*/
19+
20+
import * as React from 'react';
21+
import { Link } from 'react-router-dom';
22+
import { Inbox } from 'lucide-react';
23+
import { useCanAuthorMetadata } from '../../hooks/useCanAuthorMetadata.js';
24+
import { useMetadataClient, useMetadataTypes, type RichMetadataTypeEntry } from './useMetadata.js';
25+
import { resolveResourceConfig } from './registry.js';
26+
import { t, tFormat, translateMetadataType } from './i18n.js';
27+
import { isLooseRow } from './looseMove.js';
28+
import { LIST_LOOSE_SOURCE, LIST_SOURCE_PARAM } from './metadataListState.js';
29+
import { STUDIO_ALL_PACKAGES_SEGMENT, studioMetadataAreaAddress } from '../studio-design/studioAddress.js';
30+
31+
/** The types whose loose rows are counted: those that take a runtime write. */
32+
export function looseCountTypes(entries: readonly RichMetadataTypeEntry[]): RichMetadataTypeEntry[] {
33+
return entries.filter((e) => e.type !== 'package' && (e.allowRuntimeCreate || e.allowEnvironmentOverlay));
34+
}
35+
36+
/** A type's "Loose" list on Studio's cross-package leg. */
37+
export function looseListPath(type: string): string {
38+
return studioMetadataAreaAddress(STUDIO_ALL_PACKAGES_SEGMENT, encodeURIComponent(type), {
39+
query: `${LIST_SOURCE_PARAM}=${LIST_LOOSE_SOURCE}`,
40+
});
41+
}
42+
43+
export interface LooseCounts {
44+
/** Loose rows per type, types with none left out. */
45+
byType: Array<{ type: string; count: number }>;
46+
total: number;
47+
/** Types whose list could not be read. */
48+
unread: string[];
49+
}
50+
51+
export function useLooseItemCounts(enabled: boolean, refreshKey: unknown = 0): LooseCounts | null {
52+
const client = useMetadataClient();
53+
const { entries, loading } = useMetadataTypes(client);
54+
const [counts, setCounts] = React.useState<LooseCounts | null>(null);
55+
// Read through a ref: the count is keyed on the types it reads, never on the
56+
// client's identity, which a host may hand out fresh on each render.
57+
const clientRef = React.useRef(client);
58+
clientRef.current = client;
59+
const typesKey = looseCountTypes(entries)
60+
.map((e) => e.type)
61+
.join(',');
62+
React.useEffect(() => {
63+
if (!enabled || loading) return;
64+
let cancelled = false;
65+
const types = looseCountTypes(entries);
66+
Promise.allSettled(
67+
types.map(async (entry) => {
68+
const list = await clientRef.current.list<any>(entry.type);
69+
const listFilter = resolveResourceConfig(entry.type, entry).listFilter;
70+
let count = 0;
71+
for (const raw of list ?? []) {
72+
const item = (raw && typeof raw === 'object' && 'item' in raw ? raw.item : raw) ?? {};
73+
if (listFilter && !listFilter(item)) continue;
74+
if (isLooseRow(item)) count++;
75+
}
76+
return count;
77+
}),
78+
).then((results) => {
79+
if (cancelled) return;
80+
const byType: LooseCounts['byType'] = [];
81+
const unread: string[] = [];
82+
results.forEach((r, i) => {
83+
if (r.status === 'rejected') unread.push(types[i].type);
84+
else if (r.value > 0) byType.push({ type: types[i].type, count: r.value });
85+
});
86+
setCounts({ byType, total: byType.reduce((sum, b) => sum + b.count, 0), unread });
87+
});
88+
return () => {
89+
cancelled = true;
90+
};
91+
// Keyed on the types read, never on `entries`' or the client's identity.
92+
// eslint-disable-next-line react-hooks/exhaustive-deps
93+
}, [enabled, loading, typesKey, refreshKey]);
94+
return enabled ? counts : null;
95+
}
96+
97+
export function LooseItemsBanner({ locale, refreshKey }: { locale: string; refreshKey?: unknown }) {
98+
const canAuthor = useCanAuthorMetadata();
99+
const counts = useLooseItemCounts(canAuthor, refreshKey);
100+
if (!counts || counts.total === 0) return null;
101+
return (
102+
<div
103+
className="mb-4 flex items-start gap-2 rounded-md border border-amber-300/70 bg-amber-50/70 px-3 py-2.5 text-sm dark:border-amber-700/40 dark:bg-amber-950/20"
104+
data-testid="loose-items-banner"
105+
>
106+
<Inbox className="mt-0.5 h-4 w-4 shrink-0 text-amber-700 dark:text-amber-300" aria-hidden="true" />
107+
<div className="min-w-0 space-y-1">
108+
<p className="font-medium">
109+
{counts.total === 1
110+
? t('engine.looseItems.bannerOne', locale)
111+
: tFormat('engine.looseItems.banner', locale, { count: counts.total })}
112+
</p>
113+
<p className="text-xs text-muted-foreground">{t('engine.looseItems.bannerHint', locale)}</p>
114+
<ul className="flex flex-wrap gap-x-3 gap-y-1 text-xs" data-testid="loose-items-banner-types">
115+
{counts.byType.map(({ type, count }) => (
116+
<li key={type}>
117+
<Link
118+
to={looseListPath(type)}
119+
className="text-primary hover:underline"
120+
data-testid={`loose-items-banner-${type}`}
121+
>
122+
{tFormat('engine.looseItems.typeCount', locale, { type: translateMetadataType(type, locale), count })}
123+
</Link>
124+
</li>
125+
))}
126+
</ul>
127+
{counts.unread.length > 0 && (
128+
<p className="text-xs text-muted-foreground" data-testid="loose-items-banner-unread">
129+
{tFormat('engine.looseItems.unread', locale, { types: counts.unread.join(', ') })}
130+
</p>
131+
)}
132+
</div>
133+
</div>
134+
);
135+
}

0 commit comments

Comments
 (0)