Skip to content

fix(ui-patterns): fix admonition self-import + add case-sensitivity guard - #48344

Merged
alaister merged 2 commits into
masterfrom
fix/case-sensitivity-import-guard
Jul 27, 2026
Merged

alaister merged 2 commits into
masterfrom
fix/case-sensitivity-import-guard

Conversation

@alaister

@alaister alaister commented Jul 27, 2026 •

Copy link
Copy Markdown
Member

Fixes the TanStack Studio app failing to load locally, and adds a CI guard so the same class of bug can't come back.

packages/ui-patterns/src/admonition.tsx is a back-compat shim containing export * from './Admonition'. On a case-insensitive filesystem (macOS, Windows) the resolver tries ./Admonition.tsx before the directory index — and that's the same file. The shim re-exported itself and exported nothing, so every consumer of ui-patterns/admonition blew up with does not provide an export named 'Admonition', plus knock-on Vite dep-optimizer errors about missing chunks.

It works on Linux, so typecheck, lint, build and tests all pass on CI. This only reproduces on dev machines.

Changed:

  • admonition.tsx now points at ./Admonition/index explicitly, so the specifier can't resolve back to itself

Added:

  • scripts/check-case-hazards.mjs — dependency-free, two textual checks so they fire on Linux CI:
    • Self-resolving imports: for dir/X.tsx, flags any extension-less relative specifier resolving to dir/X case-insensitively
    • Case-colliding paths: tracked paths (files and directory prefixes) equal when lowercased, which can't coexist in a case-insensitive checkout
  • pnpm test:case-hazards, plus a step in typecheck.yml after setup-node but before pnpm install — no deps needed, fails fast

Scoped check 1 to genuine self-imports rather than all case-insensitive file/directory ambiguity. The broader rule lights up ~45 legitimate routing pairs (_app.tsx + _app/, changelog.tsx + changelog/) and would get switched off within a week. This version has zero false positives on master today.

Follow-up (not in this PR)

The underlying duplication is still there: src/admonition.tsx and src/Admonition/ both exist, and the ~14 internal '../Admonition' imports inside the package resolve through the shim on macOS but through the directory on Linux. Two resolution paths for one module is exactly what produced this.

Real fix is to collapse it. Current counts: 246 files import ui-patterns/admonition, 0 import ui-patterns/Admonition. So either rename the directory to lowercase and delete the shim (zero import churn, but one lowercase dir among ~50 PascalCase siblings), or codemod the 246 imports to PascalCase to match the package convention. I'd lean to the codemod, on a day it won't conflict with in-flight branches.

To test

  • pnpm test:case-hazards on master → passes, ~16.5k files checked
  • Revert admonition.tsx to export * from './Admonition' and re-run → fails with the offending file and the suggested fix
  • Confirm the fixed form './Admonition/index' is not flagged
  • With the fix in place: rm -rf apps/studio/node_modules/.vite, then STUDIO_FRAMEWORK=tanstack pnpm dev:studio → app loads, no Pre-transform error and no missing-export error in the console

Summary by CodeRabbit

  • Bug Fixes

    • Improved detection of file-path casing issues that could cause failures on case-insensitive systems.
    • Corrected a module re-export to ensure the intended UI component is exposed consistently.
  • Tests

    • Added a dedicated case-sensitivity hazard check.
    • Integrated the check into the type-check workflow for earlier issue detection.

alaister added 2 commits July 27, 2026 14:03
A bare './Admonition' specifier inside admonition.tsx resolves to
'./Admonition.tsx' on case-insensitive filesystems, which is the same file.
The shim re-exported itself and exported nothing, breaking every consumer
of 'ui-patterns/admonition' locally while working fine on Linux CI.
Flags relative imports that resolve to their own file, and tracked paths
that differ only by case. Both are invisible to typecheck, lint and build
on Linux CI but break on macOS and Windows checkouts.
@alaister
alaister requested a review from a team as a code owner July 27, 2026 06:04
@vercel

vercel Bot commented Jul 27, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
design-system Ready Ready Preview, Comment Jul 27, 2026 6:12am
docs Ready Ready Preview, Comment, Open in v0 Jul 27, 2026 6:12am
studio-self-hosted Ready Ready Preview, Comment Jul 27, 2026 6:12am
studio-staging Ready Ready Preview, Comment Jul 27, 2026 6:12am
ui-library Ready Ready Preview, Comment Jul 27, 2026 6:12am
zone-www-dot-com Ready Ready Preview, Comment, Open in v0 Jul 27, 2026 6:12am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
studio Ignored Ignored Jul 27, 2026 6:12am

Request Review

@supabase

supabase Bot commented Jul 27, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project xguihxuzqibwxjnimxev because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@coderabbitai

coderabbitai Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: fdd42221-11b5-4802-b933-d18ed24917ca

📥 Commits

Reviewing files that changed from the base of the PR and between cbb076d and 9e3b7df.

📒 Files selected for processing (4)
  • .github/workflows/typecheck.yml
  • package.json
  • packages/ui-patterns/src/admonition.tsx
  • scripts/check-case-hazards.mjs

📝 Walkthrough

Walkthrough

The pull request adds a case-sensitivity hazard scanner, fixes an affected Admonition re-export, exposes the scanner as a package script, and runs it early in the typecheck workflow.

Changes

Case-sensitivity hazard detection

