Repository navigation
Commit 7c523aa
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
File tree
- .changeset
- ui/packages/app-shell/src/console/marketplace
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
| 4 | + | |
| 5 | + | |
6 | 6 | | |
7 | | - | |
8 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
15 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
16 | 24 | | |
17 | 25 | | |
18 | 26 | | |
| |||
30 | 38 | | |
31 | 39 | | |
32 | 40 | | |
33 | | - | |
| 41 | + | |
34 | 42 | | |
35 | | - | |
36 | 43 | | |
37 | 44 | | |
38 | 45 | | |
| |||
46 | 53 | | |
47 | 54 | | |
48 | 55 | | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | 56 | | |
53 | 57 | | |
54 | 58 | | |
55 | 59 | | |
56 | | - | |
57 | | - | |
| 60 | + | |
| 61 | + | |
58 | 62 | | |
59 | 63 | | |
60 | 64 | | |
61 | 65 | | |
62 | | - | |
63 | | - | |
64 | | - | |
| 66 | + | |
65 | 67 | | |
66 | 68 | | |
67 | | - | |
| 69 | + | |
68 | 70 | | |
69 | 71 | | |
70 | 72 | | |
71 | 73 | | |
72 | 74 | | |
73 | 75 | | |
74 | 76 | | |
75 | | - | |
| 77 | + | |
76 | 78 | | |
77 | 79 | | |
78 | 80 | | |
79 | | - | |
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
83 | 84 | | |
84 | 85 | | |
85 | 86 | | |
86 | 87 | | |
87 | | - | |
| 88 | + | |
88 | 89 | | |
89 | | - | |
| 90 | + | |
90 | 91 | | |
91 | 92 | | |
92 | 93 | | |
93 | | - | |
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
| 101 | + | |
102 | 102 | | |
103 | | - | |
| 103 | + | |
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
108 | 107 | | |
109 | 108 | | |
110 | 109 | | |
| |||
0 commit comments