-
Notifications
You must be signed in to change notification settings - Fork 125
Feature/target env plugin #7456
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?
Conversation
Summary of ChangesHello @mskorokhodov, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a robust plugin system to the Laboratory feature, significantly enhancing its extensibility. The primary demonstration of this new capability is the 'Target Environment' plugin, which allows users to define and manage environment variables directly within the Laboratory. This change also refines the preflight script execution by enabling header manipulation and improves logging visibility, making the Laboratory more versatile and user-friendly for complex testing scenarios. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
🚀 Snapshot Release (
|
| Package | Version | Info |
|---|---|---|
@graphql-hive/apollo |
0.46.0-alpha-20251223213227-2823a4efeb0cb3ff095ab6be9bf6538a67e950a0 |
npm ↗︎ unpkg ↗︎ |
@graphql-hive/cli |
0.57.0-alpha-20251223213227-2823a4efeb0cb3ff095ab6be9bf6538a67e950a0 |
npm ↗︎ unpkg ↗︎ |
@graphql-hive/core |
0.19.0-alpha-20251223213227-2823a4efeb0cb3ff095ab6be9bf6538a67e950a0 |
npm ↗︎ unpkg ↗︎ |
@graphql-hive/envelop |
0.40.1-alpha-20251223213227-2823a4efeb0cb3ff095ab6be9bf6538a67e950a0 |
npm ↗︎ unpkg ↗︎ |
@graphql-hive/yoga |
0.46.1-alpha-20251223213227-2823a4efeb0cb3ff095ab6be9bf6538a67e950a0 |
npm ↗︎ unpkg ↗︎ |
hive |
8.14.0-alpha-20251223213227-2823a4efeb0cb3ff095ab6be9bf6538a67e950a0 |
npm ↗︎ unpkg ↗︎ |
hive-apollo-router-plugin |
2.3.6-alpha-20251223213227-2823a4efeb0cb3ff095ab6be9bf6538a67e950a0 |
npm ↗︎ unpkg ↗︎ |
hive-console-sdk-rs |
0.2.3-alpha-20251223213227-2823a4efeb0cb3ff095ab6be9bf6538a67e950a0 |
npm ↗︎ unpkg ↗︎ |
📚 Storybook DeploymentThe latest changes are available as preview in: https://pr-7456.hive-storybook.pages.dev |
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.
Code Review
This pull request introduces a plugin system for the Laboratory, enabling extensibility with custom commands and tabs, and includes an example 'Target Environment' plugin. My review focuses on the completeness and robustness of this new system. I've identified a critical issue with the plugin state management which appears incomplete, preventing stateful plugins from functioning as designed. Additionally, there's a high-severity issue regarding the LaboratoryTab type definition that compromises type safety. I've also noted some medium-severity concerns related to code duplication and redundant hook calls that should be addressed to enhance maintainability and performance.
| | 'onSettingsChange' | ||
| | 'defaultTests' | ||
| | 'onTestsChange' | ||
| | 'plugins' |
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.
The current implementation of the plugin system appears to be incomplete, particularly regarding state management. The LaboratoryPlugin interface defines defaultState and onStateChange, and the preflight.lab.object function signature includes state and setState. However, the core logic to manage this state within the Laboratory component or its hooks seems to be missing. Consequently, plugin commands and tabs are called with a hardcoded empty object {} for their state, and the preflight integration for plugins is not functional. This prevents plugins from being stateful, which seems to be a key part of the design as shown in the target-env plugin example.
| export type LaboratoryTab = | ||
| | LaboratoryTabOperation | ||
| | LaboratoryTabPreflight | ||
| | LaboratoryTabEnv | ||
| | LaboratoryTabHistory | ||
| | LaboratoryTabSettings | ||
| | LaboratoryTabTest; | ||
| | LaboratoryTabTest | ||
| | LaboratoryTabCustom; |
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.
The LaboratoryTab union type is not a safe discriminated union. The LaboratoryTabCustom interface has type: string, which is too broad and prevents TypeScript from correctly narrowing the type of tab in switch statements or if conditions. This forces the use of unsafe type assertions, as seen in packages/web/app/src/laboratory/components/laboratory/tabs.tsx. This compromises type safety and can lead to runtime errors if a plugin uses a type that conflicts with a built-in tab type.
To fix this, you could consider restricting custom tab types to not overlap with built-in ones, and potentially refine the LaboratoryTab and LaboratoryTabCustom types to make the union safer.
| env, | ||
| plugins, | ||
| } = useLaboratory(); | ||
| const laboratory = useLaboratory(); |
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.
The useLaboratory hook is called here for a second time. It's more efficient to call it only once at the top of the component, store its result in a variable (e.g., const laboratory = useLaboratory()), and then destructure the needed properties from that variable. This avoids redundant hook execution. This same pattern is repeated in LaboratoryContent (laboratory.tsx) and Tab (tabs.tsx) components.
| let customTab: LaboratoryPluginTab<Record<string, unknown>> | null = null; | ||
|
|
||
| for (const plugin of plugins) { | ||
| for (const tab of plugin.tabs ?? []) { | ||
| if (tab.type === props.item.type) { | ||
| customTab = tab; | ||
| break; | ||
| } | ||
| } | ||
| } |
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.
This logic to find a custom tab definition by its type is duplicated in tabName and tabIcon memos within this file, and also in the LaboratoryContent component in laboratory.tsx. To improve maintainability and reduce code duplication, this logic should be extracted into a reusable helper function or a custom hook, for example usePluginTab(tabType: string).
|
🐋 This PR was built and pushed to the following Docker images: Targets: Platforms: Image Tag: |
💻 Website PreviewThe latest changes are available as preview in: https://pr-7456.hive-landing-page.pages.dev |
c0189bd to
93ad419
Compare
Background
Description
Checklist