[codex] fix(desktop): preserve chat cursor position#2993
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughA React hook was refactored to cache the Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
Summary
This change fixes the desktop chat composer moving the caret to the start of the prompt while typing.
What Changed
textInput.focuscallback instead of the fulltextInputcontroller objectRoot Cause
useFocusPromptOnPanedepended on the entiretextInputobject from the prompt controller. That object is recreated whenever the controlled prompt value changes, so the effect ran again on each keystroke while the pane was focused. Re-focusing the textarea during typing reset the selection and made the cursor jump.Impact
Typing in the desktop chat composer should now preserve the caret position across rerenders, including edits in the middle of existing text.
Validation
cd apps/desktop && bun run typecheckSummary by cubic
Fixes the desktop chat composer cursor jumping to the start while typing. The focus hook now uses the stable textInput.focus callback instead of the full controller, so the prompt keeps its caret on rerenders and only auto-focuses when the pane becomes active.
Written for commit c939232. Summary will update on new commits.
Summary by CodeRabbit