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: app Automation tab opens on the tasks switched on for the app, with All/search filters (#12592)
[._.]/ Adam Eivy35078c8d9d9c
diff --git a/client/src/components/apps/tabs/AutomationTab.jsx b/client/src/components/apps/tabs/AutomationTab.jsxindex 7802b662fc..671f459db8 100644--- a/client/src/components/apps/tabs/AutomationTab.jsx+++ b/client/src/components/apps/tabs/AutomationTab.jsx@@ -1,6 +1,6 @@import { useState, useEffect, useCallback } from 'react';-import { useNavigate } from 'react-router';-import { RefreshCw, Play, PauseCircle, Sparkles, AlertTriangle } from 'lucide-react';+import { useNavigate, useSearchParams } from 'react-router';+import { RefreshCw, Play, PauseCircle, Sparkles, AlertTriangle, Search } from 'lucide-react';import toast from '../../ui/Toast';import BrailleSpinner from '../../BrailleSpinner';import CronInput from '../../CronInput';@@ -21,8 +21,24 @@ const INTERVAL_OPTIONS = [{ value: 'cron', label: 'Scheduled' }];+// Order the catalogue with this app's switched-on tasks first, then alphabetical.+const orderTaskTypes = (taskTypes, overrides) => [...taskTypes].sort((a, b) => {+ const onA = overrides[a]?.enabled === true;+ const onB = overrides[b]?.enabled === true;+ return onA === onB ? a.localeCompare(b) : onA ? -1 : 1;+});+export default function AutomationTab({ appId, appName }) {const navigate = useNavigate();+ const [searchParams, setSearchParams] = useSearchParams();+ const showParam = searchParams.get('show');+ const query = searchParams.get('q') || '';+ const updateParam = (key, value, defaultValue = '') => {+ const params = new URLSearchParams(searchParams);+ if (!value || value === defaultValue) params.delete(key);+ else params.set(key, value);+ setSearchParams(params, { replace: true });+ };const [overrides, setOverrides] = useState({});const [schedule, setSchedule] = useState(null);const [providers, setProviders] = useState([]);@@ -145,6 +161,23 @@ export default function AutomationTab({ appId, appName }) {}const taskTypes = schedule?.tasks ? Object.keys(schedule.tasks).sort() : [];+ const enabledCount = taskTypes.filter(t => overrides[t]?.enabled === true).length;+ // A configured app opens on its live automation; an unconfigured one on the full catalogue.+ const defaultShow = enabledCount > 0 ? 'on' : 'all';+ const show = showParam === 'on' || showParam === 'all' ? showParam : defaultShow;+ const needle = query.trim().toLowerCase();+ const visibleTaskTypes = orderTaskTypes(taskTypes, overrides).filter(t => {+ if (show === 'on' && overrides[t]?.enabled !== true) return false;+ if (!needle) return true;+ return `${t} ${schedule.tasks[t]?.description || ''}`.toLowerCase().includes(needle);+ });+ const clearFilters = () => {+ const params = new URLSearchParams(searchParams);+ params.delete('q');+ params.set('show', 'all');+ if (defaultShow === 'all') params.delete('show');+ setSearchParams(params, { replace: true });+ };const allEnabled = taskTypes.length > 0 && taskTypes.every(t => (overrides[t] || {}).enabled === true);const handleToggleAll = async () => {@@ -219,8 +252,45 @@ export default function AutomationTab({ appId, appName }) {No task types configured in the schedule</div>) : (+ <>+ <div className="flex flex-wrap items-center gap-3">+ <div role="group" aria-label="Task visibility" className="inline-flex rounded-lg border border-port-border overflow-hidden">+ {[['on', `On for this app (${enabledCount})`], ['all', `All (${taskTypes.length})`]].map(([value, label]) => (+ <button+ key={value}+ type="button"+ aria-pressed={show === value}+ onClick={() => updateParam('show', value, defaultShow)}+ className={`px-3 py-1.5 text-xs font-medium ${show === value ? 'bg-port-accent/20 text-port-accent' : 'text-gray-400 hover:text-white'}`}+ >+ {label}+ </button>+ ))}+ </div>+ <div className="relative flex-1 min-w-[12rem] max-w-md">+ <Search size={14} className="absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-500" aria-hidden="true" />+ <input+ type="search"+ aria-label="Search tasks"+ value={query}+ onChange={e => updateParam('q', e.target.value)}+ placeholder="Search task id or description…"+ className="w-full pl-8 pr-3 py-1.5 bg-port-bg border border-port-border rounded-lg text-xs text-white focus:border-port-accent focus:outline-hidden"+ />+ </div>+ </div>+ {visibleTaskTypes.length === 0 && (+ <div className="bg-port-card border border-port-border rounded-lg p-6 text-center text-gray-500 space-y-2">+ <p>+ No tasks match {show === 'on' ? '“On for this app”' : 'all tasks'}{needle ? ` and “${query.trim()}”` : ''}.+ </p>+ <button type="button" onClick={clearFilters} className="px-3 py-1.5 bg-port-border hover:bg-port-border/80 text-white rounded-lg text-xs">+ Show all tasks+ </button>+ </div>+ )}<div className="grid grid-cols-1 lg:grid-cols-2 2xl:grid-cols-3 gap-4 items-start">- {taskTypes.map(taskType => {+ {visibleTaskTypes.map(taskType => {const override = overrides[taskType] || {};const globalConfig = schedule.tasks[taskType] || {};const isEnabled = override.enabled === true;@@ -386,6 +456,7 @@ export default function AutomationTab({ appId, appName }) {);})}</div>+ </>)}diff --git a/client/src/components/apps/tabs/AutomationTab.test.jsx b/client/src/components/apps/tabs/AutomationTab.test.jsxindex 863fd86f6d..868efb86ce 100644--- a/client/src/components/apps/tabs/AutomationTab.test.jsx+++ b/client/src/components/apps/tabs/AutomationTab.test.jsx@@ -4,9 +4,11 @@ import { awaitEnabled } from '../../../test/enabledBarrier.js';// ── Mock router — capture navigate calls, no real Router needed ────────────────const mockNavigate = vi.hoisted(() => vi.fn());-vi.mock('react-router', () => ({+vi.mock('react-router', async (importOriginal) => ({+ ...(await importOriginal()),useNavigate: () => mockNavigate,}));+import { MemoryRouter, useLocation } from 'react-router';// ── Mock toast ────────────────────────────────────────────────────────────────const mockToast = vi.hoisted(() => Object.assign(vi.fn(), { success: vi.fn(), error: vi.fn(), loading: vi.fn(), dismiss: vi.fn() }));@@ -53,7 +55,16 @@ const PROVIDERS = {],};-const renderTab = async (overrides = {}) => {+let currentSearch = '';+const LocationProbe = () => { currentSearch = useLocation().search; return null; };+const mountTab = (entry = '/?show=all') => render(+ <MemoryRouter initialEntries={[entry]}>+ <LocationProbe />+ <AutomationTab appId="app-1" appName="MyApp" />+ </MemoryRouter>+);++const renderTab = async (overrides = {}, entry) => {api.getAppTaskTypes.mockResolvedValue({ taskTypeOverrides: overrides });api.getCosSchedule.mockResolvedValue(SCHEDULE);api.getCosStatus.mockResolvedValue({ paused: false });@@ -61,8 +72,8 @@ const renderTab = async (overrides = {}) => {api.getCosJobs.mockResolvedValue({ jobs: [] });api.getSettings.mockResolvedValue({ timezone: 'UTC' });api.updateAppTaskTypeOverride.mockResolvedValue({ success: true });- render(<AutomationTab appId="app-1" appName="MyApp" />);- await screen.findByText('layered-intelligence');+ mountTab(entry);+ await screen.findByRole('group', { name: 'Task visibility' });// Drain the remaining mount fetches (CustomTasksSection's getCosJobs etc.)// inside act — the schedule findByText above can win before they land.await act(async () => {});@@ -116,7 +127,7 @@ describe('AutomationTab per-app options', () => {api.getProviders.mockResolvedValue(PROVIDERS);api.getCosJobs.mockResolvedValue({ jobs: [] });api.getSettings.mockResolvedValue({ timezone: 'UTC' });- const { container } = render(<AutomationTab appId="app-1" appName="MyApp" />);+ const { container } = mountTab();await screen.findByText('layered-intelligence');await act(async () => {});@@ -277,3 +288,49 @@ describe('AutomationTab per-app options', () => {));});});++describe('AutomationTab task visibility filter', () => {+ const cardOrder = () => ['layered-intelligence', 'app-improvement', 'security']+ .map(t => [t, screen.queryByText(t)])+ .filter(([, el]) => el)+ .sort(([, a], [, b]) => (a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1))+ .map(([t]) => t);++ it('opens on the switched-on tasks when any are on, and keeps the full count on All', async () => {+ await renderTab({ security: { enabled: true } }, '/');+ expect(cardOrder()).toEqual(['security']);+ expect(screen.getByRole('button', { name: 'On for this app (1)' })).toHaveAttribute('aria-pressed', 'true');+ expect(screen.getByRole('button', { name: 'All (3)' })).toBeInTheDocument();+ });++ it('opens on All when nothing is switched on', async () => {+ await renderTab({}, '/');+ expect(cardOrder()).toHaveLength(3);+ expect(screen.getByRole('button', { name: 'All (3)' })).toHaveAttribute('aria-pressed', 'true');+ });++ it('lists switched-on tasks first on All, then alphabetical', async () => {+ await renderTab({ security: { enabled: true } }, '/?show=all');+ expect(cardOrder()).toEqual(['security', 'app-improvement', 'layered-intelligence']);+ });++ it('keeps show and q in the URL, dropping each at its default', async () => {+ await renderTab({ security: { enabled: true } }, '/');+ fireEvent.click(screen.getByRole('button', { name: 'All (3)' }));+ expect(currentSearch).toBe('?show=all');+ fireEvent.change(screen.getByRole('searchbox', { name: 'Search tasks' }), { target: { value: 'app' } });+ expect(currentSearch).toBe('?show=all&q=app');+ expect(cardOrder()).toEqual(['app-improvement']);+ fireEvent.click(screen.getByRole('button', { name: 'On for this app (1)' }));+ fireEvent.change(screen.getByRole('searchbox', { name: 'Search tasks' }), { target: { value: '' } });+ expect(currentSearch).toBe('');+ });++ it('shows a zero-match empty state that resets to all tasks', async () => {+ await renderTab({ security: { enabled: true } }, '/?q=zzz');+ expect(screen.getByText(/No tasks match/)).toHaveTextContent('“On for this app” and “zzz”');+ fireEvent.click(screen.getByRole('button', { name: 'Show all tasks' }));+ expect(currentSearch).toBe('?show=all');+ expect(cardOrder()).toHaveLength(3);+ });+});