Skip to content

fix(desktop): deliver cron results to source session - #68468

Draft
Th0rgal wants to merge 4 commits into
NousResearch:mainfrom
Th0rgal:agent/desktop-cron-session-origin
Draft

fix(desktop): deliver cron results to source session#68468
Th0rgal wants to merge 4 commits into
NousResearch:mainfrom
Th0rgal:agent/desktop-cron-session-origin

Conversation

@Th0rgal

@Th0rgal Th0rgal commented Jul 21, 2026

Copy link
Copy Markdown

What does this PR do?

Routes unattended cron results back to the durable Desktop/WebUI conversation that created the job instead of falling through to the configured messaging home channel. Desktop now captures its stored session key as the local delivery origin while keeping the ephemeral UI window id separate. Local delivery follows compression continuations, rejects cross-surface session ids, merges observed cron messages into live gateway history, and polls the selected stored transcript so the open Desktop window sees the result.

This preserves and credits Enhe’s two commits from #60923, then generalizes the WebUI session-store delivery path to Desktop.

Related issues

Type of change

  • Bug fix
  • Tests

Validation

  • pytest tests/cron/test_scheduler.py -q — 237 passed
  • pytest tests/test_tui_gateway_server.py -q — 384 passed
  • Desktop TypeScript typecheck
  • Desktop background-sync Vitest — 3 passed
  • ruff check on changed Python files
  • git diff --check

Tested on macOS arm64.

@alt-glitch alt-glitch added type/feature New feature or request P2 Medium — degraded but workaround exists comp/desktop Electron desktop app (apps/desktop/*) comp/cron Cron scheduler and job management comp/tui Terminal UI (ui-tui/ + tui_gateway/) sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages labels Jul 21, 2026

@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 preserving the focused SessionDB delivery approach from #60923. The underlying Desktop/WebUI cron-origin problem still exists on current main: tools/cronjob_tools.py:285-308 requires platform/chat context that tui_gateway/server.py:2825-2830 does not bind for local sessions, and cron/scheduler.py:1132-1138 / 1537-1575 still routes such origins through gateway Platform(...) dispatch.

Problems

  • tui_gateway/server.py:2325 sets session_id=session_key unconditionally. Current main intentionally prefers agent.session_id in tui_gateway/server.py:2807-2829 and re-anchors the durable key after compression in tui_gateway/server.py:4367-4445. Preserve that newer identity handling when adding the local delivery origin.

Suggested changes

  • Salvage the local-session routing and observed-message delivery, but layer Desktop/WebUI platform/chat fields onto current _set_session_context without replacing its session-id selection.
  • Adapt the Desktop hydration work to current sessions.changed synchronization (tui_gateway/server.py:3060-3123) rather than restoring the older polling-only assumptions.

Automated hermes-sweeper review.

Comment thread tui_gateway/server.py
return set_session_vars(
platform=source if local_session_origin else "",
session_key=session_key,
session_id=session_key,

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.

Current main deliberately prefers agent.session_id here when present (tui_gateway/server.py:2807-2829) and later re-anchors session_key after compression. Please retain that identity derivation while adding the Desktop/WebUI origin fields; unconditionally using session_key would regress the current compression-safe path.

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/cron Cron scheduler and job management comp/desktop Electron desktop app (apps/desktop/*) comp/tui Terminal UI (ui-tui/ + tui_gateway/) P2 Medium — degraded but workaround exists 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 sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants