update
This commit is contained in:
1 parent
806200b3d1
commit
5547c29491
216 files changed
+5043
-3352
No files matched your search
@@ -1,20 +1,34 @@
|
||||
import { useCallback, useState } from "react";
|
||||
import { Buildings, FolderOpen } from "../ui/icons";
|
||||
import type { ConnectorId } from "@shared/types";
|
||||
import { ActionButton, Input, TextArea, Select } from "../ui";
|
||||
import { OnboardingStep } from "./OnboardingStep";
|
||||
import { useOnboarding } from "./OnboardingContext";
|
||||
import {
|
||||
useOnboardingConnectors,
|
||||
useOnboardingWizard,
|
||||
} from "./OnboardingContext";
|
||||
|
||||
export interface CompanyStepValues {
|
||||
companyName: string;
|
||||
companyDescription: string;
|
||||
workspacePath: string;
|
||||
}
|
||||
|
||||
interface CompanyStepProps {
|
||||
onContinue: () => void;
|
||||
initialValues: CompanyStepValues;
|
||||
onPickDirectory: () => Promise<string | null>;
|
||||
onContinue: (values: CompanyStepValues) => void;
|
||||
onBack: () => void;
|
||||
}
|
||||
|
||||
export function CompanyStep({ onContinue, onBack }: CompanyStepProps) {
|
||||
export function CompanyStep({
|
||||
initialValues,
|
||||
onPickDirectory,
|
||||
onContinue,
|
||||
onBack,
|
||||
}: CompanyStepProps) {
|
||||
const { currentLocale, t, error } = useOnboardingWizard();
|
||||
const {
|
||||
companyName,
|
||||
setCompanyName,
|
||||
companyDescription,
|
||||
setCompanyDescription,
|
||||
selectedConnectorId,
|
||||
setSelectedConnectorId,
|
||||
selectedModel,
|
||||
@@ -22,13 +36,20 @@ export function CompanyStep({ onContinue, onBack }: CompanyStepProps) {
|
||||
executionReadyConnectors,
|
||||
modelOptions,
|
||||
loadingModels,
|
||||
workspacePath,
|
||||
setWorkspacePath,
|
||||
onPickDirectory,
|
||||
error,
|
||||
currentLocale,
|
||||
t,
|
||||
} = useOnboarding();
|
||||
} = useOnboardingConnectors();
|
||||
|
||||
const [companyName, setCompanyName] = useState(initialValues.companyName);
|
||||
const [companyDescription, setCompanyDescription] = useState(initialValues.companyDescription);
|
||||
const [workspacePath, setWorkspacePath] = useState(initialValues.workspacePath);
|
||||
|
||||
const handlePick = useCallback(async () => {
|
||||
const picked = await onPickDirectory();
|
||||
if (picked) setWorkspacePath(picked);
|
||||
}, [onPickDirectory]);
|
||||
|
||||
const handleContinue = useCallback(() => {
|
||||
onContinue({ companyName, companyDescription, workspacePath });
|
||||
}, [companyName, companyDescription, workspacePath, onContinue]);
|
||||
|
||||
return (
|
||||
<OnboardingStep
|
||||
@@ -88,7 +109,10 @@ export function CompanyStep({ onContinue, onBack }: CompanyStepProps) {
|
||||
htmlFor="onboarding-workspace-path"
|
||||
className="mb-1.5 block text-[12px] font-medium text-muted-foreground"
|
||||
>
|
||||
{t("onboarding.workspaceFolder")} <span className="font-normal text-muted-foreground">{t("onboarding.workspaceFolderOptional")}</span>
|
||||
{t("onboarding.workspaceFolder")}{" "}
|
||||
<span className="font-normal text-muted-foreground">
|
||||
{t("onboarding.workspaceFolderOptional")}
|
||||
</span>
|
||||
</label>
|
||||
<div className="flex gap-3">
|
||||
<Input
|
||||
@@ -98,7 +122,11 @@ export function CompanyStep({ onContinue, onBack }: CompanyStepProps) {
|
||||
onChange={setWorkspacePath}
|
||||
placeholder={t("onboarding.workspaceFolderPlaceholder")}
|
||||
/>
|
||||
<ActionButton label={currentLocale === "zh" ? "选择" : "Choose"} onClick={onPickDirectory} icon={FolderOpen} />
|
||||
<ActionButton
|
||||
label={currentLocale === "zh" ? "选择" : "Choose"}
|
||||
onClick={() => void handlePick()}
|
||||
icon={FolderOpen}
|
||||
/>
|
||||
</div>
|
||||
<div className="mt-1.5 text-[11px] text-muted-foreground">
|
||||
{t("onboarding.workspaceHelp")}
|
||||
@@ -122,7 +150,7 @@ export function CompanyStep({ onContinue, onBack }: CompanyStepProps) {
|
||||
</button>
|
||||
<ActionButton
|
||||
label={t("onboarding.continue")}
|
||||
onClick={onContinue}
|
||||
onClick={handleContinue}
|
||||
icon={Buildings}
|
||||
tone="accent"
|
||||
disabled={!companyName.trim() || !selectedConnectorId}
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
import { useState } from "react";
|
||||
import { ArrowRight, Brain, UserCircle, type Icon } from "../ui/icons";
|
||||
import type { ExecutionMode } from "@shared/types";
|
||||
import { OnboardingStep } from "./OnboardingStep";
|
||||
import { useOnboarding } from "./OnboardingContext";
|
||||
import { useOnboardingWizard } from "./OnboardingContext";
|
||||
|
||||
interface ExecutionModeStepProps {
|
||||
onContinue: () => void;
|
||||
initialValue: ExecutionMode;
|
||||
onContinue: (mode: ExecutionMode) => void;
|
||||
onBack: () => void;
|
||||
}
|
||||
|
||||
export function ExecutionModeStep({ onContinue, onBack }: ExecutionModeStepProps) {
|
||||
const { executionMode, setExecutionMode, t } = useOnboarding();
|
||||
export function ExecutionModeStep({ initialValue, onContinue, onBack }: ExecutionModeStepProps) {
|
||||
const { t } = useOnboardingWizard();
|
||||
const [executionMode, setExecutionMode] = useState<ExecutionMode>(initialValue);
|
||||
|
||||
return (
|
||||
<OnboardingStep
|
||||
@@ -49,7 +53,7 @@ export function ExecutionModeStep({ onContinue, onBack }: ExecutionModeStepProps
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={onContinue}
|
||||
onClick={() => onContinue(executionMode)}
|
||||
className="flex items-center gap-2 rounded-md bg-[color:var(--primary)] px-4 py-2 text-[13px] font-medium text-white transition hover:opacity-90"
|
||||
>
|
||||
{t("onboarding.continue")}
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
import { motion } from "framer-motion";
|
||||
import { CheckCircle, Rocket } from "../ui/icons";
|
||||
import { ActionButton } from "../ui";
|
||||
import { useOnboarding } from "./OnboardingContext";
|
||||
import {
|
||||
useOnboardingConnectors,
|
||||
useOnboardingWizard,
|
||||
} from "./OnboardingContext";
|
||||
|
||||
interface LaunchStepProps {
|
||||
onFinish: () => void;
|
||||
}
|
||||
|
||||
export function LaunchStep({ onFinish }: LaunchStepProps) {
|
||||
const { launchSummary, selectedConnector, loading, error, t } = useOnboarding();
|
||||
const { launchSummary, loading, error, t } = useOnboardingWizard();
|
||||
const { selectedConnector } = useOnboardingConnectors();
|
||||
|
||||
if (!launchSummary) return null;
|
||||
|
||||
|
||||
@@ -1,24 +1,29 @@
|
||||
import { useCallback, useState } from "react";
|
||||
import { motion } from "framer-motion";
|
||||
import { Cpu, Lightning } from "../ui/icons";
|
||||
import { ActionButton, Input, TextArea } from "../ui";
|
||||
import { getStepNumber, TOTAL_STEPS } from "./OnboardingHero";
|
||||
import { useOnboarding } from "./OnboardingContext";
|
||||
import { useOnboardingWizard } from "./OnboardingContext";
|
||||
|
||||
export interface MissionStepValues {
|
||||
goalTitle: string;
|
||||
goalDescription: string;
|
||||
}
|
||||
|
||||
interface MissionStepProps {
|
||||
onLaunch: () => void;
|
||||
initialValues: MissionStepValues;
|
||||
onLaunch: (values: MissionStepValues) => void;
|
||||
onBack: () => void;
|
||||
}
|
||||
|
||||
export function MissionStep({ onLaunch, onBack }: MissionStepProps) {
|
||||
const {
|
||||
goalTitle,
|
||||
setGoalTitle,
|
||||
goalDescription,
|
||||
setGoalDescription,
|
||||
loading,
|
||||
error,
|
||||
t,
|
||||
} = useOnboarding();
|
||||
export function MissionStep({ initialValues, onLaunch, onBack }: MissionStepProps) {
|
||||
const { loading, error, t } = useOnboardingWizard();
|
||||
const [goalTitle, setGoalTitle] = useState(initialValues.goalTitle);
|
||||
const [goalDescription, setGoalDescription] = useState(initialValues.goalDescription);
|
||||
|
||||
const handleLaunch = useCallback(() => {
|
||||
onLaunch({ goalTitle, goalDescription });
|
||||
}, [goalTitle, goalDescription, onLaunch]);
|
||||
|
||||
return (
|
||||
<motion.div
|
||||
@@ -80,7 +85,7 @@ export function MissionStep({ onLaunch, onBack }: MissionStepProps) {
|
||||
</button>
|
||||
<ActionButton
|
||||
label={loading ? t("onboarding.launching") : t("onboarding.launchCompany")}
|
||||
onClick={onLaunch}
|
||||
onClick={handleLaunch}
|
||||
icon={Lightning}
|
||||
tone="accent"
|
||||
loading={loading}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import { ActionButton } from "../ui";
|
||||
import { ModelToggleList, StatusBadge } from "../execution/ModelManagementShared";
|
||||
import { OnboardingStep } from "./OnboardingStep";
|
||||
import { useOnboarding } from "./OnboardingContext";
|
||||
import {
|
||||
useOnboardingConnectors,
|
||||
useOnboardingWizard,
|
||||
} from "./OnboardingContext";
|
||||
|
||||
interface ModelPoolStepProps {
|
||||
onBack: () => void;
|
||||
@@ -9,16 +12,14 @@ interface ModelPoolStepProps {
|
||||
}
|
||||
|
||||
export function ModelPoolStep({ onBack, onContinue }: ModelPoolStepProps) {
|
||||
const { error, t } = useOnboardingWizard();
|
||||
const {
|
||||
currentLocale,
|
||||
connectorModelPools,
|
||||
error,
|
||||
onToggleConnectorModel,
|
||||
selectedConnectorId,
|
||||
selectedConnectorEnabledModels,
|
||||
totalEnabledModels,
|
||||
t,
|
||||
} = useOnboarding();
|
||||
} = useOnboardingConnectors();
|
||||
|
||||
const selectedConnectorIsRunnable = selectedConnectorEnabledModels > 0;
|
||||
const hasAnyEnabledModels = totalEnabledModels > 0;
|
||||
@@ -53,23 +54,20 @@ export function ModelPoolStep({ onBack, onContinue }: ModelPoolStepProps) {
|
||||
</span>
|
||||
{connector.id === selectedConnectorId ? (
|
||||
<span className="rounded-full bg-accent px-2 py-0.5 text-[10px] font-semibold uppercase tracking-[0.06em] text-primary">
|
||||
{currentLocale === "zh" ? "CEO 当前运行时" : "CEO runtime"}
|
||||
{t("models.ceoRuntime")}
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="mt-1 text-[11px] text-muted-foreground">
|
||||
{currentLocale === "zh"
|
||||
? `已启用 ${enabledCount} / ${models.length || 0} 个模型`
|
||||
: `${enabledCount} / ${models.length || 0} models enabled`}
|
||||
{t("models.poolSummary").replace("{enabled}", String(enabledCount)).replace("{total}", String(models.length || 0))}
|
||||
</div>
|
||||
</div>
|
||||
<StatusBadge status={connector.status} zh={currentLocale === "zh"} />
|
||||
<StatusBadge status={connector.status} />
|
||||
</div>
|
||||
<ModelToggleList
|
||||
models={models}
|
||||
onToggle={(modelId) => void onToggleConnectorModel(connector.id, modelId)}
|
||||
canRemove={false}
|
||||
zh={currentLocale === "zh"}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
import { ActionButton } from "../ui";
|
||||
import type { TerminalCommandKey } from "@shared/contracts";
|
||||
import { OnboardingStep } from "./OnboardingStep";
|
||||
import { useOnboarding } from "./OnboardingContext";
|
||||
import { useOnboardingWizard } from "./OnboardingContext";
|
||||
|
||||
interface NodeCheckStepProps {
|
||||
onContinue: () => void;
|
||||
@@ -44,7 +44,7 @@ node -v`,
|
||||
};
|
||||
|
||||
export function NodeCheckStep({ onContinue, onBack }: NodeCheckStepProps) {
|
||||
const { nodeStatus, nodeChecking, onCheckNode, onInstallCommand, t } = useOnboarding();
|
||||
const { nodeStatus, nodeChecking, onCheckNode, onInstallCommand, t } = useOnboardingWizard();
|
||||
const platform = window.agentCompany.platform;
|
||||
const platformInfo = INSTALL_COMMANDS[platform] ?? INSTALL_COMMANDS.linux;
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ import { createContext, useContext, type ReactNode } from "react";
|
||||
import type { AppLocale } from "@shared/locale";
|
||||
import type {
|
||||
ConnectorId,
|
||||
ExecutionMode,
|
||||
OnboardingBootstrapResult,
|
||||
ProfileSnapshot,
|
||||
} from "@shared/types";
|
||||
@@ -10,18 +9,47 @@ import type { ConnectorModelEntry } from "@shared/connector-models";
|
||||
import type { TerminalCommandKey } from "@shared/contracts";
|
||||
import type { TranslationFn } from "../../i18n";
|
||||
|
||||
export interface OnboardingContextValue {
|
||||
/**
|
||||
* Wizard-level shell state: locale, translation, load/error, finalized
|
||||
* launch snapshot. Narrow on purpose so that typing in a step does not
|
||||
* invalidate every consumer.
|
||||
*/
|
||||
export interface OnboardingWizardContextValue {
|
||||
currentLocale: AppLocale;
|
||||
t: TranslationFn;
|
||||
|
||||
error: string | null;
|
||||
loading: boolean;
|
||||
|
||||
launchSummary: OnboardingBootstrapResult | null;
|
||||
nodeStatus: { installed: boolean; version: string | null } | null;
|
||||
nodeChecking: boolean;
|
||||
onCheckNode: () => void;
|
||||
onInstallCommand: (commandKey: TerminalCommandKey) => void;
|
||||
}
|
||||
|
||||
const OnboardingWizardContext = createContext<OnboardingWizardContextValue | null>(null);
|
||||
|
||||
export function OnboardingWizardProvider({
|
||||
value,
|
||||
children,
|
||||
}: {
|
||||
value: OnboardingWizardContextValue;
|
||||
children: ReactNode;
|
||||
}) {
|
||||
return <OnboardingWizardContext.Provider value={value}>{children}</OnboardingWizardContext.Provider>;
|
||||
}
|
||||
|
||||
export function useOnboardingWizard(): OnboardingWizardContextValue {
|
||||
const ctx = useContext(OnboardingWizardContext);
|
||||
if (!ctx) {
|
||||
throw new Error("useOnboardingWizard must be used within an OnboardingWizardProvider");
|
||||
}
|
||||
return ctx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Connector/model slice. Shared by CompanyStep, ModelPoolStep, LaunchStep.
|
||||
*/
|
||||
export interface OnboardingConnectorsContextValue {
|
||||
connectors: ProfileSnapshot["connectors"];
|
||||
hasAtLeastOneReady: boolean;
|
||||
onTestConnector: (connectorId: string) => void;
|
||||
@@ -33,11 +61,6 @@ export interface OnboardingContextValue {
|
||||
) => void;
|
||||
onLoginConnector: (connectorId: string) => void;
|
||||
|
||||
companyName: string;
|
||||
setCompanyName: (value: string) => void;
|
||||
companyDescription: string;
|
||||
setCompanyDescription: (value: string) => void;
|
||||
|
||||
selectedConnectorId: ConnectorId | "";
|
||||
setSelectedConnectorId: (value: ConnectorId | "") => void;
|
||||
selectedModel: string;
|
||||
@@ -54,38 +77,30 @@ export interface OnboardingContextValue {
|
||||
totalEnabledModels: number;
|
||||
selectedConnectorEnabledModels: number;
|
||||
onToggleConnectorModel: (connectorId: ConnectorId, modelId: string) => void;
|
||||
|
||||
workspacePath: string;
|
||||
setWorkspacePath: (value: string) => void;
|
||||
onPickDirectory: () => void;
|
||||
|
||||
executionMode: ExecutionMode;
|
||||
setExecutionMode: (value: ExecutionMode) => void;
|
||||
|
||||
goalTitle: string;
|
||||
setGoalTitle: (value: string) => void;
|
||||
goalDescription: string;
|
||||
setGoalDescription: (value: string) => void;
|
||||
|
||||
launchSummary: OnboardingBootstrapResult | null;
|
||||
}
|
||||
|
||||
const OnboardingContext = createContext<OnboardingContextValue | null>(null);
|
||||
const OnboardingConnectorsContext = createContext<OnboardingConnectorsContextValue | null>(null);
|
||||
|
||||
export function OnboardingProvider({
|
||||
export function OnboardingConnectorsProvider({
|
||||
value,
|
||||
children,
|
||||
}: {
|
||||
value: OnboardingContextValue;
|
||||
value: OnboardingConnectorsContextValue;
|
||||
children: ReactNode;
|
||||
}) {
|
||||
return <OnboardingContext.Provider value={value}>{children}</OnboardingContext.Provider>;
|
||||
return (
|
||||
<OnboardingConnectorsContext.Provider value={value}>
|
||||
{children}
|
||||
</OnboardingConnectorsContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
export function useOnboarding(): OnboardingContextValue {
|
||||
const ctx = useContext(OnboardingContext);
|
||||
export function useOnboardingConnectors(): OnboardingConnectorsContextValue {
|
||||
const ctx = useContext(OnboardingConnectorsContext);
|
||||
if (!ctx) {
|
||||
throw new Error("useOnboarding must be used within an OnboardingProvider");
|
||||
throw new Error(
|
||||
"useOnboardingConnectors must be used within an OnboardingConnectorsProvider",
|
||||
);
|
||||
}
|
||||
return ctx;
|
||||
}
|
||||
@@ -1,13 +1,14 @@
|
||||
import { AnimatePresence } from "framer-motion";
|
||||
import type { ExecutionMode } from "@shared/types";
|
||||
import { OnboardingHero, type OnboardingStep } from "./OnboardingHero";
|
||||
import { NodeCheckStep } from "./NodeCheckStep";
|
||||
import { ProvidersStep } from "./ProvidersStep";
|
||||
import { CompanyStep } from "./CompanyStep";
|
||||
import { CompanyStep, type CompanyStepValues } from "./CompanyStep";
|
||||
import { ModelPoolStep } from "./ModelPoolStep";
|
||||
import { ExecutionModeStep } from "./ExecutionModeStep";
|
||||
import { MissionStep } from "./MissionStep";
|
||||
import { MissionStep, type MissionStepValues } from "./MissionStep";
|
||||
import { LaunchStep } from "./LaunchStep";
|
||||
import { useOnboarding } from "./OnboardingContext";
|
||||
import { useOnboardingWizard } from "./OnboardingContext";
|
||||
|
||||
interface OnboardingStepPanelProps {
|
||||
step: OnboardingStep;
|
||||
@@ -17,11 +18,15 @@ interface OnboardingStepPanelProps {
|
||||
onBack: (step: OnboardingStep) => void;
|
||||
onContinueFromNodeCheck: () => void;
|
||||
onContinueFromProviders: () => void;
|
||||
onContinueFromCompany: () => void;
|
||||
onContinueFromCompany: (values: CompanyStepValues) => void;
|
||||
onContinueFromModelPool: () => void;
|
||||
onContinueFromExecutionMode: () => void;
|
||||
onLaunchCompany: () => void;
|
||||
onContinueFromExecutionMode: (mode: ExecutionMode) => void;
|
||||
onLaunchCompany: (values: MissionStepValues) => void;
|
||||
onFinishLaunch: () => void;
|
||||
onPickDirectory: () => Promise<string | null>;
|
||||
companyValues: CompanyStepValues;
|
||||
missionValues: MissionStepValues;
|
||||
executionMode: ExecutionMode;
|
||||
}
|
||||
|
||||
export function OnboardingStepPanel({
|
||||
@@ -37,16 +42,16 @@ export function OnboardingStepPanel({
|
||||
onContinueFromExecutionMode,
|
||||
onLaunchCompany,
|
||||
onFinishLaunch,
|
||||
onPickDirectory,
|
||||
companyValues,
|
||||
missionValues,
|
||||
executionMode,
|
||||
}: OnboardingStepPanelProps) {
|
||||
const { currentLocale, t, launchSummary } = useOnboarding();
|
||||
const { currentLocale, t, launchSummary } = useOnboardingWizard();
|
||||
|
||||
return (
|
||||
<>
|
||||
<OnboardingHero
|
||||
step={step}
|
||||
currentLocale={currentLocale}
|
||||
t={t}
|
||||
/>
|
||||
<OnboardingHero step={step} currentLocale={currentLocale} t={t} />
|
||||
|
||||
<div className="min-h-0 overflow-y-auto border-l border-border bg-background">
|
||||
<div className="relative flex min-h-full items-center px-6 py-10 md:px-10">
|
||||
@@ -77,6 +82,8 @@ export function OnboardingStepPanel({
|
||||
|
||||
{step === "company" ? (
|
||||
<CompanyStep
|
||||
initialValues={companyValues}
|
||||
onPickDirectory={onPickDirectory}
|
||||
onContinue={onContinueFromCompany}
|
||||
onBack={() => onBack("providers")}
|
||||
/>
|
||||
@@ -91,6 +98,7 @@ export function OnboardingStepPanel({
|
||||
|
||||
{step === "executionmode" ? (
|
||||
<ExecutionModeStep
|
||||
initialValue={executionMode}
|
||||
onContinue={onContinueFromExecutionMode}
|
||||
onBack={() => onBack("modelpool")}
|
||||
/>
|
||||
@@ -98,6 +106,7 @@ export function OnboardingStepPanel({
|
||||
|
||||
{step === "mission" ? (
|
||||
<MissionStep
|
||||
initialValues={missionValues}
|
||||
onLaunch={onLaunchCompany}
|
||||
onBack={() => onBack("executionmode")}
|
||||
/>
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import type { ConnectorId, ExecutionMode, OnboardingBootstrapResult, ProfileSnapshot } from "@shared/types";
|
||||
import type {
|
||||
ConnectorId,
|
||||
ExecutionMode,
|
||||
OnboardingBootstrapResult,
|
||||
ProfileSnapshot,
|
||||
} from "@shared/types";
|
||||
import type { AppLocale } from "@shared/locale";
|
||||
import { useT } from "../../i18n";
|
||||
import { unwrap } from "../../lib/desktop";
|
||||
@@ -8,7 +13,22 @@ import { WelcomeStep } from "./WelcomeStep";
|
||||
import { OnboardingStepPanel } from "./OnboardingStepPanel";
|
||||
import { useConnectorCallbacks } from "./useConnectorCallbacks";
|
||||
import { useConnectorModelSelection } from "./useConnectorModelSelection";
|
||||
import { OnboardingProvider, type OnboardingContextValue } from "./OnboardingContext";
|
||||
import {
|
||||
OnboardingConnectorsProvider,
|
||||
OnboardingWizardProvider,
|
||||
type OnboardingConnectorsContextValue,
|
||||
type OnboardingWizardContextValue,
|
||||
} from "./OnboardingContext";
|
||||
import type { CompanyStepValues } from "./CompanyStep";
|
||||
import type { MissionStepValues } from "./MissionStep";
|
||||
|
||||
const EMPTY_COMPANY: CompanyStepValues = {
|
||||
companyName: "",
|
||||
companyDescription: "",
|
||||
workspacePath: "",
|
||||
};
|
||||
|
||||
const EMPTY_MISSION: MissionStepValues = { goalTitle: "", goalDescription: "" };
|
||||
|
||||
export function CompanyOnboarding({
|
||||
connectors,
|
||||
@@ -32,13 +52,24 @@ export function CompanyOnboarding({
|
||||
const [step, setStep] = useState<OnboardingStep>("welcome");
|
||||
const [nodeStatus, setNodeStatus] = useState<{ installed: boolean; version: string | null } | null>(null);
|
||||
const [nodeChecking, setNodeChecking] = useState(false);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [launchSummary, setLaunchSummary] = useState<OnboardingBootstrapResult | null>(null);
|
||||
|
||||
// Finalized step-local snapshots. Written only on step "commit" (continue).
|
||||
const [companyValues, setCompanyValues] = useState<CompanyStepValues>(EMPTY_COMPANY);
|
||||
const [executionMode, setExecutionMode] = useState<ExecutionMode>("ai_ceo");
|
||||
const [missionValues, setMissionValues] = useState<MissionStepValues>(EMPTY_MISSION);
|
||||
|
||||
const checkNode = useCallback(async () => {
|
||||
setNodeChecking(true);
|
||||
try {
|
||||
const result = unwrap(await window.agentCompany.checkNodeInstalled());
|
||||
setNodeStatus(result);
|
||||
} catch {
|
||||
} catch (error) {
|
||||
console.warn(
|
||||
`[onboarding/OnboardingWizard] checkNodeInstalled failed; assuming uninstalled: ${error instanceof Error ? error.message : String(error)}`,
|
||||
);
|
||||
setNodeStatus({ installed: false, version: null });
|
||||
} finally {
|
||||
setNodeChecking(false);
|
||||
@@ -54,15 +85,7 @@ export function CompanyOnboarding({
|
||||
|
||||
const { handleTestConnector, handleSaveConnector, handleLoginConnector, handleInstallCommand } =
|
||||
useConnectorCallbacks(connectors);
|
||||
const [companyName, setCompanyName] = useState("");
|
||||
const [companyDescription, setCompanyDescription] = useState("");
|
||||
const [workspacePath, setWorkspacePath] = useState("");
|
||||
const [executionMode, setExecutionMode] = useState<ExecutionMode>("ai_ceo");
|
||||
const [goalTitle, setGoalTitle] = useState("");
|
||||
const [goalDescription, setGoalDescription] = useState("");
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [launchSummary, setLaunchSummary] = useState<OnboardingBootstrapResult | null>(null);
|
||||
|
||||
const {
|
||||
connectorModelPools,
|
||||
executionReadyConnectors,
|
||||
@@ -79,70 +102,73 @@ export function CompanyOnboarding({
|
||||
toggleConnectorModel,
|
||||
} = useConnectorModelSelection(connectors, currentLocale, t, setError);
|
||||
|
||||
const pickDirectory = useCallback(async () => {
|
||||
const pickDirectory = useCallback(async (): Promise<string | null> => {
|
||||
setError(null);
|
||||
const result = await window.agentCompany.pickDirectory();
|
||||
if (!result.ok) {
|
||||
setError(result.error.message);
|
||||
return;
|
||||
}
|
||||
if (result.data) {
|
||||
setWorkspacePath(result.data);
|
||||
return null;
|
||||
}
|
||||
return result.data ?? null;
|
||||
}, []);
|
||||
|
||||
const bootstrap = useCallback(async () => {
|
||||
const result = unwrap(await window.agentCompany.bootstrapOnboarding({
|
||||
companyName: companyName.trim(),
|
||||
companyDescription: companyDescription.trim(),
|
||||
workspacePath: workspacePath.trim(),
|
||||
autoApproveHires: executionMode === "ai_ceo",
|
||||
reviewDeliverables: executionMode === "ai_cofounder",
|
||||
executionMode,
|
||||
goalTitle: goalTitle.trim(),
|
||||
goalDescription: goalDescription.trim(),
|
||||
connectorId: selectedConnector?.id as ConnectorId | undefined,
|
||||
connectorModel: selectedModel.trim(),
|
||||
}));
|
||||
setLaunchSummary(result);
|
||||
setStep("launch");
|
||||
}, [
|
||||
executionMode,
|
||||
companyDescription,
|
||||
companyName,
|
||||
goalDescription,
|
||||
goalTitle,
|
||||
selectedConnector?.id,
|
||||
selectedModel,
|
||||
workspacePath,
|
||||
]);
|
||||
const handleContinueFromCompany = useCallback(
|
||||
(values: CompanyStepValues) => {
|
||||
if (loading) return;
|
||||
if (!values.companyName.trim()) {
|
||||
setError(t("onboarding.enterCompanyName"));
|
||||
return;
|
||||
}
|
||||
setCompanyValues(values);
|
||||
setError(null);
|
||||
setStep("modelpool");
|
||||
},
|
||||
[loading, t],
|
||||
);
|
||||
|
||||
const continueToMission = useCallback(() => {
|
||||
if (loading) return;
|
||||
if (!companyName.trim()) {
|
||||
setError(t("onboarding.enterCompanyName"));
|
||||
return;
|
||||
}
|
||||
const handleContinueFromExecutionMode = useCallback((mode: ExecutionMode) => {
|
||||
setExecutionMode(mode);
|
||||
setError(null);
|
||||
setStep("modelpool");
|
||||
}, [companyName, loading, t]);
|
||||
setStep("mission");
|
||||
}, []);
|
||||
|
||||
const launchCompany = useCallback(async () => {
|
||||
if (loading) return;
|
||||
if (!goalTitle.trim()) {
|
||||
setError(t("onboarding.describeFirstGoal"));
|
||||
return;
|
||||
}
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
try {
|
||||
await bootstrap();
|
||||
} catch (submitError) {
|
||||
setError(submitError instanceof Error ? submitError.message : t("onboarding.unableToBootstrap"));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, [bootstrap, goalTitle, loading, t]);
|
||||
const launchCompany = useCallback(
|
||||
async (values: MissionStepValues) => {
|
||||
if (loading) return;
|
||||
if (!values.goalTitle.trim()) {
|
||||
setError(t("onboarding.describeFirstGoal"));
|
||||
return;
|
||||
}
|
||||
setMissionValues(values);
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
try {
|
||||
const result = unwrap(
|
||||
await window.agentCompany.bootstrapOnboarding({
|
||||
companyName: companyValues.companyName.trim(),
|
||||
companyDescription: companyValues.companyDescription.trim(),
|
||||
workspacePath: companyValues.workspacePath.trim(),
|
||||
autoApproveHires: executionMode === "ai_ceo",
|
||||
reviewDeliverables: executionMode === "ai_cofounder",
|
||||
executionMode,
|
||||
goalTitle: values.goalTitle.trim(),
|
||||
goalDescription: values.goalDescription.trim(),
|
||||
connectorId: selectedConnector?.id as ConnectorId | undefined,
|
||||
connectorModel: selectedModel.trim(),
|
||||
}),
|
||||
);
|
||||
setLaunchSummary(result);
|
||||
setStep("launch");
|
||||
} catch (submitError) {
|
||||
setError(
|
||||
submitError instanceof Error ? submitError.message : t("onboarding.unableToBootstrap"),
|
||||
);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
},
|
||||
[companyValues, executionMode, loading, selectedConnector?.id, selectedModel, t],
|
||||
);
|
||||
|
||||
const finishLaunch = useCallback(async () => {
|
||||
if (!launchSummary) return;
|
||||
@@ -151,34 +177,38 @@ export function CompanyOnboarding({
|
||||
try {
|
||||
await onDone(launchSummary);
|
||||
} catch (submitError) {
|
||||
setError(submitError instanceof Error ? submitError.message : t("onboarding.unableToOpenControlCenter"));
|
||||
setError(
|
||||
submitError instanceof Error
|
||||
? submitError.message
|
||||
: t("onboarding.unableToOpenControlCenter"),
|
||||
);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, [launchSummary, onDone, t]);
|
||||
|
||||
const isWelcome = step === "welcome";
|
||||
const heroStep: OnboardingStep = step as OnboardingStep;
|
||||
|
||||
const contextValue = useMemo<OnboardingContextValue>(
|
||||
const wizardValue = useMemo<OnboardingWizardContextValue>(
|
||||
() => ({
|
||||
currentLocale,
|
||||
t,
|
||||
error,
|
||||
loading,
|
||||
launchSummary,
|
||||
nodeStatus,
|
||||
nodeChecking,
|
||||
onCheckNode: () => void checkNode(),
|
||||
onInstallCommand: (commandKey) => void handleInstallCommand(commandKey),
|
||||
}),
|
||||
[currentLocale, t, error, loading, launchSummary, nodeStatus, nodeChecking, checkNode, handleInstallCommand],
|
||||
);
|
||||
|
||||
const connectorsValue = useMemo<OnboardingConnectorsContextValue>(
|
||||
() => ({
|
||||
connectors,
|
||||
hasAtLeastOneReady,
|
||||
onTestConnector: (id) => void handleTestConnector(id),
|
||||
onSaveConnector: (id, env, model, notes) => void handleSaveConnector(id, env, model, notes),
|
||||
onLoginConnector: (id) => void handleLoginConnector(id),
|
||||
companyName,
|
||||
setCompanyName,
|
||||
companyDescription,
|
||||
setCompanyDescription,
|
||||
selectedConnectorId,
|
||||
setSelectedConnectorId,
|
||||
selectedModel,
|
||||
@@ -190,34 +220,15 @@ export function CompanyOnboarding({
|
||||
loadingModels,
|
||||
totalEnabledModels,
|
||||
selectedConnectorEnabledModels,
|
||||
onToggleConnectorModel: (connectorId, modelId) => void toggleConnectorModel(connectorId, modelId),
|
||||
workspacePath,
|
||||
setWorkspacePath,
|
||||
onPickDirectory: () => void pickDirectory(),
|
||||
executionMode,
|
||||
setExecutionMode,
|
||||
goalTitle,
|
||||
setGoalTitle,
|
||||
goalDescription,
|
||||
setGoalDescription,
|
||||
launchSummary,
|
||||
onToggleConnectorModel: (connectorId, modelId) =>
|
||||
void toggleConnectorModel(connectorId, modelId),
|
||||
}),
|
||||
[
|
||||
currentLocale,
|
||||
t,
|
||||
error,
|
||||
loading,
|
||||
nodeStatus,
|
||||
nodeChecking,
|
||||
checkNode,
|
||||
handleInstallCommand,
|
||||
connectors,
|
||||
hasAtLeastOneReady,
|
||||
handleTestConnector,
|
||||
handleSaveConnector,
|
||||
handleLoginConnector,
|
||||
companyName,
|
||||
companyDescription,
|
||||
selectedConnectorId,
|
||||
setSelectedConnectorId,
|
||||
selectedModel,
|
||||
@@ -230,24 +241,18 @@ export function CompanyOnboarding({
|
||||
totalEnabledModels,
|
||||
selectedConnectorEnabledModels,
|
||||
toggleConnectorModel,
|
||||
workspacePath,
|
||||
pickDirectory,
|
||||
executionMode,
|
||||
goalTitle,
|
||||
goalDescription,
|
||||
launchSummary,
|
||||
],
|
||||
);
|
||||
|
||||
const isWelcome = step === "welcome";
|
||||
const heroStep: OnboardingStep = step as OnboardingStep;
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`relative h-[100dvh] overflow-hidden bg-background ${
|
||||
isWelcome
|
||||
? "flex items-stretch"
|
||||
: "grid md:grid-cols-[minmax(0,1fr)_540px]"
|
||||
isWelcome ? "flex items-stretch" : "grid md:grid-cols-[minmax(0,1fr)_540px]"
|
||||
}`}
|
||||
>
|
||||
{/* Drag region for frameless title bar */}
|
||||
<div className="sidebar-drag absolute inset-x-0 top-0 z-10 h-[38px]" />
|
||||
|
||||
{isWelcome ? (
|
||||
@@ -258,22 +263,37 @@ export function CompanyOnboarding({
|
||||
t={t}
|
||||
/>
|
||||
) : (
|
||||
<OnboardingProvider value={contextValue}>
|
||||
<OnboardingStepPanel
|
||||
step={heroStep}
|
||||
canCancel={canCancel}
|
||||
onCancel={onCancel}
|
||||
isFirstLaunch={isFirstLaunch}
|
||||
onBack={setStep}
|
||||
onContinueFromNodeCheck={() => { setError(null); setStep("providers"); }}
|
||||
onContinueFromProviders={() => { setError(null); setStep("company"); }}
|
||||
onContinueFromCompany={() => void continueToMission()}
|
||||
onContinueFromModelPool={() => { setError(null); setStep("executionmode"); }}
|
||||
onContinueFromExecutionMode={() => { setError(null); setStep("mission"); }}
|
||||
onLaunchCompany={() => void launchCompany()}
|
||||
onFinishLaunch={() => void finishLaunch()}
|
||||
/>
|
||||
</OnboardingProvider>
|
||||
<OnboardingWizardProvider value={wizardValue}>
|
||||
<OnboardingConnectorsProvider value={connectorsValue}>
|
||||
<OnboardingStepPanel
|
||||
step={heroStep}
|
||||
canCancel={canCancel}
|
||||
onCancel={onCancel}
|
||||
isFirstLaunch={isFirstLaunch}
|
||||
onBack={setStep}
|
||||
onContinueFromNodeCheck={() => {
|
||||
setError(null);
|
||||
setStep("providers");
|
||||
}}
|
||||
onContinueFromProviders={() => {
|
||||
setError(null);
|
||||
setStep("company");
|
||||
}}
|
||||
onContinueFromCompany={handleContinueFromCompany}
|
||||
onContinueFromModelPool={() => {
|
||||
setError(null);
|
||||
setStep("executionmode");
|
||||
}}
|
||||
onContinueFromExecutionMode={handleContinueFromExecutionMode}
|
||||
onLaunchCompany={(values) => void launchCompany(values)}
|
||||
onFinishLaunch={() => void finishLaunch()}
|
||||
onPickDirectory={pickDirectory}
|
||||
companyValues={companyValues}
|
||||
missionValues={missionValues}
|
||||
executionMode={executionMode}
|
||||
/>
|
||||
</OnboardingConnectorsProvider>
|
||||
</OnboardingWizardProvider>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
listFeaturedOnboardingConnectors,
|
||||
} from "@shared/connector-catalog";
|
||||
import { OnboardingStep } from "./OnboardingStep";
|
||||
import { useOnboarding } from "./OnboardingContext";
|
||||
import { useOnboardingWizard } from "./OnboardingContext";
|
||||
import { OnboardingProviderDispatch } from "./provider-cards/ProviderCard";
|
||||
|
||||
interface ProvidersStepProps {
|
||||
@@ -20,7 +20,7 @@ const FEATURED_IDS = new Set(FEATURED.map((entry) => entry.id));
|
||||
const ADVANCED = CONNECTOR_CATALOG.filter((entry) => !FEATURED_IDS.has(entry.id));
|
||||
|
||||
export function ProvidersStep({ onContinue, onBack }: ProvidersStepProps) {
|
||||
const { t, error } = useOnboarding();
|
||||
const { t, error } = useOnboardingWizard();
|
||||
const [credentialsMap, setCredentialsMap] = useState<Map<string, CredentialSummary>>(
|
||||
new Map(),
|
||||
);
|
||||
|
||||
@@ -4,12 +4,12 @@ import type { ConnectorCatalogEntry } from "@shared/connector-catalog";
|
||||
import type { CredentialSummary } from "@shared/contracts/schemas-credentials";
|
||||
import type { TranslationFn } from "../../../i18n";
|
||||
import {
|
||||
INPUT_CLS,
|
||||
InlineFeedback,
|
||||
OnboardingProviderCard,
|
||||
OnboardingStatusBadge,
|
||||
type OnboardingCardStatus,
|
||||
} from "./shared";
|
||||
import { Input } from "../../ui";
|
||||
|
||||
interface ApiKeyCardProps {
|
||||
entry: ConnectorCatalogEntry;
|
||||
@@ -96,14 +96,11 @@ export function ApiKeyProviderCard({
|
||||
{t("onboarding.providers.apiKeyLabel")}{" "}
|
||||
<span className="font-mono text-[11px] text-muted-foreground/70">({envKey})</span>
|
||||
</label>
|
||||
<input
|
||||
<Input
|
||||
type="password"
|
||||
className={INPUT_CLS}
|
||||
value={value}
|
||||
onChange={(event) => setValue(event.target.value)}
|
||||
onChange={setValue}
|
||||
placeholder={connected ? t("onboarding.providers.apiKeyReplacePlaceholder") : ""}
|
||||
autoComplete="off"
|
||||
spellCheck={false}
|
||||
disabled={busy}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -2,9 +2,7 @@ import { CaretDown, CaretRight } from "../../ui/icons";
|
||||
import type { ReactNode } from "react";
|
||||
import type { CredentialSummary } from "@shared/contracts/schemas-credentials";
|
||||
import type { TranslationFn } from "../../../i18n";
|
||||
|
||||
export const INPUT_CLS =
|
||||
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring w-full rounded-lg border border-border bg-card px-3 py-2.5 text-[13px] text-foreground placeholder:text-muted-foreground";
|
||||
import { Card } from "../../ui";
|
||||
|
||||
export type OnboardingCardStatus = CredentialSummary["status"] | "checking" | "not_configured";
|
||||
|
||||
@@ -24,7 +22,7 @@ export function OnboardingProviderCard({
|
||||
children: ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<div className="overflow-hidden rounded-lg border border-border bg-card">
|
||||
<Card padding="none" className="overflow-hidden">
|
||||
<button
|
||||
type="button"
|
||||
onClick={onToggle}
|
||||
@@ -46,7 +44,7 @@ export function OnboardingProviderCard({
|
||||
<div className="flex-shrink-0 pt-0.5">{badge}</div>
|
||||
</button>
|
||||
{expanded ? <div className="space-y-3 px-4 pb-4">{children}</div> : null}
|
||||
</div>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,8 +9,10 @@ export function useConnectorCallbacks(connectors: ProfileSnapshot["connectors"])
|
||||
const handleTestConnector = useCallback(async (connectorId: string) => {
|
||||
try {
|
||||
unwrap(await window.agentCompany.testConnector(connectorId as ConnectorId));
|
||||
} catch {
|
||||
// Health check result is stored in DB and reflected via domain-changed
|
||||
} catch (error) {
|
||||
console.warn(
|
||||
`[onboarding/useConnectorCallbacks] testConnector(${connectorId}) failed (result reflected via domain-changed): ${error instanceof Error ? error.message : String(error)}`,
|
||||
);
|
||||
}
|
||||
}, []);
|
||||
|
||||
@@ -27,16 +29,20 @@ export function useConnectorCallbacks(connectors: ProfileSnapshot["connectors"])
|
||||
}));
|
||||
// Run health check AFTER save completes so the probe uses the new config
|
||||
unwrap(await window.agentCompany.testConnector(connectorId as ConnectorId));
|
||||
} catch {
|
||||
// Error is non-fatal; result reflected via domain-changed
|
||||
} catch (error) {
|
||||
console.warn(
|
||||
`[onboarding/useConnectorCallbacks] saveConnector+testConnector(${connectorId}) failed (result reflected via domain-changed): ${error instanceof Error ? error.message : String(error)}`,
|
||||
);
|
||||
}
|
||||
}, [connectors]);
|
||||
|
||||
const handleLoginConnector = useCallback(async (connectorId: string) => {
|
||||
try {
|
||||
unwrap(await window.agentCompany.openConnectorAuthTerminal(connectorId as ConnectorId));
|
||||
} catch {
|
||||
// Terminal open failure is non-fatal
|
||||
} catch (error) {
|
||||
console.warn(
|
||||
`[onboarding/useConnectorCallbacks] openConnectorAuthTerminal(${connectorId}) failed: ${error instanceof Error ? error.message : String(error)}`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
// Poll connector health after login terminal opens (same pattern as ConnectorEditor)
|
||||
@@ -46,15 +52,21 @@ export function useConnectorCallbacks(connectors: ProfileSnapshot["connectors"])
|
||||
if (attempts > 12) { clearInterval(poll); return; }
|
||||
try {
|
||||
unwrap(await window.agentCompany.testConnector(connectorId as ConnectorId));
|
||||
} catch { /* health check result reflected via domain-changed */ }
|
||||
} catch (error) {
|
||||
console.warn(
|
||||
`[onboarding/useConnectorCallbacks] post-login testConnector(${connectorId}) failed (attempt ${attempts}): ${error instanceof Error ? error.message : String(error)}`,
|
||||
);
|
||||
}
|
||||
}, 5000);
|
||||
}, []);
|
||||
|
||||
const handleInstallCommand = useCallback(async (commandKey: z.infer<typeof openTerminalCommandSchema>["commandKey"]) => {
|
||||
try {
|
||||
unwrap(await window.agentCompany.openTerminalCommand({ commandKey }));
|
||||
} catch {
|
||||
// Terminal open failure is non-fatal
|
||||
} catch (error) {
|
||||
console.warn(
|
||||
`[onboarding/useConnectorCallbacks] openTerminalCommand(${commandKey}) failed: ${error instanceof Error ? error.message : String(error)}`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
// Poll all connectors after install (install may make a new CLI available)
|
||||
@@ -64,7 +76,13 @@ export function useConnectorCallbacks(connectors: ProfileSnapshot["connectors"])
|
||||
if (attempts > 12) { clearInterval(poll); return; }
|
||||
for (const c of connectors) {
|
||||
if (c.status !== "ready") {
|
||||
try { unwrap(await window.agentCompany.testConnector(c.id as ConnectorId)); } catch { /* reflected via domain-changed */ }
|
||||
try {
|
||||
unwrap(await window.agentCompany.testConnector(c.id as ConnectorId));
|
||||
} catch (error) {
|
||||
console.warn(
|
||||
`[onboarding/useConnectorCallbacks] post-install testConnector(${c.id}) failed (attempt ${attempts}): ${error instanceof Error ? error.message : String(error)}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 5000);
|
||||
|
||||
@@ -136,8 +136,11 @@ export function useConnectorModelSelection(
|
||||
setConnectorModelsById((previous) =>
|
||||
connectorCatalogsEqual(previous, next) ? previous : next,
|
||||
);
|
||||
} catch {
|
||||
} catch (error) {
|
||||
if (cancelled) return;
|
||||
console.warn(
|
||||
`[onboarding/useConnectorModelSelection] connector model fetch failed; clearing catalog: ${error instanceof Error ? error.message : String(error)}`,
|
||||
);
|
||||
setConnectorModelsById((previous) => (Object.keys(previous).length === 0 ? previous : {}));
|
||||
setSelectedModel("");
|
||||
} finally {
|
||||
|
||||
Reference in new issue
Block a user