The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(settings): restore missing cron job list entries
Steven Enamakel77e2e7e7401d
diff --git a/app/src/components/settings/panels/cron/CoreJobList.tsx b/app/src/components/settings/panels/cron/CoreJobList.tsxindex cdcf3e166c..a595a50a7f 100644--- a/app/src/components/settings/panels/cron/CoreJobList.tsx+++ b/app/src/components/settings/panels/cron/CoreJobList.tsx@@ -1,7 +1,13 @@+import { History, Pause, Pencil, Play, Trash2, Zap } from 'lucide-react';+import { Fragment, type ReactNode, useMemo, useState } from 'react';+import { useT } from '../../../../lib/i18n/I18nContext';import type { CoreCronJob, CoreCronRun } from '../../../../utils/tauriCommands';-import Badge from '../../../ui/Badge';+import Badge, { type BadgeVariant } from '../../../ui/Badge';import Button from '../../../ui/Button';+import DataTable, { type DataTableColumn } from '../../../ui/DataTable';+import EmptyState from '../../../ui/EmptyState';+import { TableCell, TableRow } from '../../../ui/Table';interface CoreJobListProps {loading: boolean;@@ -14,8 +20,43 @@ interface CoreJobListProps {onRemoveCoreJob: (jobId: string) => void;/** Optional: when provided, an Edit button is rendered per row. */onEditCoreJob?: (job: CoreCronJob) => void;+ /** Card title / description / header actions (New job, Refresh). */+ title?: ReactNode;+ description?: ReactNode;+ actions?: ReactNode;+ /** Rendered above the rows (load / action failures). */+ error?: ReactNode;+}++/** Map a free-form core status ("ok", "error", "failed", …) to a chip tone. */+function statusVariant(status: string): BadgeVariant {+ const s = status.toLowerCase();+ if (/(ok|success|succeeded|completed|done)/.test(s)) return 'success';+ if (/(err|fail|timeout|panic)/.test(s)) return 'danger';+ if (/(skip|cancel|warn)/.test(s)) return 'warning';+ return 'neutral';}+/** Date over time, in the user's locale; raw value when unparseable. */+const DateTimeCell = ({ value }: { value: string }) => {+ const ts = Date.parse(value);+ if (Number.isNaN(ts)) return <span className="text-content-muted">{value}</span>;+ const date = new Date(ts);+ return (+ <span className="flex flex-col leading-tight" title={date.toLocaleString()}>+ <span className="text-content">{date.toLocaleDateString()}</span>+ <span className="text-xs text-content-muted">{date.toLocaleTimeString()}</span>+ </span>+ );+};++const STATUS_FILTER_VALUES = ['enabled', 'paused'] as const;++/**+ * The scheduled-jobs table: one row per core cron job with its schedule, next+ * run, last status and row actions. "Runs" loads the job's recent history into+ * a full-width sub-row under it.+ */const CoreJobList = ({loading,coreJobs,@@ -26,181 +67,272 @@ const CoreJobList = ({onLoadCoreRuns,onRemoveCoreJob,onEditCoreJob,+ title,+ description,+ actions,+ error,}: CoreJobListProps) => {const { t } = useT();+ const [query, setQuery] = useState('');+ const [selectedStatus, setSelectedStatus] = useState<ReadonlySet<string>>(new Set());++ const scheduleText = (job: CoreCronJob) =>+ job.schedule.kind === 'cron'+ ? job.schedule.expr+ : job.schedule.kind === 'every'+ ? t('settings.cron.jobs.scheduleEvery').replace('{ms}', String(job.schedule.every_ms))+ : t('settings.cron.jobs.scheduleAt').replace('{time}', job.schedule.at);- const toggleButtonLabel = (job: CoreCronJob) => {- if (coreBusyKey === `core-toggle:${job.id}`) {- return t('settings.cron.jobs.saving');- }- return job.enabled ? t('settings.cron.jobs.pause') : t('settings.cron.jobs.resume');- };+ const filteredJobs = useMemo(() => {+ const needle = query.trim().toLowerCase();+ return coreJobs.filter(job => {+ if (selectedStatus.size > 0 && !selectedStatus.has(job.enabled ? 'enabled' : 'paused')) {+ return false;+ }+ if (!needle) return true;+ return [job.name ?? '', job.id, job.command ?? '', job.prompt ?? ''].some(value =>+ value.toLowerCase().includes(needle)+ );+ });+ }, [coreJobs, query, selectedStatus]);- const runButtonLabel = (jobId: string) =>+ const toggleLabel = (job: CoreCronJob) =>+ coreBusyKey === `core-toggle:${job.id}`+ ? t('settings.cron.jobs.saving')+ : job.enabled+ ? t('settings.cron.jobs.pause')+ : t('settings.cron.jobs.resume');+ const runLabel = (jobId: string) =>coreBusyKey === `core-run:${jobId}`? t('settings.cron.jobs.runningNow'): t('subconscious.runNow');-- const viewRunsButtonLabel = (jobId: string) =>+ const runsLabel = (jobId: string) =>coreBusyKey === `core-runs:${jobId}`? t('settings.cron.jobs.loadingRuns'): t('settings.cron.jobs.viewRuns');-- const removeButtonLabel = (jobId: string) =>+ const removeLabel = (jobId: string) =>coreBusyKey === `core-remove:${jobId}` ? t('settings.cron.jobs.removing') : t('common.remove');- return (- // A plain divided list, not a card: the only host (`CronJobsPanel`) already- // renders this inside a titled `SettingsSection`, so the frame and heading- // this used to draw were a titled card nested in a titled card. The rows- // are `py-3` because that host's `px-4` supplies the horizontal gutter —- // a `p-4` here would inset them 32px, past the buttons above them.- <div className="divide-y divide-line-subtle">- {loading && (- <div className="py-3 text-sm text-content-faint">{t('settings.cron.jobs.loading')}</div>- )}-- {!loading && coreJobs.length === 0 && (- <div className="py-3 text-sm text-content-faint">{t('settings.cron.jobs.empty')}</div>- )}-- {!loading &&- coreJobs.map(job => {- const runs = coreRunsByJob[job.id] ?? [];- return (- <div key={job.id} data-testid={`cron-job-row-${job.id}`} className="space-y-3 py-3">- <div className="flex items-start justify-between gap-3">- <div>- <div className="text-sm font-semibold text-content">{job.name || job.id}</div>- <div className="text-[11px] text-content-faint">{job.id}</div>- </div>- <Badge variant={job.enabled ? 'success' : 'neutral'}>- {job.enabled ? t('common.enabled') : t('settings.cron.jobs.paused')}- </Badge>- </div>+ /** Compact icon button; the (busy-aware) label rides aria-label + tooltip. */+ const iconAction = (+ label: string,+ icon: ReactNode,+ onClick: () => void,+ testId: string,+ opts: { disabled?: boolean; danger?: boolean } = {}+ ) => (+ <Button+ type="button"+ variant="tertiary"+ tone={opts.danger ? 'danger' : undefined}+ size="sm"+ aria-label={label}+ title={label}+ data-testid={testId}+ disabled={opts.disabled}+ onClick={event => {+ event.stopPropagation();+ onClick();+ }}+ className="h-8 w-8 px-0">+ {icon}+ </Button>+ );- <div className="text-xs text-content-secondary space-y-1">- <div>- {t('settings.cron.jobs.schedule')}{' '}- <span className="font-medium text-content-secondary">- {job.schedule.kind === 'cron'- ? job.schedule.expr- : job.schedule.kind === 'every'- ? t('settings.cron.jobs.scheduleEvery').replace(- '{ms}',- String(job.schedule.every_ms)- )- : t('settings.cron.jobs.scheduleAt').replace('{time}', job.schedule.at)}- </span>- </div>- <div>- {t('settings.cron.jobs.nextRun')}{' '}- <span className="font-medium text-content-secondary">- {new Date(job.next_run).toLocaleString()}- </span>- </div>- {job.last_status && (- <div>- {t('settings.cron.jobs.lastStatus')}{' '}- <span className="font-medium text-content-secondary">{job.last_status}</span>- </div>- )}- </div>+ const columns: DataTableColumn<CoreCronJob>[] = [+ {+ id: 'job',+ header: t('settings.cron.jobs.columnJob'),+ className: 'w-full max-w-0',+ cell: job => (+ <div className="min-w-0">+ <p className="truncate font-medium text-content" title={job.name || job.id}>+ {job.name || job.id}+ </p>+ <p className="truncate font-mono text-[11px] text-content-faint" title={job.id}>+ {job.id}+ </p>+ </div>+ ),+ },+ {+ id: 'schedule',+ header: t('settings.cron.jobs.schedule'),+ className: 'w-px whitespace-nowrap',+ cell: job => <span className="font-mono text-xs text-content">{scheduleText(job)}</span>,+ },+ {+ id: 'next',+ header: t('settings.cron.jobs.nextRun'),+ className: 'w-px whitespace-nowrap tabular-nums',+ cell: job => <DateTimeCell value={job.next_run} />,+ },+ {+ id: 'last',+ header: t('settings.cron.jobs.lastStatus'),+ className: 'w-px whitespace-nowrap',+ cell: job =>+ job.last_status ? (+ <Badge variant={statusVariant(job.last_status)}>{job.last_status}</Badge>+ ) : (+ <span className="text-content-faint">—</span>+ ),+ },+ {+ id: 'state',+ header: t('settings.cron.jobs.columnState'),+ className: 'w-px whitespace-nowrap',+ cell: job => (+ <Badge variant={job.enabled ? 'success' : 'neutral'}>+ {job.enabled ? t('common.enabled') : t('settings.cron.jobs.paused')}+ </Badge>+ ),+ },+ {+ id: 'actions',+ header: <span className="sr-only">{t('settings.cron.jobs.columnActions')}</span>,+ align: 'right',+ className: 'w-px whitespace-nowrap',+ cell: job => (+ <div className="flex items-center justify-end gap-0.5">+ {iconAction(+ toggleLabel(job),+ job.enabled ? (+ <Pause className="h-4 w-4" aria-hidden />+ ) : (+ <Play className="h-4 w-4" aria-hidden />+ ),+ () => onToggleCoreJob(job),+ `cron-job-toggle-${job.id}`,+ { disabled: coreBusyKey === `core-toggle:${job.id}` }+ )}+ {iconAction(+ runLabel(job.id),+ <Zap className="h-4 w-4" aria-hidden />,+ () => onRunCoreJob(job.id),+ `cron-job-run-${job.id}`,+ { disabled: coreBusyKey === `core-run:${job.id}` }+ )}+ {iconAction(+ runsLabel(job.id),+ <History className="h-4 w-4" aria-hidden />,+ () => onLoadCoreRuns(job.id),+ `cron-job-view-runs-${job.id}`,+ { disabled: coreBusyKey === `core-runs:${job.id}` }+ )}+ {onEditCoreJob &&+ iconAction(+ t('settings.cron.jobs.edit'),+ <Pencil className="h-4 w-4" aria-hidden />,+ () => onEditCoreJob(job),+ `cron-job-edit-${job.id}`+ )}+ {iconAction(+ removeLabel(job.id),+ <Trash2 className="h-4 w-4" aria-hidden />,+ () => onRemoveCoreJob(job.id),+ `cron-job-remove-${job.id}`,+ { disabled: coreBusyKey === `core-remove:${job.id}`, danger: true }+ )}+ </div>+ ),+ },+ ];- <div className="flex flex-wrap gap-2">- <Button- type="button"- variant="secondary"- size="sm"- data-testid={`cron-job-toggle-${job.id}`}- className="whitespace-nowrap"- disabled={coreBusyKey === `core-toggle:${job.id}`}- onClick={() => onToggleCoreJob(job)}>- {toggleButtonLabel(job)}- </Button>- <Button- type="button"- variant="secondary"- size="sm"- data-testid={`cron-job-run-${job.id}`}- className="whitespace-nowrap"- disabled={coreBusyKey === `core-run:${job.id}`}- onClick={() => onRunCoreJob(job.id)}>- {runButtonLabel(job.id)}- </Button>- <Button- type="button"- variant="secondary"- size="sm"- data-testid={`cron-job-view-runs-${job.id}`}- className="whitespace-nowrap"- disabled={coreBusyKey === `core-runs:${job.id}`}- onClick={() => onLoadCoreRuns(job.id)}>- {viewRunsButtonLabel(job.id)}- </Button>- {onEditCoreJob && (- <Button- type="button"- variant="secondary"- size="sm"- data-testid={`cron-job-edit-${job.id}`}- className="whitespace-nowrap"- onClick={() => onEditCoreJob(job)}>- {t('settings.cron.jobs.edit')}- </Button>- )}- <Button- type="button"- variant="primary"- tone="danger"- size="sm"- data-testid={`cron-job-remove-${job.id}`}- className="whitespace-nowrap"- disabled={coreBusyKey === `core-remove:${job.id}`}- onClick={() => onRemoveCoreJob(job.id)}>- {removeButtonLabel(job.id)}- </Button>- </div>+ const renderRuns = (job: CoreCronJob, runs: CoreCronRun[]) => (+ <TableRow className="hover:bg-transparent">+ <TableCell colSpan={columns.length} className="bg-surface-muted py-3">+ <div data-testid={`cron-job-runs-${job.id}`} className="space-y-2">+ <p className="text-xs font-medium text-content-muted">+ {t('settings.cron.jobs.recentRuns')}+ </p>+ <ul className="flex flex-wrap gap-2">+ {runs.map(run => {+ const finishedAt = new Date(run.finished_at).toLocaleString();+ // Split on the placeholders (rather than assuming+ // "{status} at {time}" order) so a locale that reorders the+ // phrase still renders correctly.+ const parts = t('settings.cron.jobs.runFinishedAt').split(/(\{status\}|\{time\})/g);+ return (+ <li key={run.id}>+ <Badge variant={statusVariant(run.status)} title={run.output ?? undefined}>+ {parts.map((part, index) =>+ part === '{status}' ? (+ <Fragment key={index}>{run.status}</Fragment>+ ) : part === '{time}' ? (+ <span key={index} className="font-normal text-content-muted">+ {finishedAt}+ </span>+ ) : (+ <Fragment key={index}>{part}</Fragment>+ )+ )}+ </Badge>+ </li>+ );+ })}+ </ul>+ </div>+ </TableCell>+ </TableRow>+ );- {runs.length > 0 && (- <div- data-testid={`cron-job-runs-${job.id}`}- className="rounded-lg border border-line bg-surface-muted p-3 space-y-1">- <div className="text-[11px] uppercase tracking-wide text-content-faint">- {t('settings.cron.jobs.recentRuns')}- </div>- {runs.map(run => {- const finishedAt = new Date(run.finished_at).toLocaleString();- // Split on the placeholders (rather than assuming- // "{status} at {time}" order) so a locale that reorders- // the phrase still renders correctly.- const parts = t('settings.cron.jobs.runFinishedAt').split(- /(\{status\}|\{time\})/g- );- return (- <div key={run.id} className="text-xs text-content-secondary">- {parts.map((part, index) => {- if (part === '{status}') {- return (- <span key={index} className="font-medium text-content-secondary">- {run.status}- </span>- );- }- if (part === '{time}') {- return <span key={index}>{finishedAt}</span>;- }- return part;- })}- </div>- );- })}- </div>- )}- </div>- );- })}- </div>+ return (+ <DataTable<CoreCronJob>+ title={title}+ description={description}+ actions={actions}+ error={error}+ columns={columns}+ rows={filteredJobs}+ rowKey={job => job.id}+ renderRow={job => {+ const runs = coreRunsByJob[job.id] ?? [];+ return (+ <Fragment key={job.id}>+ <TableRow data-testid={`cron-job-row-${job.id}`}>+ {columns.map(column => (+ <TableCell+ key={column.id}+ className={+ column.align === 'right'+ ? `${column.className ?? ''} text-right`+ : column.className+ }>+ {column.cell?.(job)}+ </TableCell>+ ))}+ </TableRow>+ {runs.length > 0 && renderRuns(job, runs)}+ </Fragment>+ );+ }}+ search={{+ value: query,+ onChange: setQuery,+ placeholder: t('settings.cron.jobs.searchPlaceholder'),+ testId: 'cron-jobs-search',+ }}+ filters={[+ {+ id: 'state',+ label: t('settings.cron.jobs.columnState'),+ options: STATUS_FILTER_VALUES.map(value => ({+ value,+ label: value === 'enabled' ? t('common.enabled') : t('settings.cron.jobs.paused'),+ })),+ selected: selectedStatus,+ onChange: setSelectedStatus,+ testId: 'cron-jobs-state-filter',+ },+ ]}+ pagination={{ pageSize: 25 }}+ loading={loading}+ loadingLabel={t('settings.cron.jobs.loading')}+ empty={<EmptyState label={t('settings.cron.jobs.empty')} />}+ ariaLabel={t('cron.scheduledJobs')}+ testId="cron-jobs-table"+ />);};