Repository navigation
perf: skip error list updates for unrelated notebook changes - #12256
Conversation
e226d2f to
fb99022
Compare
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the notebook error-list optimization.
No open issues 🎉
What changed in this PR
Optimizes the notebook error list to avoid scans and React commits when unrelated cell changes leave displayed errors unchanged.
Changes:
- Tracks actionable errors per cell and reads names only for cells with visible errors.
- Preserves notebook ordering and releases cached atoms when cells are deleted.
- Adds tests for skipped updates, error filtering, ordering, renaming, and cell lifecycle behavior across stores.
| File | Description |
|---|---|
| frontend/src/core/cells/cells.ts | Adds per-cell error tracking, shallow comparison, and cleanup. |
| frontend/src/core/cells/__tests__/cell-errors.test.tsx | Tests update efficiency and error-list correctness. |
Review effort: Balanced
|
React Doctor found 1 new issue in 1 file · 1 warning · score 97 / 100 (Great) · 0 fixed · vs 1 warning
Reviewed by React Doctor for commit |
| }); | ||
|
|
||
| export const cellErrorsAtom = selectAtom( | ||
| atom((get) => get(cellIdsAtom).map((id) => get(cellErrorAtom(id)))), |
There was a problem hiding this comment.
React Doctor · react-doctor/jotai-derived-atom-returns-fresh-object (warning)
This derived atom returns a new array each time, so jotai's Object.is check fails & re-renders every consumer on every update. Split into one atom per field, or use selectAtom(source, fn, shallow).
Fix → Split it into one derived atom per field (each compares cleanly with Object.is), or wrap with selectAtom(source, fn, shallow) from jotai/utils if you really need one object.
Coverage Report for ./frontend
File Coverage
|
||||||||||||||||||||||||||||||||||||||
📝 Summary
Skip the full notebook scan and React commit when a log append, a code edit, or a rename leaves the displayed errors unchanged. Track actionable errors per cell and read the cell name only while it has a visible error. Keep entries in notebook order and release the per-cell atoms on deletion.
In a 500-cell notebook, 20 log appends, 20 code edits in an errored cell, and 20 renames of a healthy cell previously caused 60 full scans and 60 error-list commits. Both counts fell to zero, saving 30,000 cell ID visits. Both versions displayed the same ordered errors after every update.
At 500 cells, unrelated updates were faster in all six alternating pairs against
06fe945858. Visible error changes were slower in all six. Each still triggered one scan and one commit. Total time across all three phases improved in three of six pairs. The benchmark measured one mounted list in jsdom and excluded browser layout and paint.Focused tests cover multiple errors in one cell, rename, reorder, clear, deletion and re-addition, and independent notebook stores.
Addresses the cell error subscription work in MO-8797.