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
import { useState } from 'react';
import Drawer from '../../../Drawer';
import useDrawerTab from '../../../../hooks/useDrawerTab';
import TaskHeader from './TaskHeader';
import { pipelineStages } from './scheduleConstants';
import PipelineStageConfig from './PipelineStageConfig';
import GlobalConfigControls from './GlobalConfigControls';
import PerAppOverrideList from './PerAppOverrideList';
import MusicVideoAutopilotSettings from './MusicVideoAutopilotSettings';
// Slide-over panel holding the full configuration for a single task.
// Receives the live config object so it re-renders against the freshest
// schedule after each onUpdate refetch.
//
// The (formerly page-length) config is split into deep-linkable tabs so no
// single section runs off the bottom of the drawer:
// - Stage config — per-stage provider/model (only when the task has a
// pipeline; count = number of stages)
// - Video settings — the music-video-autopilot task's run settings
// (only for that task type)
// - Global defaults — schedule/provider/prompt controls (always present)
// - Per-app options — turns the task on/off per app, plus that app's
// optional per-app settings (only when there are
// active apps; count = number of active apps)
// The active tab lives in the `taskTab` URL param so it survives reload and is
// shareable. TaskHeader (identity + badges) stays at the top of every tab.
export default function TaskConfigDrawer({
open,
taskType,
config,
onClose,
onUpdate,
onTrigger,
providers,
providersLoaded,
activeProviderId,
apps,
onUpdateOverride,
onBulkToggleOverride,
allTaskTypes,
orderStep,
improvementDisabled,
dataInputCatalog,
}) {
const [updating, setUpdating] = useState(false);
const stages = pipelineStages(config);
const hasStages = stages.length > 0;
const activeApps = apps?.filter(app => !app.archived) || [];
const hasOverrides = activeApps.length > 0;
// Tabs are dynamic: a task without a pipeline hides Stage config, and an
// install with no active apps hides Per-app options — never an empty tab.
const hasVideoSettings = taskType === 'music-video-autopilot';
const tabs = [
hasVideoSettings && { id: 'video', label: 'Video settings' },
hasStages && { id: 'stages', label: 'Stage config', count: stages.length },
{ id: 'global', label: 'Global defaults' },
hasOverrides && { id: 'overrides', label: 'Per-app options', count: activeApps.length },
].filter(Boolean);
const tabIds = tabs.map(t => t.id);
const defaultTab = hasVideoSettings ? 'video' : hasStages ? 'stages' : 'global';
const [activeTab, setActiveTab] = useDrawerTab('taskTab', defaultTab, tabIds);
return (
<Drawer
open={open && !!config}
onClose={onClose}
title={config?.displayName || taskType || 'Task'}
size="md"
tabs={tabs}
activeTab={activeTab}
onTabChange={setActiveTab}
// Don't allow an Esc keystroke to discard a config change mid-save.
closeOnEsc={!updating}
>
{config && (
<div className="space-y-6">
<TaskHeader taskType={taskType} config={config} orderStep={orderStep} />
{activeTab === 'stages' && hasStages && (
<PipelineStageConfig
taskType={taskType}
config={config}
providers={providers}
providersLoaded={providersLoaded}
onUpdate={onUpdate}
updating={updating}
setUpdating={setUpdating}
/>
)}
{activeTab === 'video' && hasVideoSettings && (
<MusicVideoAutopilotSettings
key={taskType}
taskType={taskType}
config={config}
onUpdate={onUpdate}
updating={updating}
setUpdating={setUpdating}
/>
)}
{activeTab === 'global' && (
<GlobalConfigControls
key={taskType}
taskType={taskType}
config={config}
onUpdate={onUpdate}
onTrigger={onTrigger}
category="appImprovement"
providers={providers}
providersLoaded={providersLoaded}
activeProviderId={activeProviderId}
apps={apps}
updating={updating}
setUpdating={setUpdating}
allTaskTypes={allTaskTypes}
improvementDisabled={improvementDisabled}
dataInputCatalog={dataInputCatalog}
/>
)}
{activeTab === 'overrides' && hasOverrides && (
<PerAppOverrideList
taskType={taskType}
config={config}
apps={apps}
providers={providers}
providersLoaded={providersLoaded}
onUpdateOverride={onUpdateOverride}
onBulkToggleOverride={onBulkToggleOverride}
/>
)}
</div>
)}
</Drawer>
);
}