Curtailment: wire update event API#329
Conversation
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
Wires the active curtailment Manage modal to the UpdateCurtailmentEvent API. The modal now supports an edit mode that hides non-editable fields (target/tolerance/min duration/scope/maintenance) and surfaces only operator-safe fields (reason, max duration, restore batch size, restore interval). The hook maps the active event into editable form values, builds a typed update request that only includes changed fields, and refreshes active/history state on success.
Changes:
- Add
editmode UI and validation branch toCurtailmentStartModaland gate preview/sections accordingly. - Add
buildUpdateCurtailmentEventRequestthat sends only changed operator-safe fields (and zero when clearing a numeric setting). - Extend
useCurtailmentApiwithupdateCurtailment,isUpdating,updateError, andactiveEventFormValuesmapped from the live event; wireCurtailmentManagementPanelto open the edit modal fromActiveCurtailmentStatus.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| client/src/protoFleet/features/energy/CurtailmentStartModal.tsx | Adds edit-mode rendering, gated validation, and preview-state helper. |
| client/src/protoFleet/features/energy/CurtailmentStartModal.test.tsx | Updates edit-mode test to verify limited fields and preview disabling. |
| client/src/protoFleet/features/energy/curtailmentRequestBuilders.ts | Adds shared field-option constants and buildUpdateCurtailmentEventRequest. |
| client/src/protoFleet/features/energy/curtailmentRequestBuilders.test.ts | Covers update request mapping for changed-only and clear-to-zero cases. |
| client/src/protoFleet/features/energy/CurtailmentManagementPanel.tsx | Replaces single open-flag with modalMode, wires update submit and stop-from-editor. |
| client/src/protoFleet/features/energy/CurtailmentManagementPanel.test.tsx | Adds tests for edit submit and stop-from-editor flows. |
| client/src/protoFleet/api/useCurtailmentApi.ts | Maps event to form values; adds updateCurtailment, isUpdating, updateError. |
| client/src/protoFleet/api/useCurtailmentApi.test.ts | Covers activeEventFormValues mapping and update flow with refresh + change event. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c60df059c6
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b5c88a7079
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a51c4c6cac
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b3c1113a2f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e9c3ea8c72
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Brings in: - #325 RBAC swap: List/GetActive/Update curtailment RPCs now gated via RequirePermission; new entries in ProcedurePermissions. - #329 UpdateCurtailmentEvent client wiring + edit-modal UI. - #321 Curtailment start/restore action UI. - #322 / #323 fleetnode enrollment + heartbeat stack. Conflict resolution: server/internal/handlers/middleware/rpc_permissions.go. Main added CurtailmentService reads + Update + DeviceCollection + DeviceSet + ErrorQuery + FleetManagement entries; the branch added IngestCurtailmentSignal. Took the union — folded the Ingest entry into the CurtailmentService block alongside Update/reads/AdminTerminate. handler.go auto-merged cleanly; build + targeted tests pass.
🤖 Created by AI agent for Negar.
Summary
Test plan
Closes #328