-
Notifications
You must be signed in to change notification settings - Fork 13
UI to support Runtimes recommendation env parameters display #243
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: mvp_demo
Are you sure you want to change the base?
UI to support Runtimes recommendation env parameters display #243
Conversation
Reviewer's GuideAdds conditional rendering and formatting of environment variable parameters in recommendation detail code snippets for both cost and performance views in Local and Remote Monitoring, while normalizing YAML-like output formatting. Class diagram for recommendation details components env handlingclassDiagram
class CostDetailsRemote {
+recommendedData any[]
+currentData any[]
+chartData any
+day any
+endt any
+formatEnvParams(recommendedData any[]): string
+buildRecommendedCode(): string
}
class PerfDetailsRemote {
+recommendedData any[]
+currentData any[]
+chartData any
+day any
+endt any
+formatEnvParams(recommendedData any[]): string
+buildRecommendedCode(): string
}
class CostDetailsLocal {
+recommendedData any[]
+currentData any[]
+chartData any
+day any
+endt any
+experimentType string
+formatEnvParams(recommendedData any[]): string
+buildRecommendedCode(): string
}
class PerfDetailsLocal {
+recommendedData any[]
+currentData any[]
+chartData any
+day any
+endt any
+experimentType string
+formatEnvParams(recommendedData any[]): string
+buildRecommendedCode(): string
}
class RecommendationData {
+requests any
+limits any
+recommendation_engines RecommendationEngines
}
class RecommendationEngines {
+cost RecommendationEngine
+performance RecommendationEngine
}
class RecommendationEngine {
+config RecommendationEngineConfig
+variation any
}
class RecommendationEngineConfig {
+requests any
+limits any
+env EnvParam[]
}
class EnvParam {
+name string
+value string
}
CostDetailsRemote --> RecommendationData : uses_recommendedData
PerfDetailsRemote --> RecommendationData : uses_recommendedData
CostDetailsLocal --> RecommendationData : uses_recommendedData
PerfDetailsLocal --> RecommendationData : uses_recommendedData
RecommendationData --> RecommendationEngines : has
RecommendationEngines --> RecommendationEngine : cost_and_performance
RecommendationEngine --> RecommendationEngineConfig : has
RecommendationEngineConfig --> EnvParam : env_parameters
CostDetailsRemote ..> EnvParam : formats_env_section
PerfDetailsRemote ..> EnvParam : formats_env_section
CostDetailsLocal ..> EnvParam : formats_env_section
PerfDetailsLocal ..> EnvParam : formats_env_section
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey - I've found 2 issues, and left some high level feedback:
- The
envParams→envSectionformatting logic is duplicated across four components; consider extracting this into a shared utility/helper to avoid repetition and keep formatting consistent. - When interpolating
e.valueinto the YAML-like output, consider escaping or sanitizing values (e.g., embedded quotes or newlines) so that the generated snippet remains valid and copy‑paste‑able.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `envParams` → `envSection` formatting logic is duplicated across four components; consider extracting this into a shared utility/helper to avoid repetition and keep formatting consistent.
- When interpolating `e.value` into the YAML-like output, consider escaping or sanitizing values (e.g., embedded quotes or newlines) so that the generated snippet remains valid and copy‑paste‑able.
## Individual Comments
### Comment 1
<location> `src/app/Analytics/RemoteMonitoring/RecommendationComponents/CostDetails.tsx:38-40` </location>
<code_context>
- const recommended_code = `${resource_name}:
- requests:
+ // Format env parameters if they exist
+ const envParams = props.recommendedData[0]?.recommendation_engines?.cost?.config?.env;
+ const envSection = envParams?.length > 0
+ ? '\nenv:\n' + envParams.map(e => ` - name: ${e.name}\n value: "${e.value}"`).join('\n')
+ : '';
+
</code_context>
<issue_to_address>
**issue (bug_risk):** Environment values are interpolated without escaping, which can break the rendered YAML when values contain quotes or newlines.
Values containing quotes, newlines, or `#` will produce invalid or misleading YAML in this template. It’d be safer to run each `env` value through a quoting/escaping helper (for example, wrapping in single quotes and escaping internal single quotes, and normalizing/removing newlines) before interpolating into the YAML string.
</issue_to_address>
### Comment 2
<location> `src/app/Analytics/RemoteMonitoring/RecommendationComponents/PerfDetails.tsx:37-39` </location>
<code_context>
- const recommended_code = `${resource_name}:
- requests:
+ // Format env parameters if they exist
+ const envParams = props.recommendedData[0]?.recommendation_engines?.performance?.config?.env;
+ const envSection = envParams?.length > 0
+ ? '\nenv:\n' + envParams.map(e => ` - name: ${e.name}\n value: "${e.value}"`).join('\n')
+ : '';
+
</code_context>
<issue_to_address>
**suggestion:** The env formatting logic is duplicated across multiple components and could be centralized.
Similar `envParams` / `envSection` logic now lives in multiple components (including the local monitoring variants). Consider extracting a shared helper (e.g., `formatEnv(envParams)`) to avoid duplication and ensure YAML formatting stays consistent if the behavior changes later.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| const envParams = props.recommendedData[0]?.recommendation_engines?.cost?.config?.env; | ||
| const envSection = envParams?.length > 0 | ||
| ? '\nenv:\n' + envParams.map(e => ` - name: ${e.name}\n value: "${e.value}"`).join('\n') |
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.
issue (bug_risk): Environment values are interpolated without escaping, which can break the rendered YAML when values contain quotes or newlines.
Values containing quotes, newlines, or # will produce invalid or misleading YAML in this template. It’d be safer to run each env value through a quoting/escaping helper (for example, wrapping in single quotes and escaping internal single quotes, and normalizing/removing newlines) before interpolating into the YAML string.
| const envParams = props.recommendedData[0]?.recommendation_engines?.performance?.config?.env; | ||
| const envSection = envParams?.length > 0 | ||
| ? '\nenv:\n' + envParams.map(e => ` - name: ${e.name}\n value: "${e.value}"`).join('\n') |
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.
suggestion: The env formatting logic is duplicated across multiple components and could be centralized.
Similar envParams / envSection logic now lives in multiple components (including the local monitoring variants). Consider extracting a shared helper (e.g., formatEnv(envParams)) to avoid duplication and ensure YAML formatting stays consistent if the behavior changes later.
Description:
Adds support for displaying environment variable parameters in recommendation configurations.
Changes:
Summary by Sourcery
Add UI support to surface environment variable parameters in recommendation details for both cost and performance views across local and remote monitoring.
New Features:
Enhancements: