-
Notifications
You must be signed in to change notification settings - Fork 8
feat(drivers): see, edit and try a driver's Lua — then suggest it back #679
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
Merged
+2,830
−13
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
499d883
feat(drivers): see the Lua a driver is actually running
frahlg b506afb
feat(drivers): edit a driver's Lua and try it for a fixed window
frahlg 8d0c21d
feat(drivers): suggest a driver change back to the repository
frahlg a5aab40
fix(drivers): write a draft through a rename, not over the file
frahlg 5325240
feat(drivers): a real editor for driver Lua, and a linter that cannot…
frahlg ff0f565
feat(drivers): find a driver by the hardware you own
frahlg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "ftw": minor | ||
| --- | ||
|
|
||
| The driver editor is its own full-height view with syntax highlighting, line numbers, find and replace, and two linters. Ace is vendored under `/vendor/ace/` rather than pulled from a CDN, for the same reason three.js is — a gateway has to work without the internet, and a driver editor is most needed exactly when something is wrong. It loads on first open, not on page load. Ace's own Lua linter marks problems as you type; `POST /api/drivers/{id}/lint` then asks gopher-lua, the parser that actually decides whether the driver will start, and that verdict gates running a draft. Problems are listed under the editor and clicking one jumps to its line. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "ftw": minor | ||
| --- | ||
|
|
||
| Edit a driver's Lua and try it for a fixed window. The edit runs as a local override, the driver restarts against it, and it puts the previous file back on its own unless you keep it — so the failure mode of walking away is the driver you started with. A draft that does not compile, or that renames itself into another driver's slot, never reaches the overlay; one that will not start is undone before the error is reported. Keeping a draft turns it into an ordinary override, which already shadows the channel and already tells you when a newer version exists. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "ftw": minor | ||
| --- | ||
|
|
||
| Find a driver by the hardware you own. The catalog was a dropdown of 37 entries in alphabetical order, which asked you to translate: you know you have an SH10RT, not that you need "Sungrow SH Hybrid Inverter". There is a search field now that matches the manufacturer, the driver name and the models each driver has actually been run against — type SH10RT and one card comes back. Results are cards showing which DERs the driver covers and whether anyone has run it on hardware, with the four proven drivers first instead of scattered alphabetically among the 33 that are not. Nothing is selected until you select it; Add now says so rather than quietly adding whichever driver happened to be first. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "ftw": minor | ||
| --- | ||
|
|
||
| See the Lua a driver is actually running. Every driver is one file and the repository is the source of truth, but from the gateway there was no way to read the code — so a working fix for someone's inverter stayed on their machine. Each configured driver now has a Source view showing the file that is running, which of the three overlays it came from, its size and hash, and a link to the same driver in device-drivers. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "ftw": minor | ||
| --- | ||
|
|
||
| Suggest a driver change back to device-drivers from the gateway. One click opens a pre-filled issue carrying the driver, its version, where the running copy came from, the hash it was based on, and the edit as a diff. The gateway holds no GitHub token and needs none — GitHub accepts a pre-filled issue over a URL and the operator is already signed in to their own browser. The change travels as a diff rather than the whole file: drivers run to tens of kilobytes and a URL is limited to about eight, so sending the file meant the code never travelled at all. |
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the process restarts during a draft,
go/cmd/ftw/main.goresolves and starts the drivers before callingapi.New, so the registry has already loaded the draft from the user overlay by the time this executes.RevertDraftsOnStartonly restores/removes the files; it neither repointsCfg.Drivers[i].Luanor restarts the registry entry. The experimental VM therefore keeps running past its promised window while its config points to a removed file. Revert these records before the initialreg.Addloop, or restart the affected drivers here.Useful? React with 👍 / 👎.