Files
apes-sidebar/docs
Jerryyyyy1 7b61e1282b fix(state): contain a throwing store listener instead of blanking the sidebar
`service.subscribeState` is the store's own `subscribe`, so a consumer
plugin's listener runs inside `notify()` — and `notify()` runs inline in
whatever call site mutated the store (`setSession` from the Sidebar's mount
effect, `reduce` from a click handler). A throw escaping that loop therefore
surfaces in the React commit phase, where the ROOT RenderBoundary in
index.tsx swaps the ENTIRE sidebar for its error strip.

Observed on a real install (DSH Desktop, this plugin 0.19.0 + a consumer
plugin): the consumer's listener still walked the right column's `splits`
tree, a field 0.19.0 dropped, so it threw "Cannot read properties of
undefined (reading 'kind')" from inside `notify()` and took the panel down
for every other plugin and for the user, with the sidebar stuck on the error
strip until a manual reload.

Isolate each listener with try/catch + console.error. React's own
useSyncExternalStore callback shares this loop, so the remaining subscribers
still receive the change and re-render.

Tests: two store-level cases (a throwing listener is contained and the rest
still get notified; later mutations still fan out) plus a shell-level case
that subscribes a throwing listener through the real service against the
real Sidebar. All three fail against the previous implementation.
2026-09-13 12:32:22 +08:00
..