The tree was a debranded snapshot of upstream taken around 2026-02-20, and upstream has moved about five months since. This replaces it with upstream master, mechanically re-derived: bin/debrand does the rename, and the pipeline and squashed migrations are restored from the shipped tree. Not a merge. The previous import replaced the tree wholesale in a single commit, so there is no shared content history to merge against. Reproducing the rename on the new tree is what actually converges. What survives: .hanzo/workflows, the Dockerfiles and bin/docker* entrypoints, compose files, LLM.md, and insights/migrations. The squashed initial migration is load-bearing — the live database records it by name, so upstream's ~918 individual migrations cannot come back. Nine products are dropped as unreferenced. Twenty-one more that we do not run are kept anyway because the core app still imports them; unpicking those is a refactor and does not belong in a rebase. This base does not build yet, and the reasons are not in the rename: upstream now wants Python 3.13.13 against our 3.12.12 and Django 5.2 against our 4.2, and the dependency manifests still name upstream packages that we republish under our own names. Those are decisions, not renames.
2.8 KiB
Persisting state
Two plugins cover persistence concerns:
kea-localstorage— survive reload by writing a reducer tolocalStoragekea-window-values— derive values fromwindow(innerWidth,fullscreenElement) and stay in sync as the window changes
Both are globally registered in initKea.ts, so any logic can use them.
{ persist: true } — survive reload
Make a reducer's value survive page reload by passing { persist: true } as the
second element of the reducer tuple:
reducers({
themeMode: [
'system' as ThemeMode, // default
{ persist: true }, // persistence config
{ setThemeMode: (_, { themeMode }) => themeMode }, // handlers
],
})
The plugin writes the value to localStorage keyed by the logic's path. On mount it
hydrates the reducer from storage if a value exists, otherwise uses the default.
When persist is the right answer
- User preferences (theme, sidebar width, default tab)
- Dismissed-once UI (tooltip dismissals, onboarding banners)
- Filter state that should survive reload but isn't worth a URL
When persist is the wrong answer
- Server state. Use a loader. localStorage will go stale immediately and confuse the next session.
- Auth / identity. That belongs in the API layer (cookies / auth headers).
- Anything sensitive. localStorage is plaintext, JS-readable, and synced by some browser profiles.
- State another tab also writes. localStorage is shared; concurrent writes race.
Resetting
If you change a reducer's shape, the old value in localStorage will type-mismatch. Either:
- Add migration logic in the reducer default (read the old shape, transform).
- Change the path (rare — breaks everything else).
Don't silently break — at minimum, the reducer default should be a valid value if the stored shape doesn't match.
windowValues — read live values from window
import { windowValues } from 'kea-window-values'
windowValues(() => ({
fullscreen: (window: Window) => !!window.document.fullscreenElement,
mobileLayout: (window: Window) => window.innerWidth < 992,
})),
Each key becomes a selector. The plugin re-evaluates them on resize / scroll /
fullscreenchange and triggers a re-render for subscribers.
When this is the right answer
- Responsive breakpoints in a logic (so the JSX stays clean)
- Reading
document.fullscreenElementfor fullscreen-aware UI
When this is the wrong answer
- Media queries.
MediaQueryList.addEventListener('change', ...)viacache.disposablesis more efficient and gives you the exact breakpoint. window.innerWidthchecks inside a render function. Use awindowValuesentry so it's reactive.
Anti-patterns
See anti-patterns.md for the consolidated catalogue.