Skip to content

Commit 7c523aa

Browse files
feat(console): filter and page the marketplace catalog through the list door (#31288)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"} --> _Requested by **Leehom** · [project thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1X3TFS5tXyqCwM19gKCYSVFj)_ Fixes #31267 Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:控制台市场页不再一次拉 100 条再在浏览器里筛。搜索词、三个维度的选择和分页窗口随列表请求一起发给 `GET /api/v1/marketplace/packages`:`businessFunctions` / `industries` / `solutionTypes` 各一个逗号拼接的参数,没选的维度不发,`q` 在停止输入 300 毫秒后发,`limit` / `offset` 由卡片下方的翻页器驱动(每页 24 条)。`listMarketplacePackages` 还接受 `maturity`,页面本身不选它。 - 为什么改:#31234 已让服务端按这四个维度筛选并分页;前端筛只看得到前 100 条,目录超过 100 条后其余模板永远显示不出来。 - 风险与回滚:只改私有包 `@object-ui/app-shell` 的市场页(随 `@object-ui/console` 的构建发出),patch。可见变化:维度按钮现在列出规格声明的全部取值、不再显示数量(一页筛选结果数不出全目录,列表接口也不返回计数);搜索改由服务端匹配(名称与应用 ID,与占位文字一致),不再匹配描述和本地化名称。默认配置下请求原样转发 cloud,cloud 按同名参数筛选要等 cloud#3661。回滚即 revert 本 PR。 - 先看:`ui/packages/app-shell/src/console/marketplace/MarketplacePage.tsx`(`catalogRequest`、读取 effect、翻页器)、`marketplaceApi.ts` 的 `listMarketplacePackages`(参数拼法)、`marketplaceTaxonomy.ts` 的 `facetListParams` 与 `widenServedFacets`。 - 两分钟验证:`pnpm --dir ui exec vitest run packages/app-shell/src/console/marketplace/__tests__/MarketplacePage.facets-31011.test.tsx packages/app-shell/src/console/marketplace/__tests__/marketplaceApi.listQuery-31267.test.ts`,预期 17 个用例全绿(点按钮、打字、翻页,断言列表请求收到的查询串)。 - 需要你做的:无,席位落地。 ## What changes - **`listMarketplacePackages`** (`marketplaceApi.ts`) takes `MarketplaceListParams`: `q`, `limit`, `offset`, and the four filters of `MarketplaceSearchRequestSchema` spelled as the published spec names them, `businessFunctions`, `industries`, `solutionTypes` (plural) and `maturity`. Each list filter goes out as ONE comma-joined parameter; a list that selects nothing is left out, never sent empty; `maturity` is one value; `category` is never sent. These are exactly the three shapes the list door refuses with 400 `VALIDATION_ERROR` (empty facet, repeated facet key, retired `category`), so the console sends none of them. - **`MarketplacePage.tsx`** no longer reads `{ limit: 100 }` and filters in the browser. Its read is `catalogRequest`: the debounced search text as `q`, the selection through `facetListParams`, `limit: CATALOG_PAGE_SIZE` (24) and the page's `offset`. One effect reads whenever that request's spelling changes; each new read retires the pending one, so only the newest settles the page (the existing `loadSeq` mechanism). The first read, Refresh, Retry and the read after an install also read the installs and the org's packages; a page turn or a new selection reads the catalog alone. The search box reads once typing pauses for `SEARCH_DEBOUNCE_MS` (300 ms). A new search or selection reads from the first page. The cards drawn are the door's answer, unfiltered. Empty answers say "No apps match your filters." under a search or a selection and "No apps have been approved…" without one. - **Pager.** Under the cards when the door's `total` spans more than one page: Previous, "Page N of M", Next, disabled at either end and while a read is pending. It reuses the existing keys `common.previous`, `common.next` and `table.pageInfo`; no i18n key is added, removed or reworded. - **Facets** (`MarketplaceFacetFilters.tsx`, `marketplaceTaxonomy.ts`). A drawn facet offers every value the spec declares, in the spec's order, read from the schemas' `.options` as before. The per-value count is gone, and so are `matchesFacets` and `facetOptions`: one page of the filtered catalog cannot count the catalog, and the list door answers no counts. Which facets are drawn is `ServedFacets`, widened by `widenServedFacets` from each answer: a facet appears once some answered listing carries it (the solution type once one declares a type) and stays drawn while a selection narrows the page, so a catalog serving no taxonomy still draws no filter (the #31011 behaviour). - **Row defaults (card item 4).** The console no longer applies a default to filter: the server does (`solutionTypes` reads a row without the column as `app`, `maturity` as `stable`). The one console reading that remains, `effectiveSolutionType` on the package page, is `DEFAULT_SOLUTION_TYPE` from `@objectstack/spec/marketplace`, the same constant the door imports; the Beta badge reads `maturity === 'beta'`, so an absent maturity draws as `stable`. No second copy of either default is added. - **Changeset** `.changeset/31267-marketplace-server-facets.md`, `@object-ui/app-shell` patch, with both declaration lines (precedent: `.changeset/30330-marketplace-readme-fits-page.md`, an app-shell-only change shipped through `@object-ui/console`'s `dist`). ## Tests - `MarketplacePage.facets-31011.test.tsx`, the page's existing harness, rewritten for the server read (15 cases). The catalog stub records each list read's query string and answers from a per-test function. Every click, keystroke and page turn goes through the rendered page; the assertions read the query the data layer sent: keys, comma-joined values in the spec order, an omitted empty facet, no `category`, no empty value, at most one occurrence of each key, `limit` / `offset`. One case answers a `hr` read with listings that carry no `hr` and asserts both are drawn: the console filters nothing. The pager case walks three pages by `offset` and checks that a selection on page 2 reads from offset 0. The #31011 cases that still hold (facets hide with no taxonomy, per-facet hiding, out-of-vocabulary values drawn nowhere, non-array columns, primary-function and Beta badges) stay, read through the server answer. - `marketplaceApi.listQuery-31267.test.ts` (new, 2 cases): the exact URL `listMarketplacePackages` builds for all four filters, `maturity` included, and that empty lists and no filters send nothing extra. - `MarketplacePage.searchPlaceholder-10900.test.tsx`: its third case pinned the browser-side search; it now asserts the box's text reaches the read as trimmed `q` from offset 0, and that the door's empty answer draws no card. The placeholder's promise (name or app ID) is the door's `q` matching, `catalogRowMatches` in `@objectstack/cloud-connection`'s marketplace proxy. ## Acceptance notes - **Counts are gone from the facet buttons.** #31011 drew, beside each value, the loaded listings that held it. With the server filtering and paging, no count the console could compute would be true, and `GET /api/v1/marketplace/packages` answers `{ items, total, limit, offset }` with no aggregation. The spec does declare an optional `facets` member on `MarketplaceSearchResponseSchema` (one count list per facet), but no in-repo producer serves it, so the console does not read it. If counts are wanted back, the list door serving those counts is the route; noted, not filed. - **Search moved to the server, and narrowed with it.** The browser search matched the localized display name, the manifest id and the localized description. The door's `q` (proxy path) matches `display_name` and `manifest_id`, which is what the placeholder says ("by name or app ID"). Matching the description or a localized name is gone; noted, not filed. - **Default configuration forwards to cloud.** With `OS_MARKETPLACE_PUBLIC_BASE_URL` unset, the proxy validates the query and forwards it verbatim to the cloud list route, which adopts the same names on cloud#3661 (carrier: cloud). Until that lands, a deployment on the default path may answer a facet read unfiltered; the console draws what it is answered. The R2 fast path filters in-repo. - **Maturity** is accepted by `listMarketplacePackages` (card item 1) and pinned there; the page selects no maturity, as before (maturity is a badge, not a facet, in the spec's own words). - **Page size 24**: a whole number of card-grid rows at two, three, four and six columns; the door caps a page at 100. ## Verification All on head `aad134cc` unless named. Exit codes captured before any pipe. <details><summary>Rendered and unit tests: 58/58 files, 515/515 tests</summary> - `pnpm --dir ui exec vitest run packages/app-shell/src/console/marketplace/` under the verification lock: `Test Files 58 passed (58)`, `Tests 515 passed (515)`, VERDICT command-exit 0. - `pnpm --filter @object-ui/app-shell run type-check` (both `tsconfig.json` and `tsconfig.test.json`): exit 0. - `eslint` on the seven changed files: 0 errors (warnings only; the read effect's `exhaustive-deps` warning was already on `main`'s effect, and the debounce effect adds one of the same kind). - `pnpm --dir ui check:new-line-citations`: 0 new citations, exit 0. </details> <details><summary>Ablations: six mutations, each red, each restored to the HEAD blob</summary> `node scripts/ablation-replace.mjs` on `f7c43530`, running the three changed test files; ui vitest reads app-shell from `src/`, so no build sits between mutation and run. Every leg printed `ok restored: blob == HEAD` with `git diff HEAD` empty. - A, an empty facet sent (`if (values)` for `if (values && values.length > 0)` in `listMarketplacePackages`): 1 red, `leaves out a filter that selects nothing, and never sends category`. - B, the selection kept off the read (`...facetParams,` deleted from `catalogRequest`): 7 red, every case that clicks a facet. The first attempt at B used a replacement that was a substring of the anchor; the script refused it (rise 0, nothing ran), so it was redone with `--delete`. - C, repeated keys instead of one comma-joined value (`usp.append` per value): 3 red. - D, the old window (`limit: 100`, no `offset`): 6 red, including the pager and the search placeholder case. - E, insertion order instead of the spec order in `facetListParams`: 1 red, `businessFunctions=sales,hr` expected. - F, a facet that does not stay drawn (`served.businessFunctions ||` removed in `widenServedFacets`): 1 red, `a drawn facet stays drawn when a selection narrows the page`. </details> <details><summary>Derived gates: 37 derived, 37 run, all exit 0</summary> `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack`, reconciled with `--ran`: `37 derived famil(ies) accounted for — 37 run, 0 NOT-MEASURED`. - The 27 families the ui paths derive ran on `f7c43530` (the code commit): `check-closing-keyword-parity` (and `--self-test`), `check-comment-mask-corpus`, `check-sdui-manifest` (and `--self-test`), `pnpm --dir ui exec vitest run scripts/`, spec `check:duration-unit-keys`, `check:error-code-provenance`, `check:cross-package-test-inputs`, `check:dispatcher-error-vocabulary`, `check:driver-memory-census`, `check:engine-double-contract`, `check:gitlink-declared`, `check:nul-bytes`, `check:published-files`, `check:query-options-erasure`, `check:refd-timer-probe`, `check:registry-log-declared`, `check:rest-log-spy-declared`, `check:skill-identifier-liveness`, `check:test-source-alias`, `check:tier-file-adoption`, `check:type-check-coverage`, `check:type-check-debt`, `check:undeclared-dep-imports`, `check:watch-hint-literal`, `check:where-matcher`: all exit 0. - The 10 families the changeset path adds ran on `aad134cc`: `check-adr-0087-registration` (`--base origin/main` and `--self-test`), `check-changeset-no-major`, `check-empty-changeset` (`--base origin/main` and `--self-test`), `ci/snapshot-next --self-test`, `pm/release-rehearsal-clone --self-test`, `release-pending-publish --self-test`, `check:changeset-gate-self-tests`, `check:closed-ceremony-text`: all exit 0. - `f7c43530..aad134c` adds the changeset file only, and the derivation maps that path to exactly those 10 families, so the 27 were not re-run on the changeset commit. - Full dogfood: not owed (no `!` in the title, no `(narrowing)` arm). </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01FEkQ5npnoTzeRFxu1Mj26Q)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 131f855 commit 7c523aa

8 files changed

Lines changed: 551 additions & 259 deletions
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
---
4+
5+
feat(console): the marketplace catalog is filtered and paged by the server
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
The Console's marketplace page read the first 100 listings once and filtered them in the browser, so a catalog of more than 100 listings could never show the rest. It now reads one page at a time from `GET /api/v1/marketplace/packages`, and the search text, the facet selection and the page window travel with the read:
11+
12+
- `businessFunctions`, `industries` and `solutionTypes`, each one comma-joined parameter (`?businessFunctions=sales,marketing`), OR inside a facet and AND across facets, as the list door applies them. A facet with nothing selected is left out, never sent empty, and the retired `category` is never sent.
13+
- The search box sends its text as `q` once typing pauses, and the list door does the matching.
14+
- `limit` / `offset`: a pager under the cards walks the door's `total`, 24 listings a page. A new search or selection starts again from the first page.
15+
16+
`listMarketplacePackages` takes the four filters, `maturity` included, which the page itself does not select.
17+
18+
A drawn facet now lists every value the marketplace declares, in the spec's order, and no longer prints a count beside each value: one page of the filtered catalog cannot count the catalog, and the list door answers no counts. A facet appears once some listing the door answered carries it, and stays while a selection narrows the page, so a catalog that serves no taxonomy still draws no filter.

‎ui/packages/app-shell/src/console/marketplace/MarketplaceFacetFilters.tsx‎

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
11
/**
22
* The marketplace catalog's facet filters: solution type as a segment (one
33
* value or All), business function and industry as toggle rows (any number of
4-
* values, OR inside the row). The rows combine with AND. Each value carries
5-
* the count of loaded listings that hold it under the other facets' selection.
4+
* values, OR inside the row). The rows combine with AND. The server applies
5+
* the selection: the page sends it with the list read and draws the answer.
66
*
7-
* `facetOptions` (`marketplaceTaxonomy.ts`) decides what is drawn: a facet no
8-
* loaded listing carries is empty and its row is not drawn, so a catalog that
7+
* A drawn facet offers every value the spec declares, in the spec's order: the
8+
* page holds one page of the filtered catalog, so the values its rows carry
9+
* are not the values a selection can add. `ServedFacets`
10+
* (`marketplaceTaxonomy.ts`) decides which facets are drawn, so a catalog that
911
* does not serve the taxonomy yet draws no filter at all.
1012
*/
1113

1214
import type { ReactNode } from 'react';
1315
import { Button } from '@object-ui/components';
1416
import { useObjectTranslation } from '@object-ui/i18n';
15-
import type { FacetOptions, FacetSelection } from './marketplaceTaxonomy.js';
17+
import {
18+
BUSINESS_FUNCTIONS,
19+
INDUSTRIES,
20+
SOLUTION_TYPES,
21+
type FacetSelection,
22+
type ServedFacets,
23+
} from './marketplaceTaxonomy.js';
1624

1725
function toggled<T>(set: ReadonlySet<T>, value: T): Set<T> {
1826
const next = new Set(set);
@@ -30,9 +38,8 @@ function FacetRow({ label, testId, children }: { label: string; testId: string;
3038
);
3139
}
3240

33-
function FacetButton({ label, count, pressed, onClick, testId }: {
41+
function FacetButton({ label, pressed, onClick, testId }: {
3442
label: string;
35-
count?: number;
3643
pressed: boolean;
3744
onClick: () => void;
3845
testId: string;
@@ -46,65 +53,57 @@ function FacetButton({ label, count, pressed, onClick, testId }: {
4653
data-testid={testId}
4754
>
4855
{label}
49-
{count !== undefined && (
50-
<span className="ml-1.5 text-xs tabular-nums opacity-70" data-testid={`${testId}-count`}>{count}</span>
51-
)}
5256
</Button>
5357
);
5458
}
5559

56-
export function MarketplaceFacetFilters({ options, selection, onChange }: {
57-
options: FacetOptions;
60+
export function MarketplaceFacetFilters({ served, selection, onChange }: {
61+
served: ServedFacets;
5862
selection: FacetSelection;
5963
onChange: (next: FacetSelection) => void;
6064
}) {
6165
const { t } = useObjectTranslation();
62-
if (options.solutionType.length === 0 && options.businessFunctions.length === 0 && options.industries.length === 0) {
63-
return null;
64-
}
66+
if (!served.solutionType && !served.businessFunctions && !served.industries) return null;
6567
return (
6668
<div className="flex flex-col gap-2" data-testid="marketplace-facets">
67-
{options.solutionType.length > 0 && (
69+
{served.solutionType && (
6870
<FacetRow label={t('marketplace.facet.solutionType')} testId="marketplace-facet-solutionType">
6971
<FacetButton
7072
label={t('marketplace.all')}
7173
pressed={selection.solutionType === null}
7274
onClick={() => onChange({ ...selection, solutionType: null })}
7375
testId="marketplace-facet-solutionType-all"
7476
/>
75-
{options.solutionType.map(({ value, count }) => (
77+
{SOLUTION_TYPES.map((value) => (
7678
<FacetButton
7779
key={value}
7880
label={t(`marketplace.solutionType.${value}`)}
79-
count={count}
8081
pressed={selection.solutionType === value}
8182
onClick={() => onChange({ ...selection, solutionType: value })}
8283
testId={`marketplace-facet-solutionType-${value}`}
8384
/>
8485
))}
8586
</FacetRow>
8687
)}
87-
{options.businessFunctions.length > 0 && (
88+
{served.businessFunctions && (
8889
<FacetRow label={t('marketplace.facet.businessFunction')} testId="marketplace-facet-businessFunction">
89-
{options.businessFunctions.map(({ value, count }) => (
90+
{BUSINESS_FUNCTIONS.map((value) => (
9091
<FacetButton
9192
key={value}
9293
label={t(`marketplace.businessFunction.${value}`)}
93-
count={count}
9494
pressed={selection.businessFunctions.has(value)}
9595
onClick={() => onChange({ ...selection, businessFunctions: toggled(selection.businessFunctions, value) })}
9696
testId={`marketplace-facet-businessFunction-${value}`}
9797
/>
9898
))}
9999
</FacetRow>
100100
)}
101-
{options.industries.length > 0 && (
101+
{served.industries && (
102102
<FacetRow label={t('marketplace.facet.industry')} testId="marketplace-facet-industry">
103-
{options.industries.map(({ value, count }) => (
103+
{INDUSTRIES.map((value) => (
104104
<FacetButton
105105
key={value}
106106
label={t(`marketplace.industry.${value}`)}
107-
count={count}
108107
pressed={selection.industries.has(value)}
109108
onClick={() => onChange({ ...selection, industries: toggled(selection.industries, value) })}
110109
testId={`marketplace-facet-industry-${value}`}

0 commit comments

Comments
 (0)