Skip to content

fix(kernel): a conversation with jobs scheduled keeps its process out of view - #1292

Merged
leookun merged 1 commit into
mainfrom
fix/cron-survives
Nov 24, 2026
Merged

leookun merged 1 commit into
mainfrom
fix/cron-survives

Conversation

@leookun

@leookun leookun commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Fixes #994 (and the earlier #514)

Cause. When no view shows a conversation (the user opens another one), ChatSession.detach calls kernel.release(), which tears down an idle CLI process to save resources. Session-scoped CronCreate jobs and a pending ScheduleWakeup live only in that process, so they never fired. Opening the conversation again restarted the CLI, which is why #514 saw tasks fire "only after re-entering".

Fix. A small ScheduledJobs tracker watches the main agent's CronCreate / CronDelete / ScheduleWakeup calls and their successful results. release() keeps the process while anything is pending: a job until it is deleted, a wakeup until the CLI takes up a prompt of its own or the loop is stopped. Once nothing is pending, the next idle release goes through as before.

Not covered: changing the model restarts the CLI, which still drops session-only jobs. Durable jobs (.claude/scheduled_tasks.json) are picked up again on restart.

Tests: test/kernel_test.dart (a new case next to the background-task release test).

🤖 Generated with BaoCode

… of view

A conversation no view showed (another one opened) let go of its idle
Claude Code process, and with it the jobs the session had scheduled
(CronCreate) and a loop's next round (ScheduleWakeup): they live in the
process, and did not come at their time. The process is now kept while
any is to come: jobs until deleted, a loop's round until it comes or is
stopped.

Fixes #994

Co-Authored-By: BaoCode <noreply@baocode.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] 会话内设置的 Cron 定时任务经常到点不执行

2 participants