This commit is contained in:
ZacharyZhang-NY committed 2026-04-04 12:03:50 -04:00
1 parent 66158e222e
commit 67c757f481
314 files changed
+37945 -22962

No files matched your search

+292
View File
@@ -0,0 +1,292 @@
import { AnimatePresence, motion } from "framer-motion";
import {
Kanban,
ListChecks,
MagnifyingGlass,
Target,
TerminalWindow,
UsersThree,
} from "@phosphor-icons/react";
import type { AgentRecord, GoalRecord, ProjectRecord, RunRecord, SectionId, TaskRecord } from "@shared/types";
import { ListFrame, ListRow, StatusPill } from "../components/ui";
type NavItem = { id: SectionId; label: string; icon: typeof MagnifyingGlass };
type PaletteAction = {
key: string;
section: SectionId;
entityId?: string;
};
interface CommandPaletteViewProps {
commandPaletteOpen: boolean;
setCommandPaletteOpen: (value: boolean) => void;
commandPaletteSearch: string;
setCommandPaletteSearch: (value: string) => void;
selectedPaletteIndex: number;
setSelectedPaletteIndex: (value: number) => void;
paletteTrapRef: React.RefObject<HTMLDivElement | null>;
filteredNavItems: NavItem[];
matchedAgents: AgentRecord[];
matchedTasks: TaskRecord[];
matchedRuns: RunRecord[];
matchedGoals: GoalRecord[];
matchedProjects: ProjectRecord[];
hasEntityResults: boolean;
paletteActions: PaletteAction[];
paletteActionIndex: Map<string, number>;
runs: RunRecord[];
navigateTo: (section: SectionId, entityId?: string) => void;
panelTransition: { duration: number; ease?: readonly [number, number, number, number] } | { duration: number };
t: (key: string) => string;
}
export function CommandPaletteView({
commandPaletteOpen,
setCommandPaletteOpen,
commandPaletteSearch,
setCommandPaletteSearch,
selectedPaletteIndex,
setSelectedPaletteIndex,
paletteTrapRef,
filteredNavItems,
matchedAgents,
matchedTasks,
matchedRuns,
matchedGoals,
matchedProjects,
hasEntityResults,
paletteActionIndex,
runs,
navigateTo,
panelTransition,
t,
}: CommandPaletteViewProps) {
const paletteQuery = commandPaletteSearch.trim().toLowerCase();
return (
<AnimatePresence>
{commandPaletteOpen ? (
<motion.div
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
className="fixed inset-0 z-50 flex items-start justify-center bg-background/72 px-4 pt-24 backdrop-blur-sm"
onClick={() => { setCommandPaletteOpen(false); setCommandPaletteSearch(""); }}
>
<motion.div
ref={paletteTrapRef}
role="dialog"
aria-modal="true"
aria-label="Command palette"
initial={{ opacity: 0, y: 14, scale: 0.98 }}
animate={{ opacity: 1, y: 0, scale: 1 }}
exit={{ opacity: 0, y: 10, scale: 0.98 }}
transition={panelTransition}
className="w-full max-w-[560px] rounded-lg border border-border bg-card px-5 py-4 shadow-[0_18px_40px_rgba(15,23,42,0.08)]"
onClick={(event) => event.stopPropagation()}
>
<div className="mb-3 flex items-center gap-3">
<MagnifyingGlass size={18} className="text-primary" />
<input
type="text"
aria-label="Search"
className="flex-1 bg-transparent text-[14px] text-foreground placeholder:text-muted-foreground outline-none"
placeholder={t("app.search")}
value={commandPaletteSearch}
onChange={(e) => setCommandPaletteSearch(e.target.value)}
autoFocus
/>
{commandPaletteSearch && (
<button
className="text-[12px] text-muted-foreground hover:text-foreground"
onClick={() => setCommandPaletteSearch("")}
>
{t("app.clear")}
</button>
)}
</div>
{filteredNavItems.length > 0 ? (
<>
<div className="mb-1 text-[10px] font-semibold uppercase tracking-[0.08em] text-muted-foreground">{t("entity.sections")}</div>
<ListFrame>
{filteredNavItems.map((item) => (
<ListRow
key={item.id}
className={`py-3 ${paletteActionIndex.get(`section:${item.id}`) === selectedPaletteIndex ? "bg-muted" : ""}`}
onClick={() => {
navigateTo(item.id);
setCommandPaletteOpen(false);
setCommandPaletteSearch("");
setSelectedPaletteIndex(0);
}}
>
<div className="flex items-center justify-between">
<div className="flex items-center gap-3 text-foreground">
<item.icon size={16} />
<span className="text-[13px] tracking-[0.005em]">{item.label}</span>
</div>
<span className="font-mono text-[11px] text-muted-foreground">{item.id}</span>
</div>
</ListRow>
))}
</ListFrame>
</>
) : null}
{hasEntityResults ? (
<div className="mt-3 space-y-3">
{matchedAgents.length > 0 ? (
<>
<div className="text-[10px] font-semibold uppercase tracking-[0.08em] text-muted-foreground">{t("entity.agents")}</div>
<ListFrame>
{matchedAgents.map((agent) => (
<ListRow
key={agent.id}
className={`py-3 ${paletteActionIndex.get(`agent:${agent.id}`) === selectedPaletteIndex ? "bg-muted" : ""}`}
onClick={() => {
navigateTo("agents", agent.id);
setCommandPaletteOpen(false);
setCommandPaletteSearch("");
setSelectedPaletteIndex(0);
}}
>
<div className="flex items-center justify-between">
<div className="flex items-center gap-3 text-foreground">
<UsersThree size={16} />
<span className="text-[13px] tracking-[0.005em]">{agent.name}</span>
<span className="text-[11px] text-muted-foreground">{agent.role}</span>
</div>
<StatusPill status={agent.status} />
</div>
</ListRow>
))}
</ListFrame>
</>
) : null}
{matchedTasks.length > 0 ? (
<>
<div className="text-[10px] font-semibold uppercase tracking-[0.08em] text-muted-foreground">{t("entity.tasks")}</div>
<ListFrame>
{matchedTasks.map((task) => (
<ListRow
key={task.id}
className={`py-3 ${paletteActionIndex.get(`task:${task.id}`) === selectedPaletteIndex ? "bg-muted" : ""}`}
onClick={() => {
navigateTo("tasks", task.id);
setCommandPaletteOpen(false);
setCommandPaletteSearch("");
setSelectedPaletteIndex(0);
}}
>
<div className="flex items-center justify-between">
<div className="flex items-center gap-3 text-foreground">
<ListChecks size={16} />
<span className="text-[13px] tracking-[0.005em]">{task.title}</span>
</div>
<StatusPill status={task.status} />
</div>
</ListRow>
))}
</ListFrame>
</>
) : null}
{matchedRuns.length > 0 ? (
<>
<div className="text-[10px] font-semibold uppercase tracking-[0.08em] text-muted-foreground">{t("entity.runs")}</div>
<ListFrame>
{matchedRuns.map((run) => (
<ListRow
key={run.id}
className={`py-3 ${paletteActionIndex.get(`run:${run.id}`) === selectedPaletteIndex ? "bg-muted" : ""}`}
onClick={() => {
navigateTo("runs", run.id);
setCommandPaletteOpen(false);
setCommandPaletteSearch("");
setSelectedPaletteIndex(0);
}}
>
<div className="flex items-center justify-between gap-3">
<div className="min-w-0 flex items-center gap-3 text-foreground">
<TerminalWindow size={16} />
<span className="truncate text-[13px] tracking-[0.005em]">
{run.summary || runs.find((entry) => entry.id === run.id)?.id.slice(0, 8) || run.id.slice(0, 8)}
</span>
</div>
<StatusPill status={run.status} />
</div>
</ListRow>
))}
</ListFrame>
</>
) : null}
{matchedGoals.length > 0 ? (
<>
<div className="text-[10px] font-semibold uppercase tracking-[0.08em] text-muted-foreground">{t("entity.goals")}</div>
<ListFrame>
{matchedGoals.map((goal) => (
<ListRow
key={goal.id}
className={`py-3 ${paletteActionIndex.get(`goal:${goal.id}`) === selectedPaletteIndex ? "bg-muted" : ""}`}
onClick={() => {
navigateTo("goals", goal.id);
setCommandPaletteOpen(false);
setCommandPaletteSearch("");
setSelectedPaletteIndex(0);
}}
>
<div className="flex items-center justify-between">
<div className="flex items-center gap-3 text-foreground">
<Target size={16} />
<span className="text-[13px] tracking-[0.005em]">{goal.title}</span>
</div>
<StatusPill status={goal.status} />
</div>
</ListRow>
))}
</ListFrame>
</>
) : null}
{matchedProjects.length > 0 ? (
<>
<div className="text-[10px] font-semibold uppercase tracking-[0.08em] text-muted-foreground">{t("entity.projects")}</div>
<ListFrame>
{matchedProjects.map((project) => (
<ListRow
key={project.id}
className={`py-3 ${paletteActionIndex.get(`project:${project.id}`) === selectedPaletteIndex ? "bg-muted" : ""}`}
onClick={() => {
navigateTo("projects", project.id);
setCommandPaletteOpen(false);
setCommandPaletteSearch("");
setSelectedPaletteIndex(0);
}}
>
<div className="flex items-center justify-between">
<div className="flex items-center gap-3 text-foreground">
<Kanban size={16} />
<span className="text-[13px] tracking-[0.005em]">{project.name}</span>
</div>
<StatusPill status={project.status} />
</div>
</ListRow>
))}
</ListFrame>
</>
) : null}
</div>
) : null}
{paletteQuery && filteredNavItems.length === 0 && !hasEntityResults ? (
<div className="py-6 text-center text-[13px] text-muted-foreground">{t("app.noResults")} "{commandPaletteSearch}"</div>
) : null}
</motion.div>
</motion.div>
) : null}
</AnimatePresence>
);
}
+107
View File
@@ -0,0 +1,107 @@
import { AnimatePresence, motion } from "framer-motion";
import { FolderOpen, TerminalWindow, X } from "@phosphor-icons/react";
import type { RunRecord } from "@shared/types";
import { ActionButton, Select, StatusPill } from "../components/ui";
import { formatMoney, formatTime } from "../lib/formatters";
interface ConsoleViewProps {
consoleOpen: boolean;
setConsoleOpen: (value: boolean) => void;
selectedRun: RunRecord | null;
setSelectedRunId: (id: string | null) => void;
runs: RunRecord[];
logBufferRef: React.RefObject<Record<string, string>>;
openPathWithFeedback: (path: string) => Promise<void>;
panelTransition: { duration: number; ease?: readonly [number, number, number, number] } | { duration: number };
t: (key: string) => string;
}
export function ConsoleView({
consoleOpen,
setConsoleOpen,
selectedRun,
setSelectedRunId,
runs,
logBufferRef,
openPathWithFeedback,
panelTransition,
t,
}: ConsoleViewProps) {
return (
<AnimatePresence>
{consoleOpen ? (
<motion.section
initial={{ height: 0, opacity: 0 }}
animate={{ height: "auto", opacity: 1 }}
exit={{ height: 0, opacity: 0 }}
transition={panelTransition}
className="shrink-0 overflow-hidden border-t border-border bg-card"
>
<div className="flex items-center justify-between px-5 py-2.5">
<div className="flex items-center gap-3">
<TerminalWindow size={15} className="text-muted-foreground" />
<span className="text-[13px] font-semibold text-foreground">{t("console.title")}</span>
</div>
<div className="flex items-center gap-3">
<Select
compact
value={selectedRun?.id ?? ""}
onChange={setSelectedRunId}
options={(() => {
const activeRuns = runs.filter((r) => r.summary !== "Application shut down." && r.summary !== "Worker process crashed.");
return activeRuns.length > 0
? activeRuns.map((run) => ({ value: run.id, label: run.summary || `Run ${run.id.slice(0, 8)}` }))
: [{ value: "", label: t("console.noRuns") }];
})()}
/>
<button
type="button"
className="focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 rounded-lg p-1 text-muted-foreground transition hover:text-foreground"
onClick={() => setConsoleOpen(false)}
aria-label="Close console"
>
<X size={14} />
</button>
</div>
</div>
<div className="grid border-t border-border xl:grid-cols-[240px_minmax(0,1fr)]">
<div className="border-b border-border px-5 py-3 xl:border-b-0 xl:border-r">
{selectedRun ? (
<div className="space-y-2.5 text-[12px] text-muted-foreground">
<div className="flex items-center justify-between">
<span>{t("common.status")}</span>
<StatusPill status={selectedRun.status} />
</div>
<div className="flex items-center justify-between">
<span>{t("common.started")}</span>
<span className="font-mono text-[11px]">{formatTime(selectedRun.startedAt)}</span>
</div>
<div className="flex items-center justify-between">
<span>{t("common.finished")}</span>
<span className="font-mono text-[11px]">{formatTime(selectedRun.finishedAt)}</span>
</div>
<div className="flex items-center justify-between">
<span>{t("common.cost")}</span>
<span className="font-mono text-[11px]">{formatMoney(selectedRun.costUsd)}</span>
</div>
{selectedRun.logPath ? (
<div className="pt-1">
<ActionButton label={t("common.openLog")} onClick={() => void openPathWithFeedback(selectedRun.logPath!)} icon={FolderOpen} />
</div>
) : null}
</div>
) : (
<div className="py-4 text-center text-[12px] text-muted-foreground">{t("common.noRunSelected")}</div>
)}
</div>
<div className="h-[200px] overflow-auto px-5 py-3">
<pre className="font-mono whitespace-pre-wrap break-all text-[12px] leading-relaxed text-muted-foreground">
{selectedRun ? logBufferRef.current[selectedRun.id] ?? t("common.waitingForLog") : t("common.noRunSelected")}
</pre>
</div>
</div>
</motion.section>
) : null}
</AnimatePresence>
);
}
+280
View File
@@ -0,0 +1,280 @@
import { AnimatePresence, motion } from "framer-motion";
import { WarningCircle } from "@phosphor-icons/react";
import type {
AgentRecord,
ApprovalRecord,
BrowserActionRecord,
CompanyRecord,
CostRecord,
DocumentRecord,
GoalRecord,
InboxItem,
CompanyMetrics,
KnowledgeEntryRecord,
MeetingRecord,
ProfileSnapshot,
ProjectRecord,
RunRecord,
SectionId,
SocialAccountRecord,
SprintRecord,
StandupReport,
TaskRecord,
WorkspaceRecord,
} from "@shared/types";
import type { AppLocale } from "@shared/locale";
import { ErrorBoundary } from "../components/ui";
import { OrganizationSections } from "./sections/OrganizationSections";
import { ExecutionSections } from "./sections/ExecutionSections";
import { OperationsSections } from "./sections/OperationsSections";
interface SectionContentViewProps {
section: SectionId;
error: string | null;
snapshot: ProfileSnapshot;
currentCompany: CompanyRecord | null;
locale: AppLocale;
// data collections
tasks: TaskRecord[];
runs: RunRecord[];
approvals: ApprovalRecord[];
pendingApprovals: ApprovalRecord[];
companyAgents: AgentRecord[];
companyGoals: GoalRecord[];
companyProjects: ProjectRecord[];
companyWorkspaces: WorkspaceRecord[];
companyCosts: CostRecord[];
filteredActivity: ReturnType<ProfileSnapshot["activity"]["filter"]>;
companySecrets: ProfileSnapshot["secrets"];
companyDocuments: DocumentRecord[];
companyKnowledge: KnowledgeEntryRecord[];
companyMeetings: MeetingRecord[];
companySprints: SprintRecord[];
socialAccounts: SocialAccountRecord[];
browserActions: BrowserActionRecord[];
inboxItems: InboxItem[];
companyMetrics: CompanyMetrics | null;
standupReport: StandupReport | null;
selectedRunId: string | null;
// selections
selectedTask: TaskRecord | null;
selectedTaskId: string | null;
setSelectedTaskId: (id: string | null) => void;
selectedConnector: ProfileSnapshot["connectors"][number] | null;
setSelectedConnectorId: (id: string | null) => void;
selectedApproval: ApprovalRecord | null;
selectedApprovalId: string | null;
setSelectedApprovalId: (id: string | null) => void;
selectedAgent: AgentRecord | null;
selectedAgentId: string | null;
setSelectedAgentId: (id: string | null) => void;
selectedGoal: GoalRecord | null;
selectedGoalId: string | null;
setSelectedGoalId: (id: string | null) => void;
selectedProject: ProjectRecord | null;
selectedProjectId: string | null;
setSelectedProjectId: (id: string | null) => void;
selectedWorkspace: WorkspaceRecord | null;
setSelectedWorkspaceId: (id: string | null) => void;
selectedCommunicationEntityId: string | null;
setSelectedCommunicationEntityId: (id: string | null) => void;
taskViewMode: "list" | "kanban";
setTaskViewMode: (mode: "list" | "kanban") => void;
// actions
navigateTo: (section: SectionId, entityId?: string) => void;
setSection: (section: SectionId) => void;
setConsoleOpen: (value: boolean) => void;
setSelectedRunId: (id: string | null) => void;
refresh: () => Promise<void>;
startRun: (taskId: string) => Promise<void>;
cancelRun: (runId: string) => Promise<void>;
openPathWithFeedback: (path: string) => Promise<void>;
setError: (error: string | null) => void;
// transitions
pageTransition: { duration: number; ease?: readonly [number, number, number, number] } | { duration: number };
}
export function SectionContentView({
section,
error,
snapshot,
currentCompany,
locale,
tasks,
runs,
approvals,
pendingApprovals,
companyAgents,
companyGoals,
companyProjects,
companyWorkspaces,
companyCosts,
filteredActivity,
companySecrets,
companyDocuments,
companyKnowledge,
companyMeetings,
companySprints,
socialAccounts,
browserActions,
inboxItems,
companyMetrics,
standupReport,
selectedTask,
selectedTaskId,
setSelectedTaskId,
selectedConnector,
setSelectedConnectorId,
selectedApproval,
selectedApprovalId,
setSelectedApprovalId,
selectedAgent: _selectedAgent,
selectedAgentId,
setSelectedAgentId,
selectedGoal: _selectedGoal,
selectedGoalId,
setSelectedGoalId,
selectedProject: _selectedProject,
selectedProjectId,
setSelectedProjectId,
selectedWorkspace,
setSelectedWorkspaceId,
selectedCommunicationEntityId,
setSelectedCommunicationEntityId,
taskViewMode,
setTaskViewMode,
selectedRunId,
navigateTo,
setSection,
setConsoleOpen,
setSelectedRunId,
refresh,
startRun,
cancelRun,
openPathWithFeedback,
setError,
pageTransition,
}: SectionContentViewProps) {
return (
<div className={`flex-1 ${section === "communication" ? "flex flex-col overflow-hidden" : "overflow-auto"}`}>
<div className={section === "communication" ? "flex min-h-0 flex-1 flex-col" : "mx-auto flex w-full max-w-[1040px] flex-col px-6 py-6 lg:px-10 lg:py-8"}>
{error ? (
<div className={`flex items-center gap-3 rounded-lg bg-destructive-muted px-4 py-3 text-[13px] text-destructive ${section === "communication" ? "mx-6 mt-4" : "mb-6"}`}>
<WarningCircle size={18} />
<span>{error}</span>
</div>
) : null}
<div className={section === "communication" ? "flex min-h-0 flex-1 flex-col" : "min-h-0 flex-1"}>
<ErrorBoundary>
<AnimatePresence mode="wait">
<motion.div
key={section}
initial={{ opacity: 0, y: 16 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: -12 }}
transition={pageTransition}
className={section === "communication" ? "flex min-h-0 flex-1 flex-col" : "space-y-14"}
style={section === "communication" ? { height: "100%" } : undefined}
>
<OrganizationSections
section={section}
snapshot={snapshot}
currentCompany={currentCompany}
companyAgents={companyAgents}
companyGoals={companyGoals}
companyProjects={companyProjects}
companyWorkspaces={companyWorkspaces}
selectedAgentId={selectedAgentId}
setSelectedAgentId={setSelectedAgentId}
selectedGoalId={selectedGoalId}
setSelectedGoalId={setSelectedGoalId}
selectedProjectId={selectedProjectId}
setSelectedProjectId={setSelectedProjectId}
setSection={setSection}
refresh={refresh}
/>
<ExecutionSections
section={section}
snapshot={snapshot}
currentCompany={currentCompany}
tasks={tasks}
runs={runs}
approvals={approvals}
pendingApprovals={pendingApprovals}
companyAgents={companyAgents}
companyGoals={companyGoals}
companyProjects={companyProjects}
companyWorkspaces={companyWorkspaces}
companyCosts={companyCosts}
companyDocuments={companyDocuments}
filteredActivity={filteredActivity}
selectedRunId={selectedRunId}
selectedTask={selectedTask}
selectedTaskId={selectedTaskId}
setSelectedTaskId={setSelectedTaskId}
selectedConnector={selectedConnector}
setSelectedConnectorId={setSelectedConnectorId}
selectedApproval={selectedApproval}
selectedApprovalId={selectedApprovalId}
setSelectedApprovalId={setSelectedApprovalId}
selectedGoalId={selectedGoalId}
setSelectedGoalId={setSelectedGoalId}
taskViewMode={taskViewMode}
setTaskViewMode={setTaskViewMode}
setSection={setSection}
setConsoleOpen={setConsoleOpen}
setSelectedRunId={setSelectedRunId}
setSelectedCommunicationEntityId={setSelectedCommunicationEntityId}
refresh={refresh}
startRun={startRun}
cancelRun={cancelRun}
openPathWithFeedback={openPathWithFeedback}
setError={setError}
/>
<OperationsSections
section={section}
snapshot={snapshot}
currentCompany={currentCompany}
locale={locale}
tasks={tasks}
runs={runs}
companyAgents={companyAgents}
companyProjects={companyProjects}
companyWorkspaces={companyWorkspaces}
companyDocuments={companyDocuments}
companyKnowledge={companyKnowledge}
companyMeetings={companyMeetings}
companySprints={companySprints}
socialAccounts={socialAccounts}
browserActions={browserActions}
inboxItems={inboxItems}
companyMetrics={companyMetrics}
standupReport={standupReport}
companySecrets={companySecrets}
selectedWorkspace={selectedWorkspace}
setSelectedWorkspaceId={setSelectedWorkspaceId}
selectedCommunicationEntityId={selectedCommunicationEntityId}
setSelectedCommunicationEntityId={setSelectedCommunicationEntityId}
setSelectedTaskId={setSelectedTaskId}
setSelectedApprovalId={setSelectedApprovalId}
setSection={setSection}
navigateTo={navigateTo}
refresh={refresh}
openPathWithFeedback={openPathWithFeedback}
setError={setError}
filteredActivity={filteredActivity}
companyCosts={companyCosts}
companyGoals={companyGoals}
/>
</motion.div>
</AnimatePresence>
</ErrorBoundary>
</div>
</div>
</div>
);
}
+188
View File
@@ -0,0 +1,188 @@
import {
CaretUpDown,
Check,
Command,
Gear,
Plus,
SidebarSimple,
Trash,
} from "@phosphor-icons/react";
import type { CompanyRecord, ProfileSnapshot, SectionId } from "@shared/types";
import { SectionButton } from "../components/ui";
type NavItem = { id: SectionId; label: string; icon: typeof Gear };
interface SidebarViewProps {
isMac: boolean;
sidebarCollapsed: boolean;
setSidebarCollapsed: (value: boolean) => void;
section: SectionId;
setSection: (section: SectionId) => void;
sidebarNav: NavItem[];
navBadges: Partial<Record<SectionId, { count: number; tone: "default" | "warn" | "danger" }>>;
companySwitcherOpen: boolean;
setCompanySwitcherOpen: (value: boolean) => void;
confirmDeleteCompanyId: string | null;
setConfirmDeleteCompanyId: (id: string | null) => void;
currentCompany: CompanyRecord | null;
snapshot: ProfileSnapshot;
setCompany: (companyId: string) => void;
deleteCompany: (companyId: string) => void;
setCommandPaletteOpen: (value: boolean) => void;
t: (key: string) => string;
}
export function SidebarView({
isMac,
sidebarCollapsed,
setSidebarCollapsed,
section,
setSection,
sidebarNav,
navBadges,
companySwitcherOpen,
setCompanySwitcherOpen,
confirmDeleteCompanyId,
setConfirmDeleteCompanyId,
currentCompany,
snapshot,
setCompany,
deleteCompany,
setCommandPaletteOpen,
t,
}: SidebarViewProps) {
return (
<aside className="flex h-full flex-col overflow-hidden border-r border-border bg-card">
{sidebarCollapsed ? (
<div className={`sidebar-drag flex items-center justify-center px-2 pb-3 ${isMac ? "pt-[38px]" : "pt-3"}`}>
<button
aria-label="Open command palette"
title={`Command palette (${isMac ? "⌘" : "Ctrl+"}K)`}
className="focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 flex h-[30px] w-[30px] shrink-0 items-center justify-center rounded-lg border border-border text-muted-foreground transition hover:bg-muted hover:text-foreground"
onClick={() => setCommandPaletteOpen(true)}
>
<Command size={14} />
</button>
</div>
) : (
<div className={`sidebar-drag flex items-center gap-2.5 px-4 pb-4 ${isMac ? "pt-[38px]" : "pt-3"}`}>
<div className="relative min-w-0 flex-1">
<button
type="button"
className="focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 flex w-full items-center gap-2 rounded-lg border border-border bg-card px-2.5 py-1.5 text-left text-[13px] font-medium text-foreground transition hover:bg-muted"
onClick={() => setCompanySwitcherOpen(!companySwitcherOpen)}
>
<span className="min-w-0 flex-1 truncate">{currentCompany?.name ?? t("app.selectCompany")}</span>
<CaretUpDown size={14} className="shrink-0 text-muted-foreground" />
</button>
{companySwitcherOpen && (
<>
<div className="fixed inset-0 z-40" onClick={() => { setCompanySwitcherOpen(false); setConfirmDeleteCompanyId(null); }} />
<div className="absolute left-0 right-0 top-full z-50 mt-1 overflow-hidden rounded-lg border border-border bg-card shadow-lg">
<div className="max-h-[240px] overflow-y-auto py-1">
{snapshot.companies.map((company) => (
<div key={company.id} className="group flex items-center">
{confirmDeleteCompanyId === company.id ? (
<div className="flex w-full items-center gap-2 px-3 py-2">
<span className="flex-1 truncate text-[12px] text-destructive">Delete {company.name}?</span>
<button
type="button"
className="rounded px-2 py-0.5 text-[11px] font-semibold text-destructive transition hover:bg-destructive hover:text-primary-foreground"
onClick={() => void deleteCompany(company.id)}
>
Yes
</button>
<button
type="button"
className="rounded px-2 py-0.5 text-[11px] font-semibold text-muted-foreground transition hover:bg-muted"
onClick={() => setConfirmDeleteCompanyId(null)}
>
No
</button>
</div>
) : (
<>
<button
type="button"
className={`flex min-w-0 flex-1 items-center gap-2.5 px-3 py-2 text-left text-[13px] transition hover:bg-muted ${
company.id === currentCompany?.id ? "font-semibold text-foreground" : "text-muted-foreground"
}`}
onClick={() => { void setCompany(company.id); setCompanySwitcherOpen(false); }}
>
<span className="w-4 shrink-0">{company.id === currentCompany?.id ? <Check size={14} weight="bold" className="text-primary" /> : null}</span>
<span className="min-w-0 flex-1 truncate">{company.name}</span>
</button>
<button
type="button"
className="mr-2 rounded p-1 text-muted-foreground opacity-0 transition hover:bg-destructive hover:text-primary-foreground group-hover:opacity-100"
title={`Delete ${company.name}`}
onClick={() => setConfirmDeleteCompanyId(company.id)}
>
<Trash size={13} />
</button>
</>
)}
</div>
))}
</div>
<div className="border-t border-border">
<button
type="button"
className="flex w-full items-center gap-2.5 px-3 py-2 text-left text-[13px] text-muted-foreground transition hover:bg-muted hover:text-foreground"
onClick={() => { void setCompany("__new__"); setCompanySwitcherOpen(false); }}
>
<Plus size={14} />
<span>{t("app.newCompany")}</span>
</button>
</div>
</div>
</>
)}
</div>
<button
aria-label={`Open command palette (${isMac ? "⌘" : "Ctrl+"}K)`}
title={`Command palette (${isMac ? "⌘" : "Ctrl+"}K)`}
className="focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 flex h-[30px] shrink-0 items-center justify-center gap-1 rounded-lg border border-border px-2 text-muted-foreground transition hover:bg-muted hover:text-foreground"
onClick={() => setCommandPaletteOpen(true)}
>
<Command size={14} />
<kbd className="text-[10px] font-medium text-muted-foreground">{isMac ? "⌘K" : "^K"}</kbd>
</button>
</div>
)}
<nav aria-label="Main navigation" className={`flex-1 overflow-y-auto pb-3 ${sidebarCollapsed ? "px-1.5 pt-2" : "px-3 pt-2"}`}>
{/* Core: Overview, Team, Work */}
<div className="space-y-0.5">
{sidebarNav.slice(0, 3).map((item) => (
<SectionButton key={item.id} active={section === item.id} label={item.label} icon={item.icon} onClick={() => setSection(item.id)} badge={navBadges[item.id]?.count} badgeTone={navBadges[item.id]?.tone} collapsed={sidebarCollapsed} />
))}
</div>
<div className={`my-2 border-t border-border ${sidebarCollapsed ? "mx-1" : "mx-2"}`} />
{/* Collaborate & Extend: Communication, Skills, Documents, Approvals, Social */}
<div className="space-y-0.5">
{sidebarNav.slice(3).map((item) => (
<SectionButton key={item.id} active={section === item.id} label={item.label} icon={item.icon} onClick={() => setSection(item.id)} badge={navBadges[item.id]?.count} badgeTone={navBadges[item.id]?.tone} collapsed={sidebarCollapsed} />
))}
</div>
</nav>
<div className={`border-t border-border py-2 ${sidebarCollapsed ? "px-1.5" : "px-3"}`}>
<SectionButton
active={section === "settings"}
label="Settings"
icon={Gear}
onClick={() => setSection("settings")}
collapsed={sidebarCollapsed}
/>
<button
aria-label={sidebarCollapsed ? "Expand sidebar" : "Collapse sidebar"}
title={sidebarCollapsed ? "Expand sidebar" : "Collapse sidebar"}
className={`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 mt-1 flex w-full items-center rounded-lg py-[7px] text-muted-foreground transition duration-150 hover:bg-muted hover:text-foreground ${sidebarCollapsed ? "justify-center p-2" : "gap-2.5 px-3"}`}
onClick={() => setSidebarCollapsed(!sidebarCollapsed)}
>
<SidebarSimple size={sidebarCollapsed ? 18 : 17} />
{!sidebarCollapsed ? <span className="text-[13px] font-medium tracking-[0.005em]">{t("app.collapse")}</span> : null}
</button>
</div>
</aside>
);
}
@@ -0,0 +1,362 @@
import { useState } from "react";
import type {
AgentRecord,
ApprovalRecord,
CompanyRecord,
CostRecord,
DocumentRecord,
GoalRecord,
ProjectRecord,
RunRecord,
SectionId,
TaskRecord,
WorkspaceRecord,
ProfileSnapshot,
} from "@shared/types";
import {
Kanban,
ListChecks,
Target,
} from "@phosphor-icons/react";
import { ConnectorEditor } from "../../components/connectors";
import { KanbanBoard } from "../../components/dashboard";
import { EntityWorkspace } from "../../components/EntityWorkspace";
import { RunCenter } from "../../components/runs";
import {
ActivityList,
ApprovalInspector,
ApprovalList,
BudgetSummary,
CostList,
PendingReviewList,
TaskCreator,
TaskInspector,
TaskQueue,
} from "../../components/execution";
import { PolicyList } from "../../components/execution/PolicyList";
import { IncidentList } from "../../components/execution/IncidentList";
import {
GoalCreator,
GoalEditor,
GoalList,
} from "../../components/organization";
import { ActionButton, ListFrame, ListRow, Modal, Panel, StatusPill } from "../../components/ui";
import { unwrap } from "../../lib/desktop";
interface ExecutionSectionsProps {
section: SectionId;
snapshot: ProfileSnapshot;
currentCompany: CompanyRecord | null;
tasks: TaskRecord[];
runs: RunRecord[];
approvals: ApprovalRecord[];
pendingApprovals: ApprovalRecord[];
companyAgents: AgentRecord[];
companyGoals: GoalRecord[];
companyProjects: ProjectRecord[];
companyWorkspaces: WorkspaceRecord[];
companyCosts: CostRecord[];
companyDocuments: DocumentRecord[];
filteredActivity: ReturnType<ProfileSnapshot["activity"]["filter"]>;
selectedRunId: string | null;
selectedTask: TaskRecord | null;
selectedTaskId: string | null;
setSelectedTaskId: (id: string | null) => void;
selectedConnector: ProfileSnapshot["connectors"][number] | null;
setSelectedConnectorId: (id: string | null) => void;
selectedApproval: ApprovalRecord | null;
selectedApprovalId: string | null;
setSelectedApprovalId: (id: string | null) => void;
selectedGoalId: string | null;
setSelectedGoalId: (id: string | null) => void;
taskViewMode: "list" | "kanban";
setTaskViewMode: (mode: "list" | "kanban") => void;
setSection: (section: SectionId) => void;
setConsoleOpen: (value: boolean) => void;
setSelectedRunId: (id: string | null) => void;
setSelectedCommunicationEntityId: (id: string | null) => void;
refresh: () => Promise<void>;
startRun: (taskId: string) => Promise<void>;
cancelRun: (runId: string) => Promise<void>;
openPathWithFeedback: (path: string) => Promise<void>;
setError: (error: string | null) => void;
}
export function ExecutionSections({
section,
snapshot,
currentCompany,
tasks,
runs,
approvals: _approvals,
pendingApprovals,
companyAgents,
companyGoals,
companyProjects,
companyWorkspaces,
companyCosts,
companyDocuments,
filteredActivity,
selectedRunId,
selectedTask,
selectedTaskId,
setSelectedTaskId,
selectedConnector,
setSelectedConnectorId,
selectedApproval,
selectedApprovalId: _selectedApprovalId,
setSelectedApprovalId,
selectedGoalId,
setSelectedGoalId,
taskViewMode,
setTaskViewMode,
setSection,
setConsoleOpen,
setSelectedRunId,
setSelectedCommunicationEntityId,
refresh,
startRun,
cancelRun,
openPathWithFeedback,
setError: _setError,
}: ExecutionSectionsProps) {
const [costsTab, setCostsTab] = useState<"costs" | "policies" | "incidents">("costs");
const selectedGoal = companyGoals.find((g) => g.id === selectedGoalId) ?? null;
return (
<>
{section === "runs" ? (
<RunCenter
runs={runs}
tasks={tasks}
agents={companyAgents}
workspaces={companyWorkspaces}
selectedRunId={selectedRunId}
onSelectRun={(runId: string) => {
setSelectedRunId(runId);
}}
onOpenLogPath={async (path: string) => {
await openPathWithFeedback(path);
}}
onCancelRun={cancelRun}
onOpenConsole={(runId: string) => {
setSelectedRunId(runId);
setConsoleOpen(true);
}}
/>
) : null}
{section === "connectors" && selectedConnector ? (
<div className="space-y-10">
<Panel title="Connector registry">
<ListFrame>
{snapshot.connectors.map((connector) => (
<ListRow
key={connector.id}
onClick={() => setSelectedConnectorId(connector.id)}
className={`cursor-pointer transition-colors duration-100 ${
selectedConnector.id === connector.id
? "bg-accent"
: "hover:bg-muted"
}`}
>
<div className="flex items-center justify-between">
<div className="min-w-0">
<div className="text-[14px] font-medium text-foreground">{connector.label}</div>
<div className="mt-1 truncate text-[11px] uppercase tracking-[0.12em] text-muted-foreground">{connector.command}</div>
</div>
<StatusPill status={connector.status} />
</div>
</ListRow>
))}
</ListFrame>
</Panel>
<Panel title={selectedConnector.label}>
<ConnectorEditor connector={selectedConnector} onSaved={refresh} />
</Panel>
</div>
) : null}
{section === "tasks" ? (
<>
<Panel title="Goals" action={<ActionButton label="New goal" icon={Target} tone="accent" onClick={() => setSelectedGoalId("__new__")} />}>
<GoalList goals={companyGoals} agents={companyAgents} selectedGoalId={selectedGoalId} onSelect={setSelectedGoalId} />
</Panel>
<Modal open={selectedGoalId === "__new__" && section === "tasks"} title="New goal" onClose={() => setSelectedGoalId(null)}>
<GoalCreator companyId={currentCompany!.id} agents={companyAgents} goals={companyGoals} onSaved={async () => { setSelectedGoalId(null); await refresh(); }} />
</Modal>
<Modal open={!!selectedGoal && section === "tasks"} title={selectedGoal ? `Edit: ${selectedGoal.title}` : ""} onClose={() => setSelectedGoalId(null)}>
{selectedGoal ? (
<GoalEditor
key={selectedGoalId}
goal={selectedGoal}
goals={companyGoals}
agents={companyAgents}
companyId={currentCompany!.id}
onSaved={async () => { setSelectedGoalId(null); await refresh(); }}
onDeleted={async () => { setSelectedGoalId(null); await refresh(); }}
/>
) : null}
</Modal>
<Panel
title="Task queue"
action={
<div className="flex items-center gap-2">
<div className="flex rounded-lg border border-border bg-card">
<button
type="button"
onClick={() => setTaskViewMode("list")}
className={`px-2.5 py-1.5 text-[11px] font-medium transition ${taskViewMode === "list" ? "bg-muted text-foreground" : "text-muted-foreground hover:text-foreground"}`}
>
<ListChecks size={14} />
</button>
<button
type="button"
onClick={() => setTaskViewMode("kanban")}
className={`px-2.5 py-1.5 text-[11px] font-medium transition ${taskViewMode === "kanban" ? "bg-muted text-foreground" : "text-muted-foreground hover:text-foreground"}`}
>
<Kanban size={14} />
</button>
</div>
<ActionButton label="New task" icon={ListChecks} tone="accent" onClick={() => setSelectedTaskId("__new__")} />
</div>
}
>
{taskViewMode === "kanban" ? (
<KanbanBoard tasks={tasks} agents={companyAgents} runs={runs} onSelectTask={setSelectedTaskId} />
) : (
<TaskQueue tasks={tasks} runs={runs} onSelect={setSelectedTaskId} selectedTaskId={selectedTask?.id ?? null} />
)}
</Panel>
<Modal open={selectedTaskId === "__new__"} title="New task" onClose={() => setSelectedTaskId(null)}>
<TaskCreator companyId={currentCompany!.id} goals={companyGoals} projects={companyProjects} agents={companyAgents} workspaces={companyWorkspaces} onSaved={async () => { setSelectedTaskId(null); await refresh(); }} />
</Modal>
<Modal open={!!selectedTask} title={selectedTask?.title ?? ""} onClose={() => setSelectedTaskId(null)} width="720px">
{selectedTask ? (
<TaskInspector
task={selectedTask}
tasks={tasks}
runs={runs.filter((run) => run.taskId === selectedTask.id)}
agents={companyAgents}
goals={companyGoals}
projects={companyProjects}
workspaces={companyWorkspaces}
companyId={currentCompany!.id}
comments={(snapshot.comments ?? []).filter((comment) => comment.taskId === selectedTask.id)}
onRefresh={refresh}
onRun={startRun}
onCancelRun={cancelRun}
onCreateApproval={async () => {
const isBlocked = selectedTask.status === "blocked";
const approvalId = unwrap(await window.agentCompany.requestApproval({
companyId: currentCompany!.id,
relatedTaskId: selectedTask.id,
requestedByAgentId: selectedTask.assigneeAgentId,
type: isBlocked ? "secret_access" : "approve_ceo_strategy",
payloadSummary: isBlocked
? `Blocker: ${selectedTask.title} — needs operator assistance`
: `Review needed: ${selectedTask.title}`,
impactSummary: isBlocked
? "Agent is blocked and needs operator input (credentials, access, or decision)."
: "No automated reviewer available. Operator review required.",
}));
setSelectedApprovalId(approvalId);
await refresh();
}}
onOpenDiscussion={(taskId) => {
setSelectedTaskId(null);
setSection("communication");
setSelectedCommunicationEntityId(taskId);
}}
onDeleted={async () => { setSelectedTaskId(null); await refresh(); }}
/>
) : null}
</Modal>
</>
) : null}
{section === "approvals" ? (
<>
<Panel title="Agent reviews in progress">
<PendingReviewList tasks={tasks} agents={companyAgents} />
</Panel>
<Panel title="Pending approvals">
<ApprovalList approvals={pendingApprovals} selectedApprovalId={selectedApproval?.id ?? null} onSelect={setSelectedApprovalId} />
</Panel>
<Modal open={!!selectedApproval} title={selectedApproval?.payloadSummary ?? "Approval detail"} onClose={() => setSelectedApprovalId(null)}>
{selectedApproval ? (
<ApprovalInspector
approval={selectedApproval}
agents={companyAgents}
tasks={tasks}
documents={companyDocuments}
companyId={currentCompany!.id}
onDecide={async (state, note) => {
unwrap(await window.agentCompany.decideApproval({ companyId: currentCompany!.id, approvalId: selectedApproval.id, state, decisionNote: note ?? `${state} from desktop control surface.` }));
await refresh();
}}
onDeleted={async () => { setSelectedApprovalId(null); await refresh(); }}
/>
) : null}
</Modal>
</>
) : null}
{section === "costs" ? (
<div className="flex h-full flex-col">
<div className="flex items-center gap-1 border-b border-border px-4 pt-2">
{(["costs", "policies", "incidents"] as const).map((tab) => (
<button
key={tab}
type="button"
onClick={() => setCostsTab(tab)}
className={`rounded-t px-3 py-1.5 text-[13px] font-medium transition-colors ${
costsTab === tab
? "border-b-2 border-[color:var(--primary)] text-foreground"
: "text-muted-foreground hover:text-foreground"
}`}
>
{tab === "costs" ? "Cost Entries" : tab === "policies" ? "Policies" : "Incidents"}
</button>
))}
</div>
{costsTab === "costs" ? (
<EntityWorkspace
title="Costs"
eyebrow={undefined}
primary={
<Panel title="Recent cost entries">
<CostList costs={companyCosts} agents={companyAgents} runs={runs} />
</Panel>
}
secondary={
<Panel title="Budget posture">
<BudgetSummary agents={companyAgents} costs={companyCosts} companyId={currentCompany?.id} />
</Panel>
}
/>
) : costsTab === "policies" ? (
<PolicyList
companyId={currentCompany!.id}
agents={companyAgents.map((a) => ({ id: a.id, name: a.name }))}
projects={companyProjects.map((p) => ({ id: p.id, name: p.name }))}
/>
) : (
<IncidentList
companyId={currentCompany!.id}
agents={companyAgents.map((a) => ({ id: a.id, name: a.name }))}
projects={companyProjects.map((p) => ({ id: p.id, name: p.name }))}
/>
)}
</div>
) : null}
{section === "activity" ? (
<Panel title="Activity timeline">
<ActivityList activity={filteredActivity} />
</Panel>
) : null}
</>
);
}
@@ -0,0 +1,326 @@
import type {
AgentRecord,
BrowserActionRecord,
CompanyRecord,
DocumentRecord,
InboxItem,
CompanyMetrics,
KnowledgeEntryRecord,
MeetingRecord,
ProjectRecord,
RunRecord,
SectionId,
SocialAccountRecord,
SprintRecord,
StandupReport,
TaskRecord,
WorkspaceRecord,
ProfileSnapshot,
} from "@shared/types";
import type { AppLocale } from "@shared/locale";
import { Inbox, StandupView, PerformanceView } from "../../components/inbox";
import { Dashboard } from "../../components/dashboard";
import { EntityWorkspace } from "../../components/EntityWorkspace";
import {
SettingsPane,
ModelManagement,
WorkspaceCreator,
WorkspaceInspector,
WorkspaceList,
} from "../../components/execution";
import { SocialAccountsPanel } from "../../components/social";
import { AutomationPanel } from "../../components/automation";
import { CommunicationHub } from "../../components/communication";
import { SkillsSection } from "../../components/skills";
import { DocumentCenter, KnowledgeBaseManager, MeetingsManager, SprintManager } from "../../components/company-operations";
import { Panel } from "../../components/ui";
import { unwrap } from "../../lib/desktop";
interface OperationsSectionsProps {
section: SectionId;
snapshot: ProfileSnapshot;
currentCompany: CompanyRecord | null;
locale: AppLocale;
tasks: TaskRecord[];
runs: RunRecord[];
companyAgents: AgentRecord[];
companyProjects: ProjectRecord[];
companyWorkspaces: WorkspaceRecord[];
companyDocuments: DocumentRecord[];
companyKnowledge: KnowledgeEntryRecord[];
companyMeetings: MeetingRecord[];
companySprints: SprintRecord[];
socialAccounts: SocialAccountRecord[];
browserActions: BrowserActionRecord[];
inboxItems: InboxItem[];
companyMetrics: CompanyMetrics | null;
standupReport: StandupReport | null;
companySecrets: ProfileSnapshot["secrets"];
selectedWorkspace: WorkspaceRecord | null;
setSelectedWorkspaceId: (id: string | null) => void;
selectedCommunicationEntityId: string | null;
setSelectedCommunicationEntityId: (id: string | null) => void;
setSelectedTaskId: (id: string | null) => void;
setSelectedApprovalId: (id: string | null) => void;
setSection: (section: SectionId) => void;
navigateTo: (section: SectionId, entityId?: string) => void;
refresh: () => Promise<void>;
openPathWithFeedback: (path: string) => Promise<void>;
setError: (error: string | null) => void;
filteredActivity: ReturnType<ProfileSnapshot["activity"]["filter"]>;
companyCosts: ReturnType<ProfileSnapshot["costs"]["filter"]>;
companyGoals: ReturnType<NonNullable<ProfileSnapshot["goals"]>["filter"]>;
}
export function OperationsSections({
section,
snapshot,
currentCompany,
locale,
tasks,
runs,
companyAgents,
companyProjects,
companyWorkspaces,
companyDocuments,
companyKnowledge,
companyMeetings,
companySprints,
socialAccounts,
browserActions,
inboxItems,
companyMetrics,
standupReport,
companySecrets,
selectedWorkspace,
setSelectedWorkspaceId,
selectedCommunicationEntityId,
setSelectedCommunicationEntityId,
setSelectedTaskId,
setSelectedApprovalId,
setSection,
navigateTo,
refresh,
openPathWithFeedback,
setError,
filteredActivity,
companyCosts,
companyGoals,
}: OperationsSectionsProps) {
return (
<>
{section === "overview" ? (
<Dashboard
companyName={currentCompany?.name}
companyId={currentCompany?.id}
agents={companyAgents}
tasks={tasks}
runs={runs}
approvals={snapshot.approvals?.filter((a) => !currentCompany || a.companyId === currentCompany.id) ?? []}
goals={companyGoals}
projects={companyProjects}
activity={filteredActivity}
costs={companyCosts}
messages={snapshot.agentMessages?.filter((message) => !currentCompany || message.companyId === currentCompany.id) ?? []}
onNavigate={navigateTo}
/>
) : null}
{section === "inbox" ? (
<Inbox
items={inboxItems}
onNavigate={navigateTo}
/>
) : null}
{section === "standup" ? (
<StandupView
report={standupReport}
onNavigate={navigateTo}
/>
) : null}
{section === "performance" ? (
<PerformanceView
metrics={companyMetrics}
onNavigate={navigateTo}
/>
) : null}
{section === "social" && snapshot?.currentCompanyId && (
<SocialAccountsPanel
accounts={socialAccounts}
actions={browserActions}
agents={companyAgents.map(a => ({ id: a.id, name: a.name }))}
companyId={snapshot.currentCompanyId}
onSave={async (input) => {
try {
unwrap(await window.agentCompany.saveSocialAccount({
companyId: input.companyId,
platform: input.platform,
accountName: input.accountName,
displayName: input.displayName,
requireApproval: input.requireApproval,
profileUrl: "",
status: "login_required",
metadataJson: "{}",
}));
await refresh();
setError(null);
} catch (error) {
setError(error instanceof Error ? error.message : String(error));
}
}}
onDelete={async (id) => {
if (!snapshot?.currentCompanyId) return;
try {
unwrap(await window.agentCompany.deleteSocialAccount({ id, companyId: snapshot.currentCompanyId }));
await refresh();
setError(null);
} catch (error) {
setError(error instanceof Error ? error.message : String(error));
}
}}
onLogin={async (accountId) => {
if (!snapshot?.currentCompanyId) return;
try {
unwrap(await window.agentCompany.triggerBrowserLogin({ companyId: snapshot.currentCompanyId, socialAccountId: accountId }));
await refresh();
setError(null);
} catch (error) {
setError(error instanceof Error ? error.message : String(error));
}
}}
onOpenPath={async (path) => {
try {
unwrap(await window.agentCompany.openPath(path));
setError(null);
} catch (error) {
setError(error instanceof Error ? error.message : String(error));
}
}}
onCancelAction={async (actionId) => {
if (!snapshot?.currentCompanyId) return;
try {
unwrap(await window.agentCompany.cancelBrowserAction({ actionId, companyId: snapshot.currentCompanyId }));
await refresh();
setError(null);
} catch (error) {
setError(error instanceof Error ? error.message : String(error));
}
}}
onNavigate={(sectionName, entityId) => {
setSection(sectionName);
if (sectionName === "tasks") setSelectedTaskId(entityId);
if (sectionName === "approvals") setSelectedApprovalId(entityId);
}}
/>
)}
{section === "skills" && currentCompany ? (
<SkillsSection companyId={currentCompany.id} agents={companyAgents} onRefresh={refresh} />
) : null}
{section === "automation" && currentCompany ? (
<AutomationPanel
key={currentCompany.id}
rules={snapshot.automationRules?.filter(r => r.companyId === currentCompany.id) ?? []}
workflows={snapshot.workflows?.filter(w => w.companyId === currentCompany.id) ?? []}
companyId={currentCompany.id}
onRefresh={refresh}
/>
) : null}
{section === "communication" && currentCompany ? (
<CommunicationHub
messages={snapshot.agentMessages?.filter(m => m.companyId === currentCompany.id) ?? []}
comments={snapshot.comments?.filter((comment) => comment.companyId === currentCompany.id) ?? []}
tasks={tasks}
agents={companyAgents}
projects={companyProjects}
documents={companyDocuments}
companyId={currentCompany.id}
selectedEntityId={selectedCommunicationEntityId}
onEntityConsumed={() => setSelectedCommunicationEntityId(null)}
onNavigateToTask={(taskId) => {
setSection("tasks");
setSelectedTaskId(taskId);
}}
onRefresh={refresh}
/>
) : null}
{section === "documents" && currentCompany ? (
<DocumentCenter
companyId={currentCompany.id}
documents={companyDocuments}
agents={companyAgents}
projects={companyProjects}
goals={companyGoals}
onRefresh={refresh}
/>
) : null}
{section === "knowledge" && currentCompany ? (
<KnowledgeBaseManager companyId={currentCompany.id} entries={companyKnowledge} onRefresh={refresh} />
) : null}
{section === "meetings" && currentCompany ? (
<MeetingsManager companyId={currentCompany.id} meetings={companyMeetings} agents={companyAgents} onRefresh={refresh} />
) : null}
{section === "sprints" && currentCompany ? (
<SprintManager companyId={currentCompany.id} sprints={companySprints} onRefresh={refresh} />
) : null}
{section === "workspaces" && currentCompany ? (
<EntityWorkspace
title="Workspaces"
eyebrow={undefined}
primary={
<Panel title="Workspace registry">
<WorkspaceList
workspaces={companyWorkspaces}
projects={companyProjects}
companyId={currentCompany!.id}
selectedWorkspaceId={selectedWorkspace?.id ?? null}
onSelect={setSelectedWorkspaceId}
onOpen={openPathWithFeedback}
onDeleted={refresh}
/>
</Panel>
}
secondary={
<div className="space-y-6">
<Panel title="Workspace control center">
<WorkspaceInspector
workspace={selectedWorkspace}
agents={companyAgents}
tasks={tasks}
runs={runs}
documents={companyDocuments}
project={selectedWorkspace ? (companyProjects.find((project) => project.id === selectedWorkspace.projectId) ?? null) : null}
onOpen={openPathWithFeedback}
/>
</Panel>
<Panel title="Add workspace">
<WorkspaceCreator companyId={currentCompany!.id} projects={companyProjects} onSaved={refresh} />
</Panel>
</div>
}
/>
) : null}
{section === "settings" && currentCompany ? (
<div className="space-y-10">
<Panel title={locale === "zh" ? "配置" : "Profile and release"}>
<SettingsPane snapshot={snapshot} secrets={companySecrets} companyId={currentCompany!.id} onSaved={refresh} />
</Panel>
<Panel title={locale === "zh" ? "模型管理" : "Model Management"}>
<ModelManagement connectors={snapshot.connectors} locale={locale} onSaved={refresh} />
</Panel>
</div>
) : null}
</>
);
}
@@ -0,0 +1,175 @@
import type {
AgentRecord,
CompanyRecord,
GoalRecord,
ProjectRecord,
WorkspaceRecord,
ProfileSnapshot,
SectionId,
} from "@shared/types";
import {
Target,
UserPlus,
Kanban,
} from "@phosphor-icons/react";
import {
AgentCreator,
AgentEditor,
AgentRoster,
GoalCreator,
GoalEditor,
GoalList,
OrgChart,
ProjectCreator,
ProjectEditor,
ProjectList,
} from "../../components/organization";
import { HiringPipeline } from "../../components/hiring";
import { ActionButton, Modal, Panel } from "../../components/ui";
interface OrganizationSectionsProps {
section: SectionId;
snapshot: ProfileSnapshot;
currentCompany: CompanyRecord | null;
companyAgents: AgentRecord[];
companyGoals: GoalRecord[];
companyProjects: ProjectRecord[];
companyWorkspaces: WorkspaceRecord[];
selectedAgentId: string | null;
setSelectedAgentId: (id: string | null) => void;
selectedGoalId: string | null;
setSelectedGoalId: (id: string | null) => void;
selectedProjectId: string | null;
setSelectedProjectId: (id: string | null) => void;
setSection: (section: SectionId) => void;
refresh: () => Promise<void>;
}
export function OrganizationSections({
section,
snapshot,
currentCompany,
companyAgents,
companyGoals,
companyProjects,
companyWorkspaces,
selectedAgentId,
setSelectedAgentId,
selectedGoalId,
setSelectedGoalId,
selectedProjectId,
setSelectedProjectId,
setSection,
refresh,
}: OrganizationSectionsProps) {
const selectedAgent = companyAgents.find((a) => a.id === selectedAgentId) ?? null;
const selectedGoal = companyGoals.find((g) => g.id === selectedGoalId) ?? null;
const selectedProject = companyProjects.find((p) => p.id === selectedProjectId) ?? null;
return (
<>
{section === "agents" ? (
<>
<OrgChart agents={companyAgents} connectors={snapshot.connectors} onSelectAgent={(id) => setSelectedAgentId(id)} />
<Panel title="Agent roster" action={<ActionButton label="New hire request" icon={UserPlus} tone="accent" onClick={() => setSelectedAgentId("__new__")} />}>
<AgentRoster
agents={companyAgents}
connectors={snapshot.connectors}
workspaces={companyWorkspaces}
selectedAgentId={selectedAgentId}
onSelect={setSelectedAgentId}
/>
</Panel>
<Modal open={selectedAgentId === "__new__"} title="Request new hire" onClose={() => setSelectedAgentId(null)}>
<AgentCreator
companyId={currentCompany!.id}
connectors={snapshot.connectors}
workspaces={companyWorkspaces}
agents={companyAgents}
onSaved={async () => {
setSelectedAgentId(null);
setSection("hiring");
await refresh();
}}
/>
</Modal>
<Modal open={!!selectedAgent} title={selectedAgent ? `Edit: ${selectedAgent.name}` : ""} onClose={() => setSelectedAgentId(null)}>
{selectedAgent ? (
<AgentEditor
key={selectedAgentId}
agent={selectedAgent}
connectors={snapshot.connectors}
workspaces={companyWorkspaces}
agents={companyAgents}
companyId={currentCompany!.id}
onSaved={refresh}
onDeleted={async () => { setSelectedAgentId(null); await refresh(); }}
/>
) : null}
</Modal>
</>
) : null}
{section === "orgchart" ? (
<OrgChart agents={companyAgents} connectors={snapshot.connectors} onSelectAgent={(id) => { setSelectedAgentId(id); setSection("agents"); }} />
) : null}
{section === "hiring" && currentCompany ? (
<HiringPipeline
agents={companyAgents}
approvals={(snapshot?.approvals ?? []).filter(a => a.companyId === currentCompany!.id)}
onRefresh={refresh}
onNavigateToAgent={(id) => { setSelectedAgentId(id); setSection("agents"); }}
/>
) : null}
{section === "goals" ? (
<>
<Panel title="Goal stack" action={<ActionButton label="New goal" icon={Target} tone="accent" onClick={() => setSelectedGoalId("__new__")} />}>
<GoalList goals={companyGoals} agents={companyAgents} selectedGoalId={selectedGoalId} onSelect={setSelectedGoalId} />
</Panel>
<Modal open={selectedGoalId === "__new__"} title="New goal" onClose={() => setSelectedGoalId(null)}>
<GoalCreator companyId={currentCompany!.id} agents={companyAgents} goals={companyGoals} onSaved={async () => { setSelectedGoalId(null); await refresh(); }} />
</Modal>
<Modal open={!!selectedGoal} title={selectedGoal ? `Edit: ${selectedGoal.title}` : ""} onClose={() => setSelectedGoalId(null)}>
{selectedGoal ? (
<GoalEditor
key={selectedGoalId}
goal={selectedGoal}
goals={companyGoals}
agents={companyAgents}
companyId={currentCompany!.id}
onSaved={async () => { setSelectedGoalId(null); await refresh(); }}
onDeleted={async () => { setSelectedGoalId(null); await refresh(); }}
/>
) : null}
</Modal>
</>
) : null}
{section === "projects" ? (
<>
<Panel title="Projects" action={<ActionButton label="New project" icon={Kanban} tone="accent" onClick={() => setSelectedProjectId("__new__")} />}>
<ProjectList projects={companyProjects} goals={companyGoals} agents={companyAgents} workspaces={companyWorkspaces} selectedProjectId={selectedProjectId} onSelect={setSelectedProjectId} />
</Panel>
<Modal open={selectedProjectId === "__new__"} title="New project" onClose={() => setSelectedProjectId(null)}>
<ProjectCreator companyId={currentCompany!.id} goals={companyGoals} agents={companyAgents} onSaved={async () => { setSelectedProjectId(null); await refresh(); }} />
</Modal>
<Modal open={!!selectedProject} title={selectedProject ? `Edit: ${selectedProject.name}` : ""} onClose={() => setSelectedProjectId(null)}>
{selectedProject ? (
<ProjectEditor
key={selectedProjectId}
project={selectedProject}
goals={companyGoals}
agents={companyAgents}
companyId={currentCompany!.id}
onSaved={async () => { setSelectedProjectId(null); await refresh(); }}
onDeleted={async () => { setSelectedProjectId(null); await refresh(); }}
/>
) : null}
</Modal>
</>
) : null}
</>
);
}