Skip to content

Keep desktop messaging sessions fresh - #45677

Closed
lawyer112 wants to merge 2 commits into
NousResearch:mainfrom
lawyer112:codex/desktop-poll-messaging-sessions
Closed

Keep desktop messaging sessions fresh#45677
lawyer112 wants to merge 2 commits into
NousResearch:mainfrom
lawyer112:codex/desktop-poll-messaging-sessions

Conversation

@lawyer112

Copy link
Copy Markdown
Contributor

Summary

  • poll messaging-platform session lists while the desktop is connected and visible so background gateway traffic appears in the sidebar
  • refresh the currently open messaging-platform transcript from SessionDB on a short interval
  • include message metadata in the session row signature so updated previews, counts, and activity times are not ignored

Testing

  • npm run typecheck (apps/desktop)
  • npx eslint src/app/desktop-controller.tsx
  • git diff --check

Manual verification

  • Confirmed WeChat messages are already persisted in the local SessionDB; the desktop UI was stale because external platform sessions are not driven by the local chat websocket events.
  • Rebuilt and hot-patched the local macOS desktop bundle for immediate testing.

@lawyer112

Copy link
Copy Markdown
Contributor Author

Added a backend follow-up fix for the same desktop/messaging sync issue.

Root cause found in dogfood: a platform SessionStore entry can remain pinned to a pre-compression parent session after a restart/send failure, while desktop opens the compression continuation. That makes Weixin and desktop appear unsynced even when the desktop polling fix is present.

This update makes SessionStore heal existing mappings by walking SessionDB.get_compression_tip() before returning an entry, so platform messages resume the latest continuation.

Validation:

  • uv run --with pytest --with pytest-timeout pytest tests/gateway/test_restart_resume_pending.py::TestGetOrCreateResumePending -q
  • uv run --with ruff ruff check gateway/session.py tests/gateway/test_restart_resume_pending.py
  • git diff --check

@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/tui Terminal UI (ui-tui/ + tui_gateway/) comp/gateway Gateway runner, session dispatch, delivery labels Jun 13, 2026

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review Summary

Verdict: Approved

Feature

  • Desktop app now polls messaging-platform sessions in the background so inbound Telegram/Discord/WeChat traffic appears without manual refresh.
  • CRON poll at 30s interval, messaging poll at 10s, active messaging session at 5s.

Correctness

  • sameCronSignature now compares more fields (_lineage_root_id, source, profile, preview, message_count, last_active) to detect relevant changes without spurious re-renders.
  • gateway/session.py additions support the polling backend.

Code Quality

  • Proper use of useCallback / React patterns for polling cleanup.

No Issues Found

  • No secrets, no debug artifacts.

Reviewed by Hermes Agent

@alt-glitch alt-glitch added comp/desktop Electron desktop app (apps/desktop/*) and removed comp/tui Terminal UI (ui-tui/ + tui_gateway/) labels Jun 26, 2026
@OutThisLife

Copy link
Copy Markdown
Collaborator

Superseded by #57636.

The desktop refactor since this PR was authored extracted refreshMessagingSessions, $messagingSessions, and the related session infrastructure into a separate hook (use-session-list-actions.ts) and sameCronSignature into desktop-controller-utils.ts, so the original diff no longer applies cleanly. The supersede ports all three pieces (messaging list poll, active transcript poll, and gateway compression-tip healing) to current main with the necessary adaptations:

  • refreshMessagingSessions is now exported from useSessionListActions instead of being defined inline in the controller
  • The helpers (sessionMatchesStoredId, sessionMessagesSignature) and poll constants live in desktop-controller.tsx where the effects run
  • sameCronSignature extension lands in desktop-controller-utils.ts where it was already extracted
  • The Python test uses patch.object(store, '_compression_tip_for_session_id', ...) instead of replacing store._db with a bare MagicMock() — required because _is_session_ended_in_db was added to get_or_create_session on main after this PR was authored and a bare mock turns it truthy

Full credit preserved via Co-authored-by trailer. Thanks @lawyer112!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/desktop Electron desktop app (apps/desktop/*) comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants