Skip to content

[bug] After a one-shot (定时一次) task fires, its edit form can never be saved: mode stays "scheduled" with no runAt #95

Closed

Description

@timacek

What happens

A 定时一次 (one-shot scheduled) card becomes impossible to edit after the run fires (or after
its missed window is consumed).

Once the one-shot is consumed, the ledger keeps execution.mode: 'scheduled' but removes the
trigger and the next run:

  • src/host/scheduler.ts:260-261 (queueRunAt) deletes runAt and sets nextRunAt = undefined
    before dispatch;
  • src/host/scheduler.ts:368-369 (consumeRunAt) does the same for a missed window;
  • settlement only re-normalizes the config for cron cards
    (src/host/execution.ts:1025-1030, t.execution = { mode: 'claim' }), not for one-shots.

The untouched mode: 'scheduled' then makes the edit form unusable:

  • src/client/board/TaskFormModal.tsx:188 infers the form mode from cron only:
    scheduled ? (cron !== undefined ? 'periodic' : 'once') : 'claim';
  • :206 seeds runAt only when execution.runAt !== undefined, so the datetime field is empty;
  • :297-298 sets runAtBad = mode === 'once' && (runAt === '' || runAtMs <= Date.now()), and
    valid depends on it;
  • :781 disables the primary button (disabled={!valid || busy || imageUploading}).

Result: opening Edit on such a card shows a one-shot form with an empty trigger time, a
"pick a future trigger time" hint, and a permanently disabled Save / Create and run. There
is no way to fix a typo, change the project/prompt/checklist, or tick anything without inventing a
new future time (silently re-scheduling a finished card) or manually switching it to 认领, which
loses the one-shot intent.

Secondary visual symptom: the card badge and detail chip still render as scheduled with empty data —
src/client/board/TaskCard.tsx:213-214 prints ⏰ — and
src/client/board/TaskDetail.tsx:762-763 prints ⏰ · next with empty cron/time.

I reproduced the disabled form in a jsdom render of TaskFormModal with
execution: { mode: 'scheduled', lastTriggeredAt: 5 }: the datetime input exists, the primary
button reads Save, and it is disabled.

How to reproduce (GUI)

  1. Create a task with execution mode 定时一次 and a trigger a minute ahead.
  2. Let it fire and settle (card lands in 待验收 or returns to 待办 after a failure).
  3. Open the card → Edit.
  4. The datetime field is empty and Save is disabled; filling in a new time re-arms the schedule
    instead of just saving the edit.

Environment

  • dsh-taskboard 0.9.9 / dev @ 140e763 (originally reproduced on 0.9.6 @ 3054eba)
  • DSH 0.2.1-rc.2, Windows 11, Node 26.13.0

Suggested fix

Either normalize the consumed one-shot in the host (the cleanest place: once the run has started /
settled, a spent one-shot is effectively a claim task — the cron path already does exactly this
at execution.ts:1025-1030), or make the client defensive:

  • infer claim when execution.mode === 'scheduled' && cron === undefined && runAt === undefined
    (TaskFormModal.tsx:188, and the same guard for the runAt seed at :206);
  • hide the ⏰ badge/chip when there is neither cron, nextRunAt nor queuedRunAt
    (TaskCard.tsx:213, TaskDetail.tsx:762).

A small regression test can mount the form with a consumed one-shot and assert the primary button
is enabled and submits mode: 'claim'.

Dedupe

Nearest issues are #26/#41/#49 (scheduled session reuse) and #28 (cron permission/terminal
states). None covers editing a consumed one-shot; no open PR touches the mode inference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions