Repository navigation
Commit 8f0d838
fix(app-shell): the Diagnostics page inside a package's Studio area sweeps only that package (#29230)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} -->
_Requested by **Steedos** · [project
thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbY8yy1z7weZjvcF9CG3bmqs)_
Fixes #29179
Clause-②: no
Metadata-protocol: none
## 维护者速读
- **改了什么**:Studio「全部元数据」区里,某个包内的诊断页现在只扫描这个包,和旁边的目录页一致;跨包入口(`~all`)和
Setup 的诊断页保持全环境扫描不变。
- **为什么改**:作者在包 A 里看到目录说「没有问题」,诊断页却列出别的包的无效项,点进去还跳到一个无关页面,无法找到要修的东西。
- **风险与回滚**:风险低,只多传一个包参数给已有的诊断请求(服务器早已支持按包过滤,目录页一直这样用);回滚即还原
`DiagnosticsPage.tsx` 一处改动。
-
**先看**:`ui/packages/app-shell/src/views/metadata-admin/DiagnosticsPage.tsx`(读取区域宿主并传
`packageId` 那一段);`DiagnosticsPage.packageScope-29179.test.tsx`。
- **两分钟验证**:`pnpm --dir ui exec vitest run
packages/app-shell/src/views/metadata-admin/DiagnosticsPage.packageScope-29179.test.tsx`,预期
5 个用例全绿(在 main 上其中 3 个红)。
- **需要你做的**:无,席位落地。
## What changes
`MetadataDiagnosticsPage` now reads the Studio area host
(`useMetadataAreaHost()`) and passes `host.packageId` to
`useGlobalDiagnostics` when the area is open on a package, the way
`DirectoryPage` passes its `activePackage`. The request becomes `GET
/api/v1/meta/diagnostics?severity=…&package=PKG`, so the page's count
matches the directory's and every listed row is an item of the open
package, whose area-relative link (`../TYPE/NAME`) opens that item in
its own package's area.
Unchanged: the cross-package leg (`/studio/~all/metadata/_diagnostics`,
`packageId: null`) and Setup's page (no area host) keep the
environment-wide sweep (#28561). No copy, i18n key or exported type
changes.
## Why
Inside `com.example.showcase`'s area the directory's scoped sweep found
0 issues (no "View all issues" link), while the Diagnostics page's
unscoped sweep listed `pkga_qa_obj.qa_diag_view`, another package's
item; its link resolved into the showcase area and landed on an
unrelated Interfaces page. The server already filters the sweep by
`packageId` at its list read, and diagnostics entries carry no package,
so scoping the request is the whole fix.
## Tests
New `DiagnosticsPage.packageScope-29179.test.tsx` runs the real
`useGlobalDiagnostics` against a fake client that answers as the server
does (a `packageId` narrows the sweep), with the page nested at
`ROOT/_diagnostics` as the area and Setup mount it:
- a package's area: the request carries the package, another package's
invalid item is not listed, the page reads "All clear" (the card's
scenario);
- a package's area: an own invalid item links to
`/studio/PKG/metadata/view/NAME`;
- switching to Errors + Warnings keeps the package scope;
- the `~all` leg and Setup keep the environment-wide request and list
the foreign row (preservation pins).
<details><summary>Red on main (ea150b7), green on the fix</summary>
On `ea150b7f` with the test file alone: `Tests 3 failed | 2 passed (5)`,
the three package-area cases failing with `expected [ { severity:
'error' } ] to deeply equal [ { severity: 'error', …(1) } ]`, `expected`
the foreign row's anchor element `to be null` and `expected { severity:
'warning' } to deeply equal { severity: 'warning', …(1) }`. The two
preservation cases pass on main by design.
On the fix (`18d2b4cb`), with the two existing Diagnostics page tests:
`Test Files 3 passed (3) · Tests 12 passed (12)`.
</details>
## Acceptance notes
- Setup's directory links `./_diagnostics` without its `?package=`, so
Setup's Diagnostics page stays environment-wide beside a package-scoped
directory count. This is outside the card's Studio reach and is left as
is (noted, not fixed).
- Ablation: the red-on-main run above is the before leg (the same test
against the unfixed page, imported from source, so no dist rebuild is
involved).
## Verification
All readings on head `4cfc9074` (the fix merged with `origin/main`
104cd1a) unless stated.
<details><summary>Derived gates: 34 derived, 34 run, 0
NOT-MEASURED</summary>
`node scripts/pm/dispatch-gates.mjs --commands` derived 34 commands; the
33 unlocked ones each exit 0 in one loop, and `pnpm --dir ui exec vitest
run scripts/` ran under the lock: `Test Files 169 passed | 2 skipped
(171) · Tests 4900 passed | 2 skipped (4902)`, VERDICT command-exit 0.
`node scripts/check-sdui-manifest.mjs` exit 0. `dispatch-gates --ran`:
"34 derived famil(ies) accounted for — 34 run, 0 NOT-MEASURED". `pnpm
check:new-line-citations` (from `ui/`): `0 new citation(s)`.
</details>
<details><summary>Type-check and related tests</summary>
- `pnpm exec turbo run type-check --filter=@object-ui/app-shell
--concurrency=2`: `Tasks: 65 successful, 65 total`, VERDICT command-exit
0.
- The 19 test files that name `DiagnosticsPage` /
`MetadataDiagnosticsPage` (`git grep -l` under `ui/packages` and
`ui/apps`) plus the three `metadataAreaHost.*` tests (22 files): `Test
Files 22 passed (22) · Tests 294 passed (294)`. The rest of app-shell is
left to CI's Test UI (declared narrowing).
</details>
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
(not touched)
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes. (repo-wide lint is CI's)
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: its generated artifacts are
regenerated and committed. (not touched)
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01QsR2jV7MUKsme1kh4FsABc)_
Co-authored-by: Claude <noreply@anthropic.com>1 parent 68ecc79 commit 8f0d838
3 files changed
Lines changed: 178 additions & 1 deletion
File tree
- .changeset
- ui/packages/app-shell/src/views/metadata-admin
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 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 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
68 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
69 | 79 | | |
70 | 80 | | |
71 | 81 | | |
| |||
0 commit comments