JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.
Python
fix(cron): 修复左侧栏工作态未同步高亮 + 编辑面板长下拉框未做高度限制 + 排班的日期选项按所选月份动态限制,避免选中不存在的日期
cjh_jinduoxiabd5d2e7c6e67
diff --git a/jiuwenswarm/channels/web/frontend/src/components/CronPanel/ModelPicker.tsx b/jiuwenswarm/channels/web/frontend/src/components/CronPanel/ModelPicker.tsxindex 7cd41ee4b0..43bfe7a413 100644--- a/jiuwenswarm/channels/web/frontend/src/components/CronPanel/ModelPicker.tsx+++ b/jiuwenswarm/channels/web/frontend/src/components/CronPanel/ModelPicker.tsx@@ -40,7 +40,7 @@ export default function ModelPicker({ value, onChange, disabled = false }: Model<ChevronDown size={14} className={`text-text-muted transition-transform ${open ? 'rotate-180' : ''}`} /></button>{open && !disabled && (- <div className="absolute left-0 top-[calc(100%+4px)] z-30 w-full rounded-lg border border-border bg-card p-1.5 shadow-lg">+ <div className="absolute left-0 top-[calc(100%+4px)] z-30 max-h-60 w-full overflow-y-auto rounded-lg border border-border bg-card p-1.5 shadow-lg">{availableModels.length === 0 ? (<div className="px-2 py-2 text-xs text-text-muted">{t('cron.modelPicker.empty')}</div>) : (diff --git a/jiuwenswarm/channels/web/frontend/src/components/CronPanel/ScheduleEditor.tsx b/jiuwenswarm/channels/web/frontend/src/components/CronPanel/ScheduleEditor.tsxindex 668d3c50ab..c0c57c7e60 100644--- a/jiuwenswarm/channels/web/frontend/src/components/CronPanel/ScheduleEditor.tsx+++ b/jiuwenswarm/channels/web/frontend/src/components/CronPanel/ScheduleEditor.tsx@@ -176,6 +176,14 @@ export default function ScheduleEditor({ value, onChange, timezone }: ScheduleEd{ value: 'L', label: t('cron.schedule.lastDayOfMonth') },];const monthOptions = Array.from({ length: 12 }, (_, i) => ({ value: String(i + 1), label: t('cron.schedule.monthOption', { month: i + 1 }) }));+ // "每年"选中具体月份后,日期字段的候选天数必须跟着这个月封顶,否则像"2月31日"这种组合会被+ // 允许选中——croniter 里 day=31 和 month=2 永远不会同时命中,任务实际上永远不会触发,+ // 是个"看起来配置成功、实际静默失效"的坑,不只是下拉框太长那种纯 UI 问题。+ // 2月按平年 28 天封顶(不放到 29):闰年才会命中的"每年"排班会让用户以为每年都执行,+ // 三年不触发一次同样是隐性失效,跟"每月"用独立的 'L' 选项处理月末是两回事,这里干脆不引入歧义。+ const YEARLY_MONTH_DAY_COUNTS = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];+ const yearlyMaxDay = schedule.kind === 'yearly' && schedule.month ? YEARLY_MONTH_DAY_COUNTS[schedule.month - 1] : 31;+ const yearlyDayOptions = dayOptions.filter((o) => o.value !== 'L' && Number(o.value) <= yearlyMaxDay);const periodKindOptions = PERIOD_KINDS.map((k) => ({ value: k, label: t(`cron.schedule.${k}`) }));const weekOfMonthOptions = WEEK_OF_MONTH_OPTIONS.map((o) => ({ value: o.value, label: t(`cron.schedule.weekOfMonth.${o.key}`) }));@@ -264,7 +272,14 @@ export default function ScheduleEditor({ value, onChange, timezone }: ScheduleEd<><SimpleSelectvalue={schedule.month ? String(schedule.month) : ''}- onChange={(v) => updateSchedule({ ...schedule, month: Number(v) })}+ onChange={(v) => {+ const nextMonth = Number(v);+ const maxDay = YEARLY_MONTH_DAY_COUNTS[nextMonth - 1];+ // 已选的日期超出新月份的天数上限时(比如从"1月31日"切到"2月"),跟着收窄到+ // 该月最后一天,而不是留着一个新月份根本不存在的日期+ const nextDay = typeof schedule.day === 'number' && schedule.day > maxDay ? maxDay : schedule.day;+ updateSchedule({ ...schedule, month: nextMonth, day: nextDay });+ }}options={monthOptions}placeholder={t('cron.schedule.selectMonth') ?? undefined}className="min-w-0 flex-1"@@ -272,7 +287,7 @@ export default function ScheduleEditor({ value, onChange, timezone }: ScheduleEd<SimpleSelectvalue={schedule.day !== undefined ? String(schedule.day) : ''}onChange={(v) => updateSchedule({ ...schedule, day: Number(v) })}- options={dayOptions.filter((o) => o.value !== 'L')}+ options={yearlyDayOptions}placeholder={t('cron.schedule.selectDay') ?? undefined}className="min-w-0 flex-1"/>diff --git a/jiuwenswarm/channels/web/frontend/src/components/CronPanel/SimpleSelect.tsx b/jiuwenswarm/channels/web/frontend/src/components/CronPanel/SimpleSelect.tsxindex 6b64092006..c696dad7a2 100644--- a/jiuwenswarm/channels/web/frontend/src/components/CronPanel/SimpleSelect.tsx+++ b/jiuwenswarm/channels/web/frontend/src/components/CronPanel/SimpleSelect.tsx@@ -37,7 +37,7 @@ export default function SimpleSelect({ value, onChange, options, placeholder = '<ChevronDown size={14} className={`text-text-muted transition-transform ${open ? 'rotate-180' : ''}`} /></button>{open && !disabled && (- <div className="absolute left-0 top-[calc(100%+4px)] z-30 w-full rounded-lg border border-border bg-card p-1.5 shadow-lg">+ <div className="absolute left-0 top-[calc(100%+4px)] z-30 max-h-60 w-full overflow-y-auto rounded-lg border border-border bg-card p-1.5 shadow-lg">{options.map((opt) => {const active = opt.value === value;return (diff --git a/jiuwenswarm/channels/web/frontend/src/components/SessionSidebar/index.tsx b/jiuwenswarm/channels/web/frontend/src/components/SessionSidebar/index.tsxindex ec3b09a4ea..43eb9e14ea 100644--- a/jiuwenswarm/channels/web/frontend/src/components/SessionSidebar/index.tsx+++ b/jiuwenswarm/channels/web/frontend/src/components/SessionSidebar/index.tsx@@ -195,6 +195,10 @@ export function SessionSidebar({const visibleMainNavItems = mainNavItems.filter((item) => !hiddenNavItems.includes(item.key));const visibleMoreNavItems = moreNavItems.filter((item) => !hiddenNavItems.includes(item.key));const isMoreActive = visibleMoreNavItems.some((item) => item.key === activeNav);+ // 定时任务(cron)是"工作"区内与会话同级的视图,没有独立的导航图标,+ // 因此进入定时任务时"工作"导航项也应保持选中态+ const isNavItemActive = (item: NavItem) =>+ activeNav === item.key || (item.key === 'chat' && activeNav === 'cron');useLayoutEffect(() => {onMorePanelOpenChange?.(isMoreActive);@@ -222,7 +226,7 @@ export function SessionSidebar({{visibleMainNavItems.map((item) => (<buttonkey={item.key}- className={`icon-rail-nav-item${activeNav === item.key ? ' icon-rail-nav-item--active' : ''}`}+ className={`icon-rail-nav-item${isNavItemActive(item) ? ' icon-rail-nav-item--active' : ''}`}onClick={() => handleNavClick(item.key)}><span className="icon-rail-nav-item__icon">{item.icon}</span>