refactor(renderer): dismantle useAppController 47-prop god-hook
Sections now subscribe directly to the Zustand store via useSectionContext
(shared data derivation) and useAppStore fine-grained selectors. Delete
useAppController, useExecutionController, useOrganizationController, and
useCommunicationController; the three domain forwarders held no logic
beyond re-exporting store slices.
SectionContentView becomes a 50-line layout dispatcher taking only
{section, error, pageTransition}; cross-domain run actions (startRun /
cancelRun) move into App.tsx and are exposed to sections through a new
AppActionsContext alongside refresh / setError / openPathWithFeedback.
App.tsx now calls useUIController + useCompanyController directly and
composes palette + navigation plumbing itself.
This commit is contained in:
1 parent
de77f5f38e
commit
e2253b92fa
12 files changed
+339
-897
No files matched your search
@@ -1,12 +1,4 @@
|
||||
import type {
|
||||
AgentRecord,
|
||||
CompanyRecord,
|
||||
GoalRecord,
|
||||
ProjectRecord,
|
||||
WorkspaceRecord,
|
||||
ProfileSnapshot,
|
||||
SectionId,
|
||||
} from "@shared/types";
|
||||
import type { SectionId } from "@shared/types";
|
||||
import { NEW_ENTITY_ID } from "../../lib/constants";
|
||||
import {
|
||||
Target,
|
||||
@@ -28,48 +20,38 @@ import {
|
||||
import { HiringPipeline } from "../../components/hiring";
|
||||
import { ActionButton, Modal, Panel } from "../../components/ui";
|
||||
import { useT } from "../../i18n";
|
||||
import { useAppStore } from "../../state/store";
|
||||
import { useSectionContext } from "../../hooks/useSectionContext";
|
||||
import { useAppActions } from "../../hooks/useAppActions";
|
||||
|
||||
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) {
|
||||
export function OrganizationSections({ section }: OrganizationSectionsProps) {
|
||||
const t = useT();
|
||||
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;
|
||||
const {
|
||||
snapshot,
|
||||
currentCompany,
|
||||
companyAgents,
|
||||
companyGoals,
|
||||
companyProjects,
|
||||
companyWorkspaces,
|
||||
selectedAgent,
|
||||
selectedGoal,
|
||||
selectedProject,
|
||||
} = useSectionContext();
|
||||
const { refresh } = useAppActions();
|
||||
|
||||
if (!currentCompany) return null;
|
||||
const selectedAgentId = useAppStore((s) => s.selectedAgentId);
|
||||
const setSelectedAgentId = useAppStore((s) => s.setSelectedAgentId);
|
||||
const selectedGoalId = useAppStore((s) => s.selectedGoalId);
|
||||
const setSelectedGoalId = useAppStore((s) => s.setSelectedGoalId);
|
||||
const selectedProjectId = useAppStore((s) => s.selectedProjectId);
|
||||
const setSelectedProjectId = useAppStore((s) => s.setSelectedProjectId);
|
||||
const setSection = useAppStore((s) => s.setSection);
|
||||
|
||||
if (!snapshot || !currentCompany) return null;
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
Reference in new issue
Block a user