Repository navigation
test(app-shell): the hooks panel's AI-draft discard case waits out the AI label instead of reading it once - #38887
Merged
Conversation
…e AI label instead of reading it once After the discard, the list row turns to the live label one React commit before the open hook is re-buffered by its install effect. The case read "Guard (AI)" synchronously right after the notice wait, so it passed only when that wait's drain happened to let the effect land first; on a loaded runner it did not. The check is now a waitFor, as in the sibling case. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J8VVAnxMUbgzuoQZg8tcJP
Contributor
|
repo:objectstack@huangyiirene · huangyiirene · session_01J8VVAmaT5PwLmXgonaxjYG 维护者速读
席位意见:同意落地。 席位核对ACCEPT · repo:objectstack@huangyiirene · PR #38887 @
|
Contributor
|
repo:objectstack@huangyiirene · huangyiirene · session_01J8VVAmaT5PwLmXgonaxjYG 2026-12-01T10:00Z · Landing · PR #38887 @
State change: ready for review + auto-merge (Tier S, seat landing). Card #38877 (p0) closes on merge via |
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 Irene · project thread
Fixes #38877
What changes
ui/packages/app-shell/src/views/studio-design/ObjectHooksPanel.aiDraftNotice-36660.test.tsx, case"discard with nothing unsaved asks nothing, drops that one hook's draft at its package, and the live hook is back":
the last check, a synchronous
expect(screen.queryByText('Guard (AI)')).toBeNull(), becomesawait waitFor(() => expect(screen.queryAllByText('Guard (AI)')).toHaveLength(0), { timeout: 8000 }).This is the same wait the sibling case ("discard over an unsaved edit, confirmed") already uses. Test only:
no product code changes, and no changeset.
Why
The 4-hourly full run on
6d163f41(run 46603840101,Test UI (11/16)) failed this case at line 170:Found multiple elements with the text: Guard (AI). The two elementsCI printed are a 12px
spanand the open hook's headerdiv.No commit in the card's range causes it.
6d163f41(3/3).Test UIshard 11/16 run locally at6d163f41(vitest run --shard=11/16) passes: 452 passed, 1 skipped,the same 453 files CI ran.
ResourceEditPage.tsx, the only file fix(app-shell): a Studio item page drops its draft marks when the item is published outside the tab #38860 changes, so the triage's first suspect is cleared. The only file the range00f97b30..6d163f41touches inside that graph isuseNavTargetLabel.ts(fix(app-shell): the app sidebar names an unlabelled object entry by its label once the object read lands #38856). It arrives through the inspectorregistry, and the hooks panel never renders it.
94d552cband6d163f41give this test the same tree, so a commitbisect has nothing to find.
The race. After the discard,
discardAiDraftclears the AI mark and bumps the list nonce. The list re-read thensetListeds the published row, and that commit draws the list row as "Guard". The open hook is re-buffered by theinstall effect (
useEffecton[selected, hooks, refusedHooks]inobjectHooksBuffer.ts), which runs one commit later.findAllByText('Guard')resolves on the first commit. I logged the DOM at that point on three runs, and every run showedthe same thing:
These are exactly the two elements in the CI failure. The next line,
waitForon the notice, passes on its first check,so the case passed only when that wait's closing
setTimeout(0)drain let React's scheduler (setImmediate) flush theeffect first. On a loaded runner the timer can come first.
Forced. I preloaded a module into the vitest workers (
NODE_OPTIONS=--import) that delayssetImmediateby 30 ms,so React's scheduled work lands after a
setTimeout(0), the order a loaded runner can give:Found multiple elements … Guard (AI)at line 170The one-commit gap between the list and the buffer is a passing frame the user never acts in, so the product stays
as it is.
Verification
Clause-②: no
Metadata-protocol: none
Human Minimum
packages/specholds no runtime logic. (not touched)pnpm lintpasses. (eslint on the touched file)main, one pull request.packages/spectouched: its generated artifacts are regenerated and committed. (not touched)content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.Generated by Claude Code