← Back to PRs

#5977: fix(ui): handle optional agentId and add updateCronJob function

by xpnobug open 2026-02-01 05:06 View on GitHub →
app: web-ui
- Use nullish coalescing operator to handle undefined/null agentId before calling .trim() to prevent runtime errors in addCronJob - Add updateCronJob function to support editing existing cron jobs via cron.update RPC endpoint <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR hardens `addCronJob` against `agentId` being `null`/`undefined` by defaulting to an empty string before trimming, and adds a new `updateCronJob` controller helper that calls the `cron.update` RPC and refreshes cron jobs/status afterward. These changes live in the UI cron controller (`ui/src/ui/controllers/cron.ts`) and mirror the existing add/toggle/run/remove patterns by building schedule/payload from `cronForm` and using the gateway client RPC methods. <h3>Confidence Score: 4/5</h3> - This PR is generally safe to merge; the changes are localized and straightforward. - `addCronJob` nullish-coalescing is a clear runtime safety fix. The new `updateCronJob` mirrors existing RPC usage, but there’s some functional ambiguity around whether blank/omitted fields should clear or preserve existing values (notably `agentId`), which could lead to unintended overwrites depending on how the UI invokes it. - ui/src/ui/controllers/cron.ts <!-- greptile_other_comments_section --> <sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub> **Context used:** - Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8)) - Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13)) <!-- /greptile_comment -->

Most Similar PRs