Skip to content

Conversation

@lxfu1
Copy link
Member

@lxfu1 lxfu1 commented Dec 23, 2025

Checklist
  • npm test passes
  • documents are updated
Description of change

Dec-23-2025 20-14-51

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @lxfu1, 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 enhances the brushFilter interaction by adding a history option. This new feature allows the chart to remember previous brush selections, enabling users to revert to a prior filtered state by double-clicking. This provides a more flexible and interactive way to explore data by allowing users to undo filter operations step-by-step.

Highlights

  • Historical Brushing Capability: Introduced a new history option for the brushFilter interaction, allowing users to track and revert through previous brush selections.
  • State Management for Brushing: Implemented a mechanism to store brush states, enabling a 'step-back' functionality when resetting the brush filter.
  • New Test Cases and Documentation: Added new integration tests and updated both English and Chinese documentation to reflect the new history property for brushFilter.
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.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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 history option to the brushFilter interaction, allowing users to undo brush actions. The implementation adds logic to store brush states and revert to them on dblclick. The changes look good overall, but there are a few points to address:

  • A potential race condition exists because an async function is not being awaited.
  • The undo logic in the reset function could be made more intuitive for a multi-level undo experience.
  • The new test is missing a crucial snapshot to verify the undo behavior.
  • There's a minor typo in the updated documentation.

filtered = true;
},
reset: (event) => {
reset: async (event) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

This function is now async, but its caller, the click handler within the outer brushFilter function, does not await the call to reset. This can lead to race conditions and unpredictable behavior. The click handler should be updated to be async and await this promise.

// in brushFilter(...)
  async function click(e) {
    if (isDblclick(e)) {
      e.nativeEvent = true;
      await reset(e);
    }
  }

Although this change is outside the diff, it's critical for the correctness of this feature.

Comment on lines +28 to +48
penguinsPointBrushFilterWithHistory.steps = ({ canvas }) => {
const { document } = canvas;
const plot = document.getElementsByClassName(PLOT_CLASS_NAME)[0];
return [
{
changeState: () => {
brush(plot, 100, 100, 300, 300);
},
},
{
changeState: () => {
brush(plot, 100, 100, 300, 300);
},
},
{
changeState: () => {
dblclick(plot);
},
},
];
};
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The test for the history feature seems incomplete and could be improved:

  1. Missing Snapshot: The test steps include a dblclick to trigger the undo functionality, but the corresponding snapshot (step3.svg) is missing from the pull request. This is the most critical part of the test for this feature and should be included to verify the undo behavior.
  2. Test Case Improvement: Both brush actions use the same coordinates (100, 100, 300, 300). While this tests the history mechanism, using different coordinates for the second brush would make the visual change between step1 and step2 clearer, and would provide a more robust verification when step3 reverts to the state of step1.

| Property | Description | Type | Default | Required |
| -------- | ------------------------ | ------------- | ----------------- | -------- |
| reverse | Whether to reverse brush | boolean | false | |
| history | Whether to histroy brush | boolean | false | |
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

There's a typo here. It should be history instead of histroy.

Suggested change
| history | Whether to histroy brush | boolean | false | |
| history | Whether to history brush | boolean | false | |

setState('brushFilter');
update();
// Restore previous brush state
if (brushHistory.length > 1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The logic if (brushHistory.length > 1) for handling history is a bit counter-intuitive. It means that undoing the very first brush action results in a full reset, rather than stepping back to the initial state. A user would likely expect to be able to undo each brush step by step.

A more conventional undo behavior would be to pop from history on every dblclick until the history is empty.

Consider refactoring the logic to handle undo consistently for all levels of history. For example:

if (history && brushHistory.length > 0) {
  brushHistory.pop();
  if (brushHistory.length > 0) {
    // Restore previous state
  } else {
    // Reset to initial state
  }
} else {
  // Reset to initial state (if no history)
}

This would provide a more predictable multi-level undo experience.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 20460481285

Details

  • 26 of 26 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.003%) to 79.963%

Totals Coverage Status
Change from base Build 20455535222: -0.003%
Covered Lines: 10476
Relevant Lines: 12564

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants