Telegram /sessions: paginate the switcher, pin starred, exclude cron - #304
Open
serxa wants to merge 2 commits into
Open
Telegram /sessions: paginate the switcher, pin starred, exclude cron#304serxa wants to merge 2 commits into
serxa wants to merge 2 commits into
Conversation
The /sessions switcher fetched the 30 most-recently-updated sessions across all sources, then filtered to interactive (telegram/web) ones. Cron/automation sessions update constantly and dominated that window, so only a few interactive sessions survived the filter — often well under the button cap. Ordering was pure recency, and starring only added a marker to a label if the session already appeared, so starred (kept-alive) sessions — which exist precisely to survive going idle — sank below the cutoff and became the least reachable. Add SessionStore.list_interactive_sessions(): filter to interactive sources and non-empty sessions in SQL (so cron/automation and 0-message sessions never consume the window) and order current -> starred -> most-recent. /sessions now pages over it with Prev/More buttons (sess:page:<offset>) so every switchable session is reachable; the current session is pinned first (always visible on page one) and starred sessions ahead of merely-recent ones. Page size 8 -> 10. The per-row star toggle is unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Telegram splits a keyboard row's width evenly across its buttons with no API to size a narrow second column, so the per-row star toggle took half of every session row. Keep the star as a read-only "kept alive" marker in the switch label; star/unstar via /star and /unstar. Each row is now a single full-width tap-to-switch button. Removes the dead sessstar callback and routing, and the unused Router.toggle_session_starred wrapper. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
serxa
marked this pull request as ready for review
August 10, 2026 20:56
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
On Telegram,
/sessionssurfaced only a handful of recent sessions, and starred (kept-alive) sessions were usually not among them:updated_atand sank below the cutoff — so the sessions a user most wants to return to were the least reachable.Change
SessionStore.list_interactive_sessions(limit, offset, sources, current_id)that does the work in SQL: filters to interactive sources and non-empty sessions (so cron/automation and 0-message sessions never consume the window), and orders current → starred → most-recent. Exposed throughSessionManagerand the channelRouter._sessions_view_fornow fetches one page (page_size + 1, to detect a further page) instead of over-fetching and counting messages per session in Python.build_sessions_viewrenders⬅️ Prev/➡️ Morebuttons (newsess:page:<offset>callback) so every switchable session is reachable. Pinning the current session first keeps it on page 1 regardless of how many starred sessions precede it; starred sessions are pinned ahead of merely-recent ones so an idle kept-alive session is never buried./star·/unstar. Each row is now a single full-width tap-to-switch button.Tests
tests/test_list_interactive_sessions.py(new) — current→starred→recent ordering; exclusion of cron / empty / archived; pagination via limit/offset; next-page probe.tests/test_telegram_sessions.py— updated the switcher tests for the paged, single-button-per-row view; added first/middle/last-page nav assertions.3196 passed, 1 pre-existing unrelated failure (test_xmemory_bridge— anxmemorypackage version mismatch, independent of this change).