Bug
locale_selector() in vibetuner/frontend/middleware.py re-parses the request path to detect a language prefix:
def locale_selector(conn: HTTPConnection) -> str | None:
parts = conn.scope.get("path", "").strip("/").split("/")
if parts and len(parts[0]) == 2 and parts[0].islower() and parts[0].isalpha():
return parts[0]
return None
But LangPrefixMiddleware has already stripped the prefix from scope["path"] and stored it in scope["state"]["lang_prefix"]. So by the time locale_selector runs inside LocaleMiddleware, the path is / and it returns None.
Expected
Visiting /ca/ should detect Catalan as the locale, persist it via AdjustLangCookieMiddleware, and make it sticky.
Actual
The language prefix is ignored for locale detection. The cookie never gets updated, so the language doesn't persist.
Suggested Fix
locale_selector should read from scope["state"]["lang_prefix"]:
def locale_selector(conn: HTTPConnection) -> str | None:
return conn.scope.get("state", {}).get("lang_prefix")
Filed by Claude Code.
Bug
locale_selector()invibetuner/frontend/middleware.pyre-parses the request path to detect a language prefix:But
LangPrefixMiddlewarehas already stripped the prefix fromscope["path"]and stored it inscope["state"]["lang_prefix"]. So by the timelocale_selectorruns insideLocaleMiddleware, the path is/and it returnsNone.Expected
Visiting
/ca/should detect Catalan as the locale, persist it viaAdjustLangCookieMiddleware, and make it sticky.Actual
The language prefix is ignored for locale detection. The cookie never gets updated, so the language doesn't persist.
Suggested Fix
locale_selectorshould read fromscope["state"]["lang_prefix"]:Filed by Claude Code.