Repository navigation
Commit 70c3b1c
fix(app-shell): a draft-only object's new or first-edited list view starts from its first five fields (#30507)
domain:ui#5 · os-sales · session_01L6bhgXNFpXQRAPXfpTaqkV
<!-- claude-projects-attribution: {"github_login":"os-sales"} -->
_Requested by **Sales** · [project
thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4UuT5kyf3nN85tsw9JVYCnhMd)_
Fixes #30317
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:Studio
界面里,一个还只是草稿的对象,第一次编辑它的默认列表视图、或用「新建视图」不选列时,视图现在从对象的前五个字段起步,和已发布对象一样;之前起步是零列。
-
为什么改:面板只从外壳的合并元数据里找对象定义来生成默认列,草稿对象不在其中,于是默认列为空:第一次编辑只写进作者刚加的那一列,新建视图一列都没有。
- 风险与回滚:只改 `useObjectListViewDraft`
的默认列这一段。合并元数据里找不到对象时,多读一次本包的草稿对象定义(`GET
/meta/object/:name?preview=draft&package=`,字段选择器已在读同一个地址);已发布对象不多发请求;读失败或读不到时仍是空,和以前一样。回滚即还原本
PR。
-
先看:`ui/packages/app-shell/src/views/studio-design/ObjectListViewInspector.tsx`
里 `seedColumns` 上方新增的 `draftedDef` 一段。
- 两分钟验证:`pnpm --dir ui exec vitest run
packages/app-shell/src/views/studio-design/ObjectListViewInspector.draftObjectSeed-30317.test.tsx`,预期
4 个用例全绿;在 main 上同一文件 3 个失败。
- 需要你做的:无,席位落地。
## What changes
In Studio › Interfaces, `useObjectListViewDraft` seeds the columns of a
list view created in the panel (the first edit of a view that does not
exist yet, and New view with no columns picked) with
`defaultListColumnsFromObject(objectDef, 5)`. `objectDef` came only from
the shell's merged `metadata.objects`, which holds published objects, so
on a draft-only object the seed was `[]`.
- When the merged definition is missing, the hook now reads the object's
drafted definition from this package through the same client with the
drafts overlaid (`client.withPreviewDrafts(true).get('object', name, {
packageId })`, the read `useObjectFields` already makes for the panel's
field picker) and seeds from it. The answer is keyed on `[packageId,
objectName]` and re-read after a publish.
- A published object reads nothing new: the effect does not run while
the merged definition is present.
- A failed read, or a 404 (neither drafted nor published), seeds
nothing, as before, and is never the panel's failure.
- Nothing else in the hook changes: target resolution, the buffer load,
the save and the view switcher are untouched, so the hunks stay away
from PR #30401 and PR #30339, which edit other parts of this file.
Changeset: `.changeset/30317-draft-only-object-view-seed.md`,
`@object-ui/app-shell` patch.
Branch: the harness-assigned `claude/project-thread-9n7hb1`, not
`claude/issue-30317-*`; the card is #30317.
## Tests
New file `ObjectListViewInspector.draftObjectSeed-30317.test.tsx`: the
real hook over a real `MetadataClient`, whose transport is an in-memory
server that serves `GET /meta/object/:name?preview=draft` in its
envelope and 404 otherwise, and records the PUTs.
- draft-only `acmetrial_deal` (absent from the merged metadata, a hidden
field first): `seedColumns` is its first five visible fields, the canvas
shows them, and the first edit (made as the panel makes it, adding
`notes`) PUTs `view/acmetrial_deal.default` with those five plus
`notes`;
- New view (`createView` with a grid payload and no columns) PUTs
`view/acmetrial_deal.open_deals` with the same five;
- CONTROL: a published object seeds from the merged definition and no
`GET /meta/object/...` is sent for it;
- CONTROL: an object neither drafted nor published: one 404 read, seed
`[]`, no failure, the buffer still loads.
On `origin/main` (`989ae42d`) the file reads 3 failed, 1 passed (the
seed is `[]`; the 404 control fails because no read is sent). With the
fix, 4 passed. Since the pre-fix run is the same file over the unpatched
hook, no separate ablation was run.
<details><summary>Test runs and gates</summary>
- At `0be094aa` (fix, before merging `main`): every app-shell test file
importing `ObjectListViewInspector` or `StudioDesignSurface`, 241 files,
`--maxWorkers=2`, under the verify lock: `Test Files 241 passed (241)`,
`Tests 1751 passed (1751)`, VERDICT command-exit 0. eslint on the two
touched files: 0 errors (22 warnings, all on lines this PR does not
touch).
- `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` at `0be094aa` (3 paths): 35 commands, run
serially, every one exit 0, including `pnpm --dir ui exec vitest run
scripts/` (`Test Files 170 passed | 2 skipped (172)`, `Tests 4985 passed
| 2 skipped`). `--ran` with the recorded exit codes: 35 derived, 35 run,
0 NOT-MEASURED (a derived zero). Also run: `pnpm --filter
@object-ui/app-shell run type-check`, `pnpm --dir ui run
check:spec-symbols`, `pnpm check:changeset-fixed`, each exit 0.
- At `af914a2d` (after merging `main` `a1d0b1ee`, which carries PR
#30339's edit of this file; no conflict; app-shell closure rebuilt):
`pnpm --filter @object-ui/app-shell run type-check`, every test file
under `packages/app-shell/src/views/studio-design/` (`Test Files 330
passed (330)`, `Tests 2473 passed (2473)`) and `pnpm --dir ui run
check:spec-symbols`, one chained run, VERDICT command-exit 0.
</details>
Not run locally: the full ui suite (CI's Test UI shards run it).
## Verification
Dev boot of `examples/app-showcase` (`objectstack dev --seed-admin
--fresh`) after the `@object-ui/app-shell` and showcase build closure,
console Vite pointed at it, Playwright Chromium at 1440×900, signed in
as the dev admin. Seeded over REST: writable package
`com.example.acme-trial` (`POST /api/v1/packages`), then with
`?mode=draft` the object `acmetrial_deal` (fields name, amount, stage,
close_date, probability, notes) and the app `acmetrial_app`, whose one
nav entry is the object. Opened the entry in Studio › Interfaces. Before
= `origin/main`'s hook; after = this branch's, served by Vite HMR; the
view drafts were discarded (`DELETE …?state=draft`) between the two.
| | Before | After |
|:--|:--|:--|
| Panel on opening the entry | "Columns 0 · No columns yet" | Columns 5:
Deal name, Amount, Stage, Close date, Probability |
| First edit (Add field → Notes) PUTs `view/acmetrial_deal.default` with
columns | `[{ field: notes }]` | `[name, amount, stage, close_date,
probability, notes]` |
| New view (Grid, "Open deals", no columns picked) PUTs
`view/acmetrial_deal.open_deals` with columns | `[]` | `[name, amount,
stage, close_date, probability]` |
Shots (1440 wide) and the recorded PUT bodies are in the project's
`issue-30317/` folder (`before-1-opened-1440.png`,
`before-2-first-edit-1440.png`, `before-3-new-view-1440.png`, the three
`after-*` shots, `puts.json`); this repository has no place to commit
them, per `ui/AGENTS.md` Housekeeping.
## Acceptance notes
- The drafted read is asynchronous and is sent when the leaf opens,
beside the view-drafts read that already gates a default entry. An edit
made before it answers would still start from no columns; on the dev
boot it answered before the panel finished loading.
- The before leg's first edit wrote the column as `{ field, label }` and
the after leg's as a bare name: the column editor keeps the shape of the
list it is handed, and the seed is bare names, as it is for a published
object today. Not changed here.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01L6bhgXNFpXQRAPXfpTaqkV)_
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01L6bhgXNFpXQRAPXfpTaqkV
Co-authored-by: Claude <noreply@anthropic.com>1 parent 400b41b commit 70c3b1c
3 files changed
Lines changed: 252 additions & 2 deletions
File tree
- .changeset
- ui/packages/app-shell/src/views/studio-design
| 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 | + | |
| 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 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| |||
567 | 568 | | |
568 | 569 | | |
569 | 570 | | |
570 | | - | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
571 | 599 | | |
572 | 600 | | |
573 | 601 | | |
| |||
0 commit comments