Files
zed/crates/git_ui/src
morgankrey 7e7311ad20 Reduce waits for navigation, suggestions, and file comparisons (#66487)
# Objective

Reduce waiting when navigating code, loading details for code
suggestions, and comparing files. Zed currently starts some independent
file reads and requests only after the previous one finishes.

## Solution

- Load up to 16 definition or reference results at once. Keep their
original order. Repeated results for the same file share one read and
one open copy of the file.
- Request details for up to 16 code suggestions at once. Repeated item
indexes produce one request. Successful items still update if one
request fails. Keep the checks that each language server supports the
request.
- Read both sides of a file comparison together. Load up to 16
comparison pairs at once, while keeping their display order.
- Add controlled-delay tests. Saved file contents and the text ranges
returned by navigation stay the same.

## Testing

On current `main` at `8a47b35109`:

- 748 tests passed across `project`, `git_ui`, and `git_ui_core`. Four
tests were already ignored. Each suite ran one test at a time.
- Seven timing and behavior tests passed across 100 task execution
orders each: 700 runs. They check result order, repeated files and
suggestions, the request limit, errors, and cleanup.
- Required `./script/clippy` passed for all three packages, with all
targets and all features. Its dependency check also passed. The check
used no debug symbols and `profile.release.opt-level=0` to limit build
storage.
- Formatting and `git diff --check` passed.

The original checkout measured the following controlled delays. The port
to current `main` passes the same 40 ms checks:

| Operation | Before | After |
| --- | ---: | ---: |
| Go to definition across three unopened files | 120 ms | 40 ms |
| Find references across three unopened files | 120 ms | 40 ms |
| Load details for three code suggestions | 120 ms | 40 ms |
| Open one file comparison | 80 ms | 40 ms |
| Open three file comparisons | 240 ms | 40 ms |

Each independent read or request has a deliberate 40 ms delay. These
results prove reduced waiting in these cases. They do not establish a
whole-application speed improvement. Remote network performance and the
best concurrency limit for each machine remain unmeasured.

The earlier checkout also passed all five checks in a clean-built macOS
app. Those built-app checks predate this port. They are separate from
the current-main checks above.

Reviewers can run the focused tests with:

```sh
ITERATIONS=100 cargo test -p project -p git_ui -p git_ui_core --features project/test-support concurrently -- --nocapture
```

## Self-Review Checklist

- [x] Reviewed the changes for correctness and cleanup of completed or
failed work
- [x] Added tests for the changed behavior and measured waiting time
- [x] Kept result order and bounded active work

## Suggested .rules additions

Proposed text for the project test guidance, for review in a separate
rules change:

> In GPUI tests that check the release of invisible worktrees, drop the
final buffer handles inside `cx.update(...)`, then check the remaining
worktrees. `run_until_parked()` alone does not flush deferred entity
releases.

Release Notes:

- Improved responsiveness when navigating code, loading completion
details, and comparing files.
2026-11-03 22:41:41 +00:00
..
…