Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(editor): implement up/down arrow key history navigation for edit… #4630

Merged
merged 1 commit into from
Mar 16, 2025

Conversation

0x23d11
Copy link
Contributor

@0x23d11 0x23d11 commented Mar 13, 2025

Description

Closes #3894

  • Create isolated memory stores for chat and edit history
  • Enhance useInputHistory hook to use separate stores by key
  • Update TipTapEditor to use correct history key
  • Ensure consistent history navigation behavior across input modes
  • Persist history correctly to localStorage

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:

  1. Isolated History Stores
    Created completely separate memory stores for chat and edit histories:
const CHAT_HISTORY_STORE: JSONContent[] = [];
const EDIT_HISTORY_STORE: JSONContent[] = [];
  1. Enhanced useInputHistory Hook
    Refactored the useInputHistory hook to:
  • Use the appropriate history store based on the provided historyKey
  • Maintain proper separation between different history types
  • Handle edge cases during history navigation
  • Correctly persist history to localStorage
  1. TipTapEditor Component Updates
    Modified the TipTapEditor component to:
  • Consistently use the correct history key ('edit' or 'chat')
  • Always save inputs to the appropriate history store
  • Ensure proper navigation through history with up/down arrow keys

Checklist

  • [] The relevant docs, if any, have been updated or created
  • [] The relevant tests, if any, have been updated or created

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. ]

… mode

- Create isolated memory stores for chat and edit history
- Enhance useInputHistory hook to use separate stores by key
- Update TipTapEditor to use correct history key
- Ensure consistent history navigation behavior across input modes
- Persist history correctly to localStorage
Copy link

netlify bot commented Mar 13, 2025

Deploy Preview for continuedev ready!

Name Link
🔨 Latest commit fc92d55
🔍 Latest deploy log https://app.netlify.com/sites/continuedev/deploys/67d232e4063e4200082c97f7
😎 Deploy Preview https://deploy-preview-4630--continuedev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@0x23d11
Copy link
Contributor Author

0x23d11 commented Mar 14, 2025

@Patrick-Erichsen @sestinj can anyone of you review this PR? Thanks

@sestinj
Copy link
Contributor

sestinj commented Mar 16, 2025

@0x23d11 looks great to me, thanks for taking the time to do this!

@sestinj sestinj merged commit 6aab2c8 into continuedev:main Mar 16, 2025
30 checks passed
@RomneyDa
Copy link
Collaborator

@0x23d11
There was a bug on production in which arrow key navigation in the mention list caused it to close immediately. I bisected to this commit and since the fix wasn't immediately clear and the bug urgent, we hotfixed by reverting this PR.

This was a good improvement for the chat/edit input history so if you're able to/have the time to reimplement this and double check that arrow key functionality, would be much appreciated!

@0x23d11
Copy link
Contributor Author

0x23d11 commented Mar 20, 2025

@RomneyDa sure I would reimplement this but can you give me some more details.

Before raising the PR I tried this feature a lot and I never faced any crashes. I was using macbook air m2 and vscode

@RomneyDa
Copy link
Collaborator

@0x23d11 the product doesn't crash, you can duplicate the bug by:

  • pulling this branch and debugging
  • typing "@" and then trying to use arrow keys to navigate the context providers
  • the list closes immediately and it attempts to cycle the history

Something in the arrow key handling logic was affected so that you can no longer navigate the list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Edit history - allow users to cycle through recent edit instructions using up/down keys
3 participants