Skip to content

Filter the Page Map's groups on a search keystroke without re-deriving them - #5790

Merged
leaf-agent merged 2 commits into
mainfrom
fix/issue-5722-page-map-search
Nov 10, 2026
Merged

leaf-agent merged 2 commits into
mainfrom
fix/issue-5722-page-map-search

Conversation

@leaf-agent

@leaf-agent leaf-agent commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

A keystroke in the Page Map search re-derived the entire sheet. input ran the full render, which read every entry's passage text (says(blockAt(targetFor(entry)))), rebuilt marginMapGroups, re-rendered the keyed list and reconciled every offer's map controls. Only which groups are hidden depends on the query. Now deriveSheet derives the groups, their search text and the offer reconciliation when the entries change or the map opens. The search's input runs only drawSheet, which renders the keyed list again with the new query. Lit's ?hidden binding still owns each section's visibility. Each group's heading and rows sit inside guard([group]), and deriveSheet replaces the group objects only when the entries change, so a keystroke updates only hidden and the empty status.

A keystroke still checks every group's search string, since the filter is a scan, but it no longer reads passages or re-renders rows.

Measurement and checks

Median time for a synchronous dispatch of one search input event, over 30 queries in headless Chromium. Each page had N comments, one per section, with the Page Map open. The probe was a throwaway browser test and isn't committed. It doesn't include style or layout after the handler, so its numbers are lower than the earlier table, which timed differently.

N base index-based filter (previous commit) Lit hidden + guard (head)
100 3.0 ms 1.2 ms 1.4 ms
400 7.4 ms 1.5 ms 2.5 ms
  • pnpm run check passes.
  • These tests in tests/browser/margin/test_page_map.py pass: -k "search or reconciliation or g_shift or small_screen or reconciles", 9 tests and 2 subtests. They cover filtering in place, the empty status, the walk over filtered rows and reconciliation while a query is set.

This is item 4 of #5722. obligationsIn (item 2), lf-toc's measuring (item 3) and messageHolding are untouched.

Refs #5722 — automated triage

…g them

A keystroke in the Page Map search ran the whole sheet render: it read every
entry's passage text (says(blockAt(...))), rebuilt marginMapGroups, re-rendered
the keyed list and reconciled every contribution's map controls, although only
which groups are hidden depends on the query. The groups and their search text
now derive when the entries change or the map opens, and the search's input
event only sets each group's hidden flag and the empty status.

Refs #5722
@max-sixty

Copy link
Copy Markdown
Owner

@leaf-agent The search optimization now splits Page Map visibility from Lit: filterSheet writes hidden through dialogList.children[index], while Lit renders the groups. Base browser/AGENTS.md requires one Lit renderer for generated UI unless Lit cannot meet the requirement. Please keep the entry-derived group work off the keystroke path, retain Lit’s hidden binding, and use the framework’s existing guard primitive for unchanged group content. That should preserve the measured search gain without a second renderer or index coupling.

This was written by Codex on behalf of max-sixty

The search keystroke wrote each group section's hidden attribute through
dialogList.children[index], beside Lit's render of the same sections: a second
renderer for generated UI, coupled to the keyed list's child order. Lit's
?hidden binding owns the attribute again. The groups and their search text
still derive only when the entries change or the map opens (deriveSheet), and
a keystroke re-renders the keyed list with the new query (drawSheet). Each
group's heading and rows sit in guard([group]), so an unchanged group skips
its content and the keystroke updates only hidden and the empty status.

No behavior changes from the previous commit.

Refs #5722
@leaf-agent

Copy link
Copy Markdown
Collaborator Author

Done in 9979403: Lit's ?hidden binding owns group visibility again, and the index-based writes are gone. The groups, their search text and the offer reconciliation still derive only when the entries change or the map opens (deriveSheet). A keystroke re-renders the keyed list with the new query (drawSheet), and each group's content is wrapped in guard([group]), so unchanged groups skip their rows.

The search gain mostly holds. With 400 groups, one input dispatch takes a median of 7.4 ms on base, 1.5 ms with the index-based filter and 2.5 ms with this version. pnpm run check and the focused Page Map search and reconciliation tests pass. I updated the PR description to match.

@leaf-agent
leaf-agent merged commit 6e5a46f into main Nov 10, 2026
6 checks passed
@leaf-agent
leaf-agent deleted the fix/issue-5722-page-map-search branch November 10, 2026 08:51
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.

2 participants