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
feat(web): improve cron panel and add automation ui test id for div
SnapeK6e00ec6987e4
diff --git a/jiuwenclaw/web/src/App.tsx b/jiuwenclaw/web/src/App.tsxindex cf3cb2dbcc..1e54233933 100644--- a/jiuwenclaw/web/src/App.tsx+++ b/jiuwenclaw/web/src/App.tsx@@ -800,7 +800,7 @@ function AppContent() {: heartbeatToastPreviewRaw;return (- <div className="shell">+ <div className="shell" data-testid="app-shell" data-session-id={sessionId}>{/* Topbar */}<header className="topbar"><div className="flex items-center gap-4">@@ -912,7 +912,7 @@ function AppContent() {)}{activeNav === 'cron' && (<div className="app-section">- <CronPanel />+ <CronPanel sessionId={sessionId} /></div>)}{activeNav === 'configpanel' && (diff --git a/jiuwenclaw/web/src/components/ChatPanel/InputArea.tsx b/jiuwenclaw/web/src/components/ChatPanel/InputArea.tsxindex 2c5784e8a4..4ce70df199 100644--- a/jiuwenclaw/web/src/components/ChatPanel/InputArea.tsx+++ b/jiuwenclaw/web/src/components/ChatPanel/InputArea.tsx@@ -276,6 +276,7 @@ export function InputArea({}className="chat-input-textarea"rows={1}+ data-testid="chat-input"/><div className="chat-input-toolbar">@@ -298,6 +299,7 @@ export function InputArea({'chat-mode-btn',mode === m.value ? 'chat-mode-btn--active' : 'chat-mode-btn--inactive')}+ data-testid={`chat-mode-${m.value}`}>{m.icon}{m.label}@@ -356,6 +358,7 @@ export function InputArea({canSend ? 'chat-input-btn--send-active' : 'chat-input-btn--disabled',)}title={t('chat.send')}+ data-testid="chat-send"><svg className="chat-input-btn-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24" strokeWidth={2}><path strokeLinecap="round" strokeLinejoin="round" d="M4.5 10.5L12 3m0 0l7.5 7.5M12 3v18" />diff --git a/jiuwenclaw/web/src/components/ChatPanel/MessageItem.tsx b/jiuwenclaw/web/src/components/ChatPanel/MessageItem.tsxindex c2d3942d83..ee0eb58e8b 100644--- a/jiuwenclaw/web/src/components/ChatPanel/MessageItem.tsx+++ b/jiuwenclaw/web/src/components/ChatPanel/MessageItem.tsx@@ -246,19 +246,23 @@ export function MessageItem({ message, autoSpeak = false }: MessageItemProps) {isUser ? 'justify-end' : 'justify-start')}><div className="max-w-[82%] min-w-0">- {/* 消息气泡 */}+ {!isUser && (+ <div className="hidden" data-testid="thinking-summary" aria-hidden="true" />+ )}+<divclassName={clsx('chat-bubble relative group',isUser ? 'user' : 'assistant',isStreaming && 'streaming')}+ data-testid={!isUser ? 'thinking-panel' : undefined}>{isStreaming ? (<StreamingContent content={content} isStreaming={true} />) : (<>- <div className="chat-text">+ <div className="chat-text" data-testid={!isUser ? 'thinking-body' : undefined}>{isUser ? (<span className="whitespace-pre-wrap">{content}</span>) : (diff --git a/jiuwenclaw/web/src/components/ChatPanel/ToolGroupDisplay.tsx b/jiuwenclaw/web/src/components/ChatPanel/ToolGroupDisplay.tsxindex 77d503817f..99e7af3602 100644--- a/jiuwenclaw/web/src/components/ChatPanel/ToolGroupDisplay.tsx+++ b/jiuwenclaw/web/src/components/ChatPanel/ToolGroupDisplay.tsx@@ -33,7 +33,12 @@ export function ToolExecutionItem({ execution }: { execution: ToolExecution }) {: '';return (- <div className="tool-pair-item animate-rise">+ <div+ className="tool-pair-item animate-rise"+ data-testid={`tool-execution-${toolCall.id}`}+ data-tool-name={toolCall.name}+ data-tool-status={status}+ ><div className="tool-pair-header" onClick={() => setIsExpanded(!isExpanded)}><span className={clsx('tool-pair-icon',@@ -156,7 +161,7 @@ export function ToolGroupDisplay({ executions }: ToolGroupDisplayProps) {}, [scrollInner]);return (- <div className="tool-group-container animate-rise">+ <div className="tool-group-container animate-rise" data-testid="tool-group"><div className="tool-group-header"><div className="tool-group-header-left"><svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24" strokeWidth={1.5}>diff --git a/jiuwenclaw/web/src/components/ChatPanel/index.tsx b/jiuwenclaw/web/src/components/ChatPanel/index.tsxindex 09f2e44d5c..6a234b54d2 100644--- a/jiuwenclaw/web/src/components/ChatPanel/index.tsx+++ b/jiuwenclaw/web/src/components/ChatPanel/index.tsx@@ -127,7 +127,7 @@ export function ChatPanel({);return (- <div className="flex flex-col h-full">+ <div className="flex flex-col h-full" data-testid="chat-panel"><div ref={scrollContainerRef} className="flex-1 overflow-y-auto px-3 py-4">{historyPager && messages.length > 0 ? (<HistoryPagerBardiff --git a/jiuwenclaw/web/src/components/CronPanel/index.tsx b/jiuwenclaw/web/src/components/CronPanel/index.tsxindex 686620368c..9767dc82bd 100644--- a/jiuwenclaw/web/src/components/CronPanel/index.tsx+++ b/jiuwenclaw/web/src/components/CronPanel/index.tsx@@ -8,6 +8,8 @@ import { useState, useEffect, useCallback } from 'react';import { useTranslation } from 'react-i18next';import { webRequest } from '../../services/webClient';+const DEFAULT_CRON_TIMEZONE = 'Asia/Shanghai';+const DEFAULT_CRON_TARGET = 'web';interface CronJob {id: string;@@ -18,41 +20,153 @@ interface CronJob {wake_offset_seconds: number;description?: string;targets: string;- created_at: string;- updated_at: string;+ schedule?: {+ kind: string;+ expr?: string;+ tz?: string;+ at?: string;+ everyMs?: number;+ };+ payload?: {+ kind: string;+ text?: string;+ message?: string;+ };+ delivery?: {+ mode: string;+ channel?: string;+ };+ session_target?: string;+ wake_mode?: string;+ compat_mode?: string;+ created_at: number | string | null;+ updated_at: number | string | null;}-// 更新任务的类型,继承自CronJob并将部分字段设置为可选-interface UpdateCronJob {- id: string;+interface CronPreviewItem {+ wake_at: string;+ push_at: string;+}++interface CronJobInput {name: string;enabled: boolean;cron_expr: string;timezone: string;wake_offset_seconds: number;- description?: string;+ description: string;targets: string;- created_at?: string;- updated_at?: string;}-export default function CronPanel() {- const { t } = useTranslation();- const [cronJobs, setCronJobs] = useState<CronJob[]>([]);- const [loading, setLoading] = useState(true);- const [error, setError] = useState<string | null>(null);- const [success, setSuccess] = useState<string | null>(null);- const [newJob, setNewJob] = useState({+interface UpdateCronJob extends CronJobInput {+ id: string;+ created_at?: number | string | null;+ updated_at?: number | string | null;+}++interface CronPanelProps {+ sessionId: string;+}++function createEmptyJobInput(): CronJobInput {+ return {name: '',enabled: true,cron_expr: '',- timezone: 'Asia/Shanghai',+ timezone: DEFAULT_CRON_TIMEZONE,wake_offset_seconds: 60,description: '',- targets: 'web'- });+ targets: DEFAULT_CRON_TARGET,+ };+}++function renderScheduleSummary(job: CronJob): string {+ if (!job.schedule) {+ return job.cron_expr || '';+ }+ if (job.schedule.kind === 'cron') {+ return job.schedule.expr || job.cron_expr || '';+ }+ if (job.schedule.kind === 'every') {+ return `every ${job.schedule.everyMs || 0} ms`;+ }+ if (job.schedule.kind === 'at') {+ return job.schedule.at || job.cron_expr || '';+ }+ return job.cron_expr || '';+}++function resolveCronExpr(job: CronJob): string {+ if (job.schedule?.kind === 'cron') {+ return (job.schedule.expr || job.cron_expr || '').trim();+ }+ return (job.cron_expr || '').trim();+}++function resolveTimezone(job: CronJob): string {+ if (job.schedule?.kind === 'cron') {+ return (job.schedule.tz || job.timezone || DEFAULT_CRON_TIMEZONE).trim() || DEFAULT_CRON_TIMEZONE;+ }+ return (job.timezone || DEFAULT_CRON_TIMEZONE).trim() || DEFAULT_CRON_TIMEZONE;+}++function resolveDescription(job: CronJob): string {+ if (job.payload?.kind === 'agentTurn') {+ return (job.payload.message || job.description || '').trim();+ }+ if (job.payload?.kind === 'systemEvent') {+ return (job.payload.text || job.description || '').trim();+ }+ return (job.description || '').trim();+}++function resolveTargets(job: CronJob): string {+ const deliveryChannel = (job.delivery?.channel || '').trim();+ if (deliveryChannel && deliveryChannel !== 'last') {+ return deliveryChannel;+ }+ return (job.targets || DEFAULT_CRON_TARGET).trim() || DEFAULT_CRON_TARGET;+}++function normalizeJobForEdit(job: CronJob): UpdateCronJob {+ return {+ id: job.id,+ name: (job.name || '').trim(),+ enabled: Boolean(job.enabled),+ cron_expr: resolveCronExpr(job),+ timezone: resolveTimezone(job),+ wake_offset_seconds: Number.isFinite(job.wake_offset_seconds) ? job.wake_offset_seconds : 0,+ description: resolveDescription(job),+ targets: resolveTargets(job),+ created_at: job.created_at,+ updated_at: job.updated_at,+ };+}++function buildLegacyJobInput(job: CronJobInput | UpdateCronJob): Record<string, unknown> {+ return {+ name: job.name.trim(),+ enabled: job.enabled,+ cron_expr: job.cron_expr.trim(),+ timezone: job.timezone.trim() || DEFAULT_CRON_TIMEZONE,+ wake_offset_seconds: Math.max(0, job.wake_offset_seconds || 0),+ description: job.description.trim(),+ targets: job.targets.trim() || DEFAULT_CRON_TARGET,+ };+}++export default function CronPanel({ sessionId }: CronPanelProps) {+ const { t } = useTranslation();+ const [cronJobs, setCronJobs] = useState<CronJob[]>([]);+ const [loading, setLoading] = useState(true);+ const [error, setError] = useState<string | null>(null);+ const [success, setSuccess] = useState<string | null>(null);+ const [newJob, setNewJob] = useState<CronJobInput>(createEmptyJobInput());const [isCreating, setIsCreating] = useState(false);const [editingJobs, setEditingJobs] = useState<Record<string, UpdateCronJob>>({});+ const [previewJobId, setPreviewJobId] = useState<string | null>(null);+ const [previewRuns, setPreviewRuns] = useState<CronPreviewItem[]>([]);+ const [previewLoading, setPreviewLoading] = useState(false);// 时区选项const timezoneOptions = [@@ -65,7 +179,7 @@ export default function CronPanel() {{ value: 'Europe/Paris', label: 'Europe/Paris' },{ value: 'America/New_York', label: 'America/New_York' },{ value: 'America/Los_Angeles', label: 'America/Los_Angeles' },- { value: 'America/Chicago', label: 'America/Chicago' }+ { value: 'America/Chicago', label: 'America/Chicago' },];// 目标选项@@ -74,7 +188,7 @@ export default function CronPanel() {{ value: 'feishu', label: t('cron.targets.feishu') },{ value: 'wecom', label: t('cron.targets.wecom') },{ value: 'xiaoyi', label: t('cron.targets.xiaoyi'), disabled: true, style: { color: '#8c8c96ff' } },- { value: 'dingtalk', label: t('cron.targets.dingtalk'), disabled: true, style: { color: '#8c8c96ff' } }+ { value: 'dingtalk', label: t('cron.targets.dingtalk'), disabled: true, style: { color: '#8c8c96ff' } },];// 加载任务列表@@ -87,7 +201,6 @@ export default function CronPanel() {} catch (loadError) {const message = loadError instanceof Error ? loadError.message : t('cron.errors.loadJobs');setError(message);- // 加载失败时使用空数组setCronJobs([]);} finally {setLoading(false);@@ -110,7 +223,6 @@ export default function CronPanel() {// 创建任务const handleCreateJob = async () => {- // 检查必填字段if (!newJob.name) {setError(t('cron.errors.nameRequired'));return;@@ -133,18 +245,13 @@ export default function CronPanel() {}try {- await webRequest<{ job: CronJob }>('cron.job.create', newJob);+ await webRequest<{ job: CronJob }>('cron.job.create', {+ ...buildLegacyJobInput(newJob),+ session_id: sessionId,+ });setSuccess(t('cron.success.created'));setIsCreating(false);- setNewJob({- name: '',- enabled: true,- cron_expr: '',- timezone: 'Asia/Shanghai',- wake_offset_seconds: 60,- description: '',- targets: 'web'- });+ setNewJob(createEmptyJobInput());await loadJobs();} catch (createError) {const message = createError instanceof Error ? createError.message : t('cron.errors.createFailed');@@ -157,7 +264,7 @@ export default function CronPanel() {try {await webRequest<{ job: CronJob }>('cron.job.toggle', {id,- enabled: !enabled+ enabled: !enabled,});setSuccess(t('cron.success.statusUpdated'));await loadJobs();@@ -181,15 +288,50 @@ export default function CronPanel() {}};+ const handleRunNow = async (id: string) => {+ try {+ await webRequest<{ run_id: string }>('cron.job.run_now', { id, session_id: sessionId });+ setSuccess(t('cron.success.runNow'));+ } catch (runError) {+ const message = runError instanceof Error ? runError.message : t('cron.errors.runNowFailed');+ setError(message);+ }+ };+ const handlePreviewRuns = async (id: string) => {+ setPreviewJobId(id);+ setPreviewLoading(true);+ try {+ const payload = await webRequest<{ next: CronPreviewItem[] }>('cron.job.preview', {+ id,+ count: 3,+ session_id: sessionId,+ });+ setPreviewRuns(payload.next || []);+ } catch (previewError) {+ const message = previewError instanceof Error ? previewError.message : t('cron.errors.previewFailed');+ setError(message);+ setPreviewRuns([]);+ } finally {+ setPreviewLoading(false);+ }+ };++ const formatPreviewTime = (value: string) => {+ const parsed = new Date(value);+ if (Number.isNaN(parsed.getTime())) {+ return value;+ }+ return parsed.toLocaleString();+ };// 准备更新任务const handleUpdateJob = async (id: string) => {try {- const payload = await webRequest<{ job: CronJob }>('cron.job.get', { id });- setEditingJobs(prev => ({+ const payload = await webRequest<{ job: CronJob }>('cron.job.get', { id, session_id: sessionId });+ setEditingJobs((prev) => ({...prev,- [id]: payload.job as UpdateCronJob+ [id]: normalizeJobForEdit(payload.job),}));} catch (viewError) {const message = viewError instanceof Error ? viewError.message : t('cron.errors.loadDetailFailed');@@ -202,7 +344,6 @@ export default function CronPanel() {const editJob = editingJobs[jobId];if (!editJob) return;- // 检查必填字段if (!editJob.name) {setError(t('cron.errors.nameRequired'));return;@@ -225,26 +366,20 @@ export default function CronPanel() {}try {- // 准备更新数据,将除id外的参数用patch包起来const updateData: Record<string, unknown> = {id: editJob.id,- patch: {- name: editJob.name,- enabled: editJob.enabled,- cron_expr: editJob.cron_expr,- timezone: editJob.timezone,- wake_offset_seconds: editJob.wake_offset_seconds,- description: editJob.description,- targets: editJob.targets- }+ patch: buildLegacyJobInput(editJob),};-- await webRequest<{ job: CronJob }>('cron.job.update', updateData);++ await webRequest<{ job: CronJob }>('cron.job.update', {+ ...updateData,+ session_id: sessionId,+ });setSuccess(t('cron.success.updated'));- setEditingJobs(prev => {- const newEditingJobs = { ...prev };- delete newEditingJobs[jobId];- return newEditingJobs;+ setEditingJobs((prev) => {+ const next = { ...prev };+ delete next[jobId];+ return next;});await loadJobs();} catch (updateError) {@@ -254,15 +389,15 @@ export default function CronPanel() {};return (- <div className="flex-1 min-h-0 relative">+ <div className="flex-1 min-h-0 relative" data-testid="cron-panel" data-session-id={sessionId}>{success && (- <div className="pointer-events-none absolute top-3 left-1/2 -translate-x-1/2 z-20">+ <div className="pointer-events-none absolute top-3 left-1/2 -translate-x-1/2 z-20" data-testid="cron-success"><div className="bg-ok text-white px-4 py-2 rounded-lg shadow-lg animate-rise text-sm">{success}</div></div>)}-+<div className="card w-full h-full flex flex-col"><div className="flex items-center justify-between gap-4 mb-4"><div>@@ -272,6 +407,7 @@ export default function CronPanel() {<buttononClick={() => setIsCreating(!isCreating)}className="btn primary !px-4 !py-2"+ data-testid="cron-create-toggle">{isCreating ? t('cron.cancelCreate') : t('cron.createJob')}</button>@@ -279,7 +415,7 @@ export default function CronPanel() {<div className="flex-1 min-h-0">{error && (- <div className="rounded-lg border border-danger/30 bg-danger/10 px-3 py-2 text-danger mb-4">+ <div className="rounded-lg border border-danger/30 bg-danger/10 px-3 py-2 text-danger mb-4" data-testid="cron-error">{error}</div>)}@@ -314,6 +450,7 @@ export default function CronPanel() {onChange={(e) => setNewJob({ ...newJob, name: e.target.value })}className="w-full rounded-md border border-border bg-bg px-3 py-2 text-[13px] text-text outline-none focus:border-accent"placeholder={t('cron.placeholders.name')}+ data-testid="cron-create-name"/></td><td className="px-4 py-3">@@ -324,14 +461,15 @@ export default function CronPanel() {onChange={(e) => setNewJob({ ...newJob, cron_expr: e.target.value })}className="w-full rounded-md border border-border bg-bg px-3 py-2 text-[13px] text-text outline-none focus:border-accent pr-8"placeholder={t('cron.placeholders.cronShort')}+ data-testid="cron-create-expr"/><spanclassName="absolute right-2 top-1/2 -translate-y-1/2 text-text-muted hover:text-text cursor-help"title={t('cron.placeholders.cron')}><svg width="16" height="16" viewBox="0 0 40 40" xmlns="http://www.w3.org/2000/svg">- <circle cx="20" cy="20" r="18" fill="transparent" stroke="currentColor" stroke-width="2" />- <text x="20" y="22" font-family="Arial, sans-serif" font-size="24" fill="currentColor" text-anchor="middle" dominant-baseline="middle">?</text>+ <circle cx="20" cy="20" r="18" fill="transparent" stroke="currentColor" strokeWidth="2" />+ <text x="20" y="22" fontFamily="Arial, sans-serif" fontSize="24" fill="currentColor" textAnchor="middle" dominantBaseline="middle">?</text></svg></span></div>@@ -339,15 +477,15 @@ export default function CronPanel() {<td className="px-4 py-3"><div className="flex items-center"><span className="text-sm mr-2">{newJob.enabled ? t('cron.status.enabled') : t('cron.status.disabled')}</span>- <div+ <divclassName="relative inline-block w-10 h-6 align-middle select-none rounded-full cursor-pointer"onClick={() => setNewJob({ ...newJob, enabled: !newJob.enabled })}style={{ backgroundColor: newJob.enabled ? '#10b981' : '#d1d5db' }}>- <div+ <divclassName="absolute left-1 top-1 h-4 w-4 rounded-full bg-white transition-transform"style={{ transform: newJob.enabled ? 'translateX(16px)' : 'none' }}- ></div>+ /></div></div></td>@@ -358,15 +496,17 @@ export default function CronPanel() {onChange={(e) => setNewJob({ ...newJob, description: e.target.value })}className="w-full rounded-md border border-border bg-bg px-3 py-2 text-[13px] text-text outline-none focus:border-accent"placeholder={t('cron.placeholders.description')}+ data-testid="cron-create-description"/></td><td className="px-4 py-3"><inputtype="number"value={newJob.wake_offset_seconds}- onChange={(e) => setNewJob({ ...newJob, wake_offset_seconds: parseInt(e.target.value) || 0 })}+ onChange={(e) => setNewJob({ ...newJob, wake_offset_seconds: parseInt(e.target.value, 10) || 0 })}className="w-full rounded-md border border-border bg-bg px-3 py-2 text-[13px] text-text outline-none focus:border-accent"placeholder={t('cron.placeholders.wakeOffset')}+ data-testid="cron-create-wake-offset"/></td><td className="px-4 py-3">@@ -374,8 +514,9 @@ export default function CronPanel() {value={newJob.timezone}onChange={(e) => setNewJob({ ...newJob, timezone: e.target.value })}className="w-full rounded-md border border-border bg-bg px-3 py-2 text-[13px] text-text outline-none focus:border-accent"+ data-testid="cron-create-timezone">- {timezoneOptions.map(option => (+ {timezoneOptions.map((option) => (<option key={option.value} value={option.value}>{option.label}</option>@@ -387,8 +528,9 @@ export default function CronPanel() {value={newJob.targets}onChange={(e) => setNewJob({ ...newJob, targets: e.target.value })}className="w-full rounded-md border border-border bg-bg px-3 py-2 text-[13px] text-text outline-none focus:border-accent"+ data-testid="cron-create-target">- {targetOptions.map(option => (+ {targetOptions.map((option) => (<option key={option.value} value={option.value} disabled={option.disabled} style={option.style}>{option.label}</option>@@ -404,10 +546,10 @@ export default function CronPanel() {name: '',enabled: true,cron_expr: '',- timezone: 'Asia/Shanghai',+ timezone: DEFAULT_CRON_TIMEZONE,wake_offset_seconds: 0,description: '',- targets: 'web'+ targets: DEFAULT_CRON_TARGET,});}}className="btn !px-3 !py-1.5"@@ -417,6 +559,7 @@ export default function CronPanel() {<buttononClick={handleCreateJob}className="btn primary !px-3 !py-1.5"+ data-testid="cron-create-submit">{t('cron.create')}</button>@@ -433,19 +576,23 @@ export default function CronPanel() {</td></tr>) : (- cronJobs.map(job => {+ cronJobs.map((job) => {const isEditing = editingJobs[job.id] !== undefined;const editJob = editingJobs[job.id];-+ const displayCron = renderScheduleSummary(job);+ const displayDescription = resolveDescription(job);+ const displayTimezone = resolveTimezone(job);+ const displayTarget = resolveTargets(job);+return isEditing && editJob ? (<tr key={job.id} className="border-b border-border bg-secondary/10"><td className="px-4 py-3"><inputtype="text"value={editJob.name}- onChange={(e) => setEditingJobs(prev => ({+ onChange={(e) => setEditingJobs((prev) => ({...prev,- [job.id]: { ...prev[job.id], name: e.target.value }+ [job.id]: { ...prev[job.id], name: e.target.value },}))}className="w-full rounded-md border border-border bg-bg px-3 py-2 text-[13px] text-text outline-none focus:border-accent"placeholder={t('cron.placeholders.name')}@@ -456,9 +603,9 @@ export default function CronPanel() {<inputtype="text"value={editJob.cron_expr}- onChange={(e) => setEditingJobs(prev => ({+ onChange={(e) => setEditingJobs((prev) => ({...prev,- [job.id]: { ...prev[job.id], cron_expr: e.target.value }+ [job.id]: { ...prev[job.id], cron_expr: e.target.value },}))}className="w-full rounded-md border border-border bg-bg px-3 py-2 text-[13px] text-text outline-none focus:border-accent pr-8"placeholder={t('cron.placeholders.cronShort')}@@ -468,8 +615,8 @@ export default function CronPanel() {title={t('cron.placeholders.cron')}><svg width="16" height="16" viewBox="0 0 40 40" xmlns="http://www.w3.org/2000/svg">- <circle cx="20" cy="20" r="18" fill="transparent" stroke="currentColor" stroke-width="2" />- <text x="20" y="22" font-family="Arial, sans-serif" font-size="24" fill="currentColor" text-anchor="middle" dominant-baseline="middle">?</text>+ <circle cx="20" cy="20" r="18" fill="transparent" stroke="currentColor" strokeWidth="2" />+ <text x="20" y="22" fontFamily="Arial, sans-serif" fontSize="24" fill="currentColor" textAnchor="middle" dominantBaseline="middle">?</text></svg></span></div>@@ -477,18 +624,18 @@ export default function CronPanel() {<td className="px-4 py-3"><div className="flex items-center"><span className="text-sm mr-2">{editJob.enabled ? t('cron.status.enabled') : t('cron.status.disabled')}</span>- <div+ <divclassName="relative inline-block w-10 h-6 align-middle select-none rounded-full cursor-pointer"- onClick={() => setEditingJobs(prev => ({+ onClick={() => setEditingJobs((prev) => ({...prev,- [job.id]: { ...prev[job.id], enabled: !prev[job.id].enabled }+ [job.id]: { ...prev[job.id], enabled: !prev[job.id].enabled },}))}style={{ backgroundColor: editJob.enabled ? '#10b981' : '#d1d5db' }}>- <div+ <divclassName="absolute left-1 top-1 h-4 w-4 rounded-full bg-white transition-transform"style={{ transform: editJob.enabled ? 'translateX(16px)' : 'none' }}- ></div>+ /></div></div></td>@@ -496,9 +643,9 @@ export default function CronPanel() {<inputtype="text"value={editJob.description || ''}- onChange={(e) => setEditingJobs(prev => ({+ onChange={(e) => setEditingJobs((prev) => ({...prev,- [job.id]: { ...prev[job.id], description: e.target.value }+ [job.id]: { ...prev[job.id], description: e.target.value },}))}className="w-full rounded-md border border-border bg-bg px-3 py-2 text-[13px] text-text outline-none focus:border-accent"placeholder={t('cron.placeholders.description')}@@ -508,9 +655,9 @@ export default function CronPanel() {<inputtype="number"value={editJob.wake_offset_seconds}- onChange={(e) => setEditingJobs(prev => ({+ onChange={(e) => setEditingJobs((prev) => ({...prev,- [job.id]: { ...prev[job.id], wake_offset_seconds: parseInt(e.target.value) || 0 }+ [job.id]: { ...prev[job.id], wake_offset_seconds: parseInt(e.target.value, 10) || 0 },}))}className="w-full rounded-md border border-border bg-bg px-3 py-2 text-[13px] text-text outline-none focus:border-accent"placeholder={t('cron.placeholders.wakeOffset')}@@ -519,13 +666,13 @@ export default function CronPanel() {<td className="px-4 py-3"><selectvalue={editJob.timezone}- onChange={(e) => setEditingJobs(prev => ({+ onChange={(e) => setEditingJobs((prev) => ({...prev,- [job.id]: { ...prev[job.id], timezone: e.target.value }+ [job.id]: { ...prev[job.id], timezone: e.target.value },}))}className="w-full rounded-md border border-border bg-bg px-3 py-2 text-[13px] text-text outline-none focus:border-accent">- {timezoneOptions.map(option => (+ {timezoneOptions.map((option) => (<option key={option.value} value={option.value}>{option.label}</option>@@ -535,13 +682,13 @@ export default function CronPanel() {<td className="px-4 py-3"><selectvalue={editJob.targets}- onChange={(e) => setEditingJobs(prev => ({+ onChange={(e) => setEditingJobs((prev) => ({...prev,- [job.id]: { ...prev[job.id], targets: e.target.value }+ [job.id]: { ...prev[job.id], targets: e.target.value },}))}className="w-full rounded-md border border-border bg-bg px-3 py-2 text-[13px] text-text outline-none focus:border-accent">- {targetOptions.map(option => (+ {targetOptions.map((option) => (<option key={option.value} value={option.value} disabled={option.disabled} style={option.style}>{option.label}</option>@@ -551,10 +698,10 @@ export default function CronPanel() {<td className="px-4 py-3 text-left"><div className="flex items-center gap-2"><button- onClick={() => setEditingJobs(prev => {- const newEditingJobs = { ...prev };- delete newEditingJobs[job.id];- return newEditingJobs;+ onClick={() => setEditingJobs((prev) => {+ const next = { ...prev };+ delete next[job.id];+ return next;})}className="btn !px-3 !py-1.5">@@ -570,37 +717,75 @@ export default function CronPanel() {</td></tr>) : (- <tr key={job.id} className="border-b border-border hover:bg-secondary/10">+ <tr+ key={job.id}+ className="border-b border-border hover:bg-secondary/10"+ data-testid={`cron-row-${job.id}`}+ data-cron-id={job.id}+ data-cron-name={job.name}+ ><td className="px-4 py-3 text-sm"><div className="max-w-[100px] overflow-hidden text-ellipsis whitespace-nowrap" title={job.name}>{job.name}</div></td>- <td className="px-4 py-3 text-sm mono">{job.cron_expr}</td>+ <td className="px-4 py-3 text-sm mono" data-testid={`cron-schedule-${job.id}`}>+ {displayCron}+ </td><td className="px-4 py-3"><span className={`inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${job.enabled ? 'bg-green-100 text-green-700' : 'bg-gray-100 text-gray-700'}`}>{job.enabled ? t('cron.status.enabled') : t('cron.status.disabled')}</span></td><td className="px-4 py-3 text-sm text-text-muted">- <div className="max-w-[300px] overflow-hidden text-ellipsis whitespace-nowrap" title={job.description || '-'}>- {job.description || '-'}+ <div className="max-w-[300px] overflow-hidden text-ellipsis whitespace-nowrap" title={displayDescription || '-'}>+ {displayDescription || '-'}</div>+ {previewJobId === job.id && (+ <div className="mt-2 space-y-1 text-xs text-text-muted" data-testid={`cron-preview-${job.id}`}>+ {previewLoading ? (+ <div>{t('cron.preview.loading')}</div>+ ) : previewRuns.length > 0 ? (+ previewRuns.map((item, index) => (+ <div key={`${job.id}-${index}`} data-testid={`cron-preview-${job.id}-${index}`}>+ {t('cron.preview.label', { index: index + 1 })}: {formatPreviewTime(item.push_at)}+ </div>+ ))+ ) : (+ <div>{t('cron.preview.empty')}</div>+ )}+ </div>+ )}</td><td className="px-4 py-3 text-sm text-text-muted">{job.wake_offset_seconds}</td><td className="px-4 py-3 text-sm text-text-muted">- {job.timezone}+ {displayTimezone}</td><td className="px-4 py-3 text-sm text-text-muted">- {job.targets || '-'}+ {displayTarget || '-'}</td><td className="px-4 py-3 text-left"><div className="flex items-center gap-4">+ <span+ onClick={() => handleRunNow(job.id)}+ className="cursor-pointer text-sm text-accent"+ data-testid={`cron-run-${job.id}`}+ >+ {t('cron.runNow')}+ </span>+ <span+ onClick={() => handlePreviewRuns(job.id)}+ className="cursor-pointer text-sm text-accent"+ data-testid={`cron-preview-action-${job.id}`}+ >+ {t('cron.previewAction')}+ </span><spanonClick={() => handleToggleJob(job.id, job.enabled)}className={`cursor-pointer text-sm ${job.enabled ? 'text-danger' : 'text-accent'}`}+ data-testid={`cron-toggle-${job.id}`}>{job.enabled ? t('cron.disable') : t('cron.enable')}</span>@@ -613,6 +798,7 @@ export default function CronPanel() {<spanonClick={() => handleDeleteJob(job.id)}className="cursor-pointer text-sm text-accent"+ data-testid={`cron-delete-${job.id}`}>{t('cron.delete')}</span>@@ -620,16 +806,14 @@ export default function CronPanel() {</td></tr>);- }))- }+ })+ )}</tbody></table></div>)}</div></div>--</div>);}diff --git a/jiuwenclaw/web/src/components/TodoList/TodoItem.tsx b/jiuwenclaw/web/src/components/TodoList/TodoItem.tsxindex 0a48fbcec0..ee3c69869a 100644--- a/jiuwenclaw/web/src/components/TodoList/TodoItem.tsx+++ b/jiuwenclaw/web/src/components/TodoList/TodoItem.tsx@@ -39,6 +39,8 @@ export function TodoItem({ todo }: TodoItemProps) {return (<div+ data-testid={`todo-item-${todo.id}`}+ data-todo-status={todo.status}className={clsx('flex items-start gap-2 py-1.5 px-2 rounded-md text-sm transition-colors',todo.status === 'in_progress' && 'bg-accent-subtle',diff --git a/jiuwenclaw/web/src/components/TodoList/index.tsx b/jiuwenclaw/web/src/components/TodoList/index.tsxindex 9ad08ceab2..9130e87388 100644--- a/jiuwenclaw/web/src/components/TodoList/index.tsx+++ b/jiuwenclaw/web/src/components/TodoList/index.tsx@@ -29,7 +29,7 @@ export function TodoList() {const completed = todos.filter((t) => t.status === 'completed');return (- <div className="p-4 space-y-4">+ <div data-testid="todo-list" className="p-4 space-y-4"><h3 className="text-[11px] font-medium text-text-muted uppercase tracking-wider flex items-center justify-between"><span>{t('todoList.title')}</span><span className="px-1.5 py-0.5 bg-secondary rounded text-[10px]">{todos.length}</span>diff --git a/jiuwenclaw/web/src/components/ToolPanel/index.tsx b/jiuwenclaw/web/src/components/ToolPanel/index.tsxindex 1741d19b41..0fc92a05cf 100644--- a/jiuwenclaw/web/src/components/ToolPanel/index.tsx+++ b/jiuwenclaw/web/src/components/ToolPanel/index.tsx@@ -102,6 +102,7 @@ export function ToolPanel() {return (<div+ data-testid="tool-panel"className="bg-panel border-l border-border h-full overflow-hidden py-4 px-3 shrink-0"style={{ width: 'var(--tool-panel-width)' }}>diff --git a/jiuwenclaw/web/src/i18n/locales/en.json b/jiuwenclaw/web/src/i18n/locales/en.jsonindex 6a02a97d79..5d7635876a 100644--- a/jiuwenclaw/web/src/i18n/locales/en.json+++ b/jiuwenclaw/web/src/i18n/locales/en.json@@ -362,6 +362,8 @@"cancelCreate": "Cancel Create","update": "Update","delete": "Delete",+ "runNow": "Run Now",+ "previewAction": "Preview","enable": "Enable","disable": "Disable","loading": "Loading scheduled tasks...",@@ -399,7 +401,13 @@"created": "Task created successfully","updated": "Task updated successfully","deleted": "Task deleted successfully",- "statusUpdated": "Task status updated successfully"+ "statusUpdated": "Task status updated successfully",+ "runNow": "Task triggered successfully"+ },+ "preview": {+ "loading": "Loading next runs...",+ "empty": "No upcoming runs",+ "label": "Run {{index}}"},"errors": {"loadJobs": "Failed to load scheduled tasks",@@ -407,6 +415,8 @@"updateFailed": "Failed to update task","deleteFailed": "Failed to delete task","toggleFailed": "Failed to update task status",+ "previewFailed": "Failed to preview next runs",+ "runNowFailed": "Failed to trigger the task immediately","loadDetailFailed": "Failed to load task details","nameRequired": "Task name is required","cronRequired": "Cron expression is required",diff --git a/jiuwenclaw/web/src/i18n/locales/zh.json b/jiuwenclaw/web/src/i18n/locales/zh.jsonindex bccec67ff9..214f291569 100644--- a/jiuwenclaw/web/src/i18n/locales/zh.json+++ b/jiuwenclaw/web/src/i18n/locales/zh.json@@ -362,6 +362,8 @@"cancelCreate": "取消创建","update": "更新","delete": "删除",+ "runNow": "立即执行",+ "previewAction": "预览","enable": "启动","disable": "停用","loading": "正在加载任务列表...",@@ -399,7 +401,13 @@"created": "任务创建成功","updated": "任务更新成功","deleted": "任务删除成功",- "statusUpdated": "任务状态更新成功"+ "statusUpdated": "任务状态更新成功",+ "runNow": "任务已触发立即执行"+ },+ "preview": {+ "loading": "正在加载下次触发时间...",+ "empty": "暂无未来触发时间",+ "label": "第 {{index}} 次"},"errors": {"loadJobs": "加载定时任务失败",@@ -407,6 +415,8 @@"updateFailed": "更新任务失败","deleteFailed": "删除任务失败","toggleFailed": "更新任务状态失败",+ "previewFailed": "预览触发时间失败",+ "runNowFailed": "立即执行失败","loadDetailFailed": "获取任务详情失败","nameRequired": "任务名称不能为空","cronRequired": "Cron 表达式不能为空",