Skip to content

revert: always rebuild frontend, override caching with _NEED_FRONTEND_BUILD=true#4427

Merged
danielhanchen merged 4 commits into
mainfrom
fix/revert-frontend-build-caching
Mar 18, 2026
Merged

revert: always rebuild frontend, override caching with _NEED_FRONTEND_BUILD=true#4427
danielhanchen merged 4 commits into
mainfrom
fix/revert-frontend-build-caching

Conversation

@danielhanchen
Copy link
Copy Markdown
Member

@danielhanchen danielhanchen commented Mar 18, 2026

Summary

Adds a single _NEED_FRONTEND_BUILD=true line after the mtime-based caching block in setup.sh and setup.ps1, overriding whatever the cache check decided.

The caching logic itself is left intact for future re-enabling -- just remove the override line.

Why

Mtime-based caching is unreliable in the current setup:

  • Git does not preserve file timestamps on clone/pull
  • Tailwind v4 requires hiding site-packages/.gitignore before vite build; the cache path can bypass this, producing broken CSS

The mtime-based caching introduced in #4404/#4413 can incorrectly skip
frontend builds -- e.g. after git pull when filesystem timestamps are
not preserved, or after our Tailwind v4 discovery that the site-packages
.gitignore must be hidden before vite build (which the cached path
doesn't handle).

Always rebuild the frontend on setup. The build takes ~15s and is
safer than risking a stale dist/.
Caching disabled by always setting _NEED_FRONTEND_BUILD=true.
The mtime-based logic is preserved in comments for future re-enabling.

Reasons for disabling:
- Git does not preserve file timestamps, so cached dist/ can appear
  newer than freshly checked-out source after a pull
- Tailwind v4 requires hiding site-packages/.gitignore before vite
  build; the cache path bypasses this, producing broken CSS
@danielhanchen danielhanchen changed the title revert: remove frontend build caching from setup scripts revert: disable frontend build caching, keep code commented out Mar 18, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 removes the frontend build caching mechanism from the setup scripts. The caching, which aimed to skip frontend builds when no source files were newer than the existing dist/ directory, proved unreliable due to issues with file timestamps in Git and conflicts with the Tailwind CSS build process. By reverting to a consistent build process, this change ensures that the frontend is always built when needed, reducing the risk of shipping stale code.

Highlights

  • Reverts Frontend Build Caching: This PR reverts the mtime-based frontend build caching logic introduced previously due to its unreliability.
  • Addresses Issues with Timestamping and Tailwind: The caching logic was found to be problematic because Git doesn't preserve file timestamps, and it interfered with the Tailwind v4 oxide scanner.
  • Simplifies Build Process: The change unconditionally sets _NEED_FRONTEND_BUILD to true for non-pip installs, ensuring the frontend is always built when necessary.
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.

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.

@danielhanchen danielhanchen changed the title revert: disable frontend build caching, keep code commented out revert: always rebuild frontend, override caching with _NEED_FRONTEND_BUILD=true Mar 18, 2026
@danielhanchen danielhanchen merged commit 7ddb660 into main Mar 18, 2026
4 checks passed
@danielhanchen danielhanchen deleted the fix/revert-frontend-build-caching branch March 18, 2026 14:37
Copy link
Copy Markdown
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 disables the frontend build caching by consistently setting the build flag to true. While this achieves the goal, the implementation deletes the caching logic entirely, which contradicts the pull request's title and description stating the code should be commented out for future re-enabling. I've provided suggestions to comment out the respective logic in both setup.sh and setup.ps1 to align with the stated intent and improve maintainability.

I am having trouble creating individual review comments. Click here to see my feedback.

studio/setup.ps1 (830)

medium

The pull request description states that the caching logic should be preserved in comments for easy re-enabling. However, the elseif block containing this logic has been deleted. To align with the PR's intent, it's better to comment out this block.

}
# The mtime-based build cache is temporarily disabled. To re-enable, uncomment the following 'elseif' block.
# elseif (Test-Path (Join-Path $FrontendDir "dist")) {
#     $DistDir = Join-Path $FrontendDir "dist"
#     $DistTime = (Get-Item $DistDir).LastWriteTime
#     $NewerFile = $null
#     # Check src/ and public/ recursively (probe paths directly, not via -Include)
#     foreach ($subDir in @("src", "public")) {
#         $subPath = Join-Path $FrontendDir $subDir
#         if (Test-Path $subPath) {
#             $NewerFile = Get-ChildItem -Path $subPath -Recurse -File -ErrorAction SilentlyContinue |
#                 Where-Object { $_.LastWriteTime -gt $DistTime } | Select-Object -First 1
#             if ($NewerFile) { break }
#         }
#     }
#     # Also check all top-level files (package.json, bun.lock, vite.config.ts, index.html, etc.)
#     if (-not $NewerFile) {
#         $NewerFile = Get-ChildItem -Path $FrontendDir -File -ErrorAction SilentlyContinue |
#             Where-Object { $_.LastWriteTime -gt $DistTime } |
#             Select-Object -First 1
#     }
#     if (-not $NewerFile) {
#         $NeedFrontendBuild = $false
#         Write-Host "[OK] Frontend already built and up to date -- skipping build" -ForegroundColor Green
#     } else {
#         Write-Host "[INFO] Frontend source changed since last build -- rebuilding..." -ForegroundColor Yellow
#     }
# }

