fix(convert-chip): move layout-mode guard after all hooks#30
Conversation
The early `return null` for non-split layouts sat between `useStore`/`useT` and the later `useCallback`/`useEffect`, so toggling layoutMode produced a different hook count between renders and React threw "Rendered fewer hooks than expected" (minified #300). Moving the guard below every hook call keeps the hook order stable across layout changes. Refs nexu-io#26 (symptom 1 of 3). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Heads-up: PR #28 is also open against this same slice — both PRs touch You and @chasel34 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 this 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. |
|
Hey @cszhouwei, quick lifecycle update: PR #28 has now merged the focused That means this PR is now superseded by the merged fix. I’m routing the close for maintainer confirmation rather than asking reviewers to spend more time on the duplicate path. Thanks for jumping on this bug — the direction here matched the issue well. |
|
Thanks for the PR. I checked a local rebase onto the latest What I found:
Suggested next step:
Recommended validation for any follow-up:
|
Summary
ConvertChiphad an earlyreturn nullfor non-split layouts sitting betweenuseStore/useTand the lateruseCallback/useEffecthooks. TogglinglayoutModebetweensplitandeditor/previewtherefore changed the hook count between renders, and React threw "Rendered fewer hooks than expected" (minified#300).Refs #26 — fixes symptom 1 of 3 (the other two, the deploy-control snapshot loop and the Codex
agent_messageparser drift, are not touched here).Test plan
pnpm dev, load/, toggle layout between split / editor / preview — no React crash, chip appears only in split mode.pnpm build(reviewer to confirm in CI).🤖 Generated with Claude Code