Skip to content

fix(paths): Add cross-platform path normalization#18939

Merged
spencer426 merged 7 commits intomainfrom
fix/17136-windows-path-normalization
Feb 17, 2026
Merged

fix(paths): Add cross-platform path normalization#18939
spencer426 merged 7 commits intomainfrom
fix/17136-windows-path-normalization

Conversation

@spencer426
Copy link
Contributor

@spencer426 spencer426 commented Feb 12, 2026

Summary

Introduces a normalizePath utility function to provide consistent path representations across different operating systems. This helps prevent cross-platform inconsistencies, particularly between Windows and POSIX-based systems.

Details

This PR includes two main improvements:

  1. feat(paths): A new normalizePath utility function is created. It resolves paths to their absolute form, converts all backslashes to forward slashes, and correctly handles Windows case-insensitivity by lowercasing the entire path. This ensures a canonical path format is used throughout the application.

  2. fix(tests): The test suite is made more robust by refactoring confirmation.test.ts. The change ensure the reliable execution of asynchronous test cases by correctly mocking and handling the sequence of events in the tool confirmation flow, reducing potential flakiness.

Related Issues

Fixes #17136

How to Validate

  1. Pull down the branch.
  2. Run the full test suite to ensure all tests pass, including the new and updated ones.
    npm test
  3. To validate the new path normalization specifically, run its test file:
    npm test -- packages/core/src/utils/paths.test.ts
  4. Confirm the previously flaky test now runs reliably:
    npm test -- packages/core/src/scheduler/confirmation.test.ts

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

Introduces a
ormalizePath utility function to provide consistent
path representations across different operating systems. It resolves
paths to absolute, converts backslashes to forward slashes, and
handles Windows case-insensitivity by lowercasing the path.

fix(tests): Improve tool confirmation test stability

Refactors the confirmation.test.ts to ensure reliable execution of
asynchronous test cases by correctly mocking and handling the
sequence of events in the tool confirmation flow.
@spencer426 spencer426 requested a review from a team as a code owner February 12, 2026 18:47
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @spencer426, 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 improves the application's handling of file paths by introducing a robust cross-platform normalization utility. This ensures consistent path comparisons and operations regardless of the operating system, which is crucial for preventing subtle bugs. Concurrently, the reliability of the test suite has been enhanced, specifically addressing flakiness in asynchronous confirmation flows, leading to more stable and trustworthy tests.

Highlights

  • Cross-Platform Path Normalization: A new utility function, normalizePath, has been introduced to provide consistent path representations across different operating systems. It resolves paths to absolute form, converts backslashes to forward slashes, and handles Windows case-insensitivity by lowercasing the entire path.
  • Improved Test Reliability: The confirmation.test.ts suite has been refactored to enhance robustness and reduce flakiness, particularly for asynchronous test cases. This includes better mocking of editor resolution and reordering of test setup logic.
Changelog
  • packages/core/src/scheduler/confirmation.test.ts
    • Imported resolveEditorAsync and added a mock for it to control editor resolution in tests.
    • Ensured resolveEditorAsync mock is reset in beforeEach to prevent test flakiness.
    • Reordered test setup logic to ensure mocks for handleModifyWithEditor and toolMock.build are in place before the confirmation flow begins.
    • Refactored the test flow to explicitly wait for re-subscription after modification, improving asynchronous test reliability.
    • Added an assertion to verify that mockState.updateArgs is called after a modification.
  • packages/core/src/utils/paths.test.ts
    • Imported the new normalizePath function.
    • Added comprehensive test cases for normalizePath, covering relative to absolute path resolution, backslash conversion, Windows-specific lowercasing and drive letter normalization, and POSIX case preservation.
  • packages/core/src/utils/paths.ts
    • Updated the JSDoc for normalizePath to explicitly mention converting backslashes to forward slashes.
    • Modified the normalizePath implementation to convert all backslashes to forward slashes before applying platform-specific lowercasing on Windows.
Activity
  • The pull request introduces new features and fixes, with no explicit reviewer comments or activity recorded yet.
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.

@spencer426 spencer426 changed the title feat(paths): Add cross-platform path normalization fix(paths): Add cross-platform path normalization Feb 12, 2026
@github-actions
Copy link

github-actions bot commented Feb 12, 2026

Size Change: +56 B (0%)

Total Size: 24.4 MB

ℹ️ View Unchanged
Filename Size Change
./bundle/gemini.js 24.4 MB +56 B (0%)
./bundle/sandbox-macos-permissive-open.sb 890 B 0 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB 0 B
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB 0 B
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB 0 B
./bundle/sandbox-macos-strict-open.sb 4.82 kB 0 B
./bundle/sandbox-macos-strict-proxied.sb 5.02 kB 0 B

compressed-size-action

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 normalizePath utility function to ensure consistent path representations across different operating systems, which is a valuable addition for cross-platform compatibility. It correctly handles absolute paths, converts backslashes to forward slashes, and addresses Windows case-insensitivity by lowercasing paths. Additionally, the pull request includes refactoring of confirmation.test.ts to enhance test reliability by improving the mocking strategy and event handling, specifically targeting previously flaky asynchronous test cases. The identified issues in the review comments regarding test redundancy and assertion placement should be addressed to further improve test stability and clarity. Overall, the changes are positive for both functionality and test stability.


beforeEach(() => {
signal = new AbortController().signal;
vi.mocked(resolveEditorAsync).mockResolvedValue('vim');

This comment was marked as resolved.

const result = await promise;
expect(result.outcome).toBe(ToolConfirmationOutcome.ProceedOnce);
expect(mockModifier.handleModifyWithEditor).toHaveBeenCalled();
expect(mockState.updateArgs).toHaveBeenCalled();

This comment was marked as resolved.

@gemini-cli gemini-cli bot added the area/core Issues related to User Interface, OS Support, Core Functionality label Feb 12, 2026
- Move updateArgs assertion in confirmation.test.ts to match execution timing.
- Update shortenPath to handle both forward and backward slashes.
- Refactor isWithinRoot to use normalizePath for consistent Windows behavior.
- Use forward slashes for trailing separators in normalized paths.
- Fix assertion placement for updateArgs in ModifyWithEditor loop.
- Remove redundant awaitConfirmation unit tests covered by resolveConfirmation integration.
@spencer426 spencer426 force-pushed the fix/17136-windows-path-normalization branch 2 times, most recently from 9773ee7 to 4afb04b Compare February 12, 2026 19:43
- Move updateArgs assertion to accurately reflect execution flow.
- Retain resolveEditorAsync mock with clarification to ensure test stability.
@spencer426 spencer426 force-pushed the fix/17136-windows-path-normalization branch from 4afb04b to 4c41c2b Compare February 12, 2026 19:48
@spencer426 spencer426 enabled auto-merge February 12, 2026 22:37
@scidomino scidomino disabled auto-merge February 17, 2026 18:16
Copy link
Contributor

@jacob314 jacob314 left a comment

Choose a reason for hiding this comment

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

lgtm

@spencer426 spencer426 added this pull request to the merge queue Feb 17, 2026
Merged via the queue into main with commit 5e2f5df Feb 17, 2026
27 checks passed
@spencer426 spencer426 deleted the fix/17136-windows-path-normalization branch February 17, 2026 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Issues related to User Interface, OS Support, Core Functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows Path Robustness

3 participants