studio/setup.sh (44)

medium

The pull request description indicates that the caching logic should be commented out, but it has been deleted. To make it easier to re-enable this logic in the future, please preserve it within comments as intended.

_NEED_FRONTEND_BUILD=true
# The mtime-based build cache is temporarily disabled. To re-enable, uncomment the following block.
# if [ -d "$SCRIPT_DIR/frontend/dist" ]; then
#     # Check all top-level files (package.json, bun.lock, vite.config.ts, index.html, etc.)
#     _changed=$(find "$SCRIPT_DIR/frontend" -maxdepth 1 -type f \
#         -newer "$SCRIPT_DIR/frontend/dist" -print -quit 2>/dev/null)
#     # Check src/ and public/ recursively (|| true guards against set -e when dirs are missing)
#     if [ -z "$_changed" ]; then
#         _changed=$(find "$SCRIPT_DIR/frontend/src" "$SCRIPT_DIR/frontend/public" \
#             -type f -newer "$SCRIPT_DIR/frontend/dist" -print -quit 2>/dev/null) || true
#     fi
#     if [ -z "$_changed" ]; then
#         _NEED_FRONTEND_BUILD=false
#     fi
# fi

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9ec3ee83cf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread studio/setup.sh
Comment on lines 44 to 45
_NEED_FRONTEND_BUILD=true
if [ -d "$SCRIPT_DIR/frontend/dist" ]; then
# Check all top-level files (package.json, bun.lock, vite.config.ts, index.html, etc.)
_changed=$(find "$SCRIPT_DIR/frontend" -maxdepth 1 -type f \
-newer "$SCRIPT_DIR/frontend/dist" -print -quit 2>/dev/null)
# Check src/ and public/ recursively (|| true guards against set -e when dirs are missing)
if [ -z "$_changed" ]; then
_changed=$(find "$SCRIPT_DIR/frontend/src" "$SCRIPT_DIR/frontend/public" \
-type f -newer "$SCRIPT_DIR/frontend/dist" -print -quit 2>/dev/null) || true
fi
if [ -z "$_changed" ]; then
_NEED_FRONTEND_BUILD=false
fi
fi
if [ "$_NEED_FRONTEND_BUILD" = false ]; then
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve bundled-frontend skip before forcing Node build

This change removes the only dist short-circuit in setup.sh, so _NEED_FRONTEND_BUILD is now always true and Linux setup always runs Node/npm install + frontend rebuild. That regresses pip-installed Studio flows where a prebuilt frontend/dist is already shipped, because setup can now fail in environments that cannot fetch/install Node even though the bundled frontend is usable. Please keep a reliable pip/bundled-dist bypass before the Node/build phase.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eb8cce268b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread studio/setup.sh
_NEED_FRONTEND_BUILD=false
fi
fi
_NEED_FRONTEND_BUILD=true
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve dist skip for packaged Linux installs

This unconditional override disables the dist/ fast-path, so setup.sh now always executes the Node/npm + frontend rebuild path even when a prebuilt frontend is already bundled. unsloth studio setup resolves and runs studio/setup.sh from site-packages, and the wheel includes frontend/dist data, so pip-installed Linux environments that previously could skip frontend tooling now require Node/network access and can fail setup unnecessarily.

Useful? React with 👍 / 👎.

shibizhao pushed a commit to shibizhao/unsloth-npu that referenced this pull request Apr 7, 2026
…_BUILD=true (unslothai#4427)

* revert: remove frontend build caching from setup scripts

The mtime-based caching introduced in unslothai#4404/unslothai#4413 can incorrectly skip
frontend builds -- e.g. after git pull when filesystem timestamps are
not preserved, or after our Tailwind v4 discovery that the site-packages
.gitignore must be hidden before vite build (which the cached path
doesn't handle).

Always rebuild the frontend on setup. The build takes ~15s and is
safer than risking a stale dist/.

* revert: disable frontend build caching, keep code commented out

Caching disabled by always setting _NEED_FRONTEND_BUILD=true.
The mtime-based logic is preserved in comments for future re-enabling.

Reasons for disabling:
- Git does not preserve file timestamps, so cached dist/ can appear
  newer than freshly checked-out source after a pull
- Tailwind v4 requires hiding site-packages/.gitignore before vite
  build; the cache path bypasses this, producing broken CSS

* revert: always rebuild frontend, remove mtime caching

* revert: always rebuild frontend, override caching with _NEED_FRONTEND_BUILD=true
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.

1 participant