Skip to content

fix(desktop): scope messaging sidebar sessions to active profile - #56635

Closed
liuhao1024 wants to merge 1 commit into
NousResearch:mainfrom
liuhao1024:liuhao/cron-bugfix-56631-telegram-sidebar-profile
Closed

fix(desktop): scope messaging sidebar sessions to active profile#56635
liuhao1024 wants to merge 1 commit into
NousResearch:mainfrom
liuhao1024:liuhao/cron-bugfix-56631-telegram-sidebar-profile

Conversation

@liuhao1024

Copy link
Copy Markdown
Contributor

What does this PR do?

The messaging sidebar (Telegram, Discord, Slack, etc.) always fetched sessions with profile='all', ignoring the active profile switcher. When a user switched profiles in the desktop app, local recents updated correctly, but the messaging platform sections continued showing chats from every profile — so the Telegram sidebar appeared "stuck" on a single profile's chats.

This fix passes profileScope to listAllProfileSessions in both refreshMessagingSessions and loadMoreMessagingForPlatform, matching the existing pattern used by refreshSessions for local recents.

Related Issue

Fixes #56631

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • apps/desktop/src/app/session/hooks/use-session-list-actions.ts: Changed refreshMessagingSessions and loadMoreMessagingForPlatform to scope the session fetch to the active profileScope instead of hardcoding 'all'. Added profileScope to both useCallback dependency arrays so they re-fetch when the user switches profiles.
  • apps/desktop/src/hermes.test.ts: Added test verifying listAllProfileSessions forwards a specific profile name in the API request path.

How to Test

  1. Configure Hermes with multiple profiles (e.g., local, remote, default), each with Telegram enabled
  2. Open the desktop app and verify the Telegram sidebar shows chats from all profiles initially
  3. Switch to a specific profile (e.g., local) in the app's profile switcher
  4. The Telegram sidebar should now show only chats from the local profile
  5. Switch to remote — the sidebar should update to show only remote profile's Telegram chats
  6. Switch back to "All profiles" — the sidebar should show chats from all profiles again
  7. Should pass: npx vitest run apps/desktop/src/hermes.test.ts --reporter=verbose

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS 26.4.1 arm64

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

Screenshots / Logs

N/A — the fix is a 3-line behavioral change in session fetch scope (plus comments and dependency arrays). The listAllProfileSessions API already supports per-profile filtering; the call sites just weren't using it.

The messaging sidebar (Telegram, Discord, etc.) always fetched sessions
with profile='all', ignoring the active profile switcher. When a user
switched profiles in the desktop app, local recents updated correctly
but the messaging platform sections (e.g. Telegram chat list) continued
showing chats from every profile.

Fix by passing profileScope to listAllProfileSessions in both
refreshMessagingSessions and loadMoreMessagingForPlatform, matching the
existing pattern used by refreshSessions for local recents.

Fixes NousResearch#56631
@alt-glitch alt-glitch added type/bug Something isn't working comp/desktop Electron desktop app (apps/desktop/*) platform/telegram Telegram bot adapter P3 Low — cosmetic, nice to have labels Jul 1, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Related: competing with open #42934 (filters messaging sessions by active profile) for the same sidebar profile-scope gap that #56631 reports. This PR scopes the fetch itself (passes profileScope to listAllProfileSessions); #42934 filters after fetch. Flagging the cluster so a maintainer can pick one approach.

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for narrowing the fix to the shared messaging fetch paths. The active-profile premise is confirmed on current main: refreshMessagingSessions and loadMoreMessagingForPlatform both pass "all" at apps/desktop/src/app/session/hooks/use-session-list-actions.ts:102,126, while local recents already derive sessionProfile at :174-177.

Problems

  • The new profile-dependent refresh needs a stale-result guard. DesktopController polls it at apps/desktop/src/app/desktop-controller.tsx:901-919; after a profile switch, an older request can resolve last and overwrite the new profile's rows because the hook writes unconditionally. The local-recents path already uses a request-id guard at use-session-list-actions.ts:155-188.
  • The added apps/desktop/src/hermes.test.ts assertion only covers URL serialization already implemented by listAllProfileSessions at apps/desktop/src/hermes.ts:231-249; it does not exercise either changed hook call site.
  • apps/desktop/src/app/chat/sidebar/index.tsx:1334-1336 still suppresses messaging groups in worktree-grouped mode.

Suggested changes

  • Guard messaging refresh/page results against profile changes and add hook-level tests for concrete, all-profiles, and out-of-order responses.
  • Clarify or cover the worktree-grouped rendering behavior.

Automated hermes-sweeper review.

// Scope the fetch to the active profile so switching profiles updates the
// messaging sidebar (Telegram, Discord, …) — previously hardcoded to
// 'all', which meant the sidebar always showed every profile's chats
// regardless of the active profile switcher.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please guard this profile-scoped request before publishing its result. refreshMessagingSessions is polled, so a request started for the previous profile can resolve after a switch and overwrite the active profile's rows; mirror the request-id protection already used by refreshSessions.

@teknium1

Copy link
Copy Markdown
Contributor

Resolved on main by #87566, which consolidated this PR's fix with your Co-authored-by credit preserved in the merged commits. Thank you!

@teknium1 teknium1 closed this Aug 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/profiles Multi-profile isolation, HERMES_HOME scoping area/sessions Session lifecycle, resume, persistence, history comp/desktop Electron desktop app (apps/desktop/*) P3 Low — cosmetic, nice to have platform/telegram Telegram bot adapter sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Desktop app Telegram sidebar ignores active profile and always shows remote chats

3 participants