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): web端按照channel_id过滤cron_task
kdgmpw842300b8f4de
diff --git a/jiuwenswarm/channels/web/frontend/src/components/CronPanel/index.tsx b/jiuwenswarm/channels/web/frontend/src/components/CronPanel/index.tsxindex 5e44948d17..0cb23a0fc5 100644--- a/jiuwenswarm/channels/web/frontend/src/components/CronPanel/index.tsx+++ b/jiuwenswarm/channels/web/frontend/src/components/CronPanel/index.tsx@@ -3,7 +3,7 @@ import { useTranslation } from 'react-i18next';import { ChevronDown, Search, TrendingUp, Newspaper, Briefcase } from 'lucide-react';import { webRequest, webClient } from '../../services/webClient';import { useSessionStore } from '../../stores/sessionStore';-import { useCronStore } from '../../stores';+import { useCronStore, isWebChannelJob } from '../../stores';import { projectRegistryClient } from '../../features/workspace/projectRegistryClient';import type { ProjectInfo } from '../../features/workspace/projectTypes';import type { Session } from '../../types';@@ -163,7 +163,9 @@ export default function CronPanel({ sessionId, onCreateViaChat, onSelectSessionsetError(null);try {const payload = await webRequest<{ jobs: CronJobDTO[] }>('cron.job.list');- setJobs((payload.jobs || []).map((j) => cronJobToUI(j, projectList)));+ // Web 端工作区只展示 targets 含 "web" 的定时任务(targets 为空按后端 normalize 默认 web)+ const webJobs = (payload.jobs || []).filter((j) => isWebChannelJob(j.targets));+ setJobs(webJobs.map((j) => cronJobToUI(j, projectList)));} catch (loadError) {const message = loadError instanceof Error ? loadError.message : t('cron.errors.loadJobs');setError(message);diff --git a/jiuwenswarm/channels/web/frontend/src/stores/cronStore.ts b/jiuwenswarm/channels/web/frontend/src/stores/cronStore.tsindex 1b72c00fda..ed4badad91 100644--- a/jiuwenswarm/channels/web/frontend/src/stores/cronStore.ts+++ b/jiuwenswarm/channels/web/frontend/src/stores/cronStore.ts@@ -11,10 +11,19 @@ export interface SidebarCronJob {cron_expr: string;project_id: string;session_id?: string;+ // 推送频道 ID,字符串或逗号分隔的多个(对齐后端 CronJob.to_dict().targets);空串按后端默认 web+ targets?: string;created_at: number | string | null;updated_at: number | string | null;}+/** 判断 cron job 的 targets 是否含 "web"(空串按后端 normalize 默认 web 处理) */+export function isWebChannelJob(targets?: string): boolean {+ const s = (targets ?? '').trim();+ if (!s) return true;+ return s.split(',').some((p) => p.trim().toLowerCase() === 'web');+}+interface CronState {jobs: SidebarCronJob[];isLoading: boolean;@@ -41,7 +50,9 @@ export const useCronStore = create<CronState>((set, get) => ({set({ isLoading: true });try {const payload = await webRequest<{ jobs: SidebarCronJob[] }>('cron.job.list');- set({ jobs: payload.jobs || [], isLoading: false });+ // 侧边栏是 Web 端工作区,只展示 targets 含 "web" 的定时任务+ const webJobs = (payload.jobs || []).filter((j) => isWebChannelJob(j.targets));+ set({ jobs: webJobs, isLoading: false });} catch {set({ jobs: [], isLoading: false });}diff --git a/jiuwenswarm/channels/web/frontend/src/stores/index.ts b/jiuwenswarm/channels/web/frontend/src/stores/index.tsindex de398b8f47..8d33e0b969 100644--- a/jiuwenswarm/channels/web/frontend/src/stores/index.ts+++ b/jiuwenswarm/channels/web/frontend/src/stores/index.ts@@ -9,6 +9,6 @@ export { useSessionStore } from './sessionStore';export { PROJECT_SESSION_PAGE_SIZE, useWorkspaceStore } from './workspaceStore';export { useHarnessStore } from './harnessStore';export { ensureSessionRuntimes } from './ensureSessionRuntimes';-export { useCronStore, filterJobsForProject, isDefaultProjectId } from './cronStore';+export { useCronStore, filterJobsForProject, isDefaultProjectId, isWebChannelJob } from './cronStore';export type { SidebarCronJob } from './cronStore';export type { HarnessStageInfo, HarnessStageStatus, CachedFileTreeEntry } from './harnessStore';