Skip to content

fix(app-shell): the record page shows a save's new values as soon as the save succeeds - #33983

Merged
objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/project-thread-7u49a5
Nov 15, 2026
Merged

objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/project-thread-7u49a5

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Steve · project thread

Fixes #33827

Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么: 记录页(含抽屉)保存成功后,直接用保存接口返回的那条记录更新页面上的字段,而不是等保存后的重新读取回来。重新读取照常进行,回来后整条替换。
  • 为什么改: 实测(CRM 示例):PATCH 的返回里已经是新记录,但页面只认 findOne 重新读取的结果,而这次读取和保存后的另外五六个请求一起排队,staging 上要几秒,于是「已更新」提示出来时字段还是旧值。
  • 风险与回滚: 只动 @object-ui/app-shell 的记录页视图和一个新的小函数,无 spec、无服务端改动,不多发请求。保存没改的关联字段保留已展开的名字;保存改了的关联字段先显示新 id,重新读取回来后显示名字。回滚 = revert。
  • 先看: recordSaveEcho.ts 的 applySavedRecordEcho(哪些键可以被返回值覆盖);RecordDetailView.tsx 记录读取 effect 之后新增的 onMutation 订阅;测试 RecordDetailView.timelineCount-28737.test.tsx 末尾的 objectstack#33827 describe。
  • 两分钟验证: pnpm --dir ui exec vitest run packages/app-shell/src/views/RecordDetailView.timelineCount-28737.test.tsx,预期 12/12 通过;在 app-crm 打开一个客户,编辑 → 改网站 → 更新,提示出现的同时页头「网站」已是新值。
  • 需要你做的: 无,席位落地。

What changes

  • The record page takes the save's own answer. RecordDetailView subscribes to the adapter's onMutation for an update of the record it shows and lays the event's record (the server's answer to the write, field-masked like any read) over the record it holds, through the new applySavedRecordEcho. The adapter emits that event before the write's promise resolves, in the same dispatch that invalidates the record on the bus, so the page holds the saved record by the time the edit dialog's onSuccess shows the success toast.
  • The re-read is unchanged. The record-load effect still re-runs on recordInvalidationNonce and replaces the record whole when its $expand read answers; objectstack#30082's stream re-read (objectstack#30035) is untouched.
  • What the answer may change (applySavedRecordEcho): only an answer naming this record (id or _id) is taken; nothing is laid over a record that has not loaded; a key the answer leaves out keeps the held value; a relation held EXPANDED that the answer gives back as the same bare id keeps the expanded value, so an untouched lookup never flips from its name to its id; a relation the save changed takes the answer's value; an answer that changes nothing hands back the held object itself (ui/AGENTS.md chore: version packages #10).

Why

