Skip to content

Curtailment: wire update event API#329

Merged
negarn merged 10 commits into
mainfrom
negar/gh-328-curtailment-wire-update-event-api
May 28, 2026
Merged

Curtailment: wire update event API#329
negarn merged 10 commits into
mainfrom
negar/gh-328-curtailment-wire-update-event-api

Conversation

@negarn
Copy link
Copy Markdown
Contributor

@negarn negarn commented May 28, 2026

🤖 Created by AI agent for Negar.

Summary

  • Wire the active curtailment Manage flow to UpdateCurtailmentEvent
  • Map live active-event data into the edit modal and refresh curtailment surfaces after update
  • Add focused hook, panel, and request-builder coverage for the update path

Test plan

  • Open the active curtailment Manage modal and confirm fields are prefilled from the active event
  • Save operator-safe changes and confirm active status/history/header data refresh
  • Confirm start and stop/restore flows still work from the curtailment panel

Closes #328

@github-actions github-actions Bot added javascript Pull requests that update javascript code client labels May 28, 2026
@github-actions

This comment has been minimized.

@negarn negarn marked this pull request as ready for review May 28, 2026 15:36
Copilot AI review requested due to automatic review settings May 28, 2026 15:36
@negarn negarn requested a review from a team as a code owner May 28, 2026 15:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 edit mode UI and validation branch to CurtailmentStartModal and gate preview/sections accordingly.
  • Add buildUpdateCurtailmentEventRequest that sends only changed operator-safe fields (and zero when clearing a numeric setting).
  • Extend useCurtailmentApi with updateCurtailment, isUpdating, updateError, and activeEventFormValues mapped from the live event; wire CurtailmentManagementPanel to open the edit modal from ActiveCurtailmentStatus.

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.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment thread client/src/protoFleet/features/energy/curtailmentRequestBuilders.ts Outdated
Comment thread client/src/protoFleet/features/energy/curtailmentRequestBuilders.ts Outdated
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment thread client/src/protoFleet/features/energy/CurtailmentManagementPanel.tsx Outdated
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment thread client/src/protoFleet/features/energy/curtailmentRequestBuilders.ts Outdated
chatgpt-codex-connector[bot]

This comment was marked as resolved.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment thread client/src/protoFleet/features/energy/CurtailmentStartModal.tsx
Copy link
Copy Markdown
Contributor

@rongxin-liu rongxin-liu left a comment

Choose a reason for hiding this comment

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

Looks good overall!

Comment thread client/src/protoFleet/features/energy/CurtailmentStartModal.tsx Outdated
Comment thread client/src/protoFleet/features/energy/curtailmentRequestBuilders.ts Outdated
Comment thread client/src/protoFleet/api/useCurtailmentApi.test.ts
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment thread client/src/protoFleet/features/energy/CurtailmentManagementPanel.tsx Outdated
@negarn negarn merged commit 4abf2e8 into main May 28, 2026
72 checks passed
@negarn negarn deleted the negar/gh-328-curtailment-wire-update-event-api branch May 28, 2026 18:49
rongxin-liu added a commit that referenced this pull request May 29, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

client javascript Pull requests that update javascript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Curtailment: wire update event API

4 participants