DIY widget: autocomplete provide data-lake variables#2109
Merged
rafaellehmkuhl merged 3 commits intobluerobotics:masterfrom Sep 11, 2025
Merged
DIY widget: autocomplete provide data-lake variables#2109rafaellehmkuhl merged 3 commits intobluerobotics:masterfrom
rafaellehmkuhl merged 3 commits intobluerobotics:masterfrom
Conversation
# DIY widget autocomplete Provide Data-Lake Variables
## Summary
Added intelligent autocomplete support for JavaScript in Monaco Editor that suggests variables from `window.cockpit.dataLakeVariableData` with proper documentation and insertion templates.
## Changes
- Registered a completion item provider for JavaScript language
- Configured trigger character '(' to activate autocomplete
- Implemented dynamic suggestion generation from data-lake variables
## Technical Details
- **Range Detection**: Uses `getWordUntilPosition()` to identify the current word boundary for precise text replacement
- **Dynamic Suggestions**: Maps object entries to completion items with proper formatting
- **Documentation**: Displays variable name, current value, and type in tooltips
- **Insertion Template**: Generates proper JavaScript access syntax (`window.cockpit.dataLakeVariableData['variableName']`)
## Benefits
- Improves developer productivity with context-aware suggestions
- Reduces errors by providing correct access syntax
- Enhances code discovery with real-time value documentation
- Maintains consistency in variable access patterns
## Usage
Developers can now autocomplete cockpit variables by typing any character and selecting from the suggested list, which includes current values and types for better context.
Member
rafaellehmkuhl
left a comment
There was a problem hiding this comment.
Amazing contribution @mahdikarami8484!
Could we use the getDataLakeVariableData(...) method as the insert text instead of the direct object access? They do the same thing today, but if we end up implementing some logic in this getter in the future, it would be better if this auto-completion is already using it.
i use getAllDataLakeVariablesInfo and getDataLakeVariableData instead of dataLakeVariableData
Contributor
Author
|
Thank you so much for the encouragement! Yes, I did it. 2025-09-07.11-05-02.1.mp4 |
Contributor
Author
|
I fixed the ESLint problem! 😅 |
Member
|
Amazing @mahdikarami8484! I've tested it already and everything is working perfectly. Thanks for the updates! I plan to release our v1.16.0 stable tomorrow and merge your PR right after that, so it enters our v1.17.0 beta cycle :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DIY widget autocomplete Provide Data-Lake Variables
Summary
Added intelligent autocomplete support for JavaScript in Monaco Editor that suggests variables from
window.cockpit.dataLakeVariableDatawith proper documentation and insertion templates.Changes
Technical Details
getWordUntilPosition()to identify the current word boundary for precise text replacementwindow.cockpit.dataLakeVariableData['variableName'])Benefits
Usage
Developers can now autocomplete cockpit variables by typing any character and selecting from the suggested list, which includes current values and types for better context.