fix: FollowupPanel input submission bug#516
Conversation
Co-authored-by: ngoiyaeric <115367894+ngoiyaeric@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
|
WalkthroughThe followup panel component was refactored to improve form data handling and identifier generation. Form data construction now explicitly appends the input value using a standard key instead of relying on event target data. User message identifiers switched from timestamp-based to UUID-based generation via nanoid. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 📜 Recent review detailsConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used🧬 Code graph analysis (1)components/followup-panel.tsx (4)
🔇 Additional comments (3)
✏️ Tip: You can disable this entire section by setting Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
The fix aligns with how controlled React inputs should be submitted, but handleSubmit still allows whitespace-only submissions, which can generate empty messages and unnecessary submit calls. There’s also a minor quoting inconsistency ("input") that can be cleaned up for consistency.
Additional notes (1)
- Maintainability |
components/followup-panel.tsx:21-26
The key name"input"is now hardcoded here. If the server action expects a specific field name, this is fine, but it increases the chance of client/server drift vs. using a shared constant (or deriving the field name from the actual<Input name=...>when possible). Consider centralizing the field key so future refactors don’t silently break submission.
Summary of changes
What changed
- Updated
FollowupPanelform submission to buildFormDatamanually vianew FormData()andformData.append('input', input)instead ofnew FormData(event.currentTarget). - Swapped user message ID generation from
Date.now()tonanoid()for consistency. - Added
nanoidimport from@/lib/utils.
Files touched
components/followup-panel.tsx
| const handleSubmit = async (event: React.FormEvent<HTMLFormElement>) => { | ||
| event.preventDefault() | ||
| const formData = new FormData(event.currentTarget as HTMLFormElement) | ||
| const formData = new FormData() | ||
| formData.append("input", input) | ||
|
|
||
| const userMessage = { | ||
| id: Date.now(), | ||
| id: nanoid(), | ||
| isGenerating: false, | ||
| component: <UserMessage content={input} /> | ||
| } |
There was a problem hiding this comment.
Manual FormData construction fixes the controlled-input issue, but this handler currently trusts input as-is. If the user submits whitespace, you’ll append an empty/meaningless message and still call submit, which can create confusing UX and unnecessary server work. Consider trimming and early-returning (or disabling submit) when empty.
Suggestion
Trim and guard against empty submissions before building messages / calling submit:
const handleSubmit = async (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault()
const value = input.trim()
if (!value) return
const formData = new FormData()
formData.append('input', value)
const userMessage = {
id: nanoid(),
isGenerating: false,
component: <UserMessage content={value} />
}
// ...
}Reply with "@CharlieHelps yes please" if you'd like me to add a commit with this suggestion.
Fixed a bug where the follow-up question input in the
FollowupPanelcomponent failed to submit correctly.The issue was caused by using the native
FormDataconstructor with the form element, which often fails to capture the current value of controlled React components.Changes:
handleSubmitincomponents/followup-panel.tsxto explicitly create anew FormData()and append theinputstate value.Date.now()withnanoid()for message ID generation to maintain consistency with the rest of the codebase.bun run build.PR created automatically by Jules for task 14276778018306632149 started by @ngoiyaeric
Summary by CodeRabbit