Skip to content

fix(studio): an edit typed as a Save ends survives the Save's re-read of the object - #36651

Merged
objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/project-thread-d5iokd
Nov 23, 2026
Merged

objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/project-thread-d5iokd

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Warren · project thread

Fixes #36648
Fixes #36653

What changes

  • StudioDesignSurface.tsx, the Data pillar's object load: a re-read on the live-metadata pulse alone (refreshOnly) no longer clears the dirty flag, the kept CEL verdicts and the served verdict as its effect starts. It drops them when it installs, after the existing in-flight check (refreshOnly && objBuffersHeldRef.current ⇒ keep the buffer). A full load (another object, a publish, a reload) resets at the start as before.
  • New DataPillar.pulseAfterSave-36648.test.tsx (2 cases): types into the window deterministically (the hook wrapped to report its release; the keystroke runs in the microtask after it) and pins that the edit stays, that a valid one is sent by the next Save, and that an unparsable one is held. Both cases fail on main (expected '' to be …: the edit is gone) and pass here.
  • DataPillar.panelGate.test.tsx and panelHold-27629 are untouched: nothing skipped, retried, narrowed or slowed.

Why — root cause (product, pre-existing; not #36636)

The red in run 45133910959 is the second Save of the first case (panelGate.test.tsx:166): findByTestId('studio-save') ran its full 4 s and the button never came back after the case typed record.status ==. The button is drawn only while the page holds an edit, so the edit was gone.

A Save's publish sends the live-metadata pulse. The pillar holds it while the buffer has work (useMetadataRefreshNonce(objBuffersHeld)) and releases it in an effect the moment the Save ends; the next render's load effect re-reads the object. That effect called setDirty(false) (and cleared the verdicts) as it started, before the in-flight check. A keystroke landing between the release and that effect therefore lost its dirty flag; the read, finding nothing held, installed the server's body over it; the edit and the Save button went with it. The window is one scheduler gap, which a loaded merge-queue runner can open between the case's Save and its next keystroke. For an author it is a keystroke right after pressing Save that silently disappears.

Not #36636: StudioDesignSurface.tsx and useMetadataRefreshNonce.ts are byte-identical between #36636's parent 99ece3c4 and main; the window predates it. #36636 changed only when Save reads held, before any write.

Verification

Loaded box: 4-core container, 4 busy-loop CPU stressors, vitest run --maxWorkers=2, 20 consecutive runs.

tree files runs red
#36636's parent 99ece3c4 panelGate 20 2: both expected "vi.fn()" to not be called (:167, :175), the #36619 verdict race #36636 fixed
main e9fa6b5d panelGate 20 0 (the :166 timeout did not recur in 20; the deterministic case above reproduces it)
this head 6e21473c panelGate + panelHold-27629 + pulseAfterSave-36648 20 0: 20 of 20 green in a row, all 10 cases each run

Also green locally: every studio-design test file that saves through the top bar, reads the pulse, or is a DataPillar.* suite (50 files, 259 tests).

Also: the unit-project red that blocked this PR (#36653)

Test UI (7/16) went red on romanizeHan.test.ts:24 (expected ' weixiu zhongxin ' to be '维修中心'), a file the fix above does not touch. Cause: test order, not product. The unit project runs files with isolate: false; layout/__tests__/designModeMenuCreate-36364.test.ts (landed 08:11Z with #36606) calls loadHanRomanizer() in its beforeAll, so when it ran earlier in the same worker the shared romanizeHan module was already loaded and the "before the dictionary has loaded" cases read romanized text.

  • Reproduction: vitest run --project unit --maxWorkers=1 designModeMenuCreate-36364.test.ts romanizeHan.test.ts fails at :24 with CI's exact message on main 3cf6a44b.
  • Fix (separate commit, test only, no product code, no changeset): the before-load describe reads its own instance (vi.resetModules() + dynamic import('./romanizeHan')) and still pins "unchanged and pending until loaded"; a new case pins that the same instance stops being pending once it loads. Nothing skipped, retried or narrowed.
  • Counts: neighbour first, --maxWorkers=1, 4 busy-loop CPU stressors on a 4-core box, 20 consecutive runs: 20 of 20 green (red before). Alone: green.

Clause-②: no
Metadata-protocol: none

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic.
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; pnpm lint passes.
  • 4. One issue, one branch off an up-to-date main, one pull request.
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec touched: its generated artifacts are regenerated and committed. (not touched)
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English.
  • The Before Submitting list in CONTRIBUTING.md is done.

🤖 Generated with Claude Code

https://claude.ai/code/session_01JQwxbXCSJnUMMhWxyBmuqA

The Data pillar's re-read on the live-metadata pulse cleared the dirty
flag and the kept CEL verdicts as its effect started. The pulse is
released the moment a Save ends, so a keystroke landing between that
release and the effect lost its dirty flag, the read then saw nothing
held and installed the server's body over it, and the top bar's Save
went with the edit. A pulse-only re-read now drops the buffer's state
only when it installs, behind the existing held check.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JQwxbXCSJnUMMhWxyBmuqA
The `unit` project runs files with isolate: false, so a file earlier in the
same worker that loads the pinyin dictionary (designModeMenuCreate-36364
does, in its beforeAll) left the shared module instance loaded, and the
"before the dictionary has loaded" cases read romanized text. Those cases
now read their own instance (vi.resetModules + dynamic import), and pin
that the same instance stops being pending once it has loaded.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JQwxbXCSJnUMMhWxyBmuqA
@github-actions github-actions Bot added the tests label Nov 23, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-warren · session_01JQwxbZeHNsF3RWcWpj7rGj

维护者速读

修好 Studio 里又一个偶发失败的测试(它把别人的 PR 踢出过合并队列)。原因在产品本身,而且早就存在,不是上一个修复带来的:在数据设计里点「保存」后,页面会重新读取对象;如果用户在保存刚结束的一瞬间又敲了字,这次输入会被服务端的旧内容盖掉,「保存」按钮也一起消失。现在这次输入会被保留,可以接着保存。
新增一个能稳定复现的测试;高负载下连跑 20 次全绿。
CI 全绿,242 行(大半是新测试),非受管面,席位落地。
另外顺手修了一个无关的偶发失败测试(#36653,中文转拼音的测试受同批其它测试影响),它挡住了这个 PR。
要你做的:无。

席位核对 — ACCEPT (L1) · repo:objectstack#1 · head 0c2d1535 · 2026-11-23T09:52Z

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 23, 2026 09:53
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 23, 2026
Merged via the queue into main with commit 9348f02 Nov 23, 2026
57 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-d5iokd branch November 23, 2026 10:13
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

2 participants