feat(ui): edit per-commodity flex-contexts through a commodity tab bar#2284
Open
Flix6x wants to merge 5 commits into
Open
feat(ui): edit per-commodity flex-contexts through a commodity tab bar#2284Flix6x wants to merge 5 commits into
Flix6x wants to merge 5 commits into
Conversation
Add a 'types' key to every UI_FLEX_CONTEXT_SCHEMA entry (same convention as UI_FLEX_MODEL_SCHEMA: typeTwo = single sensor reference, typeThree = fixed value or sensor, typeFour = list of sensors), resolving the todo about the field type living hardcoded in asset_context.html in 3 places. The template now derives its sensor-only check from the schema, so new context fields (e.g. the upcoming commodities and commitments editors) only need a schema entry. No behaviour change. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016MLCUiSdXDqDBmg8GbYp1B
#2230) The flex-context modal gains a pill bar: 'electricity' (the top-level context) plus one pill per entry of the commodities list, with add/remove affordances. The existing card editor is reused per scope; the add-field dropdown only offers fields that CommodityFlexContextSchema shares (driven by a new per-commodity flag on UI_FLEX_CONTEXT_SCHEMA entries). Saving PATCHes the whole flex-context including the nested commodities list. Also documents the commodities field (new COMMODITIES metadata + docs row) and removes it from the UI-schema exclusion list. Verified end-to-end against a live server with a seeded multi-commodity asset: per-scope editing, adding/removing commodities, duplicate-name rejection, and round-tripping through PATCH + reload. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016MLCUiSdXDqDBmg8GbYp1B
Per review on #2281: define each type token's UI description once (UI_TYPE_DESCRIPTIONS) instead of repeating it per field, and derive the backend type of each UI_FLEX_CONTEXT_SCHEMA entry from the corresponding DBFlexContextSchema field. Commitments are now correctly typed as a list of structured entries (new typeSix token) rather than fixed-or-sensor. Sensor-only exceptions that live in validators rather than field types (fixed prices forbidden in the DB, aggregate-power requiring a sensor) are listed explicitly with pointers to those validators. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016MLCUiSdXDqDBmg8GbYp1B
…rives to typeSix Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016MLCUiSdXDqDBmg8GbYp1B
Documentation build overview
|
This was referenced Jul 10, 2026
Contributor
Member
Author
|
In theory, anything is fine. The custom commodity only comes into play if the same commodity is referenced in a flex-model. We might want to seed the list with some standard ones, but besides |
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.

Description
Closes #2230. Stacked on #2281.
The flex-context modal gains a commodity pill bar: electricity (the top-level context) plus one pill per entry of the
commoditieslist, an + commodity affordance (with duplicate-name rejection), and a remove icon per commodity. The existing card editor is reused per scope, so all field types (fixed value, sensor picker, sensor lists) work within each commodity context.CommodityFlexContextSchemashares, driven by a newper-commodityflag computed ontoUI_FLEX_CONTEXT_SCHEMA(guarded by a new test).commoditiesdocumented: newCOMMODITIESmetadata constant + a row in the scheduling.rst flex-context table; removed from the UI-schema exclusion list so the parity test now enforces coverage.Look & Feel
Pill bar above the field cards; switching pills swaps the card list and the add-field dropdown to that commodity's scope.
How to test
Manually (verified end-to-end against a live server with a seeded multi-commodity asset): open an asset's context page → Edit flex-context → switch pills, add a field on the gas tab, add/remove a commodity, Save → PATCH returns 200 and the persisted
flex_contextround-trips on reload.Related Items
Stacked on #2281; #1572 (commitments editor) builds on this scope mechanism.
🤖 Generated with Claude Code
https://claude.ai/code/session_016MLCUiSdXDqDBmg8GbYp1B