-
Notifications
You must be signed in to change notification settings - Fork 124
Rewrite proposal diff rendering to allow collapsing #7491
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 @jdolle, 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 fundamentally re-architects the schema diff rendering system to improve its flexibility and prepare for advanced user interface features, such as collapsible diff sections. By decoupling the diff calculation from the rendering process and introducing a structured, intermediary representation of changes, the system gains greater control over how differences are displayed and interacted with. 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/cli |
0.57.2-alpha-20260115213228-cd2bf3583e2164d109ab931f8469090c419eaccb |
npm ↗︎ unpkg ↗︎ |
hive |
9.0.0-alpha-20260115213228-cd2bf3583e2164d109ab931f8469090c419eaccb |
npm ↗︎ unpkg ↗︎ |
📚 Storybook DeploymentThe latest changes are available as preview in: https://pr-7491.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 significant and well-architected refactoring of the schema diff rendering logic. The new approach separates the diff calculation from the rendering by using a builder pattern to create an intermediate representation of the diff. This is a great improvement for maintainability and will enable new features like collapsible sections.
However, the new implementation introduces several critical correctness issues, primarily related to incorrect non-null assertions on nullable types, which will cause runtime crashes. There are also some other bugs related to change highlighting and coordinate generation that need to be addressed. Once these issues are resolved, this will be a solid improvement to the codebase.
packages/web/app/src/components/target/proposals/schema-diff/words.tsx
Outdated
Show resolved
Hide resolved
packages/web/app/src/components/target/proposals/schema-diff/core.tsx
Outdated
Show resolved
Hide resolved
| write(...words: WordProps[]) { | ||
| currentLine?.words.push(...words); | ||
| }, |
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 write method fails silently if currentLine is undefined (i.e., if write is called before newLine). This could lead to subtle bugs where parts of the diff are missing without any error being thrown.
To make the builder more robust and prevent silent failures, consider throwing an error if currentLine is not set.
write(...words: WordProps[]) {
if (!currentLine) {
throw new Error('Builder.write() was called before Builder.newLine().');
}
currentLine.words.push(...words);
},|
🐋 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-7491.hive-landing-page.pages.dev |
Background
https://linear.app/the-guild/issue/CONSOLE-1678/schema-proposals-diff-view-should-show-only-what-has-changed-and-the
For changes that touch very few lines compared to the total lines of SDL, it makes sense to collapse untouched portions of the schema. This reduces the amount of text people have to scan during a review and puts focus on exactly what has changed.
Description
Using our previous method of parsing and rendering the SDL within components made it difficult to determine which lines are able to be hidden.
To accomplish our goal, parsing needs to happen first so that the lines can be categorized appropriately before render. I first created a builder instance that would be capable to capturing and then returning all the necessary data to group and render these lines.
The rest is rewriting every component to instead leverage this builder.
With this framework in place, we can fairly easily tweak the actual rendering logic of how we collapse and show lines.