Skip to content

[Bug]: Toggling a scheduled task shuffles task list and swaps rows under cursor #16390

Closed

Description

@Mchicao

Area

apps/server

Steps to reproduce

  1. Create at least two scheduled tasks in Settings -> Scheduled tasks (or have multiple automations attached to a thread).
  2. In the scheduled tasks list, toggle the enabled switch on the second task.
  3. Observe how the rows immediately swap positions.

Expected behavior

Toggling a task should update its enabled state in place without changing the visual order of tasks in the list.

Actual behavior

ScheduledTaskService.selectAllRows orders tasks with ORDER BY updated_at DESC, task_id ASC.
When a task's enabled switch is toggled (or when a task runs), its updated_at timestamp is updated to the current time. This instantly promotes the updated task to the top of the list via the live subscription (subscribeList), causing the rows to swap positions immediately under the cursor.
Visually, the toggle switch that moved belongs to the task that was just toggled, but because it jumped to the other row's position, it appears as though toggling one task activates or deactivates another task. Clicking again then toggles the other task that shifted under the mouse.

Proposed fix

Sort scheduled_tasks by created_at ASC, task_id ASC in ScheduledTaskService.selectAllRows so that task ordering remains stable across status updates, runs, and toggles.

Activity

  1. juliusmarminge commented on Oct 6, 2026

    @juliusmarminge
    Member

    Note

    Grok responding on behalf of Julius.

    Triage

    Thanks @Mchicao for the precise report and for already pinpointing the query. This reproduces on current main, and I see you've opened #16392 for it too.

    What I found

    • ScheduledTaskService.selectAllRows orders by updated_at DESC, task_id ASC. setEnabled stamps updated_at to now and calls notifyChanged, and subscribeList re-emits list() on that signal.
    • The same stamp happens when a run starts or finishes (markRunning / markCompleted), on a missed-run reschedule, and on save, so rows can also jump while a task runs.
    • Web settings (ScheduledTasksSettings), the thread Automations section, mobile settings and list_scheduled_tasks all render this array order as-is. Rows are keyed by task id, so the switch that moves is the one that was toggled, and the next click lands on whatever row slid under the pointer.
    • listDueTasks is a separate query (ORDER BY next_run_at ASC, task_id ASC), so changing the list sort wouldn't affect scheduler order.

    Likely fix area

    A maintainer will decide on the fix direction.

  2. added
    bugSomething is broken or behaving incorrectly.
    via-triageFiled through npx t3 triage
    on Oct 6, 2026
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

    bugSomething is broken or behaving incorrectly.via-triageFiled through npx t3 triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions