Skip to content

fix(web): recompute cron next_fire_at when re-enabling routines#1080

Merged
zmanian merged 3 commits intonearai:stagingfrom
G7CNF:codex/issue-1077-web-cron-reenable
Mar 12, 2026
Merged

fix(web): recompute cron next_fire_at when re-enabling routines#1080
zmanian merged 3 commits intonearai:stagingfrom
G7CNF:codex/issue-1077-web-cron-reenable

Conversation

@G7CNF
Copy link
Copy Markdown
Contributor

@G7CNF G7CNF commented Mar 12, 2026

Summary

  • recompute next_fire_at when a cron routine is re-enabled via web toggle endpoint
  • mirror this behavior in both current web routing implementations (server.rs and handlers/routines.rs) to keep behavior consistent
  • add integration regression coverage that exercises /api/routines/{id}/toggle and verifies next_fire_at is repopulated

Why

Re-enabling a disabled cron routine through the web API updated enabled but left next_fire_at untouched. If next_fire_at was null/stale, the cron poller would never pick it up despite the routine showing as enabled.

Closes #1077

@github-actions github-actions bot added scope: channel/web Web gateway channel size: M 50-199 changed lines risk: medium Business logic, config, or moderate-risk modules labels Mar 12, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves an issue where re-enabling a disabled cron routine through the web API would not correctly update its next_fire_at field. This oversight could lead to cron routines remaining inactive despite being marked as enabled. The changes ensure that when a cron routine is re-enabled, its next_fire_at is properly recalculated, guaranteeing that the cron poller can correctly schedule and execute the routine.

Highlights

  • Cron next_fire_at Recomputation: When a cron routine is re-enabled via the web toggle endpoint, its next_fire_at timestamp is now recomputed.
  • Consistent Web API Behavior: This recomputation logic has been applied consistently across both server.rs and handlers/routines.rs to ensure uniform behavior.
  • Integration Test Coverage: A new integration test was added to specifically cover the /api/routines/{id}/toggle endpoint, verifying that next_fire_at is correctly repopulated upon re-enabling a cron routine.
Changelog
  • src/channels/web/handlers/routines.rs
    • Imported Trigger and next_cron_fire for cron schedule calculations.
    • Implemented logic to recompute routine.next_fire_at if a cron routine is re-enabled and was_enabled was false.
  • src/channels/web/server.rs
    • Imported Trigger and next_cron_fire for cron schedule calculations.
    • Implemented logic to recompute routine.next_fire_at if a cron routine is re-enabled and was_enabled was false, mirroring the change in handlers/routines.rs.
  • tests/gateway_workflow_integration.rs
    • Imported Uuid for use in the new test.
    • Added a new #[tokio::test] named routines_toggle_reenable_cron_recomputes_next_fire_at to verify the fix. This test creates a cron routine, disables it, manually sets next_fire_at to None, re-enables it via the API, and asserts that next_fire_at is no longer None.
Activity
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions github-actions bot added the contributor: regular 2-5 merged PRs label Mar 12, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request effectively addresses a bug where re-enabling a cron routine failed to recompute its next_fire_at time, which could prevent it from running. The fix is correctly implemented by recalculating the fire time when a cron routine transitions from disabled to enabled. This logic has been mirrored in two separate handler implementations for consistency, and a solid integration test has been added to cover this specific regression case.

Copy link
Copy Markdown
Collaborator

@zmanian zmanian left a comment

Choose a reason for hiding this comment

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

Correct fix for #1077. Recomputes next_fire_at via next_cron_fire() when transitioning from disabled to enabled. Applied to both toggle handlers. Integration test covers the full round-trip. LGTM.

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

Labels

contributor: regular 2-5 merged PRs risk: medium Business logic, config, or moderate-risk modules scope: channel/web Web gateway channel size: M 50-199 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

web routine toggle does not recompute next_fire_at when re-enabling cron routines

2 participants