Repository navigation
Conversation
On Windows (case-insensitive filesystem), file paths reported by the watcher may differ in casing from the resolved input/output paths. This caused watch mode to miss full rebuilds when the input CSS path had different casing, and could also cause infinite rebuild loops when the output file path casing didn't match. Add a `pathsEqual()` helper that normalizes case on Windows and use it for the two path comparisons in the watch handler: - `resolvedFullRebuildPaths` membership check - output file identity check Closes tailwindlabs#16784 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review.
|
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/@tailwindcss-cli/src/commands/build/index.ts (1)
113-119:⚠️ Potential issue | 🟠 MajorUse
pathsEqualin the input/output self-overwrite guard too.This check is still case-sensitive, so on Windows
--inputand--outputcan point at the same file with different casing and bypass the safety check.Suggested fix
- if (args['--input'] === args['--output'] && args['--input'] !== '-') { + if ( + args['--input'] !== '-' && + args['--output'] !== '-' && + args['--input'] && + args['--output'] && + pathsEqual(args['--input'], args['--output']) + ) {🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/`@tailwindcss-cli/src/commands/build/index.ts around lines 113 - 119, Replace the strict equality check for input/output with the platform-aware comparator: instead of if (args['--input'] === args['--output'] && args['--input'] !== '-') use pathsEqual(args['--input'], args['--output']) && args['--input'] !== '-'; ensure pathsEqual is imported/available in this module and keep the existing eprintln(...) and process.exit(1) behavior (still compute highlighted relative paths with relative(args['--input']) / relative(args['--output'])).
🧹 Nitpick comments (1)
packages/@tailwindcss-cli/src/utils/paths-equal.test.ts (1)
25-35: Exercise both branches in every test run.This conditional only validates the current host platform, so a non-Windows CI job never executes the Windows behavior this PR is fixing. I’d make the platform choice injectable (or factor the branch into a helper) so both cases are asserted everywhere.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/`@tailwindcss-cli/src/utils/paths-equal.test.ts around lines 25 - 35, The test currently only runs the branch for the host OS; update the tests to exercise both branches by making the platform decision injectable or by factoring the logic into a helper so you can force the platform in tests. Specifically, modify the implementation of pathsEqual (or export a helper) so it accepts a platform flag (or expose an isCaseSensitive/platform helper) and then in paths-equal.test.ts call pathsEqual with both 'win32' and a non-Windows platform to assert true and false respectively; reference the pathsEqual function (and the new injectable/platform helper) so both behaviors are asserted on every CI run.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@packages/`@tailwindcss-cli/src/commands/build/index.ts:
- Around line 113-119: Replace the strict equality check for input/output with
the platform-aware comparator: instead of if (args['--input'] ===
args['--output'] && args['--input'] !== '-') use pathsEqual(args['--input'],
args['--output']) && args['--input'] !== '-'; ensure pathsEqual is
imported/available in this module and keep the existing eprintln(...) and
process.exit(1) behavior (still compute highlighted relative paths with
relative(args['--input']) / relative(args['--output'])).
---
Nitpick comments:
In `@packages/`@tailwindcss-cli/src/utils/paths-equal.test.ts:
- Around line 25-35: The test currently only runs the branch for the host OS;
update the tests to exercise both branches by making the platform decision
injectable or by factoring the logic into a helper so you can force the platform
in tests. Specifically, modify the implementation of pathsEqual (or export a
helper) so it accepts a platform flag (or expose an isCaseSensitive/platform
helper) and then in paths-equal.test.ts call pathsEqual with both 'win32' and a
non-Windows platform to assert true and false respectively; reference the
pathsEqual function (and the new injectable/platform helper) so both behaviors
are asserted on every CI run.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: ea04a4d8-0679-484c-8a3c-6bed62d84a6a
📒 Files selected for processing (3)
packages/@tailwindcss-cli/src/commands/build/index.tspackages/@tailwindcss-cli/src/utils/paths-equal.test.tspackages/@tailwindcss-cli/src/utils/paths-equal.ts
[Medium impact] The PR appears safe to merge, with the previous test-coverage finding addressed. Reviews (3) · Last reviewed commit: "Add a Windows watch mode test for differ..." · Reviewed by Greptile |
Move getRebuildStrategy next to the other build helpers so a test can reach it without loading the native scanner, and let it take the platform. The new tests fail if the rebuild check goes back to a case-sensitive comparison. Also add the changelog entry for this fix.
|
Pushed a1a6f10 for the review note that watch behavior stayed untested. I added unit coverage rather than the end-to-end test it asked for. The rebuild decision moved into I did not add a test that starts the CLI with differently cased paths, since I have no Windows host to run it on, so that review thread is still open. Tested on macOS with Node 24.18 and Rust 1.95: vitest passes (5664 passed, 1 skipped) and cargo test passes. |
Starts the CLI with --input Src/Index.css while the file on disk is src/index.css, then changes the theme in that file. The theme change only lands through a full rebuild, so the test fails if watch mode stops recognizing the input file.
Summary
Fixes #16784
On Windows (case-insensitive filesystem), the CLI
--watchmode doesn't rebuild when the input file path casing differs from what exists on disk. For example, if the file issrc/Input.cssbut the watcher reportssrc/input.css, the comparison fails silently.The fix adds a
pathsEqual()helper that uses case-insensitive comparison onprocess.platform === 'win32'. This is applied to:[ci-all]
Test plan
pathsEqual()verifying identical paths match, different paths don't, and platform-appropriate case sensitivitypnpm build && pnpm testpassesThis contribution was developed with AI assistance (Claude Code).