Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add toggle to disable task list auto-refresh#1489

Open
knightq wants to merge 3 commits into
Shopify:main from
knightq:auto_refresh_disable_option
Open

Add toggle to disable task list auto-refresh #1489
knightq wants to merge 3 commits into
Shopify:main from
knightq:auto_refresh_disable_option

Conversation

@knightq

@knightq knightq commented May 29, 2026
edited
Loading

Copy link
Copy Markdown

Closes #1490

Problem

The Maintenance Tasks web UI auto-refreshes pages every 3 seconds to keep run statuses up to date. This behavior is driven by JavaScript in the application layout: when an element with data-refresh is present and truthy, the page periodically fetches the current URL and replaces the refreshed content in place.

While this is useful when monitoring active runs, it can be disruptive in other situations:

  • Debugging or inspecting the page — the DOM is replaced every few seconds, making it hard to read logs, copy values, or use browser dev tools.
  • Stable UI for screenshots or demos — auto-refresh causes the page to flicker and the cursor to change to a wait state.
  • Reduced background activity — unnecessary polling when the operator does not need live updates.

Two pages are affected:

Page When it auto-refreshes Prior behavior
Task list (TasksController#index) Always @refresh was hard-coded to true
Task show (TasksController#show) While the task has active runs (@task.refresh?) No way to override @task.refresh?

There was no user-facing way to turn auto-refresh off on either page.

Proposed solution

Add a user-facing toggle on the task show page (when the task has active runs) to disable and re-enable auto-refresh. Respect a shared ?refresh=false URL parameter in the controller so the preference applies consistently across both pages.

Behavior

Task show page (primary UI)

The toggle is shown only when the task has active runs (@task.refresh?). When there are no active runs, the page does not auto-refresh and no toggle is displayed.

State URL data-refresh attribute UI control
Default (auto-refresh on) /maintenance_tasks/tasks/:id true (when active runs exist) "Disable auto-refresh" button
Auto-refresh off /maintenance_tasks/tasks/:id?refresh=false absent / empty "Enable auto-refresh" button
  • Auto-refresh remains on by default when active runs are present.
  • Disabling auto-refresh navigates to the same task with ?refresh=false.
  • Re-enabling auto-refresh navigates back to the task path without the query parameter.
  • The toggle is a small button aligned to the top-right, above the runs section.

Task list page

The task list continues to auto-refresh by default and respects ?refresh=false when present, but does not include a toggle control. Users who disable auto-refresh on a task show page can keep refresh=false in the URL when navigating back to the list, or append it manually.

State URL data-refresh attribute UI control
Default (auto-refresh on) /maintenance_tasks/ true (none)
Auto-refresh off /maintenance_tasks/?refresh=false absent / empty (none)

Implementation outline

  1. Controller — Run set_refresh on both index and show, and read the refresh query parameter:

    before_action :set_refresh, only: [:index, :show]
    def set_refresh
     @refresh = params[:refresh] != "false"
    end
  2. Task show view — In app/views/maintenance_tasks/tasks/show.html.erb:

    • Render Disable/Enable toggle links when @task.refresh? is true.
    • Set data-refresh from @task.refresh? && @refresh so both active-run status and the user preference are respected.
  3. Task list view — In app/views/maintenance_tasks/tasks/index.html.erb, continue setting data-refresh from @refresh (no toggle UI).

  4. Tests — Integration tests in test/integration/maintenance_tasks/tasks_controller_test.rb covering:

    • Task show page auto-refreshes by default when there are active runs ([data-refresh=true] present).
    • refresh=false disables auto-refresh on the task show page ([data-refresh=true] absent).
    • Correct toggle link is shown in each state on the task show page.
    • No toggle links when the task has no active runs.
  5. Documentation — Document the toggle and ?refresh=false URL parameter in the README (under "Running a Task from the Web UI").

Mocks

Scope

  • In scope: User toggle on the task show page when active runs exist; controller-level ?refresh=false support on both index and show actions.
  • Out of scope: Toggle UI on the task list page; persisting the preference beyond the current URL (e.g. cookies or local storage).

Acceptance criteria

  • Task show page auto-refreshes by default when there are active runs (no change to current default behavior).
  • Users can disable auto-refresh via a visible control on the task show page (when active runs exist).
  • Disabling auto-refresh persists via the ?refresh=false URL parameter.
  • Users can re-enable auto-refresh from the same page.
  • No toggle is shown when the task has no active runs.
  • Integration tests cover both refresh states, toggle links, and the no-active-runs case.
  • README documents the feature.

The task list polls every 3s via a data-refresh attribute. This adds a UI
toggle that persists the preference with ?refresh=false in the URL.
Co-authored-by: Cursor <cursoragent@cursor.com>
Updated the task page to auto-refresh while there are active runs, ensuring real-time status updates. Added a toggle for enabling/disabling auto-refresh on both the task list and individual task pages, with appropriate links displayed based on the current state. Adjusted tests to verify the new behavior.

@adrianna-chang-shopify adrianna-chang-shopify left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @knightq , thanks for contributing to the gem! This change makes sense to me, I left a few comments.

<% end %>

<%= tag.div(data: { refresh: @task.refresh? || "" }) do %>
<% if @task.refresh? %>

@adrianna-chang-shopify adrianna-chang-shopify Jun 2, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we move this whole block into the refreshed wrapper (<%= tag.div(data: { refresh: (@task.refresh? && @refresh) || "" }) do %>)? Otherwise, when a task finishes, we'll still show the disable / enable button even though @task.refresh? is false, because we won't have refreshed this part of the page.

require "test_helper"

module MaintenanceTasks
class TasksControllerTest < ActionDispatch::IntegrationTest

@adrianna-chang-shopify adrianna-chang-shopify Jun 2, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer we follow the convention of the existing system tests and test the toggle behaviour in test/system/maintenance_tasks/tasks_test.rb.

@task = TaskDataShow.prepare(
params.fetch(:id),
runs_cursor: params[:cursor],
arguments: params.except(:id, :controller, :action).permit!,

@adrianna-chang-shopify adrianna-chang-shopify Jun 2, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should filter out refresh as a param here.


def set_refresh
@refresh = true
@refresh = params[:refresh] != "false"

@adrianna-chang-shopify adrianna-chang-shopify Jun 2, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could name this something more intention revealing now.

Suggested change
@refresh = params[:refresh] != "false"
@auto_refresh_enabled = params[:refresh] != "false"

<% if @task.refresh? %>
<div class="is-flex is-justify-content-flex-end mb-2">
<% if @refresh %>
<%= link_to "Disable auto-refresh", task_path(@task, refresh: false), class: "button is-small" %>

@adrianna-chang-shopify adrianna-chang-shopify Jun 2, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<%= link_to "Disable auto-refresh", task_path(@task, refresh: false), class: "button is-small" %>
<%= link_to "Disable auto-refresh", task_path(@task, refresh: false), class: "button is-small is-light" %>

Nit, to differentiate it from the bg a bit more.

<% if @refresh %>
<%= link_to "Disable auto-refresh", task_path(@task, refresh: false), class: "button is-small" %>
<% else %>
<%= link_to "Enable auto-refresh", task_path(@task), class: "button is-small" %>

@adrianna-chang-shopify adrianna-chang-shopify Jun 2, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<%= link_to "Enable auto-refresh", task_path(@task), class: "button is-small" %>
<%= link_to "Enable auto-refresh", task_path(@task), class: "button is-small is-light" %>

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

Reviewers

@adrianna-chang-shopify adrianna-chang-shopify adrianna-chang-shopify left review comments

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Add the ability to disable auto refresh

AltStyle によって変換されたページ (->オリジナル) /