Repository navigation
Commit 55cd85f
fix(console): a shared view's draft save keeps the list on the draft, and a second change builds on the first (#36031)
<!-- claude-projects-attribution: {"github_login":"os-sales"} -->
_Requested by **Sales** · [project
thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4UuVwX4pUdM1qvNLSqRZNSvv3)_
repo:objectstack#1 · os-sales · session_01L6bhgW85kwjGaz7HqsmEuv
Fixes #35932
Clause-②: no
Metadata-protocol: none
Skills-docs: none — console runtime behaviour only; no authorable key,
value or published skill text changes
## 维护者速读
- 管理员改共享视图(选页脚汇总、改视图设置)保存草稿后,列表不再闪回已发布版本,一直显示草稿,直到发布;其他用户照旧只看已发布版本。
- 属于列表页重做那一组工作:先前连选两次汇总再发布,只留下第二次,这里两次都保住。
- 出错时列表又会在保存后闪一下骨架屏、回到已发布版本;改动只在控制台前端,撤回此合并即恢复原样。
- 无。
## What changes
**Measured cause (not the one the card first guessed at, one layer
further down).** `persistRuntimeMetadata` does emit the metadata-refresh
pulse on every draft save, and `MetadataProvider` does refetch every
loaded type on it, as the card says. The remount itself comes from what
the route reads while that refetch is on the wire: the type cache sets
the view list to `loading`, and `viewsForObjects` counted only
`ready`/`error` as answered, so the route's object scope read `settled:
false`, `AppContent`'s `routeReadsSettled` went false, the route slot
dropped to its skeleton, and `ObjectView` mounted again. The new mount
lost its `viewDraft` state and read the published view. Measured with a
throwaway probe on the real `MetadataProvider` + `AppContent` (base
`ec243639`): holding the refetched `/meta/view` list sent the route to
the skeleton and the route element mounted twice; holding the by-name
object reads, or holding nothing, did not.
- `MetadataProvider`: a type entry carries `answered` (set when a fetch
settles, cleared only when the entry drops its items: whole-type
`invalidate`, an organization switch). A type refetching in place over
an answer it still holds counts as answered (`typeAnswered`), so a scope
stays settled on the views in hand. This is what `refreshScopes`
("Refetch every scope in place: the items stay until the answers replace
them") and `AppContent`'s `useLazyMetadataSettled` ("A bucket that
answered once and is now refetching keeps its items while it loads, so
it still counts") already said; the view half of the scope did not do
it. The pulse's meaning to its subscribers (chat, marketplace, Studio,
pending drafts) is unchanged: they are still told, and still refetch.
The provider's refresh contract is unchanged; one reader-facing
readiness answer during a refresh changed.
- `objectViewViewCrud.tsx` / `ObjectView.tsx`: the list no longer
remounts on a draft save, so the local draft copy is no longer dropped
by a remount either. The view settings draft bar's Publish and Discard
(`onAfterChange`) now go through `handleDraftBarChange`, which bumps the
refresh counter and drops `viewDraft` once the saved views have been
read again (not before, so the list does not fall back to the
pre-publish read). Before this change Discard relied on the remount to
clear the discarded draft from the screen. `ObjectView.tsx` changes two
lines (the destructure and the `onAfterChange` prop).
- `MetadataProvider`, the app-bundle path (the one the showcase takes,
measured in the browser): the pulse's `clearCache()` also drops the
adapter's app bundle (`AppBundleStore.clear()`), and the bundle then
answers `pending` until it is downloaded again. On a bundle-first route
the view list type is never loaded, so `viewsForObjects` answered
`NO_VIEWS`, not settled, and the route went to its skeleton all the
same. The provider now keeps the items of the last bundle that answered
in this world (`answeredBundleRef`, written on every `ready` peek), and
while a reload is pending `viewsForObjects` answers from them, settled,
when they hold every asked object. An asked object outside them still
waits for the reload, as before (no `/meta/view` list read is started
for it). An organization or session switch (`dropAdapterWorld`) forgets
them. The refresh contract is unchanged: `clearCache`, the pulse, and
what `peekAppBundle` readers see are as they were.
- Reports: `ReportView`'s draft save takes the same seam and the same
pulse; its route reads the `report` bucket, which was already sticky, so
nothing there changes beyond the scope no longer unsettling.
`emitMetadataRefresh` on a draft save is kept: the pending-drafts
surfaces read on it (objectui#13139), and removing it would need a new
ledger-only signal.
## Tests
- New `console/__tests__/AppContent.draftSaveKeepsList-35932.test.tsx`:
real `AuthProvider`, `MetadataProvider`, `AppContent`, `ObjectView` and
persistence seam; only the network is stubbed (the provider adapter with
the refetched view list held open, the list's data source, the metadata
client's `save`); `ListView` is a recording stand-in that counts mounts.
- acceptance 1: an admin's footer pick, while the refresh is on the wire
and after it lands: no skeleton, one mount, the pick drawn;
- acceptance 3: two successive picks (Sum on `amount`, Latest on
`closed_at`): two draft saves, the second body carries both;
- acceptance 2: the writes are draft saves; a reader (not an admin)
served the published view draws it without the admin's calculation and
is offered no pick;
- CONTROL: a whole-type `invalidate('view')` still sends the route to
the skeleton.
- The same on an app with a bundle: the provider's adapter has
`peekAppBundle`, the pulse's `clearCache()` drops the bundle as
`AppBundleStore.clear()` does, and its reload is held on the wire. A
footer pick: no skeleton, one mount, the pick drawn, while the reload is
held and after it lands. Two picks then Publish (through the seam the
draft bar calls): the second draft carries both, and the Publish pulse
keeps one mount and no skeleton. CONTROLS: a first entry held on the
wire (no bundle has answered yet) does not draw the list until it lands,
and a whole-type `invalidate('object')` on the bundle route still shows
the skeleton.
- Why the first version of this pin missed the bundle path: its adapter
had no `peekAppBundle`, so it only ever exercised the no-bundle path.
- New `views/objectViewViewCrud.draftBarChange-35932.test.tsx`: Publish
or Discard bumps the counter and drops the draft copy in the commit that
installs the next saved-views read, and only that one; CONTROL: a read
with no Publish or Discard keeps it.
## Acceptance notes
- **Side effect (accepted by the seat):** after a Publish (draft bar,
chat card, Studio), a package install, or a metadata change noticed from
another tab, the console route also stays mounted now, where it used to
flash its skeleton and remount. The other pulses get the same change,
which is what ui/AGENTS.md commandment eight asks ("refresh data, don't
rebuild UI").
- A draft save still makes every mounted `MetadataProvider` refetch all
its loaded types (one pulse, about ten reads), as before; only the
remount is gone. Narrowing that needs a ledger-only signal and is not
done here.
- **Side effect of the bundle half:** while a reloaded bundle is on the
wire, the route shows the views of the bundle that last answered (the
published views as of before the pulse). The ObjectView draft overlay
keeps the admin's draft on screen meanwhile, and the list shows the new
answer once it lands.
- Overlap: `overlap-check.mjs --branch=HEAD` merges cleanly with
origin/main and with #36026 and #36024; it conflicts with #36037 in
`ObjectView.tsx` on one prop line (this PR's
`onAfterChange={handleDraftBarChange}` beside #36037's new `readOnly`
prop next to the old `onAfterChange`). The resolution keeps both lines.
## Verification
Two-minute check: `pnpm --dir ui exec vitest run
packages/app-shell/src/console/__tests__/AppContent.draftSaveKeepsList-35932.test.tsx`
should print `Tests 8 passed (8)`.
Read first, by risk:
1. `ui/packages/app-shell/src/providers/MetadataProvider.tsx`:
`answeredBundleRef` (written in `peekBundle`, forgotten in
`dropAdapterWorld`) and its use in `viewsForObjects`; then
`typeAnswered`, the `answered` lifecycle (set in `ensureOwnType`'s two
settle arms and the session seed, cleared in whole-type `invalidate`),
and the three `viewsForObjects` / whole-registry `settled` answers.
2. `ui/packages/app-shell/src/views/objectViewViewCrud.tsx`:
`handleDraftBarChange` and its `[savedViews]` effect.
3. The new AppContent pin.
Readings on final head `7001680d` (the bundle-path fix `1a98520d` and
its changeset, on the merge of origin/main `c00be39b`, `397893e5`),
repository objectstack-ai/objectstack. The first round's readings, on
`59e9e7c5`, are kept below where they still stand.
<details><summary>Ablation, bundle half (the answered-bundle branch
removed, the AppContent pin re-run)</summary>
With `scripts/ablation-replace.mjs` on `MetadataProvider.tsx`: the
anchor (the `answered && asked.every(...) ? answered : null` arm of
`viewsForObjects`) went from 1 hit to 0, the marker from 0 to 1, and the
blob from the HEAD blob `00739af7` to `de6251bf`. The pin then read
`Tests 2 failed | 6 passed (8)`: the two new bundle cases (the footer
pick, and two picks then Publish) failed, and the no-bundle cases and
the controls held. On restore the blob was `00739af7` again, equal to
HEAD, and `git diff HEAD` was empty. A first try was refused by the tool
before running anything: its replacement text already occurred in the
file, so the marker count could not move. That try ran nothing and
counts for nothing.
</details>
<details><summary>Ablation, first round (the MetadataProvider half put
back to base, the pin's no-bundle cases re-run, on `59e9e7c5`)</summary>
`MetadataProvider.tsx` restored to base `ec243639`: the pin read `Tests
2 failed | 2 passed (4)`, with the footer-pick case and the two-picks
case red and the reader case and the control green. The file was then
restored to HEAD.
</details>
<details><summary>Affected suites</summary>
- `pnpm exec vitest run --root . --maxWorkers=2 packages/app-shell/`
(all of app-shell, run from `ui/`): `Test Files 2360 passed | 1 skipped
(2361)`, `Tests 22118 passed | 9 skipped (22127)`, exit 0.
- `pnpm run type-check` in app-shell (src and `tsconfig.test.json`):
exit 0.
- `pnpm --dir ui exec vitest run --maxWorkers=2 scripts/` (derived):
`Test Files 172 passed | 2 skipped (174)`, `Tests 5111 passed | 2
skipped (5113)`, lock VERDICT command-exit 0.
- The two 35932 pins: `Tests 8 passed (8)` and `Tests 2 passed (2)`.
</details>
<details><summary>Derived gate families</summary>
`node scripts/pm/dispatch-gates.mjs --commands` on `7001680d`: 38
families, each run, each exit 0. `check:type-check-debt` was first NOT
MEASURED (queue-timeout 99 behind this card's own suite run) and then
re-run under the lock: VERDICT command-exit 0. `--ran` with the codes
recorded: "38 derived famil(ies) accounted for, 38 run, 0 NOT-MEASURED
(a DERIVED zero)". `overlap-check.mjs --branch=HEAD`: clean with
origin/main `96b66ca9`, #36026 and #36024; one conflict with #36037 (see
Acceptance notes). Every other family is CI's.
</details>
<details><summary>Browser reading on the showcase stack (round 2, on the
bundle-path fix)</summary>
Setup: a showcase backend (`objectstack dev --seed-admin`, OS_PORT 4617)
and the Console Vite dev server (:5617, `--strictPort`) serving
app-shell src at `1a98520d`. The view `showcase_project.seat_r2` was
freshly created and published with no calculations. Every
`/api/v1/meta/view` request and every app-bundle request
(`/api/v1/meta/app/APP/bundle`) was held 1500 ms. The route skeleton and
a remount were detected by a DOM probe sampled on every mutation and
every animation frame, as the AppContent pin does. Screenshots are at
deviceScaleFactor 2 in `/mnt/project-files/build-seat1/35932/` (the
`r2-` files).
- (1) Admin, first footer pick (Sum on budget): no skeleton, 0 remounts,
1 bundle reload and 1 view read on the wire. The footer drew `Sum
$1,090,000.00`; the server draft held `budget: sum`.
- (1) Second change (Latest on start_date): no skeleton, 0 remounts.
Footers `Sum $1,090,000.00` and `Latest Dec 5`; the server draft held
`budget: sum, start_date: max`, and published nothing yet.
- (2) Publish from the view-settings draft bar: no skeleton, 0 remounts,
1 bundle reload. The published view held `budget: sum, start_date: max`,
the draft was gone (404), and the footers stayed drawn.
- (3) CONTROL A: a whole-type `invalidate('object')` on the mounted
provider showed the skeleton once and remounted once.
- (3) CONTROL B, the bundle path: a fresh open with the bundle held 4000
ms. The list was first drawn 1018 ms after the bundle answer was
released (5019 ms after it was asked), so nothing was drawn while no
bundle had answered.
- (4) A second user who is not an admin: before Publish, empty footers,
no picker offered, and the published view held no calculation. After
Publish, on a fresh open, both footers were drawn (`Sum $1,090,000.00`,
`Latest Dec 5`).
Round 1 (on `59e9e7c5`, before the bundle half) measured the defect this
round fixes: the first pick showed the skeleton and remounted, the
second draft overwrote the first, and Publish remounted. Its screenshots
are the files without the `r2-` prefix. Its reader case was NOT MEASURED
because the reading script had the reader's password wrong.
</details>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01L6bhgW85kwjGaz7HqsmEuv
<!-- signed: repo:objectstack#1 · os-sales ·
session_01L6bhgW85kwjGaz7HqsmEuv -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent e5449b5 commit 55cd85f
6 files changed
Lines changed: 737 additions & 14 deletions
File tree
- .changeset
- ui/packages/app-shell/src
- console/__tests__
- providers
- views
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
0 commit comments