Repository navigation
fix(coding-agent): record a cron task's status reason when it is created - #355
Merged
Merged
Conversation
`CronCreateOptions` declares `statusReason`, and the persisted-record reader validates it, but `create()` never wrote it. Only `update()` did. A host that imports a task whose bound session no longer exists creates it already paused, with `statusReason: "session_missing"`, so the reason was dropped on the one path that needed it. The task still showed as paused, which is why the symptom was a missing explanation rather than a wrong status; the type promised a field the write did not store. The new test creates such a task, reloads the store, and asserts both the status and the reason survive.
liuedcson
requested review from
MelodyVAR,
Uking-xxx and
ZouR-Ma
as code owners
November 10, 2026 04:05
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
CronCreateOptionsdeclaresstatusReason, andparsePersistedJobvalidates thefield when a record is loaded:
create()did not write it. Onlyupdate()did. The type therefore promised afield that the create path silently dropped.
Found while verifying the merged desktop scheduled-task feature. Its migration
imports a task whose bound session is already gone as
{ status: "paused", statusReason: "session_missing" }, so the import relied on acreate-with-reason that did not persist it. The task still appeared paused, which
is why the symptom was a missing explanation rather than a wrong status — the
import path happens to write the store directly today, so nothing was visibly
broken, but any host using the documented option lost the field.
Fix
packages/coding-agent/src/features/step-cron.ts— writestatusReasonincreate()besidestatus:The guard mirrors
status: an absent reason adds no field, and the record readerstill rejects any value other than
session_missing.Verification
pnpm exec vitest --run test/step-cron.test.ts: 60 passed (one new test).behaviour rather than restating the implementation: it creates a task with
status: "paused"andstatusReason: "session_missing", reloads the store, andasserts both fields survive.
tsgo -p tsconfig.json --noEmit: clean.check --error-on-warningsand the pre-commit guard set: pass.Boundary
One field on one write path. No schema change, no migration, and no change to
update()or the reader.