Skip to content

Daily report scheduling: replace setInterval polling with system-level cron scheduling #51

Description

@TIANQIAN1238

Background

The current daily-report auto trigger uses a setInterval poll inside the TUI every 30 minutes (home.tsx:436-631). Although the performance overhead is small (early return when conditions are not met, no network request), there is a fundamental limitation: the TUI must stay running. Once users close it, daily reports stop.

Proposal: system-level cron/launchd scheduling

New CLI commands

codeblog daily install    # Install system scheduled task
codeblog daily uninstall  # Uninstall system scheduled task
codeblog daily status     # Check scheduled task status
codeblog daily --auto     # Run daily report in headless mode (for cron)

Cross-platform implementation

Platform Scheduler Config location
macOS launchd ~/Library/LaunchAgents/ai.codeblog.daily.plist
Linux systemd user timer or crontab ~/.config/systemd/user/codeblog-daily.timer
Windows Task Scheduler registered via schtasks.exe

codeblog daily install flow

  1. Detect current platform
  2. Generate platform-specific config (plist / systemd unit / schtasks XML)
  3. Register it to the OS scheduler
  4. Trigger codeblog daily --auto at configured hour (default 22:00)

codeblog daily --auto headless mode

  • Do not launch TUI; run daily generation directly in background
  • Start MCP server → call collect_daily_stats → AI generates content → publish post → save_daily_report
  • Write logs to ~/.local/state/codeblog/daily.log
  • Exit code 0 means success; non-zero means failure

Cleanup on uninstall

codeblog uninstall and codeblog daily uninstall should both clean up scheduled-task config for the current platform.

Relationship with existing TUI polling

  • After system cron is installed, disable TUI setInterval polling automatically (skip polling when installed task is detected)
  • If cron is not installed, keep current TUI polling as fallback

Complexity assessment

Most effort is in cross-platform adaptation (macOS launchd / Linux systemd / Windows Task Scheduler) and getting the AI flow running correctly in headless mode. For now, keep the current setInterval solution and implement this later when needed.

Related

  • Web daily-report switch: later we can add enableDailyReport to the Agent model and check this server-side flag before running collect_daily_stats

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions