Skip to content

perf(side_panel): move ignore marking off the UI thread - #1087

Open
not-exist wants to merge 2 commits into
Kuddev:mainfrom
not-exist:perf/side-panel-ignore-worker
Open

not-exist wants to merge 2 commits into
Kuddev:mainfrom
not-exist:perf/side-panel-ignore-worker

Conversation

@not-exist

Copy link
Copy Markdown
Contributor

Result / User Outcome

The Files drawer no longer blocks the UI thread on full-tree ignore annotation or VCS probing:

  • Directory rows are published after enumeration, before ignore and VCS probes complete.
  • Expanding and collapsing an already-visible directory updates only the affected in-memory rows instead of synchronously rescanning the full tree or running Git.
  • Newly expanded host rows receive ignore annotations through a coalesced background pass.
  • Repositories reached through a directory symlink are still recognized for ignore checks.
  • Existing MAX_ROWS, MAX_PER_DIR, ordering, .git filtering, WSL behavior, and refresh/error semantics remain bounded and intact.

Design / Boundaries

  • pebrel_app/src/display/side_panel/mod.rs continues to own the existing snapshot worker and slot. SnapshotUpdate::Rows publishes a bare row snapshot before the annotated snapshot; SnapshotUpdate::Ignored applies only path-keyed incremental annotations. tree_generation prevents an older full snapshot from reverting a newer expand/collapse, while pending_ignore_paths coalesces follow-up work when the worker is busy.
  • click_row uses the private collapse_subtree and expand_subtree helpers. The interaction path does not perform filesystem scans or wait for subprocesses. Truncated row sets and failed expansions re-arm a full snapshot when an incremental update cannot reconstruct the complete tree.
  • The rationale, evidence, rejected alternatives, consequences, and revisit conditions are recorded in architecture/notes/pebrel_app/display/side_panel/2026-11-13-background-ignore-annotations.md.
  • No public API, persisted format, dependency, or compatibility identifier changes. The worker remains owned by each panel instance and is released through the existing SnapshotRunningGuard.

Evidence / Validation

Local checks completed against base commit c6d9d7bfebc50ee36389f4366aee7b6596cee645:

  • python3 scripts/check_architecture.py --base c6d9d7bfebc50ee36389f4366aee7b6596cee645 passed. It emitted the repository's existing review-only notices for legacy move records and file-budget tightening.
  • Architecture guardrail tests: 62 passed.
  • i18n contract tests: 24 passed, 1 ignored manual benchmark.
  • pebrel-settings tests: 110 passed.
  • pebrel --test file_line_budget: passed.
  • cargo fmt --all -- --check: passed.
  • cargo check -p pebrel --bin pebrel --features gpui-shell --tests --locked: passed.
  • Focused side-panel tests: cargo test --locked -p pebrel --bin pebrel --features gpui-shell side_panel passed.
  • git diff --check origin/main...HEAD: passed.

Regression coverage includes two-stage snapshot publication, preservation and authoritative clearing of ignore marks, the no-.git guard, incremental expand/collapse, row-cap truncation, failed host expansion, stale full snapshots, filter changes, path-keyed ignore-only updates, and symlink-aware repository lookup.

The full native matrix and release workspace checks were not run locally. Based on scripts/ci_plan.py and the changed Rust test source, this PR should schedule native tests on Ubuntu, Windows x64, and Windows ARM; macOS native tests and macOS release workspace checks should be reported as not run for this path set. GitHub Actions remains authoritative for those checks.

Required Review

  • I followed CONTRIBUTING.md, docs/architecture.md, and docs/project-constraints.md.
  • I split responsibilities, not arbitrary line ranges; no duplicate behavior authority was added.
  • python3 scripts/check_architecture.py --base <PR-base-commit> passes; budgets were not inflated to fit the change.
  • Tests cover success and failure; platform/feature coverage limitations are stated.
  • No new messages or i18n content were added; the existing typed i18n contract is unchanged.
  • This is not a governance-rule change; no governance exception or contract revision was introduced.

@not-exist
not-exist requested a review from Kuddev as a code owner November 22, 2026 12:39
The Files drawer flattened the whole expanded tree on every toggle and ran
`git check-ignore` synchronously at the end, so a click walked every expanded
directory and spawned git on the render thread even though a comment claimed
"no git re-run". The same annotation also delayed the first rows of an ordinary
background refresh: the worker published nothing until the whole vector, marks
included, was complete.

`tree_rows`/`tree_rows_wsl` now only enumerate. The snapshot worker publishes
two stages: bare rows first, then the same rows annotated by git plus the VCS
snapshot. `click_row` is incremental: collapse drops the contiguous DFS
descendant run and reads nothing; expand reads only the newly opened directory
(plus hidden expanded descendants) and inserts those rows. New rows start
unannotated and are queued by path in `pending_ignore_paths`; one background
`git check-ignore` pass annotates exactly those rows, so a click never re-checks
the whole tree and a concurrent expand or collapse is never overwritten. A full
snapshot carries `tree_generation`, so a row set captured before a local shape
change is dropped instead of reverting it.

Details that keep the incremental path equal to a re-flatten:

- The bare stage keeps the ignore marks of the rows already on screen, matched
  by path; refreshing an annotated tree no longer blanks every italic mark
  until the annotated stage lands. The annotated stage stays authoritative.
- A row set that fills `MAX_ROWS` is recorded as truncated (a full snapshot or
  an inserted subtree). Collapsing in that state re-arms one snapshot, because
  the freed space is not filled by the rows the cap dropped and only a
  re-flatten can restore them.
- An expand that ends exactly at the cap counts as truncated too (`>=`), so a
  subtree cut by the budget is restored by the next collapse-triggered scan.
- An expand reads only the rows that fit after the clicked directory
  (`MAX_ROWS - index - 1`), so the work matches the visible result.
- The annotation pass only asks git about the rows the expand inserted; rows
  already on screen keep their mark, so expanding no longer re-checks up to
  `MAX_ROWS` paths (100-360 ms for a full tree).
- A host expand whose `read_dir` fails drops the path from `expanded` and
  re-arms the snapshot instead of leaving an open chevron over nothing.
- Filter changes no longer bump `tree_generation`: the filter only selects
  among `rows`, and bumping discarded a running full scan and paid for another.
- The `.git` ancestor check left the 100 ms polling path; the worker already
  performs it.

Design note:
architecture/notes/pebrel_app/display/side_panel/2026-11-13-background-ignore-annotations.md

Validation:
- cargo test -p nebula --bin pebrel side_panel: 84 passed / 4 ignored on the
  previous revision. The narrowed annotation pass and its new test were not
  re-run locally (requested).
- cargo check -p nebula --tests and scripts/check_architecture.py --base
  09e5eb4 on that same revision.
@not-exist
not-exist force-pushed the perf/side-panel-ignore-worker branch from b776ad9 to 585dbe7 Compare November 22, 2026 12:41
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