fix: correct webui profile switching state — v0.50.150 (PR #849 by @migueltavares)
Three related profile-switching fixes: - Always persist hermes_profile=default cookie when switching back to default (was being cleared with max-age=0, causing fallback to process-global profile) - Replace undefined updateWorkspaceChip() with syncTopbar() in the sessionInProgress branch of switchToProfile() - Make sidebar/dropdown active-profile rendering prefer S.activeProfile client state when available, with safe fallback Tests: 1854 passing.
This commit is contained in:
@@ -211,17 +211,19 @@ def get_profile_cookie(handler) -> str | None:
|
||||
def build_profile_cookie(name: str) -> str:
|
||||
"""Build a Set-Cookie header value for the hermes_profile cookie.
|
||||
|
||||
name='default' clears the cookie (max-age=0).
|
||||
Any other valid profile name sets it for the browser session.
|
||||
httponly=True: the JS reads profile from /api/profile/active JSON, never
|
||||
from document.cookie, so httponly exposure is unnecessary.
|
||||
Always persist the selected profile in the cookie, including 'default'.
|
||||
Clearing the cookie causes the backend to fall back to process-global
|
||||
_active_profile, which can unexpectedly switch clients back to another
|
||||
profile.
|
||||
|
||||
Set HttpOnly because the UI reads the active profile from
|
||||
/api/profile/active JSON and does not need to access this cookie via
|
||||
document.cookie.
|
||||
"""
|
||||
import http.cookies as _hc
|
||||
cookie = _hc.SimpleCookie()
|
||||
cookie[PROFILE_COOKIE_NAME] = '' if name == 'default' else name
|
||||
cookie[PROFILE_COOKIE_NAME] = name
|
||||
cookie[PROFILE_COOKIE_NAME]['path'] = '/'
|
||||
cookie[PROFILE_COOKIE_NAME]['httponly'] = True
|
||||
cookie[PROFILE_COOKIE_NAME]['samesite'] = 'Lax'
|
||||
if name == 'default':
|
||||
cookie[PROFILE_COOKIE_NAME]['max-age'] = '0'
|
||||
return cookie[PROFILE_COOKIE_NAME].OutputString()
|
||||
|
||||
Reference in New Issue
Block a user