← Back to PRs

#22469: fix(gateway): avoid stale whatsapp labels on direct sessions

by loganprit open 2026-02-21 06:27 View on GitHub →
gateway size: S
## Summary Fixes incorrect direct-session channel labeling in gateway sessions (e.g. Telegram sessions showing as `whatsapp:g-agent-main-main`). This PR now includes three follow-up CI stability commits made while rebasing onto latest `upstream/main`: - format alignment required by `oxfmt` on CI workflow file - import-order alignment in `session-utils.ts` for `oxfmt 0.33` - restore `signal-utils` dependency used by A2UI bundling after upstream dependency drift ## What Changed - Updated direct-session channel/display derivation to prefer delivery/origin metadata instead of stale legacy `entry.channel` values. - Kept group display-name synthesis behavior unchanged for true group sessions. - Added/updated regression coverage in gateway session utils tests. - Applied CI/build follow-ups listed above to keep checks green after upstream rebase. ## User-visible Behavior - `sessions.list` / dashboard now shows direct Telegram sessions as Telegram (and user-facing Telegram label), not stale WhatsApp group-style labels. ## Linked Issues - Fixes #18146 - Related #6199 - Related #7922 ## Validation - `pnpm test src/gateway/session-utils.test.ts` - Local gateway verification via `sessions.list` - `pnpm check` - `pnpm canvas:a2ui:bundle` ## Notes - One prior Windows run failed in `extensions/msteams/src/messenger.test.ts` (`preserves parsed mentions when appending OneDrive fallback file links`) while all Linux/macOS-relevant jobs passed. This appears unrelated to the gateway session-labeling change in this PR. ## AI Disclosure - AI-assisted (Codex) <!-- greptile_comment --> <h3>Greptile Summary</h3> Fixes direct-session channel labeling bug where sessions (e.g., Telegram) incorrectly displayed stale legacy `channel` values (e.g., showing as WhatsApp group labels like `whatsapp:g-agent-main-main`). - **Main fix (session-utils.ts)**: Updated channel derivation logic to prefer fresh delivery/origin metadata over stale `entry.channel` for direct sessions, while preserving group display-name synthesis for true group sessions - **Tests added**: Two new regression tests confirm direct sessions now use correct delivery context channel and group sessions maintain existing behavior - **CI/build follow-ups**: Removed extra blank line in CI workflow for oxfmt consistency, aligned import order in session-utils.ts for oxfmt 0.33, and restored `signal-utils` dependency (required by A2UI bundling after upstream cleanup removed it) The core logic change uses session `kind` classification to apply different channel resolution strategies: direct sessions now prioritize `deliveryContext.channel` → `lastChannel` → `originChannel`, while group sessions keep the original fallback order. <h3>Confidence Score: 5/5</h3> - Safe to merge - well-tested bug fix with clear scope and comprehensive regression coverage - The PR has a focused scope addressing a specific labeling bug with clear before/after test cases. The main logic change is straightforward (reordering channel resolution priorities based on session kind), preserves existing group session behavior, and includes two new tests verifying both direct and group session handling. The follow-up commits (CI formatting, import order, dependency restoration) are justified maintenance fixes required for CI stability. No logical errors, security issues, or breaking changes identified. - No files require special attention <sub>Last reviewed commit: 05e5f77</sub> <!-- greptile_other_comments_section --> <sub>(5/5) You can turn off certain types of comments like style [here](https://app.greptile.com/review/github)!</sub> <!-- /greptile_comment -->

Most Similar PRs