Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
feat(cos): redesign schedule page with per-app granular config
Adam Eivy7edce22ce04b
diff --git a/.changelog/v0.16.x.md b/.changelog/v0.16.x.mdindex 89c3c34dbc..ef7bcf93b1 100644--- a/.changelog/v0.16.x.md+++ b/.changelog/v0.16.x.md@@ -54,3 +54,14 @@ Agent persistence, reliability, and decision transparency improvements.- **Model tier metrics drifted from reality** -- `resetTaskTypeLearning()` subtracted counts from `byTaskType`, `errorPatterns`, `routingAccuracy`, and `totals`, but never touched `byModelTier`; after rehabilitation resets, the heavy tier showed 653 completed / 3 succeeded (0.46% success) due to accumulated historical data that was cleared from other structures but not from tier metrics- **Now subtracts routing accuracy data from byModelTier** -- when a task type is reset, its per-tier succeeded/failed counts are decremented from the corresponding `byModelTier` entries, with duration estimated proportionally from the task type's average- **Empty tiers cleaned up** -- if a tier's completed count reaches zero after subtraction, the tier entry is removed entirely++## Features++### Redesigned CoS Schedule page with per-app granular config+- **Segmented control** replaces three stacked sections -- pill toggle at top switches between Self-Improvement and App Improvement panels, stored as `?view=self|app` query param for deep-linking+- **Per-app interval overrides** -- each app can now customize its task interval (Inherit, Rotation, Daily, Weekly, Once, On Demand) instead of binary enable/disable only+- **Inline per-app controls** -- expanding an app-improvement task row shows both global defaults and per-app overrides in one place, eliminating the disconnected bottom table+- **Coverage badges** -- collapsed app-improvement rows show `5/8 apps enabled` at a glance+- **Data model migrated** -- `app.disabledTaskTypes` (string array) replaced with `app.taskTypeOverrides` (object with `enabled` + optional `interval` per task type); existing data auto-migrates on first load+- **Eliminated N+1 fetch** -- schedule status API now returns `appOverrides`, `enabledAppCount`, and `totalAppCount` per task type, removing the need for separate per-app API calls on mount+- **Removed PerAppOverrides component** -- replaced by inline `PerAppOverrideList` within each task rowdiff --git a/client/src/components/cos/tabs/ScheduleTab.jsx b/client/src/components/cos/tabs/ScheduleTab.jsxindex 820a91497f..450a4ed92e 100644--- a/client/src/components/cos/tabs/ScheduleTab.jsx+++ b/client/src/components/cos/tabs/ScheduleTab.jsx@@ -1,5 +1,6 @@import { useState, useEffect, useCallback, useRef } from 'react';-import { Clock, Play, RotateCcw, ChevronDown, ChevronRight, CheckCircle, XCircle, AlertCircle, RefreshCw, Package, Settings2 } from 'lucide-react';+import { useSearchParams } from 'react-router-dom';+import { Clock, Play, RotateCcw, ChevronDown, ChevronRight, CheckCircle, XCircle, AlertCircle, RefreshCw, Package } from 'lucide-react';import toast from 'react-hot-toast';import * as api from '../../../services/api';@@ -33,9 +34,71 @@ function formatTimeRemaining(ms) {return `${minutes}m`;}-function TaskTypeRow({ taskType, config, onUpdate, onTrigger, onReset, category, providers, apps }) {- const [expanded, setExpanded] = useState(false);- const [updating, setUpdating] = useState(false);+function IntervalBadge({ type }) {+ return (+ <span className={`text-xs px-2 py-0.5 rounded ${+ type === 'daily' ? 'bg-port-accent/20 text-port-accent' :+ type === 'weekly' ? 'bg-purple-500/20 text-purple-400' :+ type === 'once' ? 'bg-port-warning/20 text-port-warning' :+ type === 'on-demand' ? 'bg-gray-500/20 text-gray-400' :+ 'bg-port-success/20 text-port-success'+ }`}>+ {INTERVAL_LABELS[type]}+ </span>+ );+}++function StatusIndicator({ config }) {+ const status = config.status || {};+ const isEligible = status.shouldRun;+ const nextRunText = status.nextRunAt+ ? formatTimeRemaining(new Date(status.nextRunAt).getTime() - Date.now())+ : null;++ if (isEligible) {+ return (+ <span className="flex items-center gap-1 text-xs text-port-success">+ <CheckCircle size={12} />+ Ready+ </span>+ );+ }+ if (status.reason === 'disabled') {+ return (+ <span className="flex items-center gap-1 text-xs text-gray-500">+ <XCircle size={12} />+ Disabled+ </span>+ );+ }+ if (status.reason === 'on-demand-only') {+ return (+ <span className="flex items-center gap-1 text-xs text-port-accent">+ <Clock size={12} />+ On Demand+ </span>+ );+ }+ if (status.reason === 'once-completed') {+ return (+ <span className="flex items-center gap-1 text-xs text-port-warning">+ <CheckCircle size={12} />+ Completed+ </span>+ );+ }+ if (nextRunText) {+ return (+ <span className="flex items-center gap-1 text-xs text-gray-400">+ <Clock size={12} />+ {nextRunText}+ </span>+ );+ }+ return null;+}++function GlobalConfigControls({ taskType, config, onUpdate, onTrigger, onReset, category, providers, apps, updating, setUpdating }) {const [selectedType, setSelectedType] = useState(config.type);const [selectedProviderId, setSelectedProviderId] = useState(config.providerId || '');const [selectedModel, setSelectedModel] = useState(config.model || '');@@ -44,18 +107,15 @@ function TaskTypeRow({ taskType, config, onUpdate, onTrigger, onReset, category,const [showAppSelector, setShowAppSelector] = useState(false);const appSelectorRef = useRef(null);- // Keep local selections in sync with external config updatesuseEffect(() => {setSelectedType(config.type);setSelectedProviderId(config.providerId || '');setSelectedModel(config.model || '');- // Only overwrite the prompt when the user is not actively editing itif (!editingPrompt) {setPromptValue(config.prompt || '');}}, [config.type, config.providerId, config.model, config.prompt, editingPrompt]);- // Close app selector when clicking outsideuseEffect(() => {const handleClickOutside = (event) => {if (appSelectorRef.current && !appSelectorRef.current.contains(event.target)) {@@ -68,12 +128,6 @@ function TaskTypeRow({ taskType, config, onUpdate, onTrigger, onReset, category,}}, [showAppSelector]);- const handleSelectApp = (appId) => {- onTrigger(taskType, appId);- setShowAppSelector(false);- };-- // Get active apps (non-archived) for app improvement tasksconst activeApps = apps?.filter(app => !app.archived) || [];const handleTypeChange = async (newType) => {@@ -94,7 +148,6 @@ function TaskTypeRow({ taskType, config, onUpdate, onTrigger, onReset, category,const handleProviderChange = async (newProviderId) => {setUpdating(true);setSelectedProviderId(newProviderId);- // Reset model when provider changes to avoid stale/invalid model selectionsetSelectedModel('');const providerId = newProviderId === '' ? null : newProviderId;await onUpdate(taskType, { providerId, model: null }).catch(() => {@@ -124,19 +177,199 @@ function TaskTypeRow({ taskType, config, onUpdate, onTrigger, onReset, category,setUpdating(false);};- const handleCancelPromptEdit = () => {- setPromptValue(config.prompt || '');- setEditingPrompt(false);- };-const selectedProvider = providers?.find(p => p.id === (selectedProviderId || ''));const availableModels = selectedProvider?.models || [];-const status = config.status || {};- const isEligible = status.shouldRun;- const nextRunText = status.nextRunAt- ? formatTimeRemaining(new Date(status.nextRunAt).getTime() - Date.now())- : null;++ return (+ <div className="space-y-4">+ <div className="flex items-center justify-between">+ <label className="text-sm text-gray-400">Enabled</label>+ <button+ onClick={handleToggleEnabled}+ disabled={updating}+ className={`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${+ config.enabled ? 'bg-port-accent' : 'bg-gray-600'+ }`}+ aria-label={config.enabled ? 'Disable task' : 'Enable task'}+ >+ <span className={`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${+ config.enabled ? 'translate-x-6' : 'translate-x-1'+ }`} />+ </button>+ </div>++ <div>+ <label className="text-sm text-gray-400 block mb-2">Interval Type</label>+ <select+ value={selectedType}+ onChange={(e) => handleTypeChange(e.target.value)}+ disabled={updating}+ className="w-full bg-port-card border border-port-border rounded px-3 py-2 text-white text-sm"+ >+ <option value="rotation">Rotation (runs in task queue)</option>+ <option value="daily">Daily (once per day)</option>+ <option value="weekly">Weekly (once per week)</option>+ <option value="once">Once (run once then stop)</option>+ <option value="on-demand">On Demand (manual trigger only)</option>+ </select>+ <p className="text-xs text-gray-500 mt-1">{INTERVAL_DESCRIPTIONS[selectedType]}</p>+ </div>++ <div>+ <label className="text-sm text-gray-400 block mb-2">Provider (optional)</label>+ <select+ value={selectedProviderId}+ onChange={(e) => handleProviderChange(e.target.value)}+ disabled={updating}+ className="w-full bg-port-card border border-port-border rounded px-3 py-2 text-white text-sm"+ >+ <option value="">Default (active provider)</option>+ {providers?.map(provider => (+ <option key={provider.id} value={provider.id}>{provider.name}</option>+ ))}+ </select>+ <p className="text-xs text-gray-500 mt-1">Leave as default to use the currently active provider</p>+ </div>++ <div>+ <label className="text-sm text-gray-400 block mb-2">Model (optional)</label>+ <select+ value={selectedModel}+ onChange={(e) => handleModelChange(e.target.value)}+ disabled={updating}+ className="w-full bg-port-card border border-port-border rounded px-3 py-2 text-white text-sm"+ >+ <option value="">Default model</option>+ {selectedModel && !availableModels.includes(selectedModel) && (+ <option value={selectedModel}>{selectedModel}</option>+ )}+ {availableModels.map(model => (+ <option key={model} value={model}>{model}</option>+ ))}+ </select>+ <p className="text-xs text-gray-500 mt-1">Leave as default to use the provider's default model</p>+ </div>++ <div>+ <div className="flex items-center justify-between mb-2">+ <label className="text-sm text-gray-400">Task Prompt</label>+ {!editingPrompt && (+ <button onClick={() => setEditingPrompt(true)} className="text-xs text-port-accent hover:text-port-accent/80">Edit</button>+ )}+ </div>+ {editingPrompt ? (+ <div className="space-y-2">+ <textarea+ value={promptValue}+ onChange={(e) => setPromptValue(e.target.value)}+ disabled={updating}+ rows={12}+ className="w-full bg-port-bg border border-port-border rounded px-3 py-2 text-white text-sm font-mono"+ placeholder="Enter task prompt"+ />+ <div className="flex gap-2">+ <button+ onClick={handleSavePrompt}+ disabled={updating}+ className="px-3 py-1.5 text-sm bg-port-accent hover:bg-port-accent/80 text-white rounded transition-colors"+ >+ Save Prompt+ </button>+ <button+ onClick={() => { setPromptValue(config.prompt || ''); setEditingPrompt(false); }}+ disabled={updating}+ className="px-3 py-1.5 text-sm bg-port-border hover:bg-port-border/80 text-white rounded transition-colors"+ >+ Cancel+ </button>+ </div>+ {category === 'appImprovement' && (+ <p className="text-xs text-gray-500">+ Use <code className="bg-port-border px-1 rounded">{'{appName}'}</code> and <code className="bg-port-border px-1 rounded">{'{repoPath}'}</code> as placeholders.+ </p>+ )}+ </div>+ ) : (+ <div+ className="bg-port-bg border border-port-border rounded px-3 py-2 text-xs text-gray-400 font-mono max-h-32 overflow-y-auto cursor-pointer hover:border-port-accent/50"+ onClick={() => setEditingPrompt(true)}+ title="Click to edit prompt"+ >+ <pre className="whitespace-pre-wrap">{promptValue || 'No prompt configured'}</pre>+ </div>+ )}+ </div>++ <div className="flex gap-2">+ {category === 'appImprovement' && activeApps.length > 0 ? (+ <div className="relative" ref={appSelectorRef}>+ <button+ onClick={() => setShowAppSelector(!showAppSelector)}+ className="flex items-center gap-1 px-3 py-1.5 text-sm bg-port-accent/20 hover:bg-port-accent/30 text-port-accent rounded transition-colors"+ title="Run this task on a specific app"+ >+ <Play size={14} />+ Run on App+ <ChevronDown size={12} className={`transition-transform ${showAppSelector ? 'rotate-180' : ''}`} />+ </button>+ {showAppSelector && (+ <div className="absolute bottom-full left-0 mb-1 z-50 w-64 max-w-[calc(100vw-2rem)] max-h-64 overflow-y-auto bg-port-card border border-port-border rounded-lg shadow-lg">+ <div className="p-2 border-b border-port-border">+ <span className="text-xs text-gray-400">Select an app to run {taskType} on:</span>+ </div>+ <div className="py-1">+ {activeApps.map(app => (+ <button+ key={app.id}+ onClick={() => { onTrigger(taskType, app.id); setShowAppSelector(false); }}+ className="w-full px-3 py-2 text-left text-sm hover:bg-port-border/50 flex items-center gap-2 min-h-[40px]"+ >+ <Package size={14} className="text-gray-400 flex-shrink-0" />+ <div className="min-w-0 flex-1">+ <div className="text-white truncate">{app.name}</div>+ {app.repoPath && <div className="text-xs text-gray-500 truncate">{app.repoPath}</div>}+ </div>+ </button>+ ))}+ </div>+ </div>+ )}+ </div>+ ) : (+ <button+ onClick={() => onTrigger(taskType)}+ className="flex items-center gap-1 px-3 py-1.5 text-sm bg-port-accent/20 hover:bg-port-accent/30 text-port-accent rounded transition-colors"+ title="Run this task immediately (bypasses schedule)"+ >+ <Play size={14} />+ Run Now+ </button>+ )}+ {config.type === 'once' && status.reason === 'once-completed' && (+ <button+ onClick={() => onReset(taskType)}+ className="flex items-center gap-1 px-3 py-1.5 text-sm bg-port-warning/20 hover:bg-port-warning/30 text-port-warning rounded transition-colors"+ title="Reset execution history to run this task again"+ >+ <RotateCcw size={14} />+ Reset+ </button>+ )}+ </div>++ {status.completedAt && (+ <div className="text-xs text-gray-500">+ Completed: {new Date(status.completedAt).toLocaleString()}+ </div>+ )}+ </div>+ );+}++function TaskTypeRow({ taskType, config, onUpdate, onTrigger, onReset, category, providers, apps }) {+ const [expanded, setExpanded] = useState(false);+ const [updating, setUpdating] = useState(false);return (<div className="border border-port-border rounded-lg">@@ -167,253 +400,196 @@ function TaskTypeRow({ taskType, config, onUpdate, onTrigger, onReset, category,</div><div className="flex items-center gap-2">- {isEligible ? (- <span className="flex items-center gap-1 text-xs text-port-success">- <CheckCircle size={12} />- Ready- </span>- ) : status.reason === 'disabled' ? (- <span className="flex items-center gap-1 text-xs text-gray-500">- <XCircle size={12} />- Disabled- </span>- ) : status.reason === 'on-demand-only' ? (- <span className="flex items-center gap-1 text-xs text-port-accent">- <Clock size={12} />- On Demand- </span>- ) : status.reason === 'once-completed' ? (- <span className="flex items-center gap-1 text-xs text-port-warning">- <CheckCircle size={12} />- Completed- </span>- ) : nextRunText ? (- <span className="flex items-center gap-1 text-xs text-gray-400">- <Clock size={12} />- {nextRunText}- </span>- ) : null}-- <span className={`text-xs px-2 py-0.5 rounded ${- config.type === 'daily' ? 'bg-port-accent/20 text-port-accent' :- config.type === 'weekly' ? 'bg-purple-500/20 text-purple-400' :- config.type === 'once' ? 'bg-port-warning/20 text-port-warning' :- config.type === 'on-demand' ? 'bg-gray-500/20 text-gray-400' :- 'bg-port-success/20 text-port-success'- }`}>- {INTERVAL_LABELS[config.type]}- </span>+ <StatusIndicator config={config} />+ <IntervalBadge type={config.type} /></div></div>{expanded && (- <div className="p-4 border-t border-port-border bg-port-bg/50 space-y-4">- <div className="flex items-center justify-between">- <label className="text-sm text-gray-400">Enabled</label>- <button- onClick={handleToggleEnabled}- disabled={updating}- className={`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${- config.enabled ? 'bg-port-accent' : 'bg-gray-600'- }`}- aria-label={config.enabled ? 'Disable task' : 'Enable task'}- >- <span- className={`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${- config.enabled ? 'translate-x-6' : 'translate-x-1'- }`}- />- </button>- </div>+ <div className="p-4 border-t border-port-border bg-port-bg/50">+ <GlobalConfigControls+ taskType={taskType}+ config={config}+ onUpdate={onUpdate}+ onTrigger={onTrigger}+ onReset={onReset}+ category={category}+ providers={providers}+ apps={apps}+ updating={updating}+ setUpdating={setUpdating}+ />+ </div>+ )}+ </div>+ );+}- <div>- <label className="text-sm text-gray-400 block mb-2">Interval Type</label>- <select- value={selectedType}- onChange={(e) => handleTypeChange(e.target.value)}- disabled={updating}- className="w-full bg-port-card border border-port-border rounded px-3 py-2 text-white text-sm"- >- <option value="rotation">Rotation (runs in task queue)</option>- <option value="daily">Daily (once per day)</option>- <option value="weekly">Weekly (once per week)</option>- <option value="once">Once (run once then stop)</option>- <option value="on-demand">On Demand (manual trigger only)</option>- </select>- <p className="text-xs text-gray-500 mt-1">{INTERVAL_DESCRIPTIONS[selectedType]}</p>- </div>+function AppOverrideRow({ app, taskType, globalIntervalType, override, onUpdate }) {+ const [updating, setUpdating] = useState(false);+ const isEnabled = override?.enabled !== false;+ const currentInterval = override?.interval || null;- <div>- <label className="text-sm text-gray-400 block mb-2">Provider (optional)</label>- <select- value={selectedProviderId}- onChange={(e) => handleProviderChange(e.target.value)}- disabled={updating}- className="w-full bg-port-card border border-port-border rounded px-3 py-2 text-white text-sm"- >- <option value="">Default (active provider)</option>- {providers?.map(provider => (- <option key={provider.id} value={provider.id}>- {provider.name}- </option>- ))}- </select>- <p className="text-xs text-gray-500 mt-1">- Leave as default to use the currently active provider- </p>- </div>+ const handleToggle = async () => {+ setUpdating(true);+ await onUpdate(app.id, taskType, { enabled: !isEnabled, interval: currentInterval }).catch(() => {});+ setUpdating(false);+ };- <div>- <label className="text-sm text-gray-400 block mb-2">Model (optional)</label>- <select- value={selectedModel}- onChange={(e) => handleModelChange(e.target.value)}- disabled={updating}- className="w-full bg-port-card border border-port-border rounded px-3 py-2 text-white text-sm"- >- <option value="">Default model</option>- {/* Show current model even if not in availableModels (e.g., provider not loaded yet) */}- {selectedModel && !availableModels.includes(selectedModel) && (- <option value={selectedModel}>{selectedModel}</option>- )}- {availableModels.map(model => (- <option key={model} value={model}>- {model}- </option>- ))}- </select>- <p className="text-xs text-gray-500 mt-1">- Leave as default to use the provider's default model- </p>- </div>+ const handleIntervalChange = async (newInterval) => {+ setUpdating(true);+ const interval = newInterval === '' ? null : newInterval;+ await onUpdate(app.id, taskType, { enabled: isEnabled, interval }).catch(() => {});+ setUpdating(false);+ };- <div>- <div className="flex items-center justify-between mb-2">- <label className="text-sm text-gray-400">Task Prompt</label>- {!editingPrompt && (- <button- onClick={() => setEditingPrompt(true)}- className="text-xs text-port-accent hover:text-port-accent/80"- >- Edit- </button>- )}- </div>- {editingPrompt ? (- <div className="space-y-2">- <textarea- value={promptValue}- onChange={(e) => setPromptValue(e.target.value)}- disabled={updating}- rows={12}- className="w-full bg-port-bg border border-port-border rounded px-3 py-2 text-white text-sm font-mono"- placeholder="Enter task prompt"- />- <div className="flex gap-2">- <button- onClick={handleSavePrompt}- disabled={updating}- className="px-3 py-1.5 text-sm bg-port-accent hover:bg-port-accent/80 text-white rounded transition-colors"- >- Save Prompt- </button>- <button- onClick={handleCancelPromptEdit}- disabled={updating}- className="px-3 py-1.5 text-sm bg-port-border hover:bg-port-border/80 text-white rounded transition-colors"- >- Cancel- </button>- </div>- <p className="text-xs text-gray-500">- For app improvement tasks, use <code className="bg-port-border px-1 rounded">{'{appName}'}</code> and <code className="bg-port-border px-1 rounded">{'{repoPath}'}</code> as placeholders.- </p>- </div>- ) : (- <div- className="bg-port-bg border border-port-border rounded px-3 py-2 text-xs text-gray-400 font-mono max-h-32 overflow-y-auto cursor-pointer hover:border-port-accent/50"- onClick={() => setEditingPrompt(true)}- title="Click to edit prompt"- >- <pre className="whitespace-pre-wrap">{promptValue || 'No prompt configured'}</pre>- </div>- )}- </div>+ return (+ <div className="flex items-center gap-3 py-2 px-3 rounded hover:bg-port-card/30">+ <div className="flex items-center gap-2 min-w-0 flex-1">+ {app.icon ? (+ <span className="text-base flex-shrink-0">{app.icon}</span>+ ) : (+ <Package size={14} className="text-gray-500 flex-shrink-0" />+ )}+ <span className="text-sm text-white truncate">{app.name}</span>+ </div>- <div className="flex gap-2">- {category === 'appImprovement' && activeApps.length > 0 ? (- <div className="relative" ref={appSelectorRef}>- <button- onClick={() => setShowAppSelector(!showAppSelector)}- className="flex items-center gap-1 px-3 py-1.5 text-sm bg-port-accent/20 hover:bg-port-accent/30 text-port-accent rounded transition-colors"- title="Run this task on a specific app"- >- <Play size={14} />- Run on App- <ChevronDown size={12} className={`transition-transform ${showAppSelector ? 'rotate-180' : ''}`} />- </button>- {showAppSelector && (- <div className="absolute bottom-full left-0 mb-1 z-50 w-64 max-w-[calc(100vw-2rem)] max-h-64 overflow-y-auto bg-port-card border border-port-border rounded-lg shadow-lg">- <div className="p-2 border-b border-port-border">- <span className="text-xs text-gray-400">Select an app to run {taskType} on:</span>- </div>- <div className="py-1">- {activeApps.map(app => (- <button- key={app.id}- onClick={() => handleSelectApp(app.id)}- className="w-full px-3 py-2 text-left text-sm hover:bg-port-border/50 flex items-center gap-2 min-h-[40px]"- >- <Package size={14} className="text-gray-400 flex-shrink-0" />- <div className="min-w-0 flex-1">- <div className="text-white truncate">{app.name}</div>- {app.repoPath && (- <div className="text-xs text-gray-500 truncate">{app.repoPath}</div>- )}- </div>- </button>- ))}- </div>- </div>- )}- </div>- ) : (- <button- onClick={() => onTrigger(taskType)}- className="flex items-center gap-1 px-3 py-1.5 text-sm bg-port-accent/20 hover:bg-port-accent/30 text-port-accent rounded transition-colors"- title="Run this task immediately (bypasses schedule)"- >- <Play size={14} />- Run Now- </button>- )}- {(config.type === 'once' && status.reason === 'once-completed') && (- <button- onClick={() => onReset(taskType)}- className="flex items-center gap-1 px-3 py-1.5 text-sm bg-port-warning/20 hover:bg-port-warning/30 text-port-warning rounded transition-colors"- title="Reset execution history to run this task again"- >- <RotateCcw size={14} />- Reset- </button>+ <select+ value={currentInterval || ''}+ onChange={(e) => handleIntervalChange(e.target.value)}+ disabled={updating}+ className="bg-port-card border border-port-border rounded px-2 py-1 text-xs text-white min-w-[140px]"+ >+ <option value="">Inherit ({INTERVAL_LABELS[globalIntervalType]})</option>+ <option value="rotation">Rotation</option>+ <option value="daily">Daily</option>+ <option value="weekly">Weekly</option>+ <option value="once">Once</option>+ <option value="on-demand">On Demand</option>+ </select>++ <button+ onClick={handleToggle}+ disabled={updating}+ className={`relative inline-flex h-5 w-9 items-center rounded-full transition-colors flex-shrink-0 ${+ isEnabled ? 'bg-port-accent' : 'bg-gray-600'+ } ${updating ? 'opacity-50' : ''}`}+ aria-label={`${isEnabled ? 'Disable' : 'Enable'} ${taskType} for ${app.name}`}+ >+ <span className={`inline-block h-3 w-3 transform rounded-full bg-white transition-transform ${+ isEnabled ? 'translate-x-5' : 'translate-x-1'+ }`} />+ </button>+ </div>+ );+}++function PerAppOverrideList({ taskType, config, apps, onUpdateOverride }) {+ const activeApps = apps?.filter(app => !app.archived) || [];+ const appOverrides = config.appOverrides || {};++ if (activeApps.length === 0) return null;++ return (+ <div>+ <h4 className="text-sm font-medium text-gray-400 mb-2">Per-App Overrides</h4>+ <div className="border border-port-border rounded-lg divide-y divide-port-border/50">+ {activeApps.map(app => (+ <AppOverrideRow+ key={app.id}+ app={app}+ taskType={taskType}+ globalIntervalType={config.type}+ override={appOverrides[app.id]}+ onUpdate={onUpdateOverride}+ />+ ))}+ </div>+ </div>+ );+}++function AppTaskTypeRow({ taskType, config, onUpdate, onTrigger, onReset, providers, apps, onUpdateOverride }) {+ const [expanded, setExpanded] = useState(false);+ const [updating, setUpdating] = useState(false);++ const enabledCount = config.enabledAppCount ?? 0;+ const totalCount = config.totalAppCount ?? 0;++ return (+ <div className="border border-port-border rounded-lg">+ <div+ className={`flex items-center gap-3 p-3 bg-port-card hover:bg-port-card/80 cursor-pointer ${expanded ? 'rounded-t-lg' : 'rounded-lg'}`}+ onClick={() => setExpanded(!expanded)}+ >+ <button+ className="text-gray-500 hover:text-white"+ onClick={(e) => { e.stopPropagation(); setExpanded(!expanded); }}+ aria-label={expanded ? 'Collapse' : 'Expand'}+ >+ {expanded ? <ChevronDown size={16} /> : <ChevronRight size={16} />}+ </button>++ <div className="flex-1 min-w-0">+ <div className="flex items-center gap-2">+ <span className="font-mono text-sm text-white">{taskType}</span>+ {!config.enabled && (+ <span className="text-xs px-2 py-0.5 bg-gray-600/50 text-gray-400 rounded">Disabled</span>)}</div>-- {status.completedAt && (+ {config.globalLastRun && (<div className="text-xs text-gray-500">- Completed: {new Date(status.completedAt).toLocaleString()}+ Last run: {new Date(config.globalLastRun).toLocaleDateString()} ({config.globalRunCount || 0} total)</div>)}</div>++ <div className="flex items-center gap-2">+ {totalCount > 0 && (+ <span className={`text-xs px-2 py-0.5 rounded ${+ enabledCount === totalCount ? 'bg-port-success/20 text-port-success' :+ enabledCount === 0 ? 'bg-port-error/20 text-port-error' :+ 'bg-port-warning/20 text-port-warning'+ }`}>+ {enabledCount}/{totalCount} apps+ </span>+ )}+ <IntervalBadge type={config.type} />+ </div>+ </div>++ {expanded && (+ <div className="p-4 border-t border-port-border bg-port-bg/50 space-y-6">+ <div>+ <h4 className="text-sm font-medium text-gray-400 mb-3">Global Defaults</h4>+ <GlobalConfigControls+ taskType={taskType}+ config={config}+ onUpdate={onUpdate}+ onTrigger={onTrigger}+ onReset={onReset}+ category="appImprovement"+ providers={providers}+ apps={apps}+ updating={updating}+ setUpdating={setUpdating}+ />+ </div>++ <PerAppOverrideList+ taskType={taskType}+ config={config}+ apps={apps}+ onUpdateOverride={onUpdateOverride}+ />+ </div>)}</div>);}function TaskTypeSection({ title, description, tasks, onUpdate, onTrigger, onReset, category, providers, apps }) {- const [collapsed, setCollapsed] = useState(false);const taskEntries = Object.entries(tasks || {});-if (taskEntries.length === 0) return null;const enabledCount = taskEntries.filter(([, config]) => config.enabled).length;@@ -421,201 +597,84 @@ function TaskTypeSection({ title, description, tasks, onUpdate, onTrigger, onResreturn (<div className="space-y-3">- <button- onClick={() => setCollapsed(!collapsed)}- className="flex items-center gap-2 w-full text-left"- >- {collapsed ? <ChevronRight size={18} /> : <ChevronDown size={18} />}+ <div className="flex items-center gap-2"><h3 className="text-lg font-semibold text-white">{title}</h3><span className="text-xs text-gray-500">{enabledCount} enabled, {readyCount} ready</span>- </button>- {description && !collapsed && (- <p className="text-sm text-gray-400 ml-2 sm:ml-6">{description}</p>- )}- {!collapsed && (- <div className="space-y-2 ml-2 sm:ml-6">- {taskEntries.map(([taskType, config]) => (- <TaskTypeRow- key={taskType}- taskType={taskType}- config={config}- onUpdate={onUpdate}- onTrigger={onTrigger}- onReset={onReset}- category={category}- providers={providers}- apps={apps}- />- ))}- </div>- )}+ </div>+ {description && <p className="text-sm text-gray-400">{description}</p>}+ <div className="space-y-2">+ {taskEntries.map(([taskType, config]) => (+ <TaskTypeRow+ key={taskType}+ taskType={taskType}+ config={config}+ onUpdate={onUpdate}+ onTrigger={onTrigger}+ onReset={onReset}+ category={category}+ providers={providers}+ apps={apps}+ />+ ))}+ </div></div>);}-function PerAppOverrides({ apps, taskTypes }) {- const [collapsed, setCollapsed] = useState(false);- const [overrides, setOverrides] = useState({}); // { appId: [disabledTaskType, ...] }- const [updating, setUpdating] = useState(null); // 'appId:taskType' while toggling-- const activeApps = apps?.filter(app => !app.archived) || [];-- const fetchOverrides = useCallback(async () => {- const results = {};- await Promise.all(activeApps.map(async (app) => {- const data = await api.getAppTaskTypes(app.id).catch(() => null);- if (data) {- results[app.id] = data.disabledTaskTypes || [];- }- }));- setOverrides(results);- }, [activeApps.map(a => a.id).join(',')]);-- useEffect(() => {- if (activeApps.length > 0) fetchOverrides();- }, [fetchOverrides]);-- const handleToggle = async (appId, taskType, currentlyEnabled) => {- const key = `${appId}:${taskType}`;- setUpdating(key);- const result = await api.toggleAppTaskType(appId, taskType, !currentlyEnabled).catch(err => {- toast.error(err.message);- return null;- });- if (result?.success) {- setOverrides(prev => ({ ...prev, [appId]: result.disabledTaskTypes }));- const appName = activeApps.find(a => a.id === appId)?.name || appId;- toast.success(`${!currentlyEnabled ? 'Enabled' : 'Disabled'} ${taskType} for ${appName}`);- }- setUpdating(null);- };+function AppTaskTypeSection({ tasks, onUpdate, onTrigger, onReset, providers, apps, onUpdateOverride }) {+ const taskEntries = Object.entries(tasks || {});+ if (taskEntries.length === 0) return null;- if (activeApps.length === 0 || taskTypes.length === 0) return null;+ const enabledCount = taskEntries.filter(([, config]) => config.enabled).length;return (<div className="space-y-3">- <button- onClick={() => setCollapsed(!collapsed)}- className="flex items-center gap-2 w-full text-left"- >- {collapsed ? <ChevronRight size={18} /> : <ChevronDown size={18} />}- <Settings2 size={18} className="text-gray-400" />- <h3 className="text-lg font-semibold text-white">Per-App Task Type Overrides</h3>+ <div className="flex items-center gap-2">+ <h3 className="text-lg font-semibold text-white">App Improvement Tasks</h3><span className="text-xs text-gray-500">- {activeApps.length} apps+ {enabledCount} enabled</span>- </button>- {!collapsed && (- <>- <p className="text-sm text-gray-400 ml-2 sm:ml-6">- Enable or disable specific task types per app. Disabled task types will be skipped during scheduled runs for that app.- </p>- {/* Mobile: card layout per app */}- <div className="ml-2 sm:hidden space-y-2">- {activeApps.map(app => {- const disabled = overrides[app.id] || [];- return (- <div key={app.id} className="border border-port-border rounded-lg p-3 bg-port-card/50">- <div className="flex items-center gap-1.5 mb-2">- <Package size={14} className="text-gray-500 flex-shrink-0" />- <span className="text-sm font-mono text-white truncate">{app.name}</span>- </div>- <div className="space-y-1.5">- {taskTypes.map(tt => {- const isEnabled = !disabled.includes(tt);- const isUpdating = updating === `${app.id}:${tt}`;- return (- <div key={tt} className="flex items-center justify-between py-1">- <span className="text-xs text-gray-400 font-mono">{tt}</span>- <button- onClick={() => handleToggle(app.id, tt, isEnabled)}- disabled={isUpdating}- className={`relative inline-flex h-5 w-9 items-center rounded-full transition-colors flex-shrink-0 ${- isEnabled ? 'bg-port-accent' : 'bg-gray-600'- } ${isUpdating ? 'opacity-50' : ''}`}- title={`${isEnabled ? 'Disable' : 'Enable'} ${tt} for ${app.name}`}- aria-label={`${isEnabled ? 'Disable' : 'Enable'} ${tt} for ${app.name}`}- >- <span- className={`inline-block h-3 w-3 transform rounded-full bg-white transition-transform ${- isEnabled ? 'translate-x-5' : 'translate-x-1'- }`}- />- </button>- </div>- );- })}- </div>- </div>- );- })}- </div>- {/* Desktop: table layout */}- <div className="hidden sm:block ml-6 overflow-x-auto">- <table className="w-full text-sm min-w-[400px]">- <thead>- <tr className="border-b border-port-border">- <th className="text-left py-2 pr-4 text-gray-400 font-medium sticky left-0 bg-port-bg min-w-[140px]">App</th>- {taskTypes.map(tt => (- <th key={tt} className="px-2 py-2 text-gray-400 font-medium text-center whitespace-nowrap">- <span className="text-xs">{tt}</span>- </th>- ))}- </tr>- </thead>- <tbody>- {activeApps.map(app => {- const disabled = overrides[app.id] || [];- return (- <tr key={app.id} className="border-b border-port-border/50 hover:bg-port-card/30">- <td className="py-2 pr-4 text-white font-mono text-xs sticky left-0 bg-port-bg">- <div className="flex items-center gap-1.5">- <Package size={12} className="text-gray-500 flex-shrink-0" />- <span className="truncate max-w-[120px]" title={app.name}>{app.name}</span>- </div>- </td>- {taskTypes.map(tt => {- const isEnabled = !disabled.includes(tt);- const isUpdating = updating === `${app.id}:${tt}`;- return (- <td key={tt} className="px-2 py-2 text-center">- <button- onClick={() => handleToggle(app.id, tt, isEnabled)}- disabled={isUpdating}- className={`relative inline-flex h-5 w-9 items-center rounded-full transition-colors ${- isEnabled ? 'bg-port-accent' : 'bg-gray-600'- } ${isUpdating ? 'opacity-50' : ''}`}- title={`${isEnabled ? 'Disable' : 'Enable'} ${tt} for ${app.name}`}- aria-label={`${isEnabled ? 'Disable' : 'Enable'} ${tt} for ${app.name}`}- >- <span- className={`inline-block h-3 w-3 transform rounded-full bg-white transition-transform ${- isEnabled ? 'translate-x-5' : 'translate-x-1'- }`}- />- </button>- </td>- );- })}- </tr>- );- })}- </tbody>- </table>- </div>- </>- )}+ </div>+ <p className="text-sm text-gray-400">+ Tasks that analyze and improve managed applications. Expand a task to configure per-app overrides.+ </p>+ <div className="space-y-2">+ {taskEntries.map(([taskType, config]) => (+ <AppTaskTypeRow+ key={taskType}+ taskType={taskType}+ config={config}+ onUpdate={onUpdate}+ onTrigger={onTrigger}+ onReset={onReset}+ providers={providers}+ apps={apps}+ onUpdateOverride={onUpdateOverride}+ />+ ))}+ </div></div>);}export default function ScheduleTab({ apps }) {+ const [searchParams, setSearchParams] = useSearchParams();const [schedule, setSchedule] = useState(null);const [providers, setProviders] = useState(null);const [loading, setLoading] = useState(true);+ const activeView = searchParams.get('view') || 'self';++ const setView = useCallback((view) => {+ setSearchParams(prev => {+ const next = new URLSearchParams(prev);+ next.set('view', view);+ return next;+ }, { replace: true });+ }, [setSearchParams]);+const fetchSchedule = useCallback(async () => {const data = await api.getCosSchedule().catch(() => null);setSchedule(data);@@ -687,8 +746,8 @@ export default function ScheduleTab({ apps }) {}};- const handleResetAppImprovement = async (taskType, appId) => {- const result = await api.resetCosTaskHistory(taskType, 'appImprovement', appId).catch(err => {+ const handleResetAppImprovement = async (taskType) => {+ const result = await api.resetCosTaskHistory(taskType, 'appImprovement').catch(err => {toast.error(err.message);return null;});@@ -698,6 +757,18 @@ export default function ScheduleTab({ apps }) {}};+ const handleUpdateAppOverride = async (appId, taskType, { enabled, interval }) => {+ const result = await api.updateAppTaskTypeOverride(appId, taskType, { enabled, interval }).catch(err => {+ toast.error(err.message);+ return null;+ });+ if (result?.success) {+ const appName = apps?.find(a => a.id === appId)?.name || appId;+ toast.success(`Updated ${taskType} override for ${appName}`);+ fetchSchedule();+ }+ };+if (loading) {return (<div className="flex items-center justify-center h-64">@@ -716,12 +787,12 @@ export default function ScheduleTab({ apps }) {}return (- <div className="space-y-8">+ <div className="space-y-6"><div className="flex items-center justify-between"><div><h2 className="text-xl font-semibold text-white">Task Schedule</h2><p className="text-sm text-gray-400 mt-1">- Configure how often each task type runs. Set intervals to daily, weekly, once, or on-demand.+ Configure how often each task type runs.</p></div><button@@ -734,6 +805,30 @@ export default function ScheduleTab({ apps }) {</button></div>+ {/* Segmented Control */}+ <div className="flex bg-port-card rounded-lg p-1 border border-port-border">+ <button+ onClick={() => setView('self')}+ className={`flex-1 px-4 py-2 text-sm font-medium rounded-md transition-colors ${+ activeView === 'self'+ ? 'bg-port-accent text-white'+ : 'text-gray-400 hover:text-white'+ }`}+ >+ Self-Improvement+ </button>+ <button+ onClick={() => setView('app')}+ className={`flex-1 px-4 py-2 text-sm font-medium rounded-md transition-colors ${+ activeView === 'app'+ ? 'bg-port-accent text-white'+ : 'text-gray-400 hover:text-white'+ }`}+ >+ App Improvement+ </button>+ </div>+{schedule.onDemandRequests?.length > 0 && (<div className="bg-port-accent/10 border border-port-accent/30 rounded-lg p-4"><h4 className="text-sm font-medium text-port-accent mb-2">Pending On-Demand Tasks</h4>@@ -747,33 +842,30 @@ export default function ScheduleTab({ apps }) {</div>)}- <TaskTypeSection- title="Self-Improvement Tasks"- description="Tasks that analyze and improve PortOS itself"- tasks={schedule.selfImprovement}- onUpdate={handleUpdateSelfImprovement}- onTrigger={handleTriggerSelfImprovement}- onReset={handleResetSelfImprovement}- category="selfImprovement"- providers={providers}- />-- <TaskTypeSection- title="App Improvement Tasks"- description="Tasks that analyze and improve managed applications"- tasks={schedule.appImprovement}- onUpdate={handleUpdateAppImprovement}- onTrigger={(taskType, appId) => handleTriggerAppImprovement(taskType, appId)}- onReset={(taskType) => handleResetAppImprovement(taskType, null)}- category="appImprovement"- providers={providers}- apps={apps}- />-- <PerAppOverrides- apps={apps}- taskTypes={Object.keys(schedule.appImprovement || {})}- />+ {activeView === 'self' && (+ <TaskTypeSection+ title="Self-Improvement Tasks"+ description="Tasks that analyze and improve PortOS itself"+ tasks={schedule.selfImprovement}+ onUpdate={handleUpdateSelfImprovement}+ onTrigger={handleTriggerSelfImprovement}+ onReset={handleResetSelfImprovement}+ category="selfImprovement"+ providers={providers}+ />+ )}++ {activeView === 'app' && (+ <AppTaskTypeSection+ tasks={schedule.appImprovement}+ onUpdate={handleUpdateAppImprovement}+ onTrigger={handleTriggerAppImprovement}+ onReset={handleResetAppImprovement}+ providers={providers}+ apps={apps}+ onUpdateOverride={handleUpdateAppOverride}+ />+ )}{schedule.lastUpdated && (<div className="text-xs text-gray-500 text-right">diff --git a/client/src/services/api.js b/client/src/services/api.jsindex cb5e04444d..e1d4952cb4 100644--- a/client/src/services/api.js+++ b/client/src/services/api.js@@ -65,9 +65,9 @@ export const openAppFolder = (id) => request(`/apps/${id}/open-folder`, { methodexport const refreshAppConfig = (id) => request(`/apps/${id}/refresh-config`, { method: 'POST' });export const getAppStatus = (id) => request(`/apps/${id}/status`);export const getAppTaskTypes = (id) => request(`/apps/${id}/task-types`);-export const toggleAppTaskType = (id, taskType, enabled) => request(`/apps/${id}/task-types/${taskType}`, {+export const updateAppTaskTypeOverride = (id, taskType, { enabled, interval } = {}) => request(`/apps/${id}/task-types/${taskType}`, {method: 'PUT',- body: JSON.stringify({ enabled })+ body: JSON.stringify({ enabled, interval })});export const getAppLogs = (id, lines = 100, processName) => {const params = new URLSearchParams({ lines: String(lines) });diff --git a/server/lib/validation.js b/server/lib/validation.jsindex e9fbbdb929..df62ab2fed 100644--- a/server/lib/validation.js+++ b/server/lib/validation.js@@ -180,7 +180,11 @@ export const appSchema = z.object({description: z.string().optional(),archived: z.boolean().optional().default(false),pm2Home: z.string().optional(), // Custom PM2_HOME path for apps that run in their own PM2 instance- disabledTaskTypes: z.array(z.string()).optional(), // Task types disabled for this app (e.g., ['typing', 'accessibility'])+ disabledTaskTypes: z.array(z.string()).optional(), // Legacy: migrated to taskTypeOverrides+ taskTypeOverrides: z.record(z.object({+ enabled: z.boolean().optional(),+ interval: z.string().nullable().optional()+ })).optional(), // Per-task overrides: { [taskType]: { enabled, interval } }jira: jiraConfigSchema.optional().nullable()});diff --git a/server/routes/apps.js b/server/routes/apps.jsindex d3a918687e..8034c3c690 100644--- a/server/routes/apps.js+++ b/server/routes/apps.js@@ -176,23 +176,25 @@ router.post('/:id/unarchive', asyncHandler(async (req, res) => {// GET /api/apps/:id/task-types - Get per-app task type overridesrouter.get('/:id/task-types', loadApp, asyncHandler(async (req, res) => {const app = req.loadedApp;- res.json({ appId: app.id, appName: app.name, disabledTaskTypes: app.disabledTaskTypes || [] });+ const overrides = await appsService.getAppTaskTypeOverrides(app.id);+ res.json({ appId: app.id, appName: app.name, taskTypeOverrides: overrides });}));-// PUT /api/apps/:id/task-types/:taskType - Toggle a task type for an app+// PUT /api/apps/:id/task-types/:taskType - Update a task type override for an approuter.put('/:id/task-types/:taskType', asyncHandler(async (req, res) => {- const { enabled } = req.body;- if (typeof enabled !== 'boolean') {- throw new ServerError('enabled must be a boolean', { status: 400, code: 'VALIDATION_ERROR' });+ const { enabled, interval } = req.body;+ if (typeof enabled !== 'boolean' && interval === undefined) {+ throw new ServerError('enabled (boolean) or interval (string|null) required', { status: 400, code: 'VALIDATION_ERROR' });}- const result = await appsService.toggleAppTaskType(req.params.id, req.params.taskType, enabled);+ const result = await appsService.updateAppTaskTypeOverride(req.params.id, req.params.taskType, { enabled, interval });if (!result) {throw new ServerError('App not found', { status: 404, code: 'NOT_FOUND' });}- console.log(`📋 ${enabled ? 'Enabled' : 'Disabled'} task type ${req.params.taskType} for ${result.name}`);- res.json({ success: true, appId: result.id, taskType: req.params.taskType, enabled, disabledTaskTypes: result.disabledTaskTypes || [] });+ const action = typeof enabled === 'boolean' ? (enabled ? 'Enabled' : 'Disabled') : 'Updated interval for';+ console.log(`📋 ${action} task type ${req.params.taskType} for ${result.name}`);+ res.json({ success: true, appId: result.id, taskType: req.params.taskType, enabled, interval, taskTypeOverrides: result.taskTypeOverrides || {} });}));// POST /api/apps/:id/start - Start app via PM2diff --git a/server/services/apps.js b/server/services/apps.jsindex 588145cd42..9a3b49a793 100644--- a/server/services/apps.js+++ b/server/services/apps.js@@ -191,36 +191,72 @@ export async function unarchiveApp(id) {}/**- * Get disabled task types for an app+ * Migrate app from legacy disabledTaskTypes array to taskTypeOverrides object.+ * Called lazily when accessing task type data.*/-export async function getAppDisabledTaskTypes(id) {+function migrateTaskTypeOverrides(app) {+ if (!app.disabledTaskTypes || app.taskTypeOverrides) return app;+ const overrides = {};+ for (const taskType of app.disabledTaskTypes) {+ overrides[taskType] = { enabled: false };+ }+ app.taskTypeOverrides = overrides;+ delete app.disabledTaskTypes;+ return app;+}++/**+ * Get task type overrides for an app+ */+export async function getAppTaskTypeOverrides(id) {const app = await getAppById(id);- return app?.disabledTaskTypes || [];+ if (!app) return {};+ migrateTaskTypeOverrides(app);+ return app.taskTypeOverrides || {};}/*** Check if a task type is enabled for a specific app*/export async function isTaskTypeEnabledForApp(id, taskType) {- const disabled = await getAppDisabledTaskTypes(id);- return !disabled.includes(taskType);+ const overrides = await getAppTaskTypeOverrides(id);+ return overrides[taskType]?.enabled !== false;}/**- * Toggle a task type for a specific app (enable/disable)+ * Get per-app interval for a task type (null = inherit global)*/-export async function toggleAppTaskType(id, taskType, enabled) {+export async function getAppTaskTypeInterval(appId, taskType) {+ const overrides = await getAppTaskTypeOverrides(appId);+ return overrides[taskType]?.interval || null;+}++/**+ * Update a task type override for a specific app (enable/disable + optional interval)+ */+export async function updateAppTaskTypeOverride(id, taskType, { enabled, interval } = {}) {const data = await loadApps();if (!data.apps[id]) return null;- const disabledTaskTypes = data.apps[id].disabledTaskTypes || [];+ // Migrate legacy format if needed+ migrateTaskTypeOverrides(data.apps[id]);++ const overrides = data.apps[id].taskTypeOverrides || {};+ const existing = overrides[taskType] || {};++ const updated = { ...existing };+ if (typeof enabled === 'boolean') updated.enabled = enabled;+ if (interval !== undefined) updated.interval = interval;- if (enabled && disabledTaskTypes.includes(taskType)) {- data.apps[id].disabledTaskTypes = disabledTaskTypes.filter(t => t !== taskType);- } else if (!enabled && !disabledTaskTypes.includes(taskType)) {- data.apps[id].disabledTaskTypes = [...disabledTaskTypes, taskType];+ // If override matches "inherit everything" defaults, remove the entry+ if (updated.enabled !== false && !updated.interval) {+ delete overrides[taskType];+ } else {+ overrides[taskType] = updated;}+ data.apps[id].taskTypeOverrides = overrides;+ delete data.apps[id].disabledTaskTypes; // Remove legacy fielddata.apps[id].updatedAt = new Date().toISOString();await saveApps(data);appsEvents.emit('changed', { action: 'update-task-types', timestamp: Date.now() });diff --git a/server/services/taskSchedule.js b/server/services/taskSchedule.jsindex 8656dbddde..64e2e4c59a 100644--- a/server/services/taskSchedule.js+++ b/server/services/taskSchedule.js@@ -23,7 +23,7 @@ import { fileURLToPath } from 'url';import { cosEvents, emitLog } from './cos.js';import { readJSONFile } from '../lib/fileUtils.js';import { getAdaptiveCooldownMultiplier } from './taskLearning.js';-import { isTaskTypeEnabledForApp } from './apps.js';+import { isTaskTypeEnabledForApp, getAppTaskTypeInterval, getActiveApps, getAppTaskTypeOverrides } from './apps.js';const __filename = fileURLToPath(import.meta.url);const __dirname = dirname(__filename);@@ -965,9 +965,9 @@ export async function shouldRunSelfImprovementTask(taskType) {*/export async function shouldRunAppImprovementTask(taskType, appId) {const schedule = await loadSchedule();- const interval = schedule.appImprovement[taskType];+ const globalInterval = schedule.appImprovement[taskType];- if (!interval || !interval.enabled) {+ if (!globalInterval || !globalInterval.enabled) {return { shouldRun: false, reason: 'disabled' };}@@ -979,6 +979,10 @@ export async function shouldRunAppImprovementTask(taskType, appId) {}}+ // Determine effective interval type: per-app override takes precedence over global+ const perAppInterval = appId ? await getAppTaskTypeInterval(appId, taskType) : null;+ const effectiveType = perAppInterval || globalInterval.type;+const key = `app-improve:${taskType}`;const execution = schedule.executions[key] || { lastRun: null, count: 0, perApp: {} };const appExecution = execution.perApp[appId] || { lastRun: null, count: 0 };@@ -998,7 +1002,7 @@ export async function shouldRunAppImprovementTask(taskType, appId) {return result;};- switch (interval.type) {+ switch (effectiveType) {case INTERVAL_TYPES.ROTATION:return { shouldRun: true, reason: 'rotation' };@@ -1044,7 +1048,7 @@ export async function shouldRunAppImprovementTask(taskType, appId) {return { shouldRun: false, reason: 'on-demand-only' };case INTERVAL_TYPES.CUSTOM: {- const baseInterval = interval.intervalMs || DAY;+ const baseInterval = globalInterval.intervalMs || DAY;const learningAdjustment = await getPerformanceAdjustedInterval(taskType, 'appImprovement', baseInterval);const adjustedInterval = learningAdjustment.adjustedIntervalMs;@@ -1334,6 +1338,10 @@ export async function getScheduleStatus() {}// Add execution status to each app improvement task type+ // Fetch active apps once for per-app override aggregation+ const activeApps = await getActiveApps().catch(() => []);+ const totalAppCount = activeApps.length;+for (const [taskType, interval] of Object.entries(schedule.appImprovement)) {const execution = schedule.executions[`app-improve:${taskType}`] || { lastRun: null, count: 0, perApp: {} };@@ -1341,11 +1349,32 @@ export async function getScheduleStatus() {const baseInterval = interval.type === 'daily' ? DAY : interval.type === 'weekly' ? WEEK : (interval.intervalMs || DAY);const learningInfo = await getPerformanceAdjustedInterval(taskType, 'appImprovement', baseInterval);+ // Build per-app overrides map and count enabled apps+ const appOverrides = {};+ let enabledAppCount = 0;+ for (const app of activeApps) {+ const overrides = await getAppTaskTypeOverrides(app.id);+ const override = overrides[taskType];+ if (override) {+ appOverrides[app.id] = {+ enabled: override.enabled !== false,+ interval: override.interval || null+ };+ }+ // App is enabled if no override or override.enabled !== false+ if (!override || override.enabled !== false) {+ enabledAppCount++;+ }+ }+status.appImprovement[taskType] = {...interval,globalLastRun: execution.lastRun,globalRunCount: execution.count,perAppCount: Object.keys(execution.perApp).length,+ appOverrides,+ enabledAppCount,+ totalAppCount,// Learning adjustment fieldslearningAdjusted: learningInfo.adjusted,learningMultiplier: learningInfo.multiplier,