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] Fix issue with different themes #180321

Merged

Conversation

ElenaStoeva
Copy link
Contributor

@ElenaStoeva ElenaStoeva commented Apr 8, 2024

Fixes #180218

Summary

This PR fixes the highlighting issue in the Monaco editor that is caused when using a theme in the output panel that is different from the theme in the editor. This fix is implemented by unifying the themes for both editors into one.

The PR also fixes the issue with Console theme overwriting theme in other code editors (e.g. embeddable Console in the index detail tabs) by reusing the euiTheme.

Note: This solution changes some of the original highlighting colors in Console (e.g. comments were green and now they are grey, background color is also different now). We might be able to fix the text colors by specifying unique token names in the Console language (e.g. using consoleComment instead of comment token name). cc: @yuliacech

Screen.Recording.2024-04-22.at.15.31.47.mov
Screen.Recording.2024-04-22.at.15.33.39.mov
Screenshot 2024-04-22 at 15 34 45

@ElenaStoeva ElenaStoeva 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 labels Apr 8, 2024
@ElenaStoeva ElenaStoeva self-assigned this Apr 8, 2024
@ElenaStoeva ElenaStoeva force-pushed the console-monaco-migration/fix-theme-issue branch from 64fd9e3 to 64656cf Compare April 18, 2024 13:20
@ElenaStoeva
Copy link
Contributor Author

/ci

@ElenaStoeva ElenaStoeva force-pushed the console-monaco-migration/fix-theme-issue branch from 83e5780 to 0ba9a19 Compare April 18, 2024 13:31
@ElenaStoeva ElenaStoeva force-pushed the console-monaco-migration/fix-theme-issue branch from 71a7912 to 8cd8166 Compare April 22, 2024 13:03
@ElenaStoeva ElenaStoeva marked this pull request as ready for review April 22, 2024 14:39
@ElenaStoeva ElenaStoeva requested review from a team as code owners April 22, 2024 14:39
@elasticmachine
Copy link
Contributor

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

@ElenaStoeva
Copy link
Contributor Author

@elasticmachine merge upstream

@ElenaStoeva ElenaStoeva marked this pull request as draft April 22, 2024 16:55
Copy link
Contributor

@yuliacech yuliacech left a comment

Choose a reason for hiding this comment

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

Thanks a lot for fixing the theme issue, @ElenaStoeva!
The new colors look great and the embeddable console doesn't seem to affect other code editors.
The circular dependency might need to be resolved before merging this PR though, I'm not sure the CI will let us otherwise.

ElenaStoeva added a commit that referenced this pull request Apr 25, 2024
## Summary

This PR moves the Monaco themes used in the Code Editor component to the
`kbn-monaco` package to prevent the circular dependency between the
`kbn-monaco` and `code_editor` packages that occurs in
#180321 (where the code editor
theme is reused from inside the `kbn-monaco` package).

<!--
### Checklist

Delete any items that are not applicable to this PR.

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [ ] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)


### 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&mdash;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&mdash;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](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) |


### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
-->

---------

Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
@ElenaStoeva ElenaStoeva force-pushed the console-monaco-migration/fix-theme-issue branch from 8eaa843 to b62e85b Compare April 25, 2024 14:27
@ElenaStoeva
Copy link
Contributor Author

/ci

@ElenaStoeva ElenaStoeva marked this pull request as ready for review April 25, 2024 16:05
kpatticha pushed a commit to kpatticha/kibana that referenced this pull request Apr 26, 2024
## Summary

This PR moves the Monaco themes used in the Code Editor component to the
`kbn-monaco` package to prevent the circular dependency between the
`kbn-monaco` and `code_editor` packages that occurs in
elastic#180321 (where the code editor
theme is reused from inside the `kbn-monaco` package).

<!--
### Checklist

Delete any items that are not applicable to this PR.

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [ ] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)


### 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&mdash;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&mdash;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](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) |


### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
-->

---------

Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
Copy link
Contributor

