Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/a-real-editor-for-driver-lua.md
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.
5 changes: 5 additions & 0 deletions .changeset/edit-and-try-a-driver.md
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.
5 changes: 5 additions & 0 deletions .changeset/find-a-driver-by-your-hardware.md
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.
5 changes: 5 additions & 0 deletions .changeset/read-a-drivers-lua-from-the-gateway.md
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.
5 changes: 5 additions & 0 deletions .changeset/suggest-a-driver-back-to-the-repo.md
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.
16 changes: 16 additions & 0 deletions go/internal/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ type Server struct {
versionUpdateMu sync.Mutex
driverUpdateMu sync.Mutex
backupMu sync.Mutex

// Timers that put a driver back after an edit has been tried for its
// window. The record on disk is what survives a restart; these only make
// the revert prompt while the process lives.
drafts *driverDrafts
}

// New creates a new API server.
Expand All @@ -214,8 +219,13 @@ func New(deps *Deps) *Server {
deps: deps,
mux: http.NewServeMux(),
dailyCache: make(map[string]state.DayEnergy),
drafts: newDriverDrafts(),
}
s.routes()
// A draft's timer died with the previous process, so anything left behind
// goes back now. What runs after a restart should be the driver that was
// chosen, not a forgotten experiment.
s.RevertDraftsOnStart()
Comment on lines +225 to +228

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Revert persisted drafts before starting their drivers

When the process restarts during a draft, go/cmd/ftw/main.go resolves and starts the drivers before calling api.New, so the registry has already loaded the draft from the user overlay by the time this executes. RevertDraftsOnStart only restores/removes the files; it neither repoints Cfg.Drivers[i].Lua nor 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 initial reg.Add loop, or restart the affected drivers here.

Useful? React with 👍 / 👎.

return s
}

Expand Down Expand Up @@ -247,6 +257,12 @@ func (s *Server) routes() {
s.handle("GET /api/drivers", s.handleDrivers)
s.handle("GET /api/drivers/catalog", s.handleDriversCatalog)
s.handle("POST /api/drivers/test", s.handleDriverTest)
s.handle("GET /api/drivers/{id}/source", s.handleDriverSource)
s.handle("POST /api/drivers/{id}/lint", s.handleDriverLint)
s.handle("POST /api/drivers/{id}/draft", s.handleDriverDraft)
s.handle("GET /api/drivers/{id}/draft", s.handleDriverDraftStatus)
s.handle("POST /api/drivers/{id}/draft/keep", s.handleDriverDraftKeep)
s.handle("POST /api/drivers/{id}/draft/revert", s.handleDriverDraftRevert)
s.handle("POST /api/drivers/fingerprint", s.handleDriverFingerprint)
s.handle("GET /api/drivers/{name}", s.handleDriverDetail)
s.handle("GET /api/drivers/{name}/logs", s.handleDriverLogs)
Expand Down
Loading
Loading