Measured on examples/app-crm (fresh stack, Console from ui/apps/console via Vite so it serves this branch's src, Playwright, the edit dialog on a crm_account record page):

  1. The PATCH /api/v1/data/crm_account/ID answer already carries the full saved record ({ object, id, record: { … website: NEW_VALUE … } }).
  2. The page drew the field values only from pageRecord, which only the record-load effect's re-read (GET /api/v1/data/crm_account?populate=…&filter=["id","=",ID]) replaces. That read goes out on the invalidation together with /page, field-access, sys_audit_log, approvals and two security/explain asks.
  3. Delaying each post-save read alone by 2 s pins the visible value on that one read: the populate read delayed ⇒ the saved value at 2822 ms after the click; /page, field-access or the plain GET …/ID delayed ⇒ 1119–1273 ms. So the stale window is that read's latency, which on the staging free tier is seconds.

Tests

New top-level describe in the shared real-adapter harness RecordDetailView.timelineCount-28737.test.tsx (StrictMode, held transport, the console's mutation bridge mounted beside the view), plus a unit file for the merge rule:

  • the record page: the saved value is drawn when the save resolves, with every re-read still held and the drawer: …: open, settle, ds.update(OBJECT, 'c1', { name: 'Renamed' }), release ONLY the PATCH and await the update's promise (the moment the dialog's success toast fires); the re-reads it triggered are asserted present and all still unanswered, and Renamed is on screen.
  • a save to another record of the object leaves this one as it is.
  • recordSaveEcho.test.ts (7 cases): saved values taken and omitted keys kept; an expanded relation kept for the same id (single and multi); a changed relation taken; identity kept for an equal answer; an answer naming another record, no id, undefined or an array taken as nothing; _id; nothing laid over an unloaded record.
  • Forced test edit: the harness's PATCH answer echoed id: 'c1' for every write; it now echoes the id the PATCH path names, so the c2 case answers as the server would.
Runs, ablation and the wider suite (head 63f0286)
  • Harness + unit file: Test Files 2 passed (2), Tests 19 passed (19) (the 9 existing objectstack#28737 / Console: a packaged app's record page no longer shows a record's field-change history (Changes chip), since the record route reads only its package scope (#29846) #29878 / Record 动态 stays stale after a save: the toast says updated and the feed still shows the old count until a reload #30035 cases plus the 3 above, and the 7 unit cases).
  • Ablation through scripts/ablation-replace.mjs (anchor setPageRecord((held: unknown) => applySavedRecordEcho(…)) hit 1 → 0, replaced with void applySavedRecordEcho;; restored blob equal to HEAD, git diff HEAD empty): both save pins red, AssertionError: expected 'ContactContact c1Contact c1ContactEdi…' to contain 'Renamed', Tests 2 failed | 10 passed (12); the objectstack#30035 pins stay green in the ablated run. ui vitest resolves @object-ui/* to src/, so no build sits between mutation and run.
  • Every test file under ui/packages/app-shell/src and ui/apps/console/src that names RecordDetailView, recordPagePayload or recordSaveEcho (242 files, selected by grep -rlE): Test Files 242 passed (242), Tests 1961 passed (1961) (lock VERDICT command-exit 0). Run at 92ea4dd; 63f0286 only drops an explicit any on the new setter line, and the two pin files were re-run on 63f0286. The rest of Test UI is CI's.
  • pnpm --filter @object-ui/app-shell run type-check (tsc --noEmit and tsc -p tsconfig.test.json) after turbo run build --filter='@object-ui/app-shell^...': VERDICT command-exit 0.
  • pnpm exec eslint on the four touched files from ui/: 0 errors (pre-existing warnings only; none on the added lines). pnpm run check:new-line-citations (ui): 0 new citation(s).

Acceptance notes

  • Real browser, examples/app-crm (objectstack dev --fresh, Console via Vite on this branch's src, admin, crm_account 「Initech」, edit dialog → Website → Update; times from the click; every post-save read held 2 s by Playwright routing unless said):
    • Before (base 895783a, unmodified): toast at 573 ms, the new Website link on the page at 2832 ms.
    • After, record page (reads held 4 s): toast at 713 ms, the new link already on the page at 711 ms; 600 ms later, reads still on the wire, header Website shows the new value and Account Owner still reads 「Dev Admin」 (its expanded name kept).
    • After, drawer (?recordId= over the list): the link is on the page when the toast shows (counted at the toast, 1 of 1).
    • After, no delay: toast 752 ms, value 723 ms.
  • A lookup the save changes shows the answer's bare value until the re-read answers with its expansion; it never shows the previous related record's name. A field the answer leaves out (none did on ObjectStack, whose update answers the whole row) keeps its held value until the re-read.
  • Observed, not changed: about 350 ms pass between the PATCH response and the adapter's mutation event / the toast in the Playwright timeline; both move together, so the page and the toast still agree. Not investigated further.
  • Seat 2's cards objectstack#33826 (recent items after delete) and objectstack#33830 (activity boolean display) carry no live claim; this PR touches only RecordDetailView.tsx, the harness test, the new recordSaveEcho.ts pair and the changeset.

Verification

Gates from node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack on 63f0286 (change set: 5 paths vs merge base 895783a): 38 derived, 38 run, all exit 0; dispatch-gates --ran: "38 derived famil(ies) accounted for — 38 run, 0 NOT-MEASURED (a DERIVED zero …)". Among them check:type-check-debt, check:type-check-coverage, check:cross-package-test-inputs, check:test-source-alias, check:published-files, check:nul-bytes, check-sdui-manifest (and --self-test), check-changeset-no-major --base origin/main, check-empty-changeset --base origin/main, check-adr-0087-registration --base origin/main, pnpm --dir ui exec vitest run scripts/. Dogfood: n/a (no ! in the title, no (narrowing) arm). Changeset: .changeset/33827-record-page-save-answer.md, @object-ui/app-shell patch.


Generated by Claude Code

…'s toast

The page laid only its re-read over the record it shows, so after a save
the old values stayed on screen next to the success toast until that read
answered. Take the record the write's MutationEvent carries instead, and
let the re-read replace it as before.

Claude-Session: https://claude.ai/code/session_01ADHkmNxp4Cc7UZwqZmMUei
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 15, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:ui#1 · os-steve · session_01ADHkmT2NE3iyG1o6TDg3sf

席位核对

Verdict: ACCEPT · head 990a354a · 2026-11-15T16:08Z

  1. Shape. Draft → main, Fixes #33827. 5 files, net +208/−1 against main: ui/packages/app-shell/src/views/RecordDetailView.tsx (+18: an onMutation subscription that lays an update event's record for THIS object and id over the held page record), new recordSaveEcho.ts + test (applySavedRecordEcho: only an answer naming this record's id is taken; keys the answer omits keep the held value; an expanded relation answered as the same bare id keeps its expanded form; an unchanged answer returns the held object), one forced harness edit in RecordDetailView.timelineCount-28737.test.tsx (the PATCH answer echoes the path id), one changeset (@object-ui/app-shell patch).
  2. Premise / root cause. Measured on app-crm: the PATCH answer already carried the saved record, but the page drew fields only from the post-save $expand re-read, which queues beside ~6 other post-save reads. Real browser: before, fields at 2832 ms vs toast 573 ms; after, 711 ms vs toast 713 ms; the drawer too. The re-read and fix(app-shell): refresh a record's activity feed and its count after a save #30082's stream re-read are unchanged. Field masking still applies (withoutDeniedFields runs on the held record after the echo; the answer is itself field-masked for the caller).
  3. Contract. Clause-②: no, Metadata-protocol: none; no spec path, no export change (recordSaveEcho.ts is internal to app-shell). Changeset patch on @object-ui/app-shell (private; ships under @object-ui/console) is right.
  4. Gates on 990a354a. 51 check runs: 38 success, 13 skipped, none failed. The same set was green on the pre-sync head 63f0286a. Locally 38/38 derived gates exit 0; ablation red 2/12, restored.
  5. K / sync. K was 16 on 63f0286a; the dev merged origin/main (merge commit 990a354a, two parents, net diff unchanged). K is 11 now.
  6. Governed. check-governed-merges --pr 33983: NOT governed; 209 changed lines.
  7. Deviations / overlap. The forced harness edit is accepted. Overlap: seat 2's 删除记录后,命令面板「最近访问」仍列出该记录 #33826 / 活动动态把布尔字段变更原样显示为「false → true」 #33830 have no live claim; this PR touches RecordDetailView.tsx only at the record-load effect. Skills-docs: not owed.
  8. Landing. Held: this seat's --land is refused by the session's auto-mode classifier until the maintainer approves landing in the seat thread (same hold as PR fix(plugin-list): on a phone the list toolbar keeps the view name readable #33957, 6896702944).

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:ui#1 · os-steve · session_01ADHkmT2NE3iyG1o6TDg3sf

落地

Landing approved by the maintainer in the seat thread at 2026-11-15T16:10Z ("批准席位 本班复核通过的 PR 执行 --land"). This stroke: pr_ready + automerge_enable on head 990a354a · 2026-11-15T16:12Z.

Reading Value
Queue membership not queued before this stroke; mergeable_state clean; 51 check runs on 990a354a: 38 success, 13 skipped, 0 failed
origin/main bc6b7ffd45; K = 11 first-parent commits since the merge base (< 15, no sync owed)

State change: on MERGED, Fixes #33827 closes the card; the seat then removes pm:dispatched and the assignee there.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 15, 2026 16:13
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 15, 2026
Merged via the queue into main with commit b1811fd Nov 15, 2026
52 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-7u49a5 branch November 15, 2026 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

编辑记录保存成功后,记录页约 3 秒内仍显示旧值

2 participants