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

Implement UX Logging and Fix LLM Translation Shortcut Functionality #3241

Merged
merged 6 commits into from
Aug 29, 2024

Conversation

ayanaar
Copy link
Contributor

@ayanaar ayanaar commented May 30, 2024

Fully fixes #3204

This PR includes the following changes:

  • Refactored the LLM hook: The LLM hook (useLLMTranslation) was refactored to return a function that is called outside of the callback. This change was made to address issues with the useHandleCtrlShiftArrow function, which previously caused the keyboard shortcut to stop functioning correctly after an LLM translation was generated.

  • Added UX logging: Implemented UX logging for when LLM translations are copied into the editor using the keyboard shortcut. This helps track the adoption and usage of the LLM translation feature.

Issue Resolved

  • The keyboard shortcut now works as expected for LLM translations and other translations, including when an LLM translation is selected from the dropdown.

Note

As discussed with @eemeli, there is a need for further refactoring to fully address this issue. Specifically, issue #3305 - "When the main edit box is not in focus, the global arrow key combinations (ArrowDown or ArrowUp) do not function as expected" - should be addressed in the future. While the current changes enable the feature to function as expected, a more comprehensive solution is still needed to address the underlying issue in the existing code.

MpcOS77

This comment was marked as off-topic.

Copy link
Member

@eemeli eemeli left a comment

Choose a reason for hiding this comment

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

This seems like a combination of 2-3 different sets of changes that would probably be clearer in separate PRs, but in general the direction for each of them seems fine.

@@ -59,7 +59,10 @@ export const LLMTranslationProvider: React.FC = ({ children }) => {
stateRef.current.set(mt, {
loading: false,
selectedOption: characteristic,
Copy link
Member

Choose a reason for hiding this comment

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

It's a bit confusing that "selected option" and "characteristic" are names for essentially the same value, which is typed only as a string. These values should be typed more strictly, with something like

type Characteristic = 'rephrased' | 'formal' | 'informal'

Also, the variable names should be consistent, so selectedCharacteristic instead of selectedOption.

Comment on lines 4 to 8
export type SelState = {
loading: boolean;
selectedOption: string;
llmTranslation: string;
llmTranslations: Record<string, string>;
};
Copy link
Member

Choose a reason for hiding this comment

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

It's unclear why this refactor is included in a fix for keyboard shortcuts.

@ayanaar ayanaar requested a review from eemeli August 27, 2024 19:22
@ayanaar ayanaar changed the title Update LLM translation context Implement UX Logging and Fix LLM Translation Shortcut Functionality Aug 28, 2024
@ayanaar ayanaar marked this pull request as ready for review August 28, 2024 18:10
@mathjazz mathjazz merged commit fd37b61 into mozilla:main Aug 29, 2024
4 checks passed
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.

LLM translations are not correctly attributed
4 participants