You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[$250] Search - list does not split into "Recent chats" and "Search results" sections. #95710
When a query is typed, the Search Router splits recentReportsOptions into two sections: "Recent chats" (locally-known results) and "Search results" (results the server returns afterward). The split is decided purely by membership in a frozenLocalRank snapshot: rows in the snapshot → "Recent chats", rows not in it → "Search results".
The problem is that the snapshot is built from the exact same array it later splits. On query change, SearchAutocompleteList.tsx:431-436 snapshots every current row of recentReportsOptions into frozenLocalRank. Then the section builder at SearchAutocompleteList.tsx:534-541 classifies every row as "local" because it's already in the snapshot, leaving serverRows empty. Since the "Search results" section is only pushed when serverRows.length > 0, it is never rendered — the list shows only "Recent chats".
The intent (see the comment at :414-416) was to freeze the order of already-visible local rows so server results merged into Onyx later don't reorder them. But the same snapshot is being (mis)used to decide local-vs-server membership, which empties the server section in the common case where client-side options already cover the matches.
Evidence & data flow
User types >3 chars → autocompleteQueryValue changes.
recentReportsOptions recomputes with the locally-matched reports for that query (:396-412).
Render-phase update snapshots those same rows into frozenLocalRank (:436, plus the size === 0 recovery branch at :438-440).
Section split classifies rows by frozenLocalRank.has(stableKey) (:534-541) → all rows land in localRows, serverRows empty.
serverResults = "Search results" section is gated on serverRows.length > 0 (:559) → skipped.
This is a pure frontend state-classification bug — production logs wouldn't add signal. The frozenLocalRank / two-section ("serverResults") design is the recent change that regressed this in 9.4.32; the shallow CI checkout doesn't expose the exact introducing PR, but the design is self-contained in this file.
What changes do you think we should make in order to solve the problem?
Stop using the frozen-order snapshot as the local-vs-server membership test. Two clean options:
Tag server-origin rows explicitly. Have the options builder (getSearchOptions / combineOrderingOfReportsAndPersonalDetails) mark rows that came from the server search vs. the local dataset, and split at :534-541 on that flag. Keep frozenLocalRank for its original job — freezing the order of the "Recent chats" rows only.
Snapshot the pre-query set. Capture frozenLocalRank from the previous query's/pre-server results so newly-matched rows for the current query fall into serverRows.
Either way, frozenLocalRank should govern ordering, not which section a row belongs to.
What alternative solutions did you explore? (Optional)
If a two-section split isn't actually required on this surface, the simplest fix is to render a single "Search results" section for non-empty queries and drop the membership split entirely — but that loses the intended "Recent chats vs. server results" distinction, so option 1 is preferred.
Confidence: High — reproduced by code inspection; the section-gating logic provably leaves serverRows empty in the normal case.
Related issue:Expensify/App#88730 ("Search - There's no 'invite as user' after typing a query for unknown emails") touches the same active-search rendering path and may be worth cross-checking, though it appears to be a distinct symptom.
Next Steps for Contributor+ team: To accept:@MelvinBot implement [this](https://github.com/Expensify/App/issues/95710) to create a draft PR. To refine:@MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.
🚨 Edited by proposal-police: This proposal was edited at 2026-07-09 14:47:15 UTC.
Proposal
What is the root cause of that problem?
The two-section split between "Recent chats" and "Search results" in src/components/Search/SearchAutocompleteList.tsx is controlled by frozenLocalRank — a Map capturing the keys of locally-known results at the moment the query changes. Items in the map go to localRows ("Recent chats"); items not in it go to serverRows ("Search results"). The "Search results" section only renders when serverRows.length > 0:
There are two cooperating defects that keep serverRows permanently empty:
Defect 1 — The 20-item hard cap silently drops server results before the split runs
recentReportsOptions — the only source that feeds nextStyledRecentReports (and therefore serverRows) — is hard-capped at 20 items:
// src/components/Search/SearchAutocompleteList.tsx L383–399constrecentReportsOptions=useMemo(()=>{// ...constreportOptions: OptionData[]=[...orderedOptions.recentReports, ...orderedOptions.personalDetails];if(searchOptions.userToInvite){reportOptions.push(searchOptions.userToInvite);}returnreportOptions.slice(0,20);// ← hard cap — silently drops server items},[autocompleteQueryValue,searchOptions]);
getSearchOptions itself also caps at the same constant:
When the user has ≥ 20 locally-cached reports matching their query, combineOrderingOfReportsAndPersonalDetails sorts all results by relevance. Server-returned reports rank lower than the well-known local ones and are silently dropped by .slice(0, 20). They never reach nextStyledRecentReports, can never be classified into serverRows, so "Search results" never renders.
Defect 2 — The frozenLocalRank recovery path incorrectly absorbs server results as local
When listOptions is null at query-change time, recentReportsOptions is [] and frozenLocalRank is set to an empty map. The recovery branch at line 425 fires on the next render:
// src/components/Search/SearchAutocompleteList.tsx L425–428}elseif(autocompleteQueryValue.trim()!==''&&frozenLocalRank.size===0&&recentReportsOptions.length>0){// Options hydrated after the rank was snapshotted as empty — recompute.setFrozenLocalRank(buildRankMap(recentReportsOptions));}
If the server API has already returned by the time this branch fires (fast network / warm cache), recentReportsOptions now contains both local and server results. The recovery indiscriminately adds all items into frozenLocalRank, so every item is classified as localRows, serverRows stays empty, and "Search results" never appears.
What changes do you think we should make in order to solve the problem?
Fix 2 — Snapshot locally-known Onyx report IDs at query-change time to accurately classify server results
Add a localKeySnapshot state that captures the set of report IDs present in the Onyx reports collection the moment the query changes. Any item that subsequently appears in nextStyledRecentReports but whose reportID was not in this snapshot is unambiguously a server result. The reports collection is already subscribed at line 177:
Add the snapshot state alongside frozenLocalRank and remove the faulty recovery branch (currently L404–428):
// src/components/Search/SearchAutocompleteList.tsx — replace L404–428const[frozenLocalRank,setFrozenLocalRank]=useState<ReadonlyMap<string,number>>(EMPTY_RANK_MAP);const[localKeySnapshot,setLocalKeySnapshot]=useState<ReadonlySet<string>>(newSet());const[prevAutocompleteQuery,setPrevAutocompleteQuery]=useState(autocompleteQueryValue);if(prevAutocompleteQuery!==autocompleteQueryValue){setPrevAutocompleteQuery(autocompleteQueryValue);if(autocompleteQueryValue.trim()===''){setFrozenLocalRank(EMPTY_RANK_MAP);setLocalKeySnapshot(newSet());}else{setFrozenLocalRank(buildRankMap(recentReportsOptions));// Snapshot Onyx report IDs synchronously before the server call returnssetLocalKeySnapshot(newSet(Object.keys(reports??{})));}// The frozenLocalRank.size === 0 recovery branch is intentionally removed.// localKeySnapshot is always built from the Onyx reports collection which is// synchronously available, so no recovery path is needed.}
Update the classification loop in the section-generation block to use localKeySnapshot (currently L519–527):
This ensures any report returned by SearchForReports that was not in the local Onyx collection at query-change time is placed into serverRows and displayed under "Search results", regardless of how it ranks relative to local results.
What alternative solutions did you explore? (Optional)
Adding an isFromServer flag to OptionData: Rejected because it requires threading a flag through getSearchOptions and OptionsListUtils, coupling the UI split concern into the data layer.
Using RAM_ONLY_IS_SEARCHING_FOR_REPORTS as the split trigger: Rejected because this flag clears before the rendered list stabilizes, causing a flash where the "Search results" header appears and immediately disappears.
Tracking a monotonic request ID per search round-trip: Accurate but significantly more complex — requires a wrapper around handleSearch and a correlation map — disproportionate for this fix.
Please re-state the problem that we are trying to solve in this issue.
When a search query longer than 3 characters is typed into the search router, the list is supposed to split into a "Recent chats" section and a "Search results" section. Instead only the "Recent chats" section renders, and the "Search results" header never appears.
What is the root cause of that problem?
The sectioned list is built in SearchAutocompleteList. During an active search the component splits the styled report rows into two buckets: localRows (rows whose keyForList is present in frozenLocalRank) and serverRows (rows that are not). localRows becomes the "Recent chats" section and serverRows becomes the "Search results" (search.serverResults) section. The problem is that the "Search results" section is only pushed when serverRows.length > 0:
Because NewDot is offline-first, the reports matching a typed query are already cached locally, so recentReportsOptions at query-change time already contains essentially every row that will ever display. That snapshot lands all of them in frozenLocalRank, so on the next render every row satisfies frozenLocalRank.has(item.keyForList) and flows into localRows, leaving serverRows empty. With serverRows empty, the if (serverRows.length > 0) guard skips the section entirely, so the user sees only "Recent chats" — exactly the reported symptom.
This is a regression from commit 3cfcd87a2bd ("hide empty server section"). The original two-section implementation (13e6cfab976) always pushed the "Search results" section — subscribing to ONYXKEYS.RAM_ONLY_IS_SEARCHING_FOR_REPORTS and rendering a loading skeleton in the section's customHeader while the server search was in flight and serverRows was still empty. 3cfcd87a2bd replaced that always-render-with-skeleton block with the serverRows.length > 0 guard and dropped the isSearchingForReports subscription, so the section (and its skeleton placeholder) disappears in the normal cached-data flow.
What changes do you think we should make in order to solve the problem?
Restore the invariant that during an active search the "Search results" section is always rendered, decoupling its visibility from serverRows.length. In the active-search else branch of the sections useMemo, replace the if (serverRows.length > 0) guard with the original always-push block, re-subscribing to ONYXKEYS.RAM_ONLY_IS_SEARCHING_FOR_REPORTS so a skeleton shows while the server search is in flight and the section header is present even before rows arrive:
skeletonHeader is already defined in this scope, and isSearchingForReports needs to be added to the sections useMemo dependency array. This is safe because it only touches the active-search branch — the empty-query "Recent chats" path and the frozen-rank ordering logic are untouched — and it re-establishes the two-section layout the component was explicitly designed for, so both headers appear whenever a query is active.
What alternative solutions did you explore? (Optional)
Simply deleting the if (serverRows.length > 0) guard (pushing the section unconditionally without the skeleton) also restores the split, but during the in-flight window serverRows is empty so the user briefly sees a bare "Search results" header with no feedback; re-adding the isSearchingForReports skeleton gives proper loading feedback and matches the original UX. I also considered re-basing the split on the pre-query recent set instead of the query-change snapshot, but that is a larger redesign that risks the row-reordering and focus regressions the frozen-rank logic was built to prevent.
The autocomplete list only splits into Recent chats and Search results when serverRows ends up non-empty. Rows are classified as local vs. server purely by whether their stable key is present in frozenLocalRank — a snapshot of the local options taken when the query changes:
The bug is in the fallback branch (else if). It uses frozenLocalRank.size === 0 as a proxy for "we haven't captured a snapshot for this query yet". But an empty map is also the legitimate snapshot for a query that has no locally-cached matches — which is exactly the case where a "Search results" section is expected (you're searching for something that isn't already in your recent chats).
When there are no local matches, recentReportsOptions starts empty, so the snapshot at query-change is empty. The first time recentReportsOptions becomes non-empty is when the server SearchForReports/SearchForUsers response merges into Onyx. At that render the fallback condition (size === 0 && recentReportsOptions.length > 0) is finally satisfied, so it snapshots the server rows into frozenLocalRank. Every row now matches the frozen rank, serverRows stays empty:
// Options are still loading and no local results matched — show a skeleton so the
// user sees feedback instead of a bare section header.
pushSection({
title: undefined,
data: [],
sectionIndex: sectionIndex++,
customHeader: skeletonHeader,
});
}
if(serverRows.length>0){
pushSection({
title: translate('search.serverResults'),
data: serverRows,
sectionIndex: sectionIndex++,
});
}
so the search.serverResults section is never pushed and the list renders only "Recent chats".
What changes do you think we should make in order to solve the problem?
We should capture the local snapshot exactly once per query — as soon as the local options are ready and before the server response merges in — instead of treating an empty map as "not captured yet".
Track the query the snapshot belongs to, and gate the (re)capture on the options being loaded (!isLoadingOptions) rather than on recentReportsOptions.length > 0. isLoadingOptions flips to false once the local Onyx options hydrate, which happens before the debounced server search returns, so the snapshot always reflects the local-only set:
const[rankSnapshotQuery,setRankSnapshotQuery]=useState<string|null>(null);if(prevAutocompleteQuery!==autocompleteQueryValue){setPrevAutocompleteQuery(autocompleteQueryValue);if(autocompleteQueryValue.trim()===''){setFrozenLocalRank(EMPTY_RANK_MAP);setRankSnapshotQuery(null);}elseif(!isLoadingOptions){// Local options are ready — snapshot them now (may legitimately be empty).setFrozenLocalRank(buildRankMap(recentReportsOptions));setRankSnapshotQuery(autocompleteQueryValue);}// else: options still loading — defer until they hydrate (handled below)}elseif(autocompleteQueryValue.trim()!==''&&rankSnapshotQuery!==autocompleteQueryValue&&!isLoadingOptions){// Local options hydrated after the query changed — snapshot before server results arrive.setFrozenLocalRank(buildRankMap(recentReportsOptions));setRankSnapshotQuery(autocompleteQueryValue);}
The key point is that an empty snapshot for a query with no local matches is now recorded as captured (rankSnapshotQuery === autocompleteQueryValue), so the fallback no longer re-fires when the server rows land — those rows fall outside frozenLocalRank and correctly populate the "Search results" section.
What alternative solutions did you explore? (Optional)
Instead of a timing-based snapshot, classify rows by their actual source: persist the report/account IDs returned by the last SearchForReports/SearchForUsers response into a dedicated Onyx key and mark any row in that set as a server result. This is more robust (immune to snapshot-timing edge cases) but heavier — it needs new Onyx state and wiring in searchInServer, so I'd prefer the minimal fix above unless we want to remove the frozen-rank heuristic entirely.
Note: This proposal is not a duplicate. It identifies a deeper root cause rather than the surface symptom.
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user opens Search on Web and types a query of 4+ characters, the results list shows only a single "Recent chats" section instead of splitting into "Recent chats" and "Search results" as it did before. This makes it impossible to distinguish locally-known matches from server-returned matches.
What is the root cause of that problem?
In src/components/Search/SearchAutocompleteList.tsx, the split into local vs. server rows uses frozenLocalRank captured at query-change time from recentReportsOptions (line 436, buildRankMap(recentReportsOptions)). The section-building loop (lines 534–540) then classifies each item in nextStyledRecentReports as local iff its stable key is already in frozenLocalRank, otherwise server. Because recentReportsOptions is derived from searchOptions (Onyx), the snapshot taken the instant the query changes already contains every locally-cached report that matches — including reports the backend will echo back. When the server response merges into Onyx, those reports keep the same stable key and hit frozenLocalRank.has(stableKey) === true, so every row is pushed to localRows and serverRows remains empty. The serverRows.length > 0 guard at line 559 then skips pushSection({title: translate('search.serverResults'), …}), and the user sees only "Recent chats". The regression was introduced by PR #95454, which reworked this exact split via getStableRankKey (lines 105–111) and the local/server partition (lines 532–544).
What changes do you think we should make in order to solve the problem?
src/components/Search/SearchAutocompleteList.tsx lines 531–557: stop deriving the "server" section by elimination from frozenLocalRank. Instead, track the origin of each row explicitly — mark items produced from local Onyx searchOptions as local, and items introduced by the search API response as server — and partition on that flag.
src/components/Search/SearchAutocompleteList.tsx lines 414–441: the frozen rank should only govern ordering of the local section (its original purpose per the comment on 414–416), not membership. Keep buildRankMap for stable sort, but decouple it from the local/server classification.
src/components/Search/SearchAutocompleteList.tsx line 559: once server rows are correctly identified, the existing pushSection({title: translate('search.serverResults'), …}) block will fire and render the "Search results" header (search.serverResults = "Search results" in src/languages/en.ts:8946).
Extend tests/ui/components/SearchAutocompleteListTest.tsx with a case where the API returns a report that was ALREADY in local recentReportsOptions at query-change time, asserting that a "Search results" section is still rendered for the newly-arrived server rows. The current DM test (added in fix known DMs missing in recent chats on fresh sign-in #95454) does not cover this shape.
What alternative solutions did you explore? (Optional)
changed the title [-]Search - list does not split into "Recent chats" and "Search results" sections.[/-][+][$250] Search - list does not split into "Recent chats" and "Search results" sections.[/+]on Jul 9, 2026
Activity
applause-bot commentedon Jul 9, 2026
While Applause doesn't embed attachments for this bug, here are the links for quick view:
https://platform.applause.com/services/links/v1/external/f957ee2662b940773a4b3bbe2f9c92572626f27d7e3c9446fcc7269e459dbb42
MelvinBot commentedon Jul 9, 2026
Proposal
What is the root cause of that problem?
When a query is typed, the Search Router splits
recentReportsOptionsinto two sections: "Recent chats" (locally-known results) and "Search results" (results the server returns afterward). The split is decided purely by membership in afrozenLocalRanksnapshot: rows in the snapshot → "Recent chats", rows not in it → "Search results".The problem is that the snapshot is built from the exact same array it later splits. On query change,
SearchAutocompleteList.tsx:431-436snapshots every current row ofrecentReportsOptionsintofrozenLocalRank. Then the section builder atSearchAutocompleteList.tsx:534-541classifies every row as "local" because it's already in the snapshot, leavingserverRowsempty. Since the "Search results" section is only pushed whenserverRows.length > 0, it is never rendered — the list shows only "Recent chats".The intent (see the comment at
:414-416) was to freeze the order of already-visible local rows so server results merged into Onyx later don't reorder them. But the same snapshot is being (mis)used to decide local-vs-server membership, which empties the server section in the common case where client-side options already cover the matches.Evidence & data flow
autocompleteQueryValuechanges.recentReportsOptionsrecomputes with the locally-matched reports for that query (:396-412).frozenLocalRank(:436, plus thesize === 0recovery branch at:438-440).frozenLocalRank.has(stableKey)(:534-541) → all rows land inlocalRows,serverRowsempty.serverResults= "Search results" section is gated onserverRows.length > 0(:559) → skipped.This is a pure frontend state-classification bug — production logs wouldn't add signal. The
frozenLocalRank/ two-section ("serverResults") design is the recent change that regressed this in 9.4.32; the shallow CI checkout doesn't expose the exact introducing PR, but the design is self-contained in this file.What changes do you think we should make in order to solve the problem?
Stop using the frozen-order snapshot as the local-vs-server membership test. Two clean options:
Tag server-origin rows explicitly. Have the options builder (
getSearchOptions/combineOrderingOfReportsAndPersonalDetails) mark rows that came from the server search vs. the local dataset, and split at:534-541on that flag. KeepfrozenLocalRankfor its original job — freezing the order of the "Recent chats" rows only.Snapshot the pre-query set. Capture
frozenLocalRankfrom the previous query's/pre-server results so newly-matched rows for the current query fall intoserverRows.Either way,
frozenLocalRankshould govern ordering, not which section a row belongs to.What alternative solutions did you explore? (Optional)
If a two-section split isn't actually required on this surface, the simplest fix is to render a single "Search results" section for non-empty queries and drop the membership split entirely — but that loses the intended "Recent chats vs. server results" distinction, so option 1 is preferred.
Confidence: High — reproduced by code inspection; the section-gating logic provably leaves
serverRowsempty in the normal case.Related issue:
Expensify/App#88730("Search - There's no 'invite as user' after typing a query for unknown emails") touches the same active-search rendering path and may be worth cross-checking, though it appears to be a distinct symptom.Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/95710)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
ashu75575 commentedon Jul 9, 2026
🚨 Edited by proposal-police: This proposal was edited at 2026-07-09 14:47:15 UTC.
Proposal
What is the root cause of that problem?
The two-section split between "Recent chats" and "Search results" in
src/components/Search/SearchAutocompleteList.tsxis controlled byfrozenLocalRank— aMapcapturing the keys of locally-known results at the moment the query changes. Items in the map go tolocalRows("Recent chats"); items not in it go toserverRows("Search results"). The "Search results" section only renders whenserverRows.length > 0:There are two cooperating defects that keep
serverRowspermanently empty:Defect 1 — The 20-item hard cap silently drops server results before the split runs
recentReportsOptions— the only source that feedsnextStyledRecentReports(and thereforeserverRows) — is hard-capped at 20 items:getSearchOptionsitself also caps at the same constant:When the user has ≥ 20 locally-cached reports matching their query,
combineOrderingOfReportsAndPersonalDetailssorts all results by relevance. Server-returned reports rank lower than the well-known local ones and are silently dropped by.slice(0, 20). They never reachnextStyledRecentReports, can never be classified intoserverRows, so "Search results" never renders.Defect 2 — The
frozenLocalRankrecovery path incorrectly absorbs server results as localWhen
listOptionsisnullat query-change time,recentReportsOptionsis[]andfrozenLocalRankis set to an empty map. The recovery branch at line 425 fires on the next render:If the server API has already returned by the time this branch fires (fast network / warm cache),
recentReportsOptionsnow contains both local and server results. The recovery indiscriminately adds all items intofrozenLocalRank, so every item is classified aslocalRows,serverRowsstays empty, and "Search results" never appears.What changes do you think we should make in order to solve the problem?
Both defects are fixed by two targeted changes confined to
src/components/Search/SearchAutocompleteList.tsx:Fix 1 — Raise the display cap so server results are not silently discarded
Add a module-level constant and apply it consistently to both
recentReportsOptionsandgetSearchOptions:Update
recentReportsOptions(currently at L398):Update the
getSearchOptionscall (currently at L223):Fix 2 — Snapshot locally-known Onyx report IDs at query-change time to accurately classify server results
Add a
localKeySnapshotstate that captures the set of report IDs present in the Onyx reports collection the moment the query changes. Any item that subsequently appears innextStyledRecentReportsbut whosereportIDwas not in this snapshot is unambiguously a server result. Thereportscollection is already subscribed at line 177:Add the snapshot state alongside
frozenLocalRankand remove the faulty recovery branch (currently L404–428):Update the classification loop in the section-generation block to use
localKeySnapshot(currently L519–527):This ensures any report returned by
SearchForReportsthat was not in the local Onyx collection at query-change time is placed intoserverRowsand displayed under "Search results", regardless of how it ranks relative to local results.What alternative solutions did you explore? (Optional)
Adding an
isFromServerflag toOptionData: Rejected because it requires threading a flag throughgetSearchOptionsandOptionsListUtils, coupling the UI split concern into the data layer.Using
RAM_ONLY_IS_SEARCHING_FOR_REPORTSas the split trigger: Rejected because this flag clears before the rendered list stabilizes, causing a flash where the "Search results" header appears and immediately disappears.Tracking a monotonic request ID per search round-trip: Accurate but significantly more complex — requires a wrapper around
handleSearchand a correlation map — disproportionate for this fix.MobileMage commentedon Jul 9, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a search query longer than 3 characters is typed into the search router, the list is supposed to split into a "Recent chats" section and a "Search results" section. Instead only the "Recent chats" section renders, and the "Search results" header never appears.
What is the root cause of that problem?
The sectioned list is built in
SearchAutocompleteList. During an active search the component splits the styled report rows into two buckets:localRows(rows whosekeyForListis present infrozenLocalRank) andserverRows(rows that are not).localRowsbecomes the "Recent chats" section andserverRowsbecomes the "Search results" (search.serverResults) section. The problem is that the "Search results" section is only pushed whenserverRows.length > 0:App/src/components/Search/SearchAutocompleteList.tsx
Lines 535 to 539 in 984116c
frozenLocalRankis snapshotted from the entire current filtered result set (recentReportsOptions) the instant the query changes:App/src/components/Search/SearchAutocompleteList.tsx
Lines 409 to 413 in 984116c
Because NewDot is offline-first, the reports matching a typed query are already cached locally, so
recentReportsOptionsat query-change time already contains essentially every row that will ever display. That snapshot lands all of them infrozenLocalRank, so on the next render every row satisfiesfrozenLocalRank.has(item.keyForList)and flows intolocalRows, leavingserverRowsempty. WithserverRowsempty, theif (serverRows.length > 0)guard skips the section entirely, so the user sees only "Recent chats" — exactly the reported symptom.This is a regression from commit
3cfcd87a2bd("hide empty server section"). The original two-section implementation (13e6cfab976) always pushed the "Search results" section — subscribing toONYXKEYS.RAM_ONLY_IS_SEARCHING_FOR_REPORTSand rendering a loading skeleton in the section'scustomHeaderwhile the server search was in flight andserverRowswas still empty.3cfcd87a2bdreplaced that always-render-with-skeleton block with theserverRows.length > 0guard and dropped theisSearchingForReportssubscription, so the section (and its skeleton placeholder) disappears in the normal cached-data flow.What changes do you think we should make in order to solve the problem?
Restore the invariant that during an active search the "Search results" section is always rendered, decoupling its visibility from
serverRows.length. In the active-searchelsebranch of the sectionsuseMemo, replace theif (serverRows.length > 0)guard with the original always-push block, re-subscribing toONYXKEYS.RAM_ONLY_IS_SEARCHING_FOR_REPORTSso a skeleton shows while the server search is in flight and the section header is present even before rows arrive:skeletonHeaderis already defined in this scope, andisSearchingForReportsneeds to be added to the sectionsuseMemodependency array. This is safe because it only touches the active-search branch — the empty-query "Recent chats" path and the frozen-rank ordering logic are untouched — and it re-establishes the two-section layout the component was explicitly designed for, so both headers appear whenever a query is active.What alternative solutions did you explore? (Optional)
Simply deleting the
if (serverRows.length > 0)guard (pushing the section unconditionally without the skeleton) also restores the split, but during the in-flight windowserverRowsis empty so the user briefly sees a bare "Search results" header with no feedback; re-adding theisSearchingForReportsskeleton gives proper loading feedback and matches the original UX. I also considered re-basing the split on the pre-query recent set instead of the query-change snapshot, but that is a larger redesign that risks the row-reordering and focus regressions the frozen-rank logic was built to prevent.David-2002065 commentedon Jul 9, 2026
Proposal
What is the root cause of that problem?
The autocomplete list only splits into Recent chats and Search results when
serverRowsends up non-empty. Rows are classified as local vs. server purely by whether their stable key is present infrozenLocalRank— a snapshot of the local options taken when the query changes:App/src/components/Search/SearchAutocompleteList.tsx
Lines 431 to 441 in f3e8b7c
The bug is in the fallback branch (
else if). It usesfrozenLocalRank.size === 0as a proxy for "we haven't captured a snapshot for this query yet". But an empty map is also the legitimate snapshot for a query that has no locally-cached matches — which is exactly the case where a "Search results" section is expected (you're searching for something that isn't already in your recent chats).When there are no local matches,
recentReportsOptionsstarts empty, so the snapshot at query-change is empty. The first timerecentReportsOptionsbecomes non-empty is when the serverSearchForReports/SearchForUsersresponse merges into Onyx. At that render the fallback condition (size === 0 && recentReportsOptions.length > 0) is finally satisfied, so it snapshots the server rows intofrozenLocalRank. Every row now matches the frozen rank,serverRowsstays empty:App/src/components/Search/SearchAutocompleteList.tsx
Lines 530 to 565 in f3e8b7c
so the
search.serverResultssection is never pushed and the list renders only "Recent chats".What changes do you think we should make in order to solve the problem?
We should capture the local snapshot exactly once per query — as soon as the local options are ready and before the server response merges in — instead of treating an empty map as "not captured yet".
Track the query the snapshot belongs to, and gate the (re)capture on the options being loaded (
!isLoadingOptions) rather than onrecentReportsOptions.length > 0.isLoadingOptionsflips tofalseonce the local Onyx options hydrate, which happens before the debounced server search returns, so the snapshot always reflects the local-only set:The key point is that an empty snapshot for a query with no local matches is now recorded as captured (
rankSnapshotQuery === autocompleteQueryValue), so the fallback no longer re-fires when the server rows land — those rows fall outsidefrozenLocalRankand correctly populate the "Search results" section.What alternative solutions did you explore? (Optional)
Instead of a timing-based snapshot, classify rows by their actual source: persist the report/account IDs returned by the last
SearchForReports/SearchForUsersresponse into a dedicated Onyx key and mark any row in that set as a server result. This is more robust (immune to snapshot-timing edge cases) but heavier — it needs new Onyx state and wiring insearchInServer, so I'd prefer the minimal fix above unless we want to remove the frozen-rank heuristic entirely.aswin-s commentedon Jul 9, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user opens Search on Web and types a query of 4+ characters, the results list shows only a single "Recent chats" section instead of splitting into "Recent chats" and "Search results" as it did before. This makes it impossible to distinguish locally-known matches from server-returned matches.
What is the root cause of that problem?
In
src/components/Search/SearchAutocompleteList.tsx, the split into local vs. server rows usesfrozenLocalRankcaptured at query-change time fromrecentReportsOptions(line 436,buildRankMap(recentReportsOptions)). The section-building loop (lines 534–540) then classifies each item innextStyledRecentReportsas local iff its stable key is already infrozenLocalRank, otherwise server. BecauserecentReportsOptionsis derived fromsearchOptions(Onyx), the snapshot taken the instant the query changes already contains every locally-cached report that matches — including reports the backend will echo back. When the server response merges into Onyx, those reports keep the same stable key and hitfrozenLocalRank.has(stableKey) === true, so every row is pushed tolocalRowsandserverRowsremains empty. TheserverRows.length > 0guard at line 559 then skipspushSection({title: translate('search.serverResults'), …}), and the user sees only "Recent chats". The regression was introduced by PR #95454, which reworked this exact split viagetStableRankKey(lines 105–111) and the local/server partition (lines 532–544).What changes do you think we should make in order to solve the problem?
src/components/Search/SearchAutocompleteList.tsxlines 531–557: stop deriving the "server" section by elimination fromfrozenLocalRank. Instead, track the origin of each row explicitly — mark items produced from local OnyxsearchOptionsas local, and items introduced by the search API response as server — and partition on that flag.src/components/Search/SearchAutocompleteList.tsxlines 414–441: the frozen rank should only govern ordering of the local section (its original purpose per the comment on 414–416), not membership. KeepbuildRankMapfor stable sort, but decouple it from the local/server classification.src/components/Search/SearchAutocompleteList.tsxline 559: once server rows are correctly identified, the existingpushSection({title: translate('search.serverResults'), …})block will fire and render the "Search results" header (search.serverResults= "Search results" insrc/languages/en.ts:8946).tests/ui/components/SearchAutocompleteListTest.tsxwith a case where the API returns a report that was ALREADY in localrecentReportsOptionsat query-change time, asserting that a "Search results" section is still rendered for the newly-arrived server rows. The current DM test (added in fix known DMs missing in recent chats on fresh sign-in #95454) does not cover this shape.What alternative solutions did you explore? (Optional)
samranahm commentedon Jul 9, 2026
🚫 Duplicated proposal withdrawn by 🤖 ProposalPolice.
melvin-bot commentedon Jul 9, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @abdulrahuman5196 (
External)[-]Search - list does not split into "Recent chats" and "Search results" sections.[/-][+][$250] Search - list does not split into "Recent chats" and "Search results" sections.[/+]46 remaining items
melvin-bot commentedon Jul 28, 2026
@mkhutornyi Huh... This is 4 days overdue. Who can take care of this?
mkhutornyi commentedon Jul 29, 2026
personalDetailsListin Onyx)demo.mov
For now, all existing contacts (no matter had a chat before or not) in
personalDetailsListshow in "Recent chats"What should be the expected behavior?
cc: @mountiny @shawnborton
mountiny commentedon Jul 29, 2026
That kinda makes sense when laid out like that. What do you think @shawnborton ?
shawnborton commentedon Aug 1, 2026
Yeah I think that's totally fine personally.
melvin-bot commentedon Aug 3, 2026
@mkhutornyi Eep! 4 days overdue now. Issues have feelings too...
mkhutornyi commentedon Aug 3, 2026
We can close this then?
melvin-bot commentedon Aug 6, 2026
@abdulrahuman5196 @mkhutornyi this issue is now 4 weeks old, please consider:
Thanks!