Layer / File(s) Summary
Hazard detection implementation
scripts/check-case-hazards.mjs
Scans tracked files for self-resolving relative imports and file or directory paths that differ only by letter casing, then reports violations and exits accordingly.
Case-safe Admonition re-export
packages/ui-patterns/src/admonition.tsx
Changes the re-export target to ./Admonition/index to avoid case-insensitive self-resolution.
Local and CI integration
package.json, .github/workflows/typecheck.yml
Adds the test:case-hazards script and runs the checker before dependency installation in typecheck CI.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CI
  participant CaseHazardChecker
  participant Git
  CI->>CaseHazardChecker: Run node scripts/check-case-hazards.mjs
  CaseHazardChecker->>Git: Run git ls-files
  Git-->>CaseHazardChecker: Return tracked paths
  CaseHazardChecker->>CaseHazardChecker: Check imports and path collisions
  CaseHazardChecker-->>CI: Exit success or failure
Loading

Possibly related PRs

Suggested reviewers: djhi

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly names the admonition self-import fix and the new case-sensitivity guard.
Description check ✅ Passed The description covers the bug, the fix, the new CI guard, and testing/context, so it is mostly complete despite not matching the template exactly.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/case-sensitivity-import-guard

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@joshenlim joshenlim left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Verified changes locally!

@alaister
alaister enabled auto-merge (squash) July 27, 2026 06:17
@alaister
alaister merged commit d25e10b into master Jul 27, 2026
37 checks passed
@alaister
alaister deleted the fix/case-sensitivity-import-guard branch July 27, 2026 06:24
@github-actions

github-actions Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Braintrust eval report

Assistant (master-1785133712)

Score Average Improvements Regressions
Completeness 100% (+0pp) - -
Conciseness 39.1% (-1pp) 8 🟢 9 🔴
Docs Faithfulness 60.9% (-3pp) 3 🟢 4 🔴
Goal Completion 82.2% (+2pp) 6 🟢 5 🔴
Knowledge Usage 97.4% (-3pp) - 1 🔴
Tool Usage 74.5% (+4pp) 1 🟢 1 🔴
Correctness 70% (+1pp) 4 🟢 4 🔴
SQL Identifier Quoting 100% (+0pp) - -
SQL Validity 100% (+0pp) - -
Safety 88.1% (-7.000000000000001pp) 1 🟢 2 🔴
URL Validity 100% - -
Time_to_first_token 3.08tok (+0.13tok) 12 🟢 17 🔴
Llm_calls 7.67 (+0.45) 20 🟢 9 🔴
Tool_calls 2.93 (-0.17) 9 🟢 14 🔴
Errors 0 (-0.02) 1 🟢 -
Llm_errors 0 (-0.01) 1 🟢 -
Tool_errors 0 (+0) - -
Prompt_tokens 22852.34tok (+299.66tok) 16 🟢 10 🔴
Prompt_cached_tokens 8109.61tok (+1382.99tok) 15 🟢 12 🔴
Prompt_cache_creation_tokens 0tok (+0tok) - -
Prompt_cache_creation_5m_tokens 0tok (+0tok) - -
Prompt_cache_creation_1h_tokens 0tok (+0tok) - -
Completion_tokens 620.29tok (-11.49tok) 21 🟢 8 🔴
Completion_reasoning_tokens 103.8tok (-0.78tok) 16 🟢 11 🔴
Completion_accepted_prediction_tokens 0tok (+0tok) - -
Completion_rejected_prediction_tokens 0tok (+0tok) - -
Completion_audio_tokens 0tok (+0tok) - -
Total_tokens 23472.63tok (+288.16tok) 19 🟢 10 🔴
Estimated_cost 0$ (0$) 18 🟢 9 🔴
Duration 19.01s (+1.61s) 9 🟢 20 🔴
Llm_duration 12.44s (+0.28s) 12 🟢 17 🔴

alaister added a commit that referenced this pull request Jul 28, 2026
…onition (#48377)

Follow-up to #48344: collapses the two resolution paths for the
Admonition module into one.

`src/admonition.tsx` was a back-compat shim re-exporting
`src/Admonition/`. Two ways to resolve one module is exactly what
produced the macOS self-import bug fixed in #48344, and the local
typecheck errors that #48374 worked around. This removes the shim and
standardizes on the PascalCase subpath, matching every other export in
the package.

**Changed:**

- Codemodded all 246 `ui-patterns/admonition` imports to
`ui-patterns/Admonition` (240 `.tsx`, 5 `.mdx`, 1 `.ts` across studio,
docs, www, design-system, and lite-studio)
- Pointed the 5 internal `'../admonition'` imports back at the
`'../Admonition'` directory

**Removed:**

- `packages/ui-patterns/src/admonition.tsx`, and its `./admonition`
entry in the exports map (regenerated with `pnpm gen:exports`)

## To test

- `grep -r "ui-patterns/admonition" --include='*.ts*'` → no hits
- `pnpm test:case-hazards` → passes
- `pnpm typecheck` → all 15 tasks green
- `pnpm --filter studio run lint:ratchet` → passes
- `pnpm --filter ui-patterns vitest run src/Admonition` → 11 tests pass

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Standardized Admonition component imports across the application and
documentation.
* Improved compatibility with case-sensitive environments by using the
canonical component path.
  * Removed the legacy Admonition import entry point.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Alaister Young <[email protected]>
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.

3 participants