#5977: fix(ui): handle optional agentId and add updateCronJob function
app: web-ui
Cluster:
Cron Job UI Enhancements
- 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
#6408: feat(ui): add job filtering and improve run history display
by Cassius0924 · 2026-02-01
85.7%
#9088: fix(cron): ensure nextRunAtMs is computed when enabled is undefined...
by divol89 · 2026-02-04
81.4%
#22627: control-ui: agent runner queue view
by vctorabrdge · 2026-02-21
80.9%
#7024: feat(ui/cron): add silent job indicator and no-runs hints
by sergi039 · 2026-02-02
78.8%
#13592: feat(ui): group cron jobs by name folders
by turanalemfilms-cloud · 2026-02-10
78.4%
#9510: Feature/cron UI filter bar
by guxu11 · 2026-02-05
78.3%
#8698: fix(cron): default enabled to true for new jobs
by emmick4 · 2026-02-04
78.2%
#3335: Fixes cron jobs
by hkirat · 2026-01-28
78.1%
#2071: fix: accept JSON string for cron.add job parameter (#1940)
by andrescardonas7 · 2026-01-26
77.5%
#11813: fix(cron): ensure 'at' schedule type correctly registers nextWakeAt...
by leo-reifying · 2026-02-08
77.2%