← Back to Pull requests

fix(plugins): a panel tree holds 20,000 nodes and says when it cuts (#1546) #1738

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Nov 10, 2026 16:44 UTC
Author

Closes #1546

A plugin panel tree (#1050, #1080) kept at most 5,000 nodes. That is too few for a country's administrative units: Brazil's 5,570 municipalities with the IBGE levels above them make 6,298 nodes, and Spain, Italy and Germany pass the limit with the municipalities alone. The BrasilData plugin, whose panel picks the work area from the IBGE boundaries, has had to send one region at a time, so a search for a municipality in a region not yet chosen finds nothing.

What changes

1. MAX_TREE_NODES is 20,000. That covers Brazil with its whole hierarchy, and Spain (~8,100), Italy (~7,900) and Germany (~10,800).
2. A cut tree is said, by name. When a tree's nodes go past the limit, the warning on the plugin's answer names the tree, how many nodes it was given and the limit: <plugin>: tree catalogue was given 20001 nodes: only the first 20000 are kept, the most a tree holds. The panel shows a note under the tree ("Only the first 20000 of the 20001 nodes the plugin gave are shown: a tree holds at most 20000."), also when a search finds nothing, since what it looks for may be among those left out. plugin.panel answers the tree's item with "cut": <nodes given>.
3. Each label is folded once. tree_nodes keeps the folded label (lower case, NFD, marks dropped) in TreeNode when the nodes arrive, and a search compares against it (TreeNode::holds_words). Before, tree_rows folded every node's label at every frame while a search was typed.

What #1667 already covered

#1667 (Plugins: report lossy panel updates) already counted nodes left out of an answer in one warning: N option(s) or tree node(s) left out (no id, one repeated or too long, too deep, or past the limit). That stays for the other reasons. What it didn't say is which tree was cut at the limit, from how many nodes, and nothing showed in the panel. Nodes past the limit are now counted apart from that generic count, so a cut isn't said twice.

Choices

  • The cut is counted where it happens. tree_nodes adds the rest of a level, with what it holds, to a past counter when it stops at the limit; the levels above count their own rest. Nodes left out for other reasons (no id, repeated, too deep) stay in Dropped::nodes.

  • fold moved to the plugins crate as TreeNode::fold, with the unicode-normalization dependency (from ui-egui, which no longer uses it elsewhere). The front end folds the query with the same function, so the two can't drift.

  • TreeNode::new builds a node with its folded label; the field is pub(crate) so a node can't be made outside the crate with a stale one.

  • The panel note is a dim line under the tree, as the empty-search "Nothing matches." is. New UI string, English only (translations are the maintainer's, before a release).
  • Measurement

    A throwaway test (not in the PR) over 20,000 nodes with municipality-like labels ("São José do Rio Preto 123", "Mãe d'Água 456"…), searching "sao jose", in the workspace's test profile (optimized + debuginfo), Windows, three runs:

    | | per search frame |
    |---|---|
    | before: fold every label, then compare | 29.6 / 30.9 / 51.3 ms |
    | after: compare the stored folded label | 1.6 / 1.2 / 2.1 ms |

    Folding is now paid once per answer that sends the nodes: building the 20,000 nodes took 34 ms (63 ms in the noisy third run), the format! of the test labels included. Before, a 20,000-node search would have spent about 30 ms of every frame on folding alone, past a 60 fps frame's 16 ms.

    Tests

  • a_tree_cut_at_its_limit_says_so (plugins): 20,000 nodes are all kept with nothing said; 20,001 keep 20,000 and say the cut once, naming the tree and the count, not again in the generic count; a nested tree cut inside a branch counts the branches after it with what they hold, and a node without an id is still counted apart; fewer nodes again clear cut.

  • a_tree_search_reads_the_label_folded_once (plugins): labels with accents (composed and decomposed), and ids standing for a missing label, are folded when kept; holds_words reads the stored folded label (changing it changes what is found).

  • tree_rows_follow_open_branches_and_searches (ui-egui) runs as before on TreeNode::new.
  • Locally (Windows): cargo fmt --check, cargo clippy -p rustgis-plugins -p rustgis-engine -p rustgis-ui-egui --all-targets -- -D warnings and cargo xtask layers pass; the tests of rustgis-plugins and rustgis-ui-egui pass. In rustgis-engine two tests fail on this PC on unrelated code: gdal_formats_open_when_gdal_is_installed (the GDAL here is older than the 3.8 it asks for) and portable_projects::reload::wrong_geometry_missing_file_and_missing_chosen_table_leave_the_layer_unchanged, which expects "file" in the operating system's error and gets it in Portuguese here. Two archive_render_revision tests failed once under load and passed when run again. unicode-normalization is already in both THIRD-PARTY-LICENSES.txt files, through other crates, so the notices don't change.

    Limits

  • France's 34,900 communes (with the levels above them) still pass 20,000. A larger list needs a lazier tree (children sent when a branch opens), a bigger change and not part of this PR. The docs say to send such lists a level at a time.

  • The limit counts nodes in the order given, depth first: a plugin that sends a whole country keeps the first 20,000, not a balanced sample.

  • The note under the tree is not covered by a UI test, and not yet tried in a real window.

  • The folded label costs one more string per node (at 20,000 nodes with 20–30 character labels, under 1 MB), paid once per answer.
  • 🤖 Generated with Claude Code

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: github-actions[bot] Review duration: 7m
    All Vouch review confidence checks passed
    Residual risk 0.37 = Change Risk (0.52) × (1 − Review Confidence (0.28)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 43% · Reviewer familiarity: 35%
    28%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #1738"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: medium confidence: 28.1% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 28.1% · Lower = rushed or shallow review
    28.1%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 37.4% · Moderate risk
    37.4%