-
Notifications
You must be signed in to change notification settings - Fork 52.8k
fix(gateway): scope sidebar messaging sessions to the active profile #71526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
FrendoWu
wants to merge
2
commits into
NousResearch:main
from
FrendoWu:fix/sidebar-messaging-profile-scope
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
messagingPlatformTotalsremains global even though this makes fetched rows profile-scoped. A per-platform load-more in profile A stores A's exact total, and after switching to B the sidebar still uses that value for its count andhasMore. Reset or key these totals bymessagingProfile, and add a profile-switch regression test.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed by keying the map rather than resetting it — pushed as a fresh commit on current
main(the old base was ~425 commits behind and had gonedirty).$messagingPlatformTotalsis now keyedprofile:source, built by a sharedmessagingTotalsKey/messagingProfileForpair instore/profile.tsso the writer (loadMoreMessagingForPlatform) and the reader (the sidebar'smessagingGroupsmemo) can't disagree about which profile a cached value belongs to. Two notes on the details:hasMoreback to the coarse$messagingTruncatedflag until something re-pages. Keyed, A→B→A restores A's real count. It also needs no new effect or subscription: a scope change reads a different slot, so there's nothing to invalidate. (A reset hung off$activeGatewayProfilewould also have missed the$showAllProfilestoggle, which changes the effective messaging profile without touching the gateway.)$profileScope, notshowAllProfiles— the latter ismultiProfile && profileScope === ALL_PROFILES, so on a single-profile install it disagrees with what the hook actually sent asmessaging_profile.Worth recording that the low-reading direction was the worse one: a stale total that's too high shows a phantom "load more" and self-heals after one wasted round-trip, but too low makes
known > ordered.lengthfalse, which overrides$messagingTruncatedand suppresses a legitimate "load more" — and nothing triggers a per-platform fetch, so that one never self-heals.Backend salvaged as you suggested. The edit is now in
hermes_cli/web_routers/profiles.pyper27b1377b4c; theweb_server.pyre-export meansTestClient(app)still serves the route, so no mount change was needed.Tests — the profile-switch regression you asked for is in
use-session-list-actions.test.tsx, using a realrerender-driven switch after a per-platform load-more (the previous messaging test rendered two independent hook instances, so it proved nothing about state carried across a switch). It asserts the new profile doesn't inherit the count and the old profile's survives. I verified it fails without the keying. That file also now resets$messagingPlatformTotals/$messagingTruncatedbetween tests — neither was reset before, which made these assertions order-dependent.On the backend side there was no test to extend: the sidebar-handler tests were removed in the two pruning waves (
6b81590c55,39975613b1) and there's notests/hermes_cli/web_routers/. Sotests/hermes_cli/test_web_server_sidebar_sessions.pyis new, following theisolated_profiles+clientfixture idiom fromtest_web_server_messaging_profiles.py. It covers scoping, theall/omitted unified view, thatmessaging.totalnarrows with the scope, and that the cron/recents windows are unaffected. Two of the four fail without the gate.One semantic change to flag:
messaging.totalnow means "rows for the requested profile". That's what the desktop resolves a section's exact count from, and no consumer reads it as a cross-profile figure (SidebarSessionSliceonly declaressessions+profiles_truncated), so I left it as-is rather than adding a second field.Green locally: full
uivitest project (3125 tests),electronproject (867), all threetscprojects, eslint, prettier, andscripts/run_tests.shon the new file plus the adjacent profile/web-server suites.Left out on purpose
Two adjacent leaks in the same family that I kept out to hold this diff to the review ask — happy to fold either in if you'd rather:
messagingVisible/messagingLoadMorePending(sidebar/index.tsx) are React-local and also survive a profile switch, so a busy profile's expanded reveal cap carries into a quieter one.store/gateway-switch.test.tsnever asserts the three messaging stores thatwipeSessionListsForGatewaySwitchclears — pre-existing coverage gap.loadMoreMessagingForPlatform'sloadedcount filters$messagingSessionsby platform only, so mid-switch it can briefly count the previous profile's rows. Self-corrects on the next refresh.