Skip to content

Refactor diff related components - #545

Merged
kyasbal merged 8 commits into
GoogleCloudPlatform:mainfrom
kyasbal:epic/diff-view-signal-migration
Mar 13, 2026
Merged

kyasbal merged 8 commits into
GoogleCloudPlatform:mainfrom
kyasbal:epic/diff-view-signal-migration

Conversation

@kyasbal

@kyasbal kyasbal commented Mar 11, 2026

Copy link
Copy Markdown
Member

This PR address the refactoring #537 for diff related components.

This replaces Observables with Signals, remove service dependency in dumb components and removed annotators.

kyasbal added 4 commits March 11, 2026 18:51
…moved annotator functionality (GoogleCloudPlatform#516)

* Refactor log-body component to use signals rather than observables and removed annotator functionality

* refactor log header component

* Simplify logic using RxJS with signals
* Removed annotator functionality

* fixed bug on timeline selection
* Generalize bisect utility

* fix suggested by gemini

* Added icon-toggle-button component in shared folder

* Refactoring log related components

* Removed unused id and class
* Generalize bisect utility

* fix suggested by gemini

* Refactor log related components. Removing service dependency from dumb components

* fix failing frontend test

* fix failing frontend test

* Added the warning message when JSON.parse failed for a log
@kyasbal
kyasbal requested a review from renamoo as a code owner March 11, 2026 10:39
@kyasbal kyasbal added the area:frontend Web frontend application and UI components label Mar 11, 2026
@kyasbal
kyasbal requested a review from jyane as a code owner March 11, 2026 10:39
@kyasbal kyasbal added the type:refactor Code refactoring without behavioral change label Mar 11, 2026
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 significantly refactors the diff-related components within the application's frontend. The primary goal was to modernize the codebase by adopting Angular Signals for reactive programming, thereby improving component modularity and reducing service dependencies in presentation components. The extensive 'annotator' system has been deprecated and removed, with its essential functionalities being absorbed into the new, more streamlined diff component architecture or replaced by a new generic CopiableKeyValueComponent. This change enhances maintainability and prepares the application for future Angular advancements.

Highlights

  • Refactoring Diff Components: The core diff viewing logic has been refactored into new, modular components: DiffContentComponent, DiffListHeaderComponent, and DiffListComponent. These components are now integrated into a new smart component, DiffSmartComponent.
  • Migration to Angular Signals: The diff-related components have been updated to utilize Angular Signals, replacing previous Observable-based patterns for state management and reactivity.
  • Removal of Annotator System: The entire annotator system, including Annotator, AnnotatorResolver, and related common components (CommonFieldAnnotatorComponent, CommonWarningMessageComponent, CommonReferenceListComponent, CommonToolbarButtonComponent), has been removed. Its functionality has been replaced by direct component inputs or the new CopiableKeyValueComponent.
  • Component Decoupling: Service dependencies have been removed from 'dumb' presentation components, promoting better separation of concerns and reusability.
  • Build and Test Script Enhancements: New make targets have been added for building Storybook (build-storybook) and running headless frontend tests (test-web-headless).
  • Consolidation of Diff Utilities: Utility functions for parsing principal information and formatting timestamps, previously in separate pipes, have been integrated directly into the DiffListComponent.
Changelog
  • scripts/make/build.mk
    • Added a new build-storybook target to build the Storybook application.
  • scripts/make/testing.mk
    • Introduced a test-web-headless target for running frontend tests in a headless Chrome environment with coverage reporting.
  • web/src/app/annotator/annotator.ts
    • Removed the core Annotator and AnnotatorResolver classes.
  • web/src/app/annotator/change-pair/default.ts
    • Removed the default change pair annotator resolver.
  • web/src/app/annotator/common-field-annotator.component.ts
    • Removed the CommonFieldAnnotatorComponent.
  • web/src/app/annotator/common-reference-list.component.html
    • Removed the HTML template for CommonReferenceListComponent.
  • web/src/app/annotator/common-reference-list.component.scss
    • Removed the SCSS styling for CommonReferenceListComponent.
  • web/src/app/annotator/common-reference-list.component.ts
    • Removed the CommonReferenceListComponent.
  • web/src/app/annotator/common-toolbar-button.component.html
    • Removed the HTML template for CommonToolbarButtonComponent.
  • web/src/app/annotator/common-toolbar-button.component.scss
    • Removed the SCSS styling for CommonToolbarButtonComponent.
  • web/src/app/annotator/common-toolbar-button.component.ts
    • Removed the CommonToolbarButtonComponent.
  • web/src/app/annotator/common-warning-message.component.html
    • Removed the HTML template for CommonWarningMessageComponent.
  • web/src/app/annotator/common-warning-message.component.ts
    • Removed the CommonWarningMessageComponent.
  • web/src/app/diff/components/diff-content.component.html
    • Added a new HTML template for the DiffContentComponent to display unified diffs and code snippets.
  • web/src/app/diff/components/diff-content.component.scss
    • Added new SCSS styling for the DiffContentComponent.
    • Renamed from web/src/app/annotator/change-pair/resolver.ts.
  • web/src/app/diff/components/diff-content.component.ts
    • Added the new DiffContentComponent to manage and display diff content, including managed fields toggling and content copying.
  • web/src/app/diff/components/diff-content.stories.ts
    • Added Storybook stories for the DiffContentComponent.
  • web/src/app/diff/components/diff-list-header.component.html
    • Added a new HTML template for the DiffListHeaderComponent to display resource metadata.
  • web/src/app/diff/components/diff-list-header.component.scss
    • Added new SCSS styling for the DiffListHeaderComponent.
    • Renamed from web/src/app/annotator/common-warning-message.component.scss.
  • web/src/app/diff/components/diff-list-header.component.ts
    • Added the new DiffListHeaderComponent to display resource timeline metadata using Angular Signals.
  • web/src/app/diff/components/diff-list-header.stories.ts
    • Added Storybook stories for the DiffListHeaderComponent.
  • web/src/app/diff/components/diff-list.component.html
    • Added a new HTML template for the DiffListComponent to display a virtual scrolling list of revisions.
  • web/src/app/diff/components/diff-list.component.scss
    • Added new SCSS styling for the DiffListComponent.
  • web/src/app/diff/components/diff-list.component.spec.ts
    • Added unit tests for utility functions within DiffListComponent (time formatting, principal parsing).
  • web/src/app/diff/components/diff-list.component.ts
    • Added the new DiffListComponent to manage and display a virtualized list of resource revisions, including selection and highlighting logic.
  • web/src/app/diff/components/diff-list.stories.ts
    • Added Storybook stories for the DiffListComponent.
  • web/src/app/diff/components/diff-toolbar.component.ts
    • Updated JSDoc comments for inputs and outputs to improve clarity.
  • web/src/app/diff/diff-smart.component.html
    • Added the new DiffSmartComponent HTML, integrating DiffListHeaderComponent, DiffListComponent, and DiffContentComponent.
  • web/src/app/diff/diff-smart.component.scss
    • Added new SCSS styling for the DiffSmartComponent.
  • web/src/app/diff/diff-smart.component.spec.ts
    • Renamed from web/src/app/diff/diff-view.component.spec.ts.
    • Removed annotator-related imports and providers from the test setup.
  • web/src/app/diff/diff-smart.component.ts
    • Renamed from web/src/app/diff/diff-view.component.ts.
    • Refactored to be a smart component, delegating presentation to new sub-components and removing direct DOM manipulation and annotator logic.
  • web/src/app/diff/diff-view-pipes.spec.ts
    • Removed the unit test file for ParsePrincipalPipe.
  • web/src/app/diff/diff-view-pipes.ts
    • Removed the ParsePrincipalPipe and related interfaces.
  • web/src/app/diff/diff-view.component.html
    • Removed the old DiffViewComponent HTML template.
  • web/src/app/diff/diff-view.component.scss
    • Removed the old DiffViewComponent SCSS styling.
  • web/src/app/extensions/public/timeline-navigator-extensions.ts
    • Updated to use CopiableKeyValueComponent instead of the removed CommonFieldAnnotatorComponent.
  • web/src/app/log/components/log-content-header.component.html
    • Updated the template to use khi-copiable-key-value instead of khi-common-field-annotator.
  • web/src/app/log/components/log-content-header.component.ts
    • Updated imports and usage to replace CommonFieldAnnotatorComponent with CopiableKeyValueComponent.
  • web/src/app/log/log-smart.component.spec.ts
    • Applied minor formatting adjustments.
  • web/src/app/log/log-smart.component.ts
    • Applied minor formatting adjustments.
  • web/src/app/pages/diff/diff.component.html
    • Updated the template to use khi-copiable-key-value and removed the loop for changePairAnnotators.
  • web/src/app/pages/diff/diff.component.spec.ts
    • Removed annotator-related imports and providers from the test setup.
  • web/src/app/pages/diff/diff.component.ts
    • Removed annotator-related imports, injections, and the changePairAnnotators property.
  • web/src/app/pages/main/main.component.html
    • Updated the main application template to use khi-diff-smart instead of khi-diff-view.
  • web/src/app/pages/main/main.component.ts
    • Updated the import statement for the diff component from DiffViewComponent to DiffSmartComponent.
  • web/src/app/root.module.ts
    • Removed annotator-related imports and providers from the root module configuration.
  • web/src/app/shared/components/copiable-key-value/copiable-key-value.component.html
    • Added new HTML template for the CopiableKeyValueComponent.
    • Renamed from web/src/app/annotator/common-field-annotator.component.html.
  • web/src/app/shared/components/copiable-key-value/copiable-key-value.component.scss
    • Added new SCSS styling for the CopiableKeyValueComponent.
    • Renamed from web/src/app/annotator/common-field-annotator.component.scss.
  • web/src/app/shared/components/copiable-key-value/copiable-key-value.component.ts
    • Added the new CopiableKeyValueComponent to display and copy key-value pairs, replacing previous annotator functionality.
  • web/src/app/timeline/components/misc/demo-builder.ts
    • Added inspectionDataUniqueID to the DemoViewModel for better identification.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 is an excellent and substantial refactoring of the diff-related components. The migration from RxJS to Signals, the adoption of standalone components, and the separation into smart and dumb components are all well-executed and align perfectly with modern Angular best practices and the repository's style guide. The removal of the Annotator pattern has significantly simplified the architecture. My review includes a couple of minor suggestions to improve CSS maintainability and code efficiency in the new components.

Note: Security Review did not run due to the size of the PR.

@renamoo renamoo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Probably in general it's better to keep PR a bit more small. For example, if it does 1) replaces Observables with Signals, 2) remove service dependency in dumb components and 3) removed annotators, there could be 3 PRs per each (if they are all independent)

@kyasbal
kyasbal merged commit 50acae9 into GoogleCloudPlatform:main Mar 13, 2026
9 of 10 checks passed
@kyasbal
kyasbal deleted the epic/diff-view-signal-migration branch March 13, 2026 01:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:frontend Web frontend application and UI components type:refactor Code refactoring without behavioral change

2 participants