Repository navigation
fix(Chat): ChatToolCalls and ChatDictationButton without a required prop name it and the fix in development - #12420
josephfarina wants to merge 3 commits into
Conversation
…rop and the fix in development
…rop name it and the fix in development
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet, and it runs once the pull request targets main and is marked ready for review. It lands only after #12386, which adds the devPropError helper this change calls. Both checks follow the components' required-prop contracts: the new message tests fail on the base with the old TypeErrors and pass here, production renders throw exactly as before, and the minified production bundle of ChatToolCalls is byte-identical.
- Non-blocking: the production test in
Chat.missingProps.test.tsxonly checks that the render throws something other than the development message, so pinning the TypeError text, asSelector.missingOptions.test.tsxpinsoptions is not iterable, would prove the "throws as before" claim.
Claims and files checked
Review mode: full; reason: no-earlier-review
Claims
- The base branch adds the shared
devPropErrorhelper this change calls: verified. - Without its required prop, each component throws a TypeError from inside itself that names neither the component nor the prop: verified on the base (
reading 'length'andreading 'isSupported'; the other example forms in the description do not occur for these two). callsanddictationare required by the types and the component records, and each is read on the first render: verified.- In development each component checks the prop and throws a
Component: messageerror that names the prop and gives an example: verified by the new tests. - The component records allow neither prop to be omitted: verified.
- The error comes from
devPropErrorinutils/devWarning.ts: verified. - One inline development check per component, dropped from a production bundle: verified; the message is absent from both production bundles.
- Before the change, each render in the test file throws a TypeError: verified; four of the six new tests fail on the base.
- After the change, each development render throws the component's message: verified.
- In production each render throws as before: verified for seven inputs on both trees.
- Production bundles keep their size, with
ChatToolCallsbyte-identical andChatDictationButtondiffering only in minified names: verified. - The new test file covers the development message, production behavior and the development-only bundle for each component: verified.
- One defect, no tagalong, no new public API, visual, default or interaction change, and no internal context: verified; the generated API comparison lists no rows.
- Tests on the Chat and utils folders, the Core type check, lint and formatting pass: verified (94 files, 1,769 tests).
- Changeset: in development both components throw an error that names the missing prop and shows the fix, instead of a TypeError: verified.
- Changeset: production output is unchanged: verified for behavior and bundle size; the
ChatDictationButtonbundle differs only in minified names.
Files
.changeset/chat-missing-props-error.md: clear.packages/core/src/Chat/Chat.missingProps.test.tsx: the non-blocking production-assertion note above.packages/core/src/Chat/ChatDictationButton.tsx: clear.packages/core/src/Chat/ChatToolCalls.tsx: clear.
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet; it runs once the pull request targets main and is marked ready for review. It lands only after #12386, which adds the devPropError helper this change calls. The production tests now pin the exact errors each component threw before, which settles the earlier test note.
- Miss: non-blocking. The
ChatDictationButtonmessage names onlyuseSpeechRecognition(), while the component's JSDoc and block templates pair it withuseChatDictation; naming both, and updating the expected message in the test, would point builders to the documented hook.
Claims and files checked
Review mode: incremental; reason: none
- Changed rules since the last review (0): none.
- Claim (changeset): in development both components throw an error that names the missing prop and the fix. Verified: the development tests in
Chat.missingProps.test.tsxpass on this head. - Claim (changeset, description): this replaces a TypeError from inside the component. Verified: the same tests fail on the base with
Cannot read properties of undefined (reading 'length')and(reading 'isSupported'). - Claim (changeset, description): production output is unchanged. Verified: the production tests pin those base errors and pass on base and head; the minified production bundle of
ChatToolCallsis byte-identical andChatDictationButton's keeps its size with only minified names changed. - Claim: the change is stacked on #12386, which adds
devPropError. Verified: the base is #12386's head, andutils/devWarning.tsexportsdevPropError. - Claim: each prop is required by the types and the component record, and is read on the first render. Verified:
ChatToolCalls.tsx:95,:597;ChatDictationButton.tsx:51,:136; both records' public contract. - Claim: the error uses Core's
Component: messageform throughdevPropError. Verified:ChatToolCalls.tsx:576,ChatDictationButton.tsx:128. - Claim: one inline
NODE_ENVcheck per component, which a production bundle drops. Verified:ChatToolCalls.tsx:575,ChatDictationButton.tsx:127, and the bundle tests. - Claim: the regression test covers the development message, the exact production error and a development-only bundle message. Verified: 6 tests pass on this head; 4 fail on the base.
- Claim: no new public API, no tagalong and no internal context. Verified: the built API comparison lists no change, and the diff holds only the two checks, the test and the release note.
- Claim: vitest on the touched directories and utils, tsc, eslint and prettier pass. Verified on this head.
- File
.changeset/chat-missing-props-error.md: clear. - File
packages/core/src/Chat/Chat.missingProps.test.tsx: clear. - File
packages/core/src/Chat/ChatDictationButton.tsx: non-blocking note on the message wording (line 131). - File
packages/core/src/Chat/ChatToolCalls.tsx: clear.
| throw devPropError( | ||
| 'ChatDictationButton', | ||
| 'dictation', | ||
| 'is required: the value of useSpeechRecognition(), for example dictation={dictation}.', |
There was a problem hiding this comment.
Miss, non-blocking: this names only useSpeechRecognition(), while the component's JSDoc (line 109), the prop docs and both block templates pair it with useChatDictation. Naming both points builders to the documented hook:
'is required: the value of useChatDictation() or useSpeechRecognition(), for example dictation={dictation}.',The expected message in Chat.missingProps.test.tsx changes with it.
PR Analysis Report🔎 Preview ·
|
- #12072 fix(templates): payment form and checkout wrap the summary below the form on a narrow first paint Author: Joey Farina <[email protected]> - #12274 fix(core): cap the Selector family's trigger-width list minimum at the viewport Author: josephfarina <[email protected]> - #12215 fix(cli): advise keeping one dependency when two packages declare one provider ID Author: Joey <[email protected]> - #12322 [experimental] export --reverse: use the project's own copy of an aliased file, or restore the page's copy with its paths entry Author: josephfarina <[email protected]> - #12403 docs(core): Text's as and PowerSearch's statusVariant list every value their types allow Author: Joey Farina <[email protected]> - #12494 fix(templates): dashboard templates use page sections, not cards, for page regions Author: Joey Farina <[email protected]> - #12282 fix(cli): theme build --check and doctor ignore which CLI release, and which command name, built a theme Author: Joey Farina <[email protected]> - #12420 fix(Chat): ChatToolCalls and ChatDictationButton without a required prop name it and the fix in development Author: Joey Farina <[email protected]> - #12205 fix(cli): equally scored icons put first one whose id the query names in full Author: Joey Farina <[email protected]> - #12455 fix(core): a theme sets the room between a checkbox or a switch and its label Author: josephfarina <[email protected]> - #12658 perf(cli): the first theme build after a CLI upgrade reuses the JavaScript it compiled from a theme's local modules Author: Joey <[email protected]> - #12323 [experimental] export: React logs no render timings while the export draws a page Author: Joey Farina <[email protected]>
|
Landed in #12713. |
Builds on #12386 (merged), which adds the shared
devPropErrorhelper. Review the commits above it.User impact
Each component below throws a TypeError from deep inside itself (
… is not iterable,Cannot read properties of undefined (reading …),… is not a function) when a caller leaves out its required prop. The message names neither the component nor the prop.callsdictationProblem and solution fit
Each prop is required by the component's types and its record's public contract, and the component reads it on its first render. In development, each component now checks the prop first and throws an error in Core's
Component: messageform that names the prop and gives an example, for example:Expected behavior and authority
The component records list each prop as part of the public contract; none allows the prop to be omitted. The error uses
devPropErrorfromutils/devWarning.ts.Smallest restoration
process.env.NODE_ENV !== 'production'check per component that throwsdevPropError. A production bundle drops it.Evidence
Chat/Chat.missingProps.test.tsx(development message, the exact production error, and the message is in a development bundle only, per component).Scope
Components: ChatToolCalls, ChatDictationButton
Testing
CI=1 vitest run --project uion each touched component directory pluspackages/core/src/utils,tsc -p packages/core, eslint and prettier on the changed files.