perf(desktop): PR view refresh button and fewer re-renders and refetches
Summary
- Refresh button next to copy link in the PR action bar, so it shows on the Pull requests page and in the workspace PR pane.
useRefreshPullRequestrefetches the detail and invalidates this PR's exact diff and thread queries (and the workspace's linked-PR queries). Spins while the detail fetch runs. - Code tab: file versions are content hashes (SUPER-2724). A file's version hashes its patch, thread annotations, and collapsed state instead of the threads query's fetch time, so a 30 s poll with no change redraws nothing. This replaces the composer and collapse version counters.
- Code tab: content-addressed
cacheKeyper file. Without one,@pierre/diffskeys its render cache on the file name, so a file whose patch changed kept showing its old content. This bug is on main today. - Code tab: no diff refetch on window focus (SUPER-2726). The new refresh button covers a manual reload.
- Markdown memoized, detail query not spread (SUPER-2725).
MarkdownRendererandPullRequestMarkdownarememowith constant plugin arrays;usePullRequestDetailreturns named fields so fetch-status changes no longer re-render the Summary. - PR list saved to disk again (SUPER-2722). Page 1 of the list with no search text is persisted via
meta: { persist: true }. #5975 moved the list off the persisted"tasks"key. hashStringmoves to_dashboard/utilsnow that two areas use it.
Measured
Dev app over CDP, main and this branch on the same instance. Full write-up with a recording: https://app.superset.sh/page/pr-view-refresh-button-and-fewer-re-renders-measur-n80dtd
| main | this branch | |
|---|---|---|
| Files redrawn per 30 s thread poll (PR #8247, 155 files) | 155 | 0 |
| Window focus on the Code tab | diff refetched, 155 redrawn | no refetch, 0 redrawn |
| Comment bodies re-rendered by a refetch with identical data | 40 | 0 |
| PR list first row after a restart (3 runs) | 4.1–4.7 s, spinner | 0.27–0.34 s, no spinner |
Sync checks on this branch: editing one thread redraws only that file; an identical poll redraws none; editing one file's patch redraws that file and the new text shows in ~0.5 s (on main it never shows); opening and closing the line composer redraws one file each.
Test plan
- Desktop tests: 8219 pass (new
getFileItemVersion.test.ts) - Biome on changed files, sherif,
check:i18n - Typecheck: no errors in changed files
- Refresh button clicked live on the Pull requests page and in a workspace PR pane: detail, diff and threads refetch
- Real new push to an open PR while its Code tab is open: changed files update, others stay put
Summary by cubic
Adds a refresh button to the PR action bar, visible on the Pull requests page and in the workspace PR pane, and cuts most redundant re-renders and refetches in the PR view. An unchanged 30-second thread poll now redraws zero files (was 155 on a 155-file PR), and the PR list loads from disk instead of a 4–5 s spinner on cold start.
Refresh button
- New button refetches the PR detail and marks the linked PR, review threads, and Code tab diff and threads stale, spinning while the fetch runs.
- Refresh invalidates only the open pane's queries — keyed by project, host, PR number, and repository (taken from the PR's own URL, as the Code tab does) — so other panes, including a same-numbered PR in another project, no longer reload.
Fewer re-renders
- File versions are hashes of the patch, thread annotations, and collapsed state, so unchanged polls redraw nothing. The diff still refetches on window focus for the standalone page (the workspace client turns it off), but an identical refetch redraws no files.
- A new content-addressed
cacheKeyper file fixes files that kept showing old content after their patch changed; the key now uses the Changes pane's content key, two FNV-1a hashes plus length. - Memoized markdown renderers and a non-spread detail query result stop identical refetches from re-rendering comment bodies.
- Page 1 of each PR list state tab is persisted again — only with no search, author, or review filter — keyed by host id instead of the host URL, whose port can change between launches and made the persisted page miss. Cold-start load drops from 4–5 s to about 0.3 s.
Summary by CodeRabbit
- New Features
- Added a refresh action to pull request pages and panes. It updates pull request details, diffs, and threads, with a loading indicator while refreshing.
- Added translations for the refresh action in supported languages.
- Improvements
- Pull request diffs now update when their content, annotations, or collapsed state changes, while unchanged content can be reused.
- Markdown and eligible pull request results are more efficiently reused.
- Markdown rendering sanitizes HTML, including when raw HTML is enabled.