1414from loguru import logger
1515
1616from aignostics .constants import WINDOW_TITLE
17+ from aignostics .platform import API_ROOT_PRODUCTION , API_ROOT_STAGING
1718from aignostics .utils import __version__ , open_user_data_directory
1819
1920from ._theme import theme
2930CLASSES_FULL_SIZE = f"{ CLASSES_FULL_WIDTH } { CLASSES_FULL_HEIGHT } "
3031
3132
33+ def get_status_page_url (api_root : str ) -> str | None :
34+ """Get the status page URL based on the API root environment.
35+
36+ Args:
37+ api_root: The API root URL to determine the environment
38+
39+ Returns:
40+ The status page URL for production/staging, or None for dev/test
41+ """
42+ if api_root == API_ROOT_PRODUCTION :
43+ return "https://status.platform.aignostics.com"
44+ elif api_root == API_ROOT_STAGING :
45+ return "https://status.platform-staging.aignostics.com"
46+ else :
47+ # No status page for dev and test environments
48+ return None
49+
50+
3251@contextmanager
3352def frame ( # noqa: C901, PLR0915
3453 navigation_title : str ,
@@ -213,7 +232,9 @@ def _update_health() -> None:
213232 coroutine = _health_load_and_render (),
214233 name = "_health_load_and_render" ,
215234 )
216- ui .run_javascript ("document.getElementById('betterstack').src = document.getElementById('betterstack').src;" )
235+ # Only refresh the status iframe if it exists (production/staging)
236+ if get_status_page_url (settings ().api_root ):
237+ ui .run_javascript ("document.getElementById('betterstack').src = document.getElementById('betterstack').src;" )
217238
218239 ui .timer (interval = HEALTH_UPDATE_INTERVAL , callback = _update_health , immediate = True )
219240
@@ -342,13 +363,15 @@ def toggle_dark_mode() -> None:
342363 ui .link ("Get Support" , "https://platform.aignostics.com/support" , new_tab = True ).mark (
343364 "LINK_DOCUMENTATION"
344365 )
345- with ui .item ().props ("clickable" ):
346- with ui .item_section ().props ("avatar" ):
347- ui .icon ("check_circle" , color = "primary" )
348- with ui .item_section ():
349- ui .link ("Check Platform Status" , "https://status.aignostics.com" , new_tab = True ).mark (
350- "LINK_DOCUMENTATION"
351- )
366+ status_url = get_status_page_url (settings ().api_root )
367+ if status_url :
368+ with ui .item ().props ("clickable" ):
369+ with ui .item_section ().props ("avatar" ):
370+ ui .icon ("check_circle" , color = "primary" )
371+ with ui .item_section ():
372+ ui .link ("Check Platform Status" , status_url , new_tab = True ).mark (
373+ "LINK_DOCUMENTATION"
374+ )
352375 with ui .item ().props ("clickable" ):
353376 with ui .item_section ().props ("avatar" ):
354377 ui .icon ("handshake" , color = "primary" )
@@ -368,14 +391,16 @@ def toggle_dark_mode() -> None:
368391 ui .row (align_items = "center" ).classes ("justify-start w-full" ),
369392 ):
370393 health_link ()
371- with ui .row ().style ("padding: 0" ):
372- ui .html (
373- '<iframe id="betterstack" src="https://status.aignostics.com/badge?theme=dark" '
374- 'width="250" height="30" frameborder="0" scrolling="no" '
375- 'style="color-scheme: dark"></iframe>' ,
376- sanitize = False ,
377- ).style ("margin-left: 0px;" )
378- ui .tooltip ("Check Platform Status" )
394+ status_url = get_status_page_url (settings ().api_root )
395+ if status_url :
396+ with ui .row ().style ("padding: 0" ):
397+ ui .html (
398+ f'<iframe id="betterstack" src="{ status_url } /badge?theme=dark" '
399+ 'width="250" height="30" frameborder="0" scrolling="no" '
400+ 'style="color-scheme: dark"></iframe>' ,
401+ sanitize = False ,
402+ ).style ("margin-left: 0px;" )
403+ ui .tooltip ("Check Platform Status" )
379404 ui .space ()
380405 with ui .row ():
381406 flavor = " (native)" if getattr (sys , "frozen" , False ) else ""
0 commit comments