Repository navigation
Commit 6d2db1d
fix(dashboard): drill a relationship-path dimension through its related ids, and localize a failed drill (#34968)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} -->
_Requested by **Yibo Wang** · [project
thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBNgJrQDxaUNx2so1ektgf6A)_
Fixes #34907
Clause-②: no
Metadata-protocol: none
repo:objectstack#3 · os-support-ai · session_01WGufzfrh8TiPJf1i2kMSoa
## 维护者速读
- **改了什么**:仪表盘与报表在「跨关系」维度(如
`crm_account.owner_id`)上点击下钻时,先经同一数据源读出关联对象中匹配所点值的记录 id,再按关系字段 `$in` 这些
id 过滤明细列表;下钻抽屉在列表读取失败时显示本地化的提示语,不再显示服务端给开发者的英文诊断。
- **为什么改**:原来下钻直接用带点路径作为过滤键,数据 API 以 `INVALID_FIELD` / 400
拒绝,抽屉把英文拒绝原文展示给中文用户(卡片中的两个实测场景)。
- **风险与回滚**:低。单对象维度的下钻逐字节不变、不多读任何东西;跨关系维度最多 3 跳(ADR-0071),每跳关联记录超过 200
条时不出列表而显示提示,绝不截断;超过 3 跳的路径不提供下钻。回滚即 revert 本 PR。
-
**先看**:`ui/packages/core/src/utils/dataset-format.ts`(`resolveDatasetDrillFilter`
与 `buildDatasetDrillFilter`
新增的带点路径拒绝)、`ui/packages/plugin-dashboard/src/DatasetWidget.tsx`(`openDrill`
的异步分支与过期结果丢弃)、`ui/packages/plugin-dashboard/src/DrillDownDrawer.tsx`(`notice`
状态与 `failureMessage`)。
- **两分钟验证**:`pnpm --dir ui exec vitest run -t relationship-path
packages/core/src/utils/__tests__/dataset-drill-relationship-path-34907.test.ts
packages/plugin-dashboard/src/__tests__/DatasetWidget.test.tsx
packages/plugin-report/src/__tests__/DatasetReportRenderer.test.tsx`,预期
15 passed。
- **需要你做的**:无,席位落地。
## What changes
- **Item 1, the drill query.** `resolveDatasetDrillFilter`
(`@object-ui/core`) resolves every dimension whose `dimensionFields`
entry is a `relationship.field` path before the drill filter is built.
It reads the related object's ids matching the clicked value through the
surface's own data source (`find(related, { $filter, $select: ['id'],
$top: 201 })`), as the viewer, and filters the base object on the
relationship field `{ FIELD: { $in: [...] } }`, an operator the client
dialect already lowers. The related object is the field's declared
target (`referenceTargetOf` from `@objectstack/spec/data`), the same
tier the analytics hop resolver uses for an inferred join. A path of up
to three hops (ADR-0071) is read innermost first, one read per hop. Path
dimensions that share a hop are read together, and a plain dimension on
the relationship field itself joins that read as an `id` condition. No
filter grammar, spec or server change.
- **Item 1b, no drill rather than a refused or wrong query.** A path
past three hops offers no drill (`datasetDrillPathsResolvable` gates the
widget's `canDrill`). A hop that is not a single-valued relationship of
its object, the empty bucket of a path dimension (it also counted rows
with no related record and rows whose related record the viewer cannot
read), and more than 200 related records at a hop do not produce a list:
the dashboard drawer opens on a localized notice, and the report emits
no drill and logs why. The id list is never truncated. The cap keeps the
drawer's own GET under a request-line limit with UUID ids.
- **Item 2, the drawer's message.** `DrillDownDrawer` takes a `notice`
(`resolving`, `too-many`, `unavailable`, `failed`) and passes
`ObjectDataTable` a new `failureMessage` React prop, so a list read the
server refuses shows `dashboard.drillFailed` instead of the error text.
The error is still logged. `ObjectDataTable` used elsewhere is unchanged
(prop absent). New keys `dashboard.drillTooMany`,
`dashboard.drillUnavailable`, `dashboard.drillFailed` are in all 11
locale packs (zh-Hant regenerated by `gen:zh-hant`).
- **Safety net.** `buildDatasetDrillFilter` now refuses a path dimension
with a `FilterOperatorError` (the error every caller already catches)
instead of writing a dotted key, and takes the resolved conditions as an
optional sixth argument. The synchronous builder path is unchanged for
every other dimension.
- One patch changeset covering `@object-ui/core`,
`@object-ui/plugin-dashboard`, `@object-ui/plugin-report`,
`@object-ui/i18n`.
## Tests
Measured at head `b8f0b9f8f` (merge of `origin/main` `fff0ad0c1` onto
`9cfef0e0d`). Dependency closure built first: `pnpm
--workspace-concurrency=2 --filter '@object-ui/plugin-dashboard^...'
--filter '@object-ui/plugin-report^...' --filter
'@object-ui/data-objectstack^...' build`, exit 0.
- Core, a card-named `dataset-drill-relationship-path-34907.test.ts` (8
tests): the exact related read and the resolved `$in` filter; a two-hop
path read innermost first; a shared hop read once beside a plain
dimension and the widget filter; no match answers `$in: []`, never an
absent condition; 201 related ids answer `too-many`; unknown
relationship, multi-valued relationship, empty bucket and hop limit
answer `unavailable` with no read; CONTROL single-object bucket equals
`buildDatasetDrillFilter` with zero reads; the synchronous builder's
refusal asserts `code` `INVALID_FILTER`, `httpStatus` 400 and the field.
- Dashboard, a top-level `describe` in the shared
`DatasetWidget.test.tsx` (5 tests): the exact related read, then the
drawer's list read with `{ crm_account: { $in: ['acc1','acc2'] } }` and
no query naming the dotted path; over-cap shows the `too-many` notice
and issues no list read; a path past the hop limit offers no drill row;
a refused list read shows the localized sentence and not the diagnostic;
CONTROL single-object drill reads only the base object with its own
equality filter.
- Report, a top-level `describe` in the shared
`DatasetReportRenderer.test.tsx` (2 tests): resolved `objectFilter`;
unresolvable relationship emits no drill and reads nothing.
- `ui/packages/data-objectstack/src/queryDataset.test.ts`: one fixture
re-spelled. It pinned `buildDatasetDrillFilter` producing `{
'account.region': 'NA' }`, the dotted key the data API refuses; the
test's claim (both sidecars reach one filter) is kept on a base-object
field.
- Run: `packages/core/src/utils/__tests__/`,
`packages/plugin-dashboard/`, `packages/plugin-report/`,
`packages/i18n/`, `queryDataset.test.ts` and the three app-shell drill
consumers (`drillEmptyBucketNavHost-9085`,
`drillEmptyBucketEscapeHatch-9159`, `drillNotNullDialect-9508`): Test
Files 455 passed (455), Tests 6268 passed, 26 skipped.
- `type-check` for `@object-ui/core`, `plugin-dashboard`,
`plugin-report`, `i18n`, `data-objectstack`: all Done, exit 0.
- ESLint on every changed ui file, from each package dir: 0 errors
(warnings are pre-existing `no-explicit-any` / `react-refresh` lines).
<details><summary>Ablations (scripts/ablation-replace.mjs; every test
imports the mutated source by relative path, so no dist leg)</summary>
Each mutation landed (`anchor 1 -> 0`) and restored (`blob == HEAD`,
`git diff HEAD` empty).
| mutation | file | red |
|---|---|---|
| resolved `$in` replaced by `$in: []` | `dataset-format.ts` | 6 of 8
core pins |
| id cap check disabled | `dataset-format.ts` | `refuses more than 200
related records` |
| builder's path refusal disabled | `dataset-format.ts` | `the
synchronous builder refuses a relationship path` |
| widget's relationship branch disabled | `DatasetWidget.tsx` | 3 of 5
widget pins |
| `datasetDrillPathsResolvable` dropped from `canDrill` |
`DatasetWidget.tsx` | `offers no drill for a path past the hop limit` |
| drawer's `failureMessage` removed | `DrillDownDrawer.tsx` | `shows the
localized failure sentence` |
| `failureMessage ?? error` reverted to `error` | `ObjectDataTable.tsx`
| `shows the localized failure sentence` |
| drawer notice branch disabled | `DrillDownDrawer.tsx` | `shows a
localized notice … too-many` |
| report emits `objectFilter: undefined` | `DatasetReportRenderer.tsx` |
`emits an objectFilter on the lookup field` |
The first hop-limit attempt used `;` as its replacement and was refused
by the tool (replacement count unchanged); it was re-run with a distinct
replacement and went red as above.
</details>
## Why a client two-step, under Prime Directive 5 (SQL first)
AGENTS.md Prime Directive 5, as written: "**No workarounds.** Adopt
sustainable, well-architected solutions — not temporary patches. **SQL
first:** build a query capability at its fastest SQL shape (JOIN or
semi-join, aggregates in the database); memory and mongo refuse what
they cannot run with a stable code; ⛔ never a slower path built only for
parity (ruling record 6888468549)."
Read against that text, the drill's step (read the related ids, then
`$in`) is an in-app join. It is chosen here for the following reason,
and it is bounded.
- **Reason.** The data API already serves the nested-relation filter (`{
FIELD: { FIELD: VALUE } }`). On SQL it compiles to a semi-join, has no
id cap, and reaches three hops (ADR-0071). The client adapter lowers
every object filter through `convertFiltersToAST`, and that AST dialect
has no node for the nested form. Adding one is a client filter-grammar
change, which the claim's ⛔ (no filter-grammar change) excludes from
this card.
- **Bounds on the in-app step.** At most 200 related ids per hop and at
most three hops. The id list is never truncated: over the cap, the
dashboard drawer shows the localized `too-many` notice and issues no
list read, and the report emits no drill. A path the client cannot
resolve gets the localized `unavailable` notice, or no drill.
- **Follow-up, named and not filed: lift the cap.** A client
filter-grammar node for the nested-relation form is the route that lifts
the 200-id cap. Once that node lands, the drill should move to it and
send the nested filter, so the join runs as the server's semi-join. This
card's ⛔ keeps it out of this PR.
- **Follow-up, named and not filed: the Studio hint.** The
dataset-picker hint 「还没有读取本包对象的数据集」
(`engine.studio.interfaces.newDataset.noPackageDatasets`) is accurate to
its condition, which is that no catalog dataset reads a non-system
object of the package being authored. In the card's case it misleads,
because usable datasets over other packages' objects are listed. Fixing
it means changing that condition or rewording it to say what it checks,
and neither is a locale-value-only change (see Acceptance notes).
## Acceptance notes
- File surface beyond the claim: one fixture in
`ui/packages/data-objectstack/src/queryDataset.test.ts`, which pinned
the defect's dotted key.
- Route chosen: the client-side two-step; the reason, its bounds and the
follow-up that lifts the cap are in the Prime Directive 5 section above.
- The empty bucket of a relationship dimension, and a relationship the
object schema does not declare as a single-valued lookup, are decided at
click time (they need the clicked value or the object schema), so they
open the drawer on the `unavailable` notice rather than removing the
click beforehand. Only the hop limit is decided before the click.
- Report drills that cannot resolve emit no drill and log a warning: the
report's drawer belongs to its host (`ReportView`), which reads an
absent `objectFilter` as an older server and would rebuild a wider
filter. A server refusal inside that drawer does get the localized
sentence, because `ReportView` renders the same `DrillDownDrawer`.
- Studio wording 「还没有读取本包对象的数据集」: read, not changed. It renders when no
catalog dataset's `object` is a non-system object owned by the package
being authored (`readsAnyObject` over `packageObjects` in
`datasetCreate.tsx`), whatever datasets over other packages' objects the
picker lists. So it is accurate to its condition and still reads as
"there are no datasets" when the usable datasets read another package's
objects. Whether that condition or the copy should change is not a
locale-value-only fix, so it is left for a separate card.
- Eager en budget: the new keys are eager (`locales/en.ts`,
`dashboard.*`). The gzip of `en.ts` source grew from 95,638 to 95,735
bytes (+97). `check:eager-closure` / `check:eager-locale-catalogues`
read a built Console bundle; `check:eager-locale-catalogues` exited 2
with PREREQUISITE NOT MET here, and dispatch-gates derives neither for
this diff, so the chunk ceiling is NOT MEASURED locally.
## Verification
- `node scripts/pm/dispatch-gates.mjs --commands` at `b8f0b9f8f`: 40
derived commands, all 40 run, each exit 0 (`pnpm --dir ui exec vitest
run scripts/`: Test Files 171 passed, 2 skipped; Tests 5077 passed, 2
skipped). `--ran` with recorded exit codes: 40 derived, 40 run, 0
NOT-MEASURED, 0 UNRUN.
- `pnpm --dir ui check:new-line-citations`: 0 new citations, exit 0.
- `node scripts/pm/overlap-check.mjs
--branch=claude/issue-34907-drill-cross-relationship` before every push
after the first: VERDICT clean, exit 0. It was not run before the first
content push (`66f504cca`); it was run immediately after it, also clean.
- CI check-runs: not yet concluded when this body was written.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01WGufzfrh8TiPJf1i2kMSoa)_
<!-- signed: repo:objectstack#3 · os-support-ai ·
session_01WGufzfrh8TiPJf1i2kMSoa -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>1 parent c0665c0 commit 6d2db1d
21 files changed
Lines changed: 877 additions & 13 deletions
File tree
- .changeset
- ui/packages
- core/src/utils
- __tests__
- data-objectstack/src
- i18n/src/locales
- plugin-dashboard/src
- __tests__
- plugin-report/src
- __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 | + | |
| 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 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
0 commit comments