Fix/studio colab button message: Add fallback message for Colab Studio button when proxy URL fails#4866
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the Colab link display by adding a fallback message and adjusting text styling for better visibility. Feedback was provided regarding trailing whitespace and the use of standard font weights to ensure cross-platform consistency.
| <p style="color: #333333; margin: 12px 0 0 0; font-size: 14px; font-weight: 600;"> | ||
| If the link doesn't work, you can scroll down to view the UI generated directly in Colab. | ||
| </p> | ||
| <p style="color: #333333; margin: 16px 0 0 0; font-size: 13px; font-family: monospace; font-weight: 600;"> | ||
| {short_url} | ||
| </p> |
There was a problem hiding this comment.
There is trailing whitespace on line 69. Additionally, while the PR description mentions "bold text", the code uses font-weight: 600 (Semi-Bold). Using bold or 700 is more standard and ensures better cross-platform consistency, especially for monospace fonts which often lack intermediate weights. Consider also making this fallback message conditional (e.g., only showing it if "localhost" in url) to keep the UI clean when the proxy URL is correctly resolved.
| <p style="color: #333333; margin: 12px 0 0 0; font-size: 14px; font-weight: 600;"> | |
| If the link doesn't work, you can scroll down to view the UI generated directly in Colab. | |
| </p> | |
| <p style="color: #333333; margin: 16px 0 0 0; font-size: 13px; font-family: monospace; font-weight: 600;"> | |
| {short_url} | |
| </p> | |
| <p style="color: #333333; margin: 12px 0 0 0; font-size: 14px; font-weight: bold;"> | |
| If the link doesn't work, you can scroll down to view the UI generated directly in Colab. | |
| </p> | |
| <p style="color: #333333; margin: 16px 0 0 0; font-size: 13px; font-family: monospace; font-weight: bold;"> | |
| {short_url} | |
| </p> |
References
- PEP 8: Avoid trailing whitespace anywhere. (link)
There was a problem hiding this comment.
added fix for:
- Trailing whitespace: Line 69 does have trailing spaces after 600;">
- Font weight: font-weight: bold (or 700) is more standard than 600, especially for monospace fonts
decided against adding:
- Conditional display: Only show the message when the URL is actually localhost (when the problem exists), keeps the UI cleaner when everything works
89f0447 to
be7e8ee
Compare
…o button when proxy URL fails (unslothai#4866) * Add fallback message for Colab Studio button when localhost link doesn't work * Make fallback message darker grey for better readability * Make fallback message bold for better visibility --------- Co-authored-by: LeoBorcherding <LeoBorcherding@users.noreply.github.com>

Problem
In some cases, the "Open Unsloth Studio" button in the Colab displays localhost:8888 instead of the proper proxy URL (
https://8000-gpu-...). This appears to be a timing issue where the Colab kernel isn't ready when the URL is requested, causing it to fall back to localhost, which doesn't work in the browser.Solution
Added a clear fallback message below the button informing users:
This helps users understand what to do if they encounter the localhost issue, since the iframe-based UI below the button always works correctly.
Changes
studio/backend/colab.pyTesting
Tested in Colab by changing the setup cell to use my fork, verified that the fallback message appears and is easy to read.