fix: scope desktop messaging sessions to active profile - #58983
fix: scope desktop messaging sessions to active profile#58983Thankyouadd wants to merge 1 commit into
Conversation
Duplicate of #56635 — both make the identical core change in |
teknium1
left a comment
There was a problem hiding this comment.
Thanks for tracing both the initial messaging slice and the per-platform pager. The current main still passes "all" in both paths at apps/desktop/src/app/session/hooks/use-session-list-actions.ts:102 and :126, while the backend already honors a concrete profile at hermes_cli/web_server.py:4132-4134, so the reported leak is real.
Problems
- The scoped requests can still leak through an out-of-order response.
refreshSessionsusesrefreshSessionsRequestRefbefore publishing results (use-session-list-actions.ts:156-188), but messaging writes directly afterawaitat:110-113and:132-138. Toggling All Profiles only updates$showAllProfiles(apps/desktop/src/store/profile.ts:329-335), so an earlier all-profile request may resolve after the new scoped request and overwrite the shared messaging rows.
Suggested changes
- Add the same request-generation/scope validation to both messaging fetch paths before publishing rows and totals.
- Add a deferred-response regression test covering a profile-scope change while the first fetch is in flight.
Automated hermes-sweeper review.
| const refreshMessagingSessions = useCallback(async () => { | ||
| try { | ||
| const result = await listAllProfileSessions(MESSAGING_SECTION_LIMIT, 1, 'exclude', 'recent', 'all', { | ||
| const sessionProfile = profileScope === ALL_PROFILES ? 'all' : profileScope |
There was a problem hiding this comment.
Please pair this scope change with a request-generation or captured-scope check before setMessagingSessions. Unlike refreshSessions, this callback publishes every completed response without guarding against an older scope's request resolving last; toggling All Profiles does not wipe this shared messaging store.
What does this PR do?
Fixes Desktop sidebar profile leakage for external messaging sessions.
Previously, the Desktop sidebar's messaging slice always queried
/api/profiles/sessionswithprofile=all. In multi-profile setups, this could surface Telegram sessions from a dedicatedtelegramprofile while the user was viewing thedefaultprofile.This PR scopes messaging session fetches to the active sidebar profile, while preserving the explicit all-profiles view behavior. It also keeps messaging sections renderable when the sidebar is in Projects/Worktree grouped mode, so a profile that only has Telegram sessions still shows its Telegram section instead of an empty session state.
Related Issue
N/A no issue filed.
Type of Change
Changes Made
apps/desktop/src/app/session/hooks/use-session-list-actions.tsrefreshMessagingSessions()to the currentprofileScopeinstead of always usingprofile=all.loadMoreMessagingForPlatform()to the currentprofileScopeas well.apps/desktop/src/app/chat/sidebar/index.tsxapps/desktop/src/app/session/hooks/use-session-list-actions.test.tsxtests/hermes_cli/test_web_server.py/api/profiles/sessions?profile=<name>filtering so sibling profile rows do not leak.How to Test
cd apps/desktop npm run test:ui -- src/app/session/hooks/use-session-list-actions.test.tsx src/hermes.test.tscd apps/desktop npm run typecheck npm run builddefaultandtelegramprofiles:defaultprofile: Telegram section/sessions are not shown.telegramprofile: Telegram section is shown with Telegram sessions.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
Screenshots / Logs
Focused verification completed locally:
Manual Desktop check:
defaultprofile: no Telegram section/sessions shown.telegramprofile: Telegram section shown with Telegram sessions.