@MichaelMarcialis MichaelMarcialis left a comment

Choose a reason for hiding this comment

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

LGTM! Approving.

On the topic of code highlighting, have there been any previous discussions on adopting the same colors used for the EUI code block component's code highlighting? Doing so would be nice for consistency. I'm mentioning it because it's a topic that came up lately for the ES|QL editor as well, which @stratoula kindly changed to adopt those colors. Is it worth opening a separate issue to do the same here?

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #74 / dashboard app - group 1 dashboard embeddable data grid are added when a cell filter is clicked
  • [job] [logs] FTR Configs #37 / lens app - group 4 lens show underlying data from dashboard should bring both dashboard context and visualization context to discover

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/monaco 124 123 -1

Async chunks

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

id before after diff
console 441.2KB 441.1KB -32.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
console 32.9KB 33.0KB +50.0B
kbnUiSharedDeps-srcJs 3.1MB 3.1MB -487.0B
total -437.0B
Unknown metric groups

API count

id before after diff
@kbn/monaco 124 123 -1

History

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

cc @ElenaStoeva

@ElenaStoeva
Copy link
Contributor Author

LGTM! Approving.

On the topic of code highlighting, have there been any previous discussions on adopting the same colors used for the EUI code block component's code highlighting? Doing so would be nice for consistency. I'm mentioning it because it's a topic that came up lately for the ES|QL editor as well, which @stratoula kindly changed to adopt those colors. Is it worth opening a separate issue to do the same here?

Thanks for the review @MichaelMarcialis!
In the Console Monaco editor, specifying text highlighting colors is trickier as we figured that a limitation in Monaco causes multiple editors on the same page to overwrite each other's themes. For example, since Console is embedded in Index Management details page, now that we have two Monaco editors on the same page, if we change the Console highlighting colors to the ones from the EUI code block component, these colors would also be applied to code editor in the Index Management setting details page, which is a behavior we try to avoid. Thankfully, the ES|QL editor seems to be a single Monaco editor on the page, so it doesn't have theme-related issues.

Still, we can investigate further whether we can implement some workaround so that we can apply the colors that you suggested to Console - I opened #182142 to track this work.

@ElenaStoeva ElenaStoeva merged commit b8d8c73 into elastic:main Apr 30, 2024
19 checks passed
@ElenaStoeva ElenaStoeva deleted the console-monaco-migration/fix-theme-issue branch April 30, 2024 14:20
@kibanamachine kibanamachine added v8.15.0 backport:skip This commit does not require backporting labels Apr 30, 2024
yuliacech pushed a commit to yuliacech/kibana that referenced this pull request May 3, 2024
…80321)

Fixes elastic#180218

## Summary

This PR fixes the highlighting issue in the Monaco editor that is caused
when using a theme in the output panel that is different from the theme
in the editor. This fix is implemented by unifying the themes for both
editors into one.

The PR also fixes the issue with Console theme overwriting theme in
other code editors (e.g. embeddable Console in the index detail tabs) by
reusing the `euiTheme`.

Note: This solution changes some of the original highlighting colors in
Console (e.g. comments were green and now they are grey, background
color is also different now). We might be able to fix the text colors by
specifying unique token names in the Console language (e.g. using
`consoleComment` instead of `comment` token name). cc: @yuliacech


https://github.com/elastic/kibana/assets/59341489/d77d4ea3-61b5-43fa-81ef-7e4ac239aadd



https://github.com/elastic/kibana/assets/59341489/1dab2eca-08e5-421b-acd4-38e0b3d91a3e


<img width="1494" alt="Screenshot 2024-04-22 at 15 34 45"
src="https://github.com/elastic/kibana/assets/59341489/a4241574-77ad-42db-8707-ae38761d52d0">




<!--
### Checklist

Delete any items that are not applicable to this PR.

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [ ] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)


### 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&mdash;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&mdash;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](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) |


### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
-->

---------

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
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] Fix highlighting bug
7 participants