Skip to content
This repository was archived by the owner on Mar 7, 2026. It is now read-only.

feat: trigger writing assistant without highlighting text completed#359

Merged
weilirs merged 5 commits intomainfrom
writing-assistant
Aug 24, 2024
Merged

feat: trigger writing assistant without highlighting text completed#359
weilirs merged 5 commits intomainfrom
writing-assistant

Conversation

@weilirs
Copy link
Copy Markdown
Collaborator

@weilirs weilirs commented Aug 18, 2024

fix #349
/claim #349

trigger.writing.assistant.without.highlighting.text.mov

@algora-pbc
Copy link
Copy Markdown

algora-pbc bot commented Aug 18, 2024

💵 To receive payouts, sign up on Algora, link your Github account and connect with Stripe.

Copy link
Copy Markdown

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This pull request implements a feature to trigger the writing assistant without highlighting text, addressing issue #349. Key changes include:

  • Added placeholder text in EditorManager.tsx suggesting to press 'space' for AI writing assistant when the current line is empty
  • Updated WritingAssistantFloatingMenu.tsx to handle space key presses for triggering the assistant on empty lines
  • Implemented cursor position management and escape key functionality in WritingAssistantFloatingMenu.tsx
  • Enhanced positioning logic for the writing assistant menu to improve user experience
  • Integrated support for both highlighted text and empty line triggers, making the assistant more versatile

These changes significantly improve the writing assistant's accessibility and usability, aligning with the requested functionality in the related issue.

2 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings

Comment on lines +134 to +137
return () => {
editor.off('update', handleUpdate)
editor.off('selectionUpdate', handleUpdate)
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

style: Consider using a cleanup function that doesn't require disabling eslint

Copy link
Copy Markdown
Collaborator

@joseplayero joseplayero left a comment

Choose a reason for hiding this comment

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

looks nice. made a small comment on the prompt.

some extra thoughts:

  • some users may not like seeing the 'press space' text in every new line so maybe we think through ways to allow them to hide it (either in settings or like the message hides after being shown once per note)
  • there is a small bug when resizing screen and the message changing places

if (!selectedText.trim()) return
let selectedText = highlightData.text
if (!selectedText.trim() && isSpaceTrigger) {
selectedText = ''
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this PR means selectedText can be empty. i dont think the prompts we have should still include """ ${selectedText} """ when selectedText is empty

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I modified how it handles customized prompts, please take a look

Copy link
Copy Markdown
Collaborator

@joseplayero joseplayero left a comment

Choose a reason for hiding this comment

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

lg @weilirs

one thought on this

the backlink extension code could be moved at some point to the EditorManager file because it does very similar things to what you're doing in this PR and moving it would clean up lots of our code (especially in how we pass around the suggestion state )

@joseplayero
Copy link
Copy Markdown
Collaborator

/tip $20

@algora-pbc
Copy link
Copy Markdown

algora-pbc bot commented Aug 23, 2024

@weilirs
Copy link
Copy Markdown
Collaborator Author

weilirs commented Aug 24, 2024

lg @weilirs

one thought on this

the backlink extension code could be moved at some point to the EditorManager file because it does very similar things to what you're doing in this PR and moving it would clean up lots of our code (especially in how we pass around the suggestion state )

Okay, I'll take a look

@weilirs weilirs merged commit d07736b into main Aug 24, 2024
@weilirs weilirs deleted the writing-assistant branch August 24, 2024 01:32
@algora-pbc
Copy link
Copy Markdown

algora-pbc bot commented Aug 24, 2024

@weilirs: You just got a $20 tip! 👉 Complete your Algora onboarding to collect your payment.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Trigger writing assistant without highlighting text

2 participants