docs: note schema-form microtask batching gotcha for tests in ui-v2 AGENTS.md - #23007
Draft
github-actions[bot] wants to merge 1 commit into
Draft
docs: note schema-form microtask batching gotcha for tests in ui-v2 AGENTS.md#23007github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
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.
Automated AGENTS.md update triggered by commit a37d448.
This PR was generated by Claude Code analyzing the diff from the latest push to main and updating any stale AGENTS.md files.
Why this belongs in AGENTS.md
Path: ui-v2/src/components/AGENTS.md Proposed text: Added one bullet to the Testing section: "**Schema forms** (`@/components/schemas`, used by deployment/block/work-pool parameter forms): `SchemaFormInputObject` batches child value changes via `queueMicrotask`, not a debounce timer. After firing input events, await a microtask (`await act(async () => { await Promise.resolve(); })`) to see propagated values — `vi.useFakeTimers()`/`runAllTimers()` no longer applies here." Non-obvious evidence: The diff rewrites `schema-form-input-object.tsx`'s value-propagation mechanism from a 10ms `useDebounceCallback` flush to a `queueMicrotask`-based pending-patch map. The existing test suite previously relied on `vi.useFakeTimers()` + `vi.runAllTimers()` to flush the debounce; the diff replaces those calls with `await act(async () => { await Promise.resolve(); })`. A future agent writing or fixing a test against any schema-driven form would naturally reach for fake timers (the previously-correct pattern) and get a silently-stale/failing test, since nothing in the component's public API signals the timing model changed. Cross-cutting scope: `SchemaFormInputObject`/`LazySchemaForm` back parameter forms across at least seven unrelated domains (deployment run parameters, deployment schedule overrides, block document create/edit, work-pool base job template, flow-run resume dialog), confirmed via grep. This is a testing-pattern contract for the whole schema-form subsystem, not a detail of one call site. Why not code comment/docstring: The component itself already has an inline comment explaining *why* patches are retained until acknowledged (the implementation rationale). What's missing is the *consumer-facing* contract for anyone testing code built on top of this component elsewhere in the tree — that lives naturally in the shared components AGENTS.md's existing Testing section, which already collects analogous JSDOM/timing gotchas (CSS custom properties, matchMedia, virtualized lists) in the same bullet-list format. Durability: The microtask-batching behavior is a structural property of the component's flush strategy, not tied to the parameter-overrides feature that triggered this diff. It will keep being the reason tests against any schema form need `await act(async () => { await Promise.resolve(); })` long after this PR is old. Counter-evidence checked: Grepped ui-v2/AGENTS.md, ui-v2/src/components/AGENTS.md, and ui-v2/src/hooks/AGENTS.md for "debounce", "runAllTimers", "useFakeTimers", "SchemaForm", "microtask" — no existing mentions, so nothing was stale to correct and this is net-new guidance. Confirmed the component's own code comment covers implementation rationale only, not the test-authoring implication, so no duplication.Changed files in triggering push