Skip to content

Group a visual review's threads by case once per render instead of filtering every thread for each case - #6369

Merged
leaf-agent merged 1 commit into
mainfrom
nightly/visual-review-render-cost
Nov 18, 2026
Merged

leaf-agent merged 1 commit into
mainfrom
nightly/visual-review-render-cost

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

Each render of lf-visual-review drew every case's article, and each case filtered the page's whole thread list, while each queue row found its number with run.cases.indexOf(record). A redraw follows every state reading and every selection (#select calls performUpdate), so it cost cases × threads + cases², the cross-collection walk root AGENTS.md ("Responsiveness") rules out.

The render now groups the threads anchored on this widget by anchor.datum once and passes each case its group, and the queue row takes its number from repeat's index (#cases maps run.cases in order). Behavior is unchanged: the grouping keeps exactly the threads the old filter kept, those whose anchor.section is the widget's id and whose anchor.datum is the case's id.

Verification: pnpm run check passes, and these focused browser tests pass: test_render_visual_review_journey.py::test_visual_review_returns_to_case_feedback_on_phone (two threads on a case, counted and opened), ::test_visual_review_source_reorder_keeps_the_focused_case_draft and ::test_visual_review_approvals_survive_reload_and_undo, plus projection/test_visual_review.py::test_visual_review_controls_keep_keyboard_navigation_local and ::test_on_me_materializes_a_reply_review_at_its_requested_case. The widget is a Lit element with no Node-level seam, so no unit test was added for the grouping.

No speedup is measured: leaf-dev bench generates no page with a visual review, so the gain is the asymptotic one above.

…ltering every thread for each case

Each render of lf-visual-review drew every case's article, and each case
filtered the page's whole thread list, while each queue row found its number
with run.cases.indexOf. A redraw, which follows every state reading and every
selection, cost cases x threads + cases^2. The render now groups the threads
anchored on this widget by datum once and hands each case its group, and the
queue row takes its number from repeat's index. No behavior changes: the
grouping keeps exactly the threads the old filter kept (anchor.section equal to
the widget's id and anchor.datum equal to the case's id).
@leaf-agent
leaf-agent merged commit fee67df into main Nov 18, 2026
5 checks passed
@leaf-agent
leaf-agent deleted the nightly/visual-review-render-cost branch November 18, 2026 07:50
max-sixty added a commit that referenced this pull request Nov 21, 2026
main now shows each part's question state in a page of parts' list (#6152), so
the comparison-only change this branch carried for that is dropped for main's
stylesheet and tab set. The widget keeps this branch's row state on main's row
index (#6369).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant