-
Notifications
You must be signed in to change notification settings - Fork 24
feat(frontier): add InputHintOption for structured preference options #442
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -518,6 +518,14 @@ message AuditLog { | |||||||||||||||||||||||||||||||||||||
| }]; | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| // InputHintOption represents a selectable option with a machine-readable name and user-friendly title | ||||||||||||||||||||||||||||||||||||||
| message InputHintOption { | ||||||||||||||||||||||||||||||||||||||
| // Machine-readable identifier (e.g., "sq_km", "megagram") | ||||||||||||||||||||||||||||||||||||||
| string name = 1; | ||||||||||||||||||||||||||||||||||||||
| // User-friendly display title (e.g., "Square Kilometers", "Megagram (Mg)") | ||||||||||||||||||||||||||||||||||||||
| string title = 2; | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| // PreferenceTrait is a trait that can be used to add preferences to a resource | ||||||||||||||||||||||||||||||||||||||
| // it explains what preferences are available for a resource | ||||||||||||||||||||||||||||||||||||||
| message PreferenceTrait { | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -547,6 +555,9 @@ message PreferenceTrait { | |||||||||||||||||||||||||||||||||||||
| reserved 20 to 26; | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| InputType input_type = 27; | ||||||||||||||||||||||||||||||||||||||
| // Structured input options with name and title for select/combobox/multiselect inputs | ||||||||||||||||||||||||||||||||||||||
| // Takes precedence over input_hints when both are provided | ||||||||||||||||||||||||||||||||||||||
| repeated InputHintOption input_options = 28; | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
557
to
+560
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make the precedence rule unambiguous when If clients send 🧭 Option A: enforce non-empty lists- // Takes precedence over input_hints when both are provided
- repeated InputHintOption input_options = 28;
+ // Takes precedence over input_hints when non-empty
+ repeated InputHintOption input_options = 28 [
+ (validate.rules).repeated = {min_items: 1}
+ ];🧭 Option B: clarify fallback in comment (if empty lists are allowed)- // Takes precedence over input_hints when both are provided
+ // Takes precedence over input_hints when non-empty; otherwise input_hints applies
repeated InputHintOption input_options = 28;📝 Committable suggestion
Suggested change
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| message Preference { | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -561,6 +572,9 @@ message Preference { | |||||||||||||||||||||||||||||||||||||
| // scope_id is the identifier of the scope context (e.g., organization ID) | ||||||||||||||||||||||||||||||||||||||
| // Only applicable when scope_type is set | ||||||||||||||||||||||||||||||||||||||
| string scope_id = 7; | ||||||||||||||||||||||||||||||||||||||
| // value_title is the human-readable display title for the value | ||||||||||||||||||||||||||||||||||||||
| // Populated from InputHintOption.title when the trait has input_options configured | ||||||||||||||||||||||||||||||||||||||
| string value_title = 8; | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| google.protobuf.Timestamp created_at = 10 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { | ||||||||||||||||||||||||||||||||||||||
| description: "The time when the preference was created.", | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
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.
Add validation for
InputHintOptionfields to avoid empty/invalid identifiers.Empty
namevalues undermine the “machine‑readable identifier” contract and can collide in storage/validation. Consider enforcing non‑empty (and optionally a stable pattern) fornameandtitle.🛡️ Suggested validation rules
message InputHintOption { // Machine-readable identifier (e.g., "sq_km", "megagram") - string name = 1; + string name = 1 [(validate.rules).string = {min_len: 1, pattern: "^[A-Za-z0-9-_]+$"}]; // User-friendly display title (e.g., "Square Kilometers", "Megagram (Mg)") - string title = 2; + string title = 2 [(validate.rules).string = {min_len: 1}]; }🤖 Prompt for AI Agents