hermes - 💡(How to fix) Fix cron: fallback to home channel when origin=cli but TUI session is dead

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

def _has_active_tui_session() -> bool: import subprocess try: result = subprocess.run( ["pgrep", "-f", "ui-tui/dist/entry.js"], capture_output=True, timeout=5, ) return result.returncode == 0 except Exception: pass # fallback: ps aux return False

Code Example

def _has_active_tui_session() -> bool:
    import subprocess
    try:
        result = subprocess.run(
            ["pgrep", "-f", "ui-tui/dist/entry.js"],
            capture_output=True, timeout=5,
        )
        return result.returncode == 0
    except Exception:
        pass
    # fallback: ps aux
    return False

---

if deliver_value == "origin" and origin:
    if origin.get("platform") == "cli" and not _has_active_tui_session():
        # fall through to home-channel fallback
        pass
    else:
        return { "platform": ..., "chat_id": ..., "thread_id": ... }
    # home-channel fallback below
RAW_BUFFERClick to expand / collapse

Problem

When a cron job is created from an active TUI session, deliver=origin is resolved to cli platform at create time. If the user then closes the TUI (or the session ends), the cron job's delivery silently fails — the output goes to cli_out/ but nobody reads it.

Users on mobile devices (Termux/Android) are particularly affected: they run the gateway in background, create cron jobs from TUI, then close the TUI. The cron runs fine but delivery is lost.

Proposed Solution

Add a dynamic session-liveness check at delivery time (not create time):

  1. Before resolving deliver=origin to the stored origin platform, check if that platform/session is actually alive.
  2. If origin.platform == "cli" but no active TUI process is detected, fall back to the existing home-channel fallback logic (iterate configured platforms).
  3. If no home channels are configured either, fall back to local-only delivery.

This is consistent with the existing fallback design: deliver=origin already falls back to home channels when origin is missing entirely. Extending it to "origin present but dead" is a natural generalization.

Implementation

A new helper scheduler._has_active_tui_session() that detects running ui-tui/dist/entry.js node processes:

def _has_active_tui_session() -> bool:
    import subprocess
    try:
        result = subprocess.run(
            ["pgrep", "-f", "ui-tui/dist/entry.js"],
            capture_output=True, timeout=5,
        )
        return result.returncode == 0
    except Exception:
        pass
    # fallback: ps aux
    return False

Then in _resolve_single_delivery_target():

if deliver_value == "origin" and origin:
    if origin.get("platform") == "cli" and not _has_active_tui_session():
        # fall through to home-channel fallback
        pass
    else:
        return { "platform": ..., "chat_id": ..., "thread_id": ... }
    # home-channel fallback below

Why this is better

  • Dynamic: detects liveness at fire time, not create time
  • Backward compatible: if TUI is alive, behavior is identical to today
  • No new config: reuses the existing home-channel mechanism
  • Minimal code: < 30 lines for the check

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - 💡(How to fix) Fix cron: fallback to home channel when origin=cli but TUI session is dead