Skip to content

Conversation

@cs-util
Copy link

@cs-util cs-util commented Dec 22, 2025

No description provided.

…l referenceDistance and verify it remains unchanged after handleDistanceModalCancel() is called
…nitSelect in index.js to include logic that updates all pinned measurement labels.

Exported setupEventHandlers: Added setupEventHandlers to the __testables export in index.js to facilitate integration testing.
Added Integration Test: Added a new test case to index.scale.test.js:268-301 to verify that pinned measurement labels are correctly updated when the global unit changes.
Improved Mocks: Updated the L.divIcon mock in index.scale.test.js:35 to correctly capture and return options for verification in tests
Creating a centralized createDistanceLabelHtml helper function in index.js:754 that handles the generation of distance labels with optional "Pin" or "Delete" buttons.
Updating drawReferenceVisualization, updateMeasureLabel, and pinCurrentMeasurement to use this new helper.
Replacing the regex-based replacement in pinCurrentMeasurement with a clean re-render of the label using the helper function
@gemini-code-assist
Copy link

Summary of Changes

Hello @cs-util, 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 significant set of advanced features and polish, completing "Phase 3" of development. It focuses on enhancing user experience through persistent settings, robust scale validation, and more flexible measurement tools. The changes also include comprehensive testing to ensure stability and correctness of the new functionalities.

Highlights

  • Persistence & Settings: Implemented localStorage for preferredUnit and referenceDistance, ensuring settings and reference visualization persist across sessions.
  • Scale Validation & Hybrid Calibration: Introduced a UI warning for significant scale mismatches (>10%) between manual and GPS calibrations, and enabled GPS calibration to use a fixed-scale similarity model when a manual reference exists.
  • Measurement Enhancements: Added support for multiple pinned measurements, a "Pin" button on measurement labels, a "Clear All" button, and automatic pinning of measurements when starting a new one.
  • UI/UX Polish: Integrated a global unit selector (m, ft, ft-in) in the header, made the reference line interactive for editing, added a delete button to the reference scale label, and ensured the reference distance is cleared upon new photo import.
  • Comprehensive Testing: Included new integration tests (src/index.scale.test.js) and property-based tests (src/scale/scale.property.test.js) for mathematical edge cases and UI interactions, achieving high test coverage.

🧠 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 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

@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 significant and well-implemented feature for manual scaling and measurement. The changes are extensive, covering UI, core logic, and persistence. The code is well-structured, particularly with the extraction of state machine logic into pure, testable functions. The addition of comprehensive integration and property-based tests is excellent and greatly improves the robustness of the new functionality. I've identified one medium-severity issue related to code duplication that could be refactored for better maintainability. Overall, this is a high-quality contribution.

Comment on lines +1705 to +1715
state.measureMode.pinned.forEach((item) => {
if (item.ui.label) {
const sourceIcon = item.source === 'manual' ? '📏' : '📡';
const newHtml = `<div class="distance-label distance-label--measure" style="background:${COLORS.MEASURE};">${sourceIcon} ${formatDistance(item.meters, state.preferredUnit)}</div>`;
item.ui.label.setIcon(L.divIcon({
className: 'measure-label',
html: newHtml,
iconAnchor: [0, 0],
}));
}
});

Choose a reason for hiding this comment

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

medium

There's a small duplication of logic here for generating the HTML for pinned measurement labels. The createDistanceLabelHtml function was introduced to centralize this logic, but it's not used here. Reusing the helper function will make the code more maintainable and consistent.

      state.measureMode.pinned.forEach((item) => {
        if (item.ui.label) {
          const sourceIcon = item.source === 'manual' ? '📏' : '📡';
          item.ui.label.setIcon(L.divIcon({
            className: 'measure-label',
            html: createDistanceLabelHtml({
              meters: item.meters,
              color: COLORS.MEASURE,
              icon: sourceIcon,
              showPin: false,
              extraClass: 'distance-label--measure',
            }),
            iconAnchor: [0, 0],
          }));
        }
      });

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.

2 participants