fix: prevent double session creation on main branch#40
Merged
Conversation
Enables .test.tsx files and the happy-dom environment so React components can be tested without a full browser. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…anch NewSessionDialog had onKeyDown on both the <input> and its wrapping <div>. Pressing Enter in the input fired handleSubmit twice via event bubbling. For the empty-branch (main branch) path there was no loading guard, so onConfirm — and createSession — ran twice, producing a duplicate session in the sidebar. Fix: call event.stopPropagation() in handleKeyDown so the event is consumed at whichever element first handles it. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
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.
Summary
NewSessionDialogwith an empty branch name (main branch session) created two sessions instead of oneonKeyDown={handleKeyDown}was on both the<input>and its wrapping<div>, so Enter firedhandleSubmittwice via event bubbling — and the empty-branch path had no loading guard to block the second callevent.stopPropagation()inhandleKeyDownso the event is consumed by whichever element first handles itWhat changed
NewSessionDialog.tsx— addstopPropagation()for Enter and Escape keysNewSessionDialog.test.tsx— new component test reproducing the double-submit bugvitest.config.ts— extend test glob to include.test.tsxfilespackage.json— addhappy-domand@testing-library/react/@testing-library/user-eventdev depsTesting
calls onConfirm exactly once when Enter is pressed with empty branch name