mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-03 02:22:24 +00:00
fix(sso): stop CLI auth success page from hanging on "Closing..."
The CLI opens the SSO success page with webbrowser.open, so the tab is not script-opened and the browser refuses window.close(). The countdown would end on "Closing..." and the tab would sit there forever. Drop the countdown and just show "You can now close this window and return to your terminal." from the start, while still attempting window.close() once so the tab auto-closes in the rare case the browser allows it. Add a regression test asserting the manual-close instruction is always present and the misleading countdown/"Closing..." text is gone.
This commit is contained in:
parent
7a680c0201
commit
fa346d6f6a
2 changed files with 21 additions and 16 deletions
|
|
@ -135,7 +135,7 @@ def render_cli_sso_success_page() -> str:
|
|||
font-size: 14px;
|
||||
}}
|
||||
|
||||
.countdown {{
|
||||
.status {{
|
||||
color: #64748b;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
|
|
@ -183,23 +183,11 @@ def render_cli_sso_success_page() -> str:
|
|||
<p>You can now use LiteLLM CLI commands with your authenticated session.</p>
|
||||
</div>
|
||||
|
||||
<div class="countdown" id="countdown">This window will close in 3 seconds...</div>
|
||||
<div class="status">You can now close this window and return to your terminal.</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
let seconds = 3;
|
||||
const countdownElement = document.getElementById('countdown');
|
||||
|
||||
const countdown = setInterval(function() {{
|
||||
seconds--;
|
||||
if (seconds > 0) {{
|
||||
countdownElement.textContent = `This window will close in ${{seconds}} second${{seconds === 1 ? '' : 's'}}...`;
|
||||
}} else {{
|
||||
countdownElement.textContent = 'Closing...';
|
||||
clearInterval(countdown);
|
||||
window.close();
|
||||
}}
|
||||
}}, 1000);
|
||||
window.close();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -1777,6 +1777,23 @@ class TestHTMLIntegration:
|
|||
assert isinstance(html, str)
|
||||
assert len(html) > 0
|
||||
|
||||
def test_success_page_instructs_manual_close_without_false_countdown(self):
|
||||
"""Browsers refuse window.close() on tabs they did not open via window.open()
|
||||
(the CLI opens the page with webbrowser.open), so a 'closing in 3...' countdown
|
||||
is a promise the browser usually can't keep and the page gets stuck on
|
||||
'Closing...'. The page must instead always show the manual-close instruction
|
||||
and never advertise an auto-close that won't happen.
|
||||
"""
|
||||
from litellm.proxy.common_utils.html_forms.cli_sso_success import (
|
||||
render_cli_sso_success_page,
|
||||
)
|
||||
|
||||
html = render_cli_sso_success_page()
|
||||
|
||||
assert "You can now close this window and return to your terminal." in html
|
||||
assert "Closing..." not in html
|
||||
assert "This window will close in" not in html
|
||||
|
||||
|
||||
class TestCustomUISSO:
|
||||
"""Test the custom UI SSO sign-in handler functionality"""
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue