fix(convert-chip): move early return after all hook calls#28
Conversation
Early return before useCallback/useEffect violated React's Rules of Hooks, causing "Rendered fewer hooks than expected" at runtime when layoutMode was not "split". Move the guard to after all hooks; add an inline layoutMode check inside useEffect so the keydown listener is only registered in split mode. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
mrcfps
left a comment
There was a problem hiding this comment.
@chasel34 I verified the hook-order fix in src/components/convert-chip.tsx: all hooks now run before the split-mode early return, and the useEffect listener is now gated on layoutMode === "split" so the shortcut is cleaned up when that pane layout is hidden. I couldn't run next build in this worktree because dependencies are not installed here (next: command not found), but the changed diff itself looks correct. Thanks for tightening this up 🙌
|
Heads-up: PR #30 is also open against this same slice — both PRs touch You and @cszhouwei may want to compare approaches; the maintainer team will pick which one lands. Sharing so neither effort gets wasted. |
|
Additional heads-up: PR #45 is now open for the same Keeping the cross-link here so reviewers and authors can compare the overlapping fixes in one place. |
|
Additional heads-up: PR #50 is now open and also touches PR #50 bundles that fix with agent parser updates, so keeping the cross-link here should help reviewers compare whether the smaller focused fix or the broader compatibility PR should land. |
|
Additional heads-up: PR #52 is now open and also touches PR #52 bundles that fix with Codex parser/output compatibility updates, so keeping the cross-link here should help reviewers compare the focused hook-order fix in this PR against the broader compatibility PR. |
Summary
layoutMode !== "split"was placed beforeuseCallbackand
useEffect, violating React's Rules of Hooks and causing a runtimecrash ("Rendered fewer hooks than expected") whenever the layout mode was
not split.
if (layoutMode !== "split") returnguard insideuseEffectso the ⌘+Enter keydown listener is only registered when thechip is actually visible.
Test plan
⌘+Enter does nothing.
🤖 Generated with Claude Code