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

[Console Monaco migration] Trigger suggestions on deletion #184673

Merged
merged 10 commits into from
Jun 10, 2024

Conversation

yuliacech
Copy link
Contributor

@yuliacech yuliacech commented Jun 3, 2024

Summary

Closes #183422

This PR adds logic to manually trigger autocomplete suggestions when the user deletes some of the text in the editor. The suggestions are only triggered if the line content before the cursor position matches specific regular expressions. The use cases include:

  • when the string is empty -> suggest autocomplete for methods
  • when the string contains a method and a whitespace -> suggest autocomplete for a url path
  • when the string contains a method and some parts of the url and ends with /, ?or =-> suggest autocomplete for a url path or url params
  • when the string contains only a double quote -> suggest autocomplete for body params
  • when the string contains a property and a colon -> suggest autocomplete for body param values

Screen recording

Screen.Recording.2024-06-04.at.17.18.49.mov

Checklist

Delete any items that are not applicable to this PR.

Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release.

When forming the risk matrix, consider some of the following examples and how they may potentially impact the change:

Risk Probability Severity Mitigation/Notes
Multiple Spaces—unexpected behavior in non-default Kibana Space. Low High Integration tests will verify that all features are still supported in non-default Kibana Space and when user switches between spaces.
Multiple nodes—Elasticsearch polling might have race conditions when multiple Kibana nodes are polling for the same tasks. High Low Tasks are idempotent, so executing them multiple times will not result in logical error, but will degrade performance. To test for this case we add plenty of unit tests around this logic and document manual testing procedure.
Code should gracefully handle cases when feature X or plugin Y are disabled. Medium High Unit tests will verify that any feature flag or plugin combination still results in our service operational.
See more potential risk examples

For maintainers

@yuliacech yuliacech added Feature:Console Dev Tools Console Feature Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more release_note:skip Skip the PR/issue when compiling release notes v8.15.0 labels Jun 3, 2024
@yuliacech
Copy link
Contributor Author

/ci

@yuliacech yuliacech marked this pull request as ready for review June 4, 2024 15:34
@yuliacech yuliacech requested a review from a team as a code owner June 4, 2024 15:34
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-management (Team:Kibana Management)

Copy link
Contributor

@ElenaStoeva ElenaStoeva left a comment

Choose a reason for hiding this comment

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

Amazing work @yuliacech! Tested locally and the autocompletion functionality works much better now. It worked as expected for all of the listed use cases in the PR.

I only have two small comments for the code changes.

endColumn: position.column,
});
// if the line is empty or it matches specified regex, trigger suggestions
console.log({lineContentBefore})
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: we might not need this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

great catch! 👍

@@ -71,6 +91,13 @@ export class MonacoEditorActionsProvider {
editor.onDidContentSizeChange(async (event) => {
await debouncedHighlightRequests();
});

editor.onKeyUp((event) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems that onKeyUp is making some jest tests fail. Could we use editor.addAction or editor.addCommand instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think there was just a function missing in the mock, so that should fix the tests, otherwise I'll have a look at these 2 alternatives

@yuliacech yuliacech enabled auto-merge (squash) June 10, 2024 13:07
@yuliacech yuliacech merged commit ad83c67 into elastic:main Jun 10, 2024
16 checks passed
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
console 455.9KB 456.6KB +723.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Console Dev Tools Console Feature release_note:skip Skip the PR/issue when compiling release notes Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Console Monaco migration] Trigger autocomplete suggestions
5 participants