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: support @mention in mid message #3043

Merged
merged 18 commits into from
Feb 8, 2024
Merged

feat: support @mention in mid message #3043

merged 18 commits into from
Feb 8, 2024

Conversation

abeatrix
Copy link
Contributor

@abeatrix abeatrix commented Feb 6, 2024

CLOSE #2633

This PR includes changes to support @mention in mid message:

  • Add context selection state and input caret tracking
  • Add setContextSelection prop to allow parent to update context selection state
  • Track inputCaretPosition in state to determine context selection based on caret position
  • Store currentChatContextQuery to track context matching query
  • Update context selection logic to use caret position rather than full input text
  • Pass inputCaretPosition to ChatUITextArea
  • Preserve text after caret when selecting context file
  • Rename e2e tests for chat:
    • chat.test.ts -> chat-rateLimit.test.ts
    • at-file-context-selecting.test.ts -> chat-atFile.test.ts

mid-at

Test plan

  • Updated existing e2e tests
  • Added a new test case for mid-sentence @-file to current e2e test
  1. In the chat input box, type "Explain file to me"
  2. Move your cursor behind 'Explain file'
  3. Add a space behind 'Explain file'
  4. Add '@'
  5. You should see the file selection window show up

image

image

image

@abeatrix abeatrix marked this pull request as ready for review February 6, 2024 17:26
@abeatrix abeatrix requested review from a team and toolmantim February 6, 2024 17:29
Copy link
Contributor

@toolmantim toolmantim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woohoo. This is shaping up really nicely!!

Gave it a good test and noticed a few things, which I've tried to highlight in this video:

CleanShot.2024-02-07.at.15.04.22.mp4
  • Accepting a suggestion should add a space
  • Using left and right cursor should hide the suggestion popover
  • After accepting a suggestion, hitting backspace and adding a character on the end shouldn't show "No matching files found" (see Slack's implementation for how we should probably handle it)
  • Triggered some kind of race condition with editing (perhaps unrelated to this PR)

@abeatrix
Copy link
Contributor Author

abeatrix commented Feb 7, 2024

@toolmantim thanks for testing this out. Just updated the branch with the following changes, all covered by the updated e2e test as well

  • Accepting a suggestion should add a space
  • Using left and right cursor should hide the suggestion popover
  • After accepting a suggestion, hitting backspace and adding a character on the end shouldn't show "No matching files found" (see Slack's implementation for how we should probably handle it)

Copy link
Contributor

@toolmantim toolmantim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super close! It still shows "No matching files found" (and doesn't dismiss the popover when you send the message)

CleanShot.2024-02-07.at.22.54.14.mp4

vs

CleanShot.2024-02-07.at.23.01.03.mp4

@abeatrix abeatrix requested review from toolmantim and a team February 7, 2024 16:20
Copy link
Contributor

@umpox umpox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Only noticed one small thing:

It seems that the "No matching files found" message doesn't go away when using the arrow keys to go left or right

ChatMiddle@.mov

@abeatrix
Copy link
Contributor Author

abeatrix commented Feb 7, 2024

@toolmantim @umpox Thanks for testing the change so thoroughly! I've manually tested it and updated the tests. Please let me know if it is not working correctly for you.

Screen.Recording.2024-02-07.at.12.39.51.PM.mov

Copy link
Contributor

@toolmantim toolmantim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me it still seems to lose the files when you edit the message:

CleanShot.2024-02-08.at.14.23.05.mp4

And the question mark case is showing "No matching files":

CleanShot.2024-02-08.at.14.24.09.mp4

@abeatrix
Copy link
Contributor Author

abeatrix commented Feb 8, 2024

For me it still seems to lose the files when you edit the message:

That's unrelated to this PR since this PR is for adding @-file in mid-sentence support. Will work on that in my next PR.

And the question mark case is showing "No matching files":

Thanks! I will update and make sure to add tests to cover this tomorrow. Surprise the current one doesn't 🫠

@toolmantim
Copy link
Contributor

That's unrelated to this PR since this PR is for adding @-file in mid-sentence support. Will work on that in my next PR.

Ah, I didn't realise sorry! I didn't check main 👍🏼

@abeatrix
Copy link
Contributor Author

abeatrix commented Feb 8, 2024

That's unrelated to this PR since this PR is for adding @-file in mid-sentence support. Will work on that in my next PR.

Ah, I didn't realise sorry! I didn't check main 👍🏼

np! Just updated the PR with tests too. i think the test should cover all the expected behavior now?

For edits, it should work the same as press UP for history input right? I can look into that next 👍

@abeatrix abeatrix merged commit 37ad02a into main Feb 8, 2024
15 checks passed
@abeatrix abeatrix deleted the bee/at-mention-mid-msg branch February 8, 2024 15:32
@toolmantim
Copy link
Contributor

🎉

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.

bug: @-mentioning files in Cody chat only works if the cursor is at the end of the input
3 participants