Repository navigation
fix(studio): Save waits for the CEL verdict to reach the page before it reads the hold - #36636
Merged
Merged
Conversation
… the hold The top bar's Save read the buffers' held state a fixed 50 ms past the lint debounce, but an action predicate's verdict climbs to the Data pillar's Save entry through four effect-driven renders. On a busy main thread the Save read the pre-edit verdict and sent the unparsable text (DataPillar.panelHold-27629, 4 of 7 runs red under a CPU stressor). Save now also awaits a transition-priority render of its own, which React commits only after every default-priority render, the verdict's last hop included. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JQwxbXCSJnUMMhWxyBmuqA
Contributor
Author
|
repo:objectstack#1 · os-warren · session_01JQwxbZeHNsF3RWcWpj7rGj 维护者速读修好 Studio 里一个偶发失败的测试,它会把别人的 PR 踢出合并队列。原因在产品本身:系统忙时,顶部「保存」可能读到旧的校验结果,把写错的条件表达式也存了进去。现在保存会先等校验结果传到位再判断。 席位核对 — ACCEPT (L1) · repo:objectstack#1 · head
|
This was referenced Nov 23, 2026
Merged
feat(console): preview images, PDF, text and CSV in the page from attachments and file fields
#36587
Merged
9 tasks done
247257110
pushed a commit
to 247257110/objectstack
that referenced
this pull request
Nov 23, 2026
… of the object (objectstack-ai#36651) <!-- claude-projects-attribution: {"github_login":"os-warren"} --> _Requested by **Warren** · [project thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ82MfFjFxvJRAyoku6XCvWt4)_ Fixes objectstack-ai#36648 Fixes objectstack-ai#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 objectstack-ai#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 objectstack-ai#36636: `StudioDesignSurface.tsx` and `useMetadataRefreshNonce.ts` are byte-identical between objectstack-ai#36636's parent `99ece3c4` and `main`; the window predates it. objectstack-ai#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 | |:--|:--|:--|:--| | objectstack-ai#36636's parent `99ece3c4` | panelGate | 20 | 2: both `expected "vi.fn()" to not be called` (:167, :175), the objectstack-ai#36619 verdict race objectstack-ai#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 (objectstack-ai#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 objectstack-ai#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 - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; `pnpm lint` passes. - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. - [x] 6. `packages/spec` touched: its generated artifacts are regenerated and committed. (not touched) - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English. - [x] The *Before Submitting* list in CONTRIBUTING.md is done. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01JQwxbXCSJnUMMhWxyBmuqA <!-- signed: repo:objectstack#1 · os-warren · session_01JQwxbXCSJnUMMhWxyBmuqA --> --------- Co-authored-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Warren · project thread
Fixes #36619
What changes
studioSaveBar.tsx: the top bar's Save, after its existing wait past the lint debounce, now also awaits a render of its own at transition priority (useRendersSettled) before it reads the buffers'held. React commits that render only once no default-priority render is left, so the verdict's whole effect chain has reached the buffer's Save entry when Save reads it. No test file changes; the test is not skipped, retried, narrowed or slowed.Why — root cause (product race, not test timing)
Both red cases fail on the first Save, before the tab is ever left: under load, all 4 red runs failed at
DataPillar.panelHold-27629.test.tsx:233(expect(save).not.toHaveBeenCalled()right after typingrecord.status ==and pressing Save). Case (b)'sstudio-held-messagemiss is the same race one step later: that Save already sent the broken text, the draft is clean, so no hold is left to name.The Save read
helda fixed 50 ms pastLINT_DEBOUNCE_MS(VERDICT_SETTLE_MS). An action predicate's verdict reaches the object's Save entry through four effect-driven renders after the lint resolves:CelPredicateField→ConditionBuilder(onBlockingIssuesChangeeffect) →ActionDefaultInspector(effect) →ObjectActionsPanel(onCelVerdictsChangeeffect) →DataPillar(held, copied into the entry ref by a layout effect). On a busy main thread the lint timer and Save's timer come due in the same timer pass, so Save's continuation runs before any of those renders and reads the pre-edit verdict (count: 0, judged ontrue), then sendsvisible: "record.status ==". That is the product sending a formula its check has not judged, the invariant the Save bar's header states; the rule-guard cases have a shorter chain and stayed green.Out of scope (Acceptance notes): the fix covers verdicts already reported when Save's timer fires. A lint still in flight then (a first-load dynamic import of the CEL engine on a slow network) is not awaited; closing that needs a pending-check signal from
metadata-admin/CelPredicateField.tsx, outside this card's file surface. Not reproduced; recorded here only.Verification
Loaded box: 4-core container, 4 busy-loop CPU stressors,
vitest run --maxWorkers=2on the file alone, consecutive runs.origin/main9e2a4ac)Every app-shell test file that saves through the top bar (27 files, 155 tests, the ones using
pressStudioSaveoruseStudioSaveCoordinator): green locally.Local
tsc --noEmiton app-shell reports no error in the changed file beyond the container's unbuilt@object-ui/*module resolution, which every file shares; the type-check lanes are CI's.Clause-②: no
Metadata-protocol: none
Human Minimum
packages/specholds no runtime logic.pnpm lintpasses.main, one pull request.packages/spectouched: its generated artifacts are regenerated and committed. (not touched)content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.🤖 Generated with Claude Code
https://claude.ai/code/session_01JQwxbXCSJnUMMhWxyBmuqA