[eric] frontend: extend the store-on-window gate so an init-script flag also exposes it on production builds, letting e2e subscribe to redux diffs against the packaged app

This commit is contained in:
Eric
2026-05-28 00:41:21 -07:00
parent 969cc07a5e
commit c44bd07fe7
+5 -4
View File
@@ -58,9 +58,10 @@ export const store = configureStore({
export type RootState = ReturnType<typeof store.getState>;
export type AppDispatch = typeof store.dispatch;
// Expose the store on window in dev so playwright + the user's devtools
// can drive UI flows without hunting for selectors. The expose is
// guarded by NODE_ENV so production bundles don't ship it.
if (typeof window !== 'undefined' && process.env.NODE_ENV !== 'production') {
// Expose the store on window in dev. In production it stays hidden UNLESS the
// renderer was launched with __OPENSWARM_E2E__ pre-set by a Playwright init
// script, which is the only way the e2e visibility recorder can subscribe to
// state diffs against the packaged build. Normal user runs never set the flag.
if (typeof window !== 'undefined' && (process.env.NODE_ENV !== 'production' || (window as unknown as { __OPENSWARM_E2E__?: boolean }).__OPENSWARM_E2E__ === true)) {
(window as unknown as { __OPENSWARM_STORE__?: typeof store }).__OPENSWARM_STORE__ = store;
}