Skip to content

fix(desktop): gate messaging session polling - #58332

Open
izumi0uu wants to merge 1 commit into
NousResearch:mainfrom
izumi0uu:fix/desktop-messaging-poll-58309
Open

fix(desktop): gate messaging session polling#58332
izumi0uu wants to merge 1 commit into
NousResearch:mainfrom
izumi0uu:fix/desktop-messaging-poll-58309

Conversation

@izumi0uu

@izumi0uu izumi0uu commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Gates the desktop's broad messaging-session polling so it only runs when there is evidence that messaging needs live updates: the Messaging view is open, the active stored session is a messaging thread, messaging rows are already loaded, or the existing /api/status snapshot reports a configured gateway platform.

This keeps inbound Telegram/WeChat/Discord sessions live for configured messaging users while avoiding the always-on 10s cross-profile session scan for desktop users who are not using messaging.

Related Issue

Fixes #58309

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

  • Added shouldPollMessagingSessions in apps/desktop/src/app/desktop-controller-utils.ts.
  • Used that helper in apps/desktop/src/app/desktop-controller.tsx before arming the 10s messaging-session interval.
  • Added focused Vitest coverage for the idle false case and the preserved live-update gates.

How to Test

  1. npm --workspace apps/desktop run test:ui -- src/app/desktop-controller-utils.test.ts
  2. npm --workspace apps/desktop exec eslint -- src/app/desktop-controller-utils.ts src/app/desktop-controller-utils.test.ts src/app/desktop-controller.tsx
  3. git diff --check

Note: npm --workspace apps/desktop run typecheck currently fails before this patch in this lane because workspace dependencies such as @codemirror/*, @xterm/addon-serialize, and fflate are not resolvable.

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 (desktop TS/Vitest checks)

Documentation & Housekeeping

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

Screenshots / Logs

Targeted validation:

npm --workspace apps/desktop run test:ui -- src/app/desktop-controller-utils.test.ts
Test Files  1 passed (1)
Tests  9 passed (9)
npm --workspace apps/desktop exec eslint -- src/app/desktop-controller-utils.ts src/app/desktop-controller-utils.test.ts src/app/desktop-controller.tsx
# no output / exit 0

Avoid arming the desktop's broad messaging session poll when there is no messaging view, active messaging thread, cached messaging row, or configured gateway platform reported by the existing status snapshot.

Constraint: Preserve live messaging updates for users who open messaging, already have messaging sessions, or run configured gateway platforms.

Rejected: Removing the messaging poll entirely | would regress inbound platform conversations that are written outside the desktop websocket.

Confidence: high

Scope-risk: narrow

Directive: Keep future desktop background polls gated by existing local state or already-running status probes before adding new recurring backend calls.

Tested: npm --workspace apps/desktop run test:ui -- src/app/desktop-controller-utils.test.ts; npm --workspace apps/desktop exec eslint -- src/app/desktop-controller-utils.ts src/app/desktop-controller-utils.test.ts src/app/desktop-controller.tsx; git diff --check

Not-tested: npm --workspace apps/desktop run typecheck currently fails before this patch on missing workspace dependencies (@codemirror/*, @xterm/addon-serialize, fflate).
@alt-glitch alt-glitch added type/bug Something isn't working comp/desktop Electron desktop app (apps/desktop/*) P3 Low — cosmetic, nice to have labels Jul 4, 2026
@teknium1 teknium1 added sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform area/sessions Session lifecycle, resume, persistence, history labels Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/sessions Session lifecycle, resume, persistence, history comp/desktop Electron desktop app (apps/desktop/*) P3 Low — cosmetic, nice to have sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Desktop GUI polling spawns new CLI process every 10 seconds, causing repeated plugin discovery

3 participants