Skip to content

Extract shared JobScheduleField and JobAgentTypeField - #880

Merged
selfcontained merged 1 commit into
mainfrom
tech-debt/job-schedule-field
Aug 5, 2026
Merged

Extract shared JobScheduleField and JobAgentTypeField#880
selfcontained merged 1 commit into
mainfrom
tech-debt/job-schedule-field

Conversation

@selfcontained

Copy link
Copy Markdown
Owner

What

Extracts two duplicated form-field blocks from jobs-add-dialog.tsx and jobs-settings-tab.tsx into jobs-form-fields.tsx (which already hosts the other shared job form fields):

  • JobScheduleField — cron input + validation error + humanSchedule preview + "Leave blank for an on-demand job." helper + the Enabled switch. The two copies differed only in the input id and the switch helper copy (now a enabledHelperText prop).
  • JobAgentTypeField — the enabledAgentTypes.filter(isCliAgentType) shadcn Select. Identical in both files.

Net -14 lines, and the two forms can no longer drift.

Why it's tech debt

Top item on the tech-debt backlog (2026-07-21 audit): ~55 lines duplicated between the two job forms. Any copy fix or behavior tweak had to be made twice.

Decision: not AgentTypeSelect

The backlog suggested checking whether these Select blocks could reuse the shared AgentTypeSelect (PR #871). They can't without a behavior change: AgentTypeSelect is a cmdk Command combobox typed to AgentType with sortAgentTypes ordering, while the job forms use the shadcn Select primitive constrained to CliAgentType. Swapping widgets would change UX and typing; this PR is housekeeping only, so the extraction keeps the existing shadcn Select. Only rendered delta: the settings-tab wrappers gain min-w-0 (no visual change; both parents are grids).

Validation

  • pnpm run check, pnpm run finalize:web green
  • E2E: 175 passed
  • Live Playwright on a dev stack: add-job dialog + settings tab — cron preview, invalid-cron error, Enabled toggle, agent-type select options (screenshots shared via dispatch_share)

Queued next

Next backlog item: extract <MessageThreadAccordion> (agent-history-detail.tsx vs messages-panel.tsx, ~35 duplicated lines).

🤖 Generated with Claude Code

The cron schedule block (input + validation error + humanSchedule preview +
on-demand helper + Enabled switch) and the agent-type Select block were
duplicated ~55 lines between jobs-add-dialog.tsx and jobs-settings-tab.tsx,
differing only in input id and switch helper copy. Both now live in
jobs-form-fields.tsx alongside the other shared job form fields.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@selfcontained
selfcontained merged commit f640c3b into mainAug 5, 2026
1 check passed
@selfcontained
selfcontained deleted the tech-debt/job-schedule-field branch August 5, 2026 09:11
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@selfcontained