runloopable / web /src /main.tsx
fsanyoto's picture
Deploy AIOS web (React glide grid + FastAPI slice)
2eae9f0 verified
Raw History Blame Contribute Delete
2.27 kB
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import './index.css'
import App, { HOSTED } from './App.tsx'
import { installStandaloneBridge } from './customer-grid/apiBridge'
import { initializeHostBridge } from './customer-grid/hostBridge'
import { installActivityLog } from './settings/activityLog'
import { installEdgeRetry } from './net/edgeRetry'
// SDLC 67 close: this module body runs only once EVERY static chunk arrived, so this is the
// moment the index.html boot watchdog stops retrying (it reloads when a boot chunk 502s).
window.__aiosBootOk?.()
initializeHostBridge()
// Before the activity log, so the log wraps the retrying fetch and records final statuses.
installEdgeRetry()
installActivityLog()
// SDLC 67 close (2026-09-29): a stale HTML page requests a hashed chunk (`ribbon-*.css`, a lazy
// route) that no longer exists once a redeploy replaces it, OR the HF proxy's 502 land mid-chunk --
// either way Vite's runtime dispatches this event instead of letting the broken `import()` reject
// into an unhandled rejection, and the page is left blank ("Sheet could not be shown"). One reload
// picks up the new HTML with the new chunk map; the session-storage guard stops a genuinely broken
// deploy from reload-looping the tab forever.
window.addEventListener("vite:preloadError", event => {
const KEY = "aios.preloadReloadedOnce"
if (sessionStorage.getItem(KEY)) return
try { sessionStorage.setItem(KEY, "1") } catch { /* private mode: reload once anyway */ }
event.preventDefault()
window.location.reload()
})
// EXIT wave 1 (X2): the standalone write path. THE ONE WIRING POINT — the embed
// bundle runs this file too, and the branch below is the whole of the wave's
// "standalone-only branches" promise. `HOSTED` is App.tsx's own constant, not a
// second copy of the predicate: a component-mode page must never register an
// HTTP sink for events that belong to the Streamlit value slot, and the two
// halves of that rule have to be reading the same answer. Ordered BEFORE render
// so the sink exists by the time the grid's first effect can emit.
if (!HOSTED) installStandaloneBridge()
createRoot(document.getElementById('root')!).render(
<StrictMode>
<App />
</StrictMode>,
)