Skip to content

fix: improve business logic in prompt editor and fix cursor bugs in Plan mode#867

Open
nmggithub wants to merge 4 commits intopingdotgg:mainfrom
nmggithub:composer-fixes
Open

fix: improve business logic in prompt editor and fix cursor bugs in Plan mode#867
nmggithub wants to merge 4 commits intopingdotgg:mainfrom
nmggithub:composer-fixes

Conversation

@nmggithub
Copy link
Contributor

@nmggithub nmggithub commented Mar 10, 2026

What Changed

This makes four changes all related to the prompt editor (each in their own commit):

  1. Removes a redundant function wrapper (least important)
  2. Ensures that onChange doesn't fire in ComposerPromptEditor for prop-controlled changes (better behavior, I believe)
  3. Fixes cursor position bug in Plan mode where the cursor isn't moved to the correct position as that code fires while the input is unfocused from a question navigation button press (Bug fix!)
  4. Fixes another cursor position bug in Plan mode where the cursor would snap to the end on each keystroke (Bug fix! Resolves In the "Plan mode" text input cursor focus forced to the right #411, Resolves bug: text input on the GPT questions #909)

3 and 4 can be seen below. 1 and 2 are business logic changes that should (hopefully) not have any affect on the UI.

I could also add raising answer state to the composerDraftStore here, but I feel like that might be scope creep. It's all a bit intertwined, though, so separating them out is difficult.

Why

Each change has its own motivations:

  1. The wrapper was redundant, and another callback was passed on its own (so I'm not breaking pattern).
  2. This, I believe, is better behavior for a (semi-)controlled input here. Any controlling parent knows what values its passing in via props, so it has little need to get told of changes to those props via the onChange handler.
  3. It appears the intended behavior is that the cursor is always put at the end when switching questions. This patches a case where that "didn't" happen (it still did end up at the end, but only because of the next bug).
  4. Users expect to be able to navigate their cursor around freely as they can with any other text input.

UI Changes

Before

Screen.Recording.2026-03-10.at.19.39.17.mov

After

Screen.Recording.2026-03-10.at.19.40.18.mov

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Note

Fix cursor bugs and prompt sync logic in Plan mode composer

  • In ChatView.tsx, the effect syncing customAnswer into the composer now tracks the last-synced requestId and questionId, updating the editor only when the active question/request changes or when the server-provided text differs from the current editor content.
  • In ComposerPromptEditor.tsx, an isApplyingControlledUpdateRef flag prevents programmatic value/cursor updates from triggering onChange callbacks, breaking the feedback loop that caused cursor bugs.
  • Selection is now applied during controlled updates even when the editor is not focused, fixing cases where cursor position was lost after a server-driven update.

Macroscope summarized a929143.

@coderabbitai
Copy link

coderabbitai bot commented Mar 10, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 4500c3f1-5855-4d80-be37-07c674cec778

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added the vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. label Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: text input on the GPT questions In the "Plan mode" text input cursor focus forced to the right

1 participant