feat(editor): implement up/down arrow key history navigation for edit… #4630
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.
Description
Closes #3894
Problem:
Currently, when users enter the edit mode by selecting text, the input box that appears doesn't maintain its own history. Unlike the chat input which allows navigating through previous inputs using up/down arrow keys, the edit mode input lacks this functionality. This creates an inconsistent user experience between the two input modes.
Solution:
This PR implements up/down arrow key history navigation for the edit mode, with completely isolated history storage from the chat mode. Now users can:
Use up/down arrow keys in edit mode to cycle through previously submitted edit inputs
Maintain separate history for chat mode and edit mode without any crossover
Experience consistent navigation behavior across both input modes
Technical Implementation
The implementation consists of several key components:
Created completely separate memory stores for chat and edit histories:
Refactored the useInputHistory hook to:
Modified the TipTapEditor component to:
Checklist
Screenshots
Before
You can see, in the video, when you are using up/down arrow, you are only getting the chat history inputs even though you are on the edit mode.
https://github.com/user-attachments/assets/8f91a69b-cc78-4939-9485-3e113073b88a
After
You can see, in the video, we have separatation of chat and edit histories, hence you can go through all your edit and chat histories easily.
Screen.Recording.2025-03-13.at.06.46.50.mov
Testing instructions
[ For new or modified features, provide step-by-step testing instructions to validate the intended behavior of the change, including any relevant tests to run. ]