The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 23, 05:30 UTC
refactor(web): the pull requests page keeps its caching without "use memo" (#20820)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 17, 2026 at 00:31 UTC
805b98e790762e06fe06cd34803e7d502997d138
1 file changed
+63
-64
apps/web/src/routes/_chat.pull-requests.tsx
+63
-64
@@ -345,9 +345,6 @@ function PullRequestsRouteView() {
345
sort === "ready" || sort === "largest" || sort === "smallest" ? "eager" : "visible";
346
const navigate = useNavigate({ from: Route.fullPath });
347
const keybindings = useAtomValue(primaryServerKeybindingsAtom);
348
- const { environments } = useEnvironments();
349
- const allProjects = useProjects();
350
- const projectsKnown = useAllEnvironmentShellsBootstrapped();
348
const {
349
capableEnvironments,
350
scopedEnvironmentId,
@@ -365,7 +362,8 @@ function PullRequestsRouteView() {
362
assignmentKey,
363
linkedSelection,
364
expectedHosts,
368
- } = usePullRequestScope(environments, allProjects, projectsKnown, search);
365
+ projectsKnown,
366
+ } = usePullRequestScope(search);
367
const rightPanelRef = capableEnvironments.length === 0 ? null : PULL_REQUESTS_PANEL_REF;
368
const openPanelPullRequestUrl = useOpenPanelPullRequestUrl(rightPanelRef);
369
const rightPanelState = useRightPanelStore((state) =>
@@ -448,9 +446,9 @@ function PullRequestsRouteView() {
446
447
const typedQuery = (search.q ?? "").trim();
448
const [filtersOpen, setFiltersOpen] = useState(false);
451
- const sentQuery = useDebouncedValue(typedQuery, SEARCH_DEBOUNCE_MS);
452
- const querySettled = typedQuery === sentQuery;
449
const {
450
+ sentQuery,
451
+ querySettled,
452
typedParsed,
453
sentParsed,
454
menuFilters,
@@ -459,7 +457,7 @@ function PullRequestsRouteView() {
457
hasFilters,
458
localFilters,
459
hasLocalFilters,
462
- } = usePullRequestQueryFilters(search, typedQuery, sentQuery);
460
+ } = usePullRequestQueryFilters(search, typedQuery);
461
const turnRefreshes = usePullRequestTurnRefreshes(
462
environmentQueries.map(({ environmentId }) => environmentId),
463
);
@@ -883,7 +881,7 @@ function PullRequestsRouteView() {
881
groups,
882
entriesByStatsKey,
883
heldPullRequestsBySurface,
886
- } = usePullRequestGroups({
884
+ } = pullRequestGroups({
885
known: ordered?.key === filterKey ? ordered.entries : (listData?.entries ?? []),
886
providers: baselineQuery.data?.providers ?? listData?.providers ?? [],
887
viewers,
@@ -1071,37 +1069,28 @@ function PullRequestsRouteView() {
1069
refreshListAndStats(requestedStatsScope);
1070
setDetailRefreshToken((token) => token + 1);
1071
};
1074
- const [hostsState, setHostsState] = useState<{
1075
- readonly source: MergedPullRequestList | null;
1076
- readonly host: string | undefined;
1077
- readonly hosts: PullRequestListResult["providers"];
1078
- }>({ source: null, host: undefined, hosts: [] });
1079
- if (answered !== null && (hostsState.source !== answered || hostsState.host !== search.host)) {
1080
- setHostsState({
1081
- source: answered,
1082
- host: search.host,
1083
- hosts:
1084
- search.host === undefined || hostsState.hosts.length === 0
1085
- ? answered.providers
1086
- : hostsState.hosts,
1087
- });
1088
- }
1089
- const hosts = hostsState.hosts;
1072
+ const {
1073
+ hosts,
1074
+ displayGroups,
1075
+ shownCount,
1076
+ hostActionsOf,
1077
+ closeSweepRows,
1078
+ listedPullRequestsBySurface,
1079
+ } = usePullRequestDisplayGroups({
1080
+ answered,
1081
+ host: search.host,
1082
+ groups,
1083
+ statsByRow,
1084
+ overrides,
1085
+ state: search.state,
1086
+ localFilters,
1087
+ hasLocalFilters,
1088
+ viewers,
1089
+ sort,
1090
+ text: typedParsed.text,
1091
+ involvement: search.involvement,
1092
+ });
1093
const showProvider = hosts.length > 1;
1091
- const { displayGroups, shownCount, hostActionsOf, closeSweepRows, listedPullRequestsBySurface } =
1092
- usePullRequestDisplayGroups({
1093
- groups,
1094
- statsByRow,
1095
- overrides,
1096
- state: search.state,
1097
- localFilters,
1098
- hasLocalFilters,
1099
- viewers,
1100
- sort,
1101
- text: typedParsed.text,
1102
- involvement: search.involvement,
1103
- hosts,
1104
- });
1094
const [closeSweepKeys, setCloseSweepKeys] = useState<ReadonlySet<string>>(() => new Set());
1095
const closeSensorRef = useRef<SidebarPointerSensor | null>(null);
1096
// A sweep spans many renders; each step reads the rows on screen at that moment.
@@ -1777,14 +1766,10 @@ function PullRequestsRouteView() {
1766
}
1767
1768
/** Which servers and projects the page reads, from the URL and what this client knows. */
1780
-function usePullRequestScope(
1781
- environments: ReturnType<typeof useEnvironments>["environments"],
1782
- allProjects: ReturnType<typeof useProjects>,
1783
- projectsKnown: boolean,
1784
- search: PullRequestsSearch,
1785
-) {
1786
- // Calls no hooks, so the compiler needs the directive to memoize it.
1787
- "use memo";
1769
+function usePullRequestScope(search: PullRequestsSearch) {
1770
+ const { environments } = useEnvironments();
1771
+ const allProjects = useProjects();
1772
+ const projectsKnown = useAllEnvironmentShellsBootstrapped();
1773
const capableEnvironments = environments
1774
.filter(
1775
(environment) => environment.serverConfig?.environment.capabilities.pullRequests === true,
@@ -1913,16 +1898,12 @@ function usePullRequestScope(
1898
assignmentKey,
1899
linkedSelection,
1900
expectedHosts,
1901
+ projectsKnown,
1902
};
1903
}
1904
1919
-function usePullRequestQueryFilters(
1920
- search: PullRequestsSearch,
1921
- typedQuery: string,
1922
- sentQuery: string,
1923
-) {
1924
- // Calls no hooks, so the compiler needs the directive to memoize it.
1925
- "use memo";
1905
+function usePullRequestQueryFilters(search: PullRequestsSearch, typedQuery: string) {
1906
+ const sentQuery = useDebouncedValue(typedQuery, SEARCH_DEBOUNCE_MS);
1907
const typedParsed = parsePullRequestQuery(typedQuery);
1908
const sentParsed = parsePullRequestQuery(sentQuery);
1909
@@ -1939,6 +1920,8 @@ function usePullRequestQueryFilters(
1920
const localFilters = { ...menuFilters, ...typedParsed.filters };
1921
const hasLocalFilters = Object.keys(localFilters).length > 0;
1922
return {
1923
+ sentQuery,
1924
+ querySettled: typedQuery === sentQuery,
1925
typedParsed,
1926
sentParsed,
1927
menuFilters,
@@ -1951,7 +1934,7 @@ function usePullRequestQueryFilters(
1934
}
1935
1936
/** The held rows narrowed to what the reader asked for, in the groups the list shows. */
1954
-function usePullRequestGroups({
1937
+function pullRequestGroups({
1938
known,
1939
providers,
1940
viewers,
@@ -1980,8 +1963,6 @@ function usePullRequestGroups({
1963
reviewing: ReadonlyArray<EnvironmentPullRequestEntry> | undefined;
1964
partitionsWanted: boolean;
1965
}) {
1983
- // Calls no hooks, so the compiler needs the directive to memoize it.
1984
- "use memo";
1966
const searchingHosts = new Set(
1967
providers.flatMap((provider) => (provider.searchesOnHost ? [provider.host] : [])),
1968
);
@@ -2057,8 +2038,13 @@ function usePullRequestGroups({
2038
};
2039
}
2040
2060
-/** The groups as shown: with measured sizes, optimistic actions, and the reader's sort. */
2041
+/**
2042
+ * The hosts the list has answered for (kept while a host filter narrows the answer), and the
2043
+ * groups as shown with measured sizes, optimistic actions, and the reader's sort.
2044
+ */
2045
function usePullRequestDisplayGroups({
2046
+ answered,
2047
+ host,
2048
groups,
2049
statsByRow,
2050
overrides,
@@ -2069,8 +2055,9 @@ function usePullRequestDisplayGroups({
2055
sort,
2056
text,
2057
involvement,
2072
- hosts,
2058
}: {
2059
+ answered: MergedPullRequestList | null;
2060
+ host: string | undefined;
2061
groups: ReadonlyArray<PullRequestGroup<EnvironmentPullRequestEntry>>;
2062
statsByRow: PullRequestDiffStats;
2063
overrides: ReadonlyMap<string, PullRequestListOverride>;
@@ -2081,13 +2068,24 @@ function usePullRequestDisplayGroups({
2068
sort: PullRequestListSort;
2069
text: string;
2070
involvement: PullRequestInvolvement;
2084
- hosts: PullRequestListResult["providers"];
2071
}) {
2086
- // Calls no hooks, so the compiler needs the directive to memoize it.
2087
- "use memo";
2072
+ const [hostsState, setHostsState] = useState<{
2073
+ readonly source: MergedPullRequestList | null;
2074
+ readonly host: string | undefined;
2075
+ readonly hosts: PullRequestListResult["providers"];
2076
+ }>({ source: null, host: undefined, hosts: [] });
2077
+ if (answered !== null && (hostsState.source !== answered || hostsState.host !== host)) {
2078
+ setHostsState({
2079
+ source: answered,
2080
+ host,
2081
+ hosts:
2082
+ host === undefined || hostsState.hosts.length === 0 ? answered.providers : hostsState.hosts,
2083
+ });
2084
+ }
2085
+ const hosts = hostsState.hosts;
2086
const displayGroups = (() => {
2087
const enriched = groups.map((group) => {
2090
- const answered = applyPullRequestOverrides(
2088
+ const overridden = applyPullRequestOverrides(
2089
group.entries.map((entry) => withDiffStat(entry, statsByRow)),
2090
overrides,
2091
pullRequestEntryKey,
@@ -2097,7 +2095,7 @@ function usePullRequestDisplayGroups({
2095
...group,
2096
entries:
2097
hasLocalFilters && overrides.size > 0
2100
- ? answered.filter(
2098
+ ? overridden.filter(
2099
(entry) =>
2100
!overrides.has(pullRequestEntryKey(entry)) ||
2101
matchesPullRequestFilters(
@@ -2106,7 +2104,7 @@ function usePullRequestDisplayGroups({
2104
pullRequestEntryViewer(entry, viewers),
2105
),
2106
)
2109
- : answered,
2107
+ : overridden,
2108
};
2109
});
2110
return sortPullRequestGroups(
@@ -2134,6 +2132,7 @@ function usePullRequestDisplayGroups({
2132
);
2133
2134
return {
2135
+ hosts,
2136
displayGroups,
2137
shownCount,
2138
hostActionsOf,