Skip to content

Commit c8a9a29

Browse files
committed
⭐️ Add pages to Navigation
1 parent e19b5fa commit c8a9a29

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1116
-870
lines changed

frontend/app/[locale]/setup/agents/config.tsx renamed to frontend/app/[locale]/agents/AgentConfiguration.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import { configStore } from "@/lib/config";
3636
import AgentSetupOrchestrator from "./components/AgentSetupOrchestrator";
3737
import DebugConfig from "./components/DebugConfig";
3838

39-
import "../../i18n";
39+
import "../i18n";
4040

4141
// Layout Height Constant Configuration
4242
const LAYOUT_CONFIG: LayoutConfig = AGENT_SETUP_LAYOUT_DEFAULT;
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
"use client";
2+
3+
import React, {useState, useEffect, useRef} from "react";
4+
import {motion} from "framer-motion";
5+
6+
import {useSetupFlow} from "@/hooks/useSetupFlow";
7+
import {
8+
ConnectionStatus,
9+
} from "@/const/modelConfig";
10+
11+
import AgentConfig, {AgentConfigHandle} from "./AgentConfiguration";
12+
import SaveConfirmModal from "./components/SaveConfirmModal";
13+
14+
interface AgentsContentProps {
15+
/** Whether currently saving */
16+
isSaving?: boolean;
17+
/** Connection status */
18+
connectionStatus?: ConnectionStatus;
19+
/** Is checking connection */
20+
isCheckingConnection?: boolean;
21+
/** Check connection callback */
22+
onCheckConnection?: () => void;
23+
/** Callback to expose connection status */
24+
onConnectionStatusChange?: (status: ConnectionStatus) => void;
25+
/** Callback to expose saving state */
26+
onSavingStateChange?: (isSaving: boolean) => void;
27+
}
28+
29+
/**
30+
* AgentsContent - Main component for agent configuration
31+
* Can be used in setup flow or as standalone page
32+
*/
33+
export default function AgentsContent({
34+
isSaving: externalIsSaving,
35+
connectionStatus: externalConnectionStatus,
36+
isCheckingConnection: externalIsCheckingConnection,
37+
onCheckConnection: externalOnCheckConnection,
38+
onConnectionStatusChange,
39+
onSavingStateChange,
40+
}: AgentsContentProps) {
41+
const agentConfigRef = useRef<AgentConfigHandle | null>(null);
42+
const [showSaveConfirm, setShowSaveConfirm] = useState(false);
43+
const pendingNavRef = useRef<null | (() => void)>(null);
44+
45+
// Use custom hook for common setup flow logic
46+
const {
47+
canAccessProtectedData,
48+
pageVariants,
49+
pageTransition,
50+
} = useSetupFlow({
51+
requireAdmin: true,
52+
externalConnectionStatus,
53+
externalIsCheckingConnection,
54+
onCheckConnection: externalOnCheckConnection,
55+
onConnectionStatusChange,
56+
nonAdminRedirect: "/setup/knowledges",
57+
});
58+
59+
const [internalIsSaving, setInternalIsSaving] = useState(false);
60+
const isSaving = externalIsSaving ?? internalIsSaving;
61+
62+
// Update external saving state
63+
useEffect(() => {
64+
onSavingStateChange?.(isSaving);
65+
}, [isSaving, onSavingStateChange]);
66+
67+
return (
68+
<>
69+
<motion.div
70+
initial="initial"
71+
animate="in"
72+
exit="out"
73+
variants={pageVariants}
74+
transition={pageTransition}
75+
style={{width: "100%", height: "100%"}}
76+
>
77+
{canAccessProtectedData ? (
78+
<AgentConfig ref={agentConfigRef} canAccessProtectedData={canAccessProtectedData} />
79+
) : null}
80+
</motion.div>
81+
82+
<SaveConfirmModal
83+
open={showSaveConfirm}
84+
onCancel={async () => {
85+
// Reload data from backend to discard changes
86+
await agentConfigRef.current?.reloadCurrentAgentData?.();
87+
setShowSaveConfirm(false);
88+
const go = pendingNavRef.current;
89+
pendingNavRef.current = null;
90+
if (go) go();
91+
}}
92+
onSave={async () => {
93+
try {
94+
setInternalIsSaving(true);
95+
await agentConfigRef.current?.saveAllChanges?.();
96+
setShowSaveConfirm(false);
97+
const go = pendingNavRef.current;
98+
pendingNavRef.current = null;
99+
if (go) go();
100+
} catch (e) {
101+
// errors are surfaced by underlying save
102+
} finally {
103+
setInternalIsSaving(false);
104+
}
105+
}}
106+
/>
107+
</>
108+
);
109+
}
110+

frontend/app/[locale]/setup/agents/components/AgentSetupOrchestrator.tsx renamed to frontend/app/[locale]/agents/components/AgentSetupOrchestrator.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useState, useEffect, useCallback, useRef, useMemo } from "react";
44
import { useTranslation } from "react-i18next";
55
import { TFunction } from "i18next";
66

7-
import { App, Modal, Typography, Button } from "antd";
7+
import { App, Modal, Button } from "antd";
88
import { WarningFilled } from "@ant-design/icons";
99

1010
import { TooltipProvider } from "@/components/ui/tooltip";

frontend/app/[locale]/setup/agents/components/DebugConfig.tsx renamed to frontend/app/[locale]/agents/components/DebugConfig.tsx

File renamed without changes.

frontend/app/[locale]/setup/agents/components/McpConfigModal.tsx renamed to frontend/app/[locale]/agents/components/McpConfigModal.tsx

File renamed without changes.

frontend/app/[locale]/setup/agents/components/PromptManager.tsx renamed to frontend/app/[locale]/agents/components/PromptManager.tsx

File renamed without changes.

frontend/app/[locale]/setup/agents/components/SaveConfirmModal.tsx renamed to frontend/app/[locale]/agents/components/SaveConfirmModal.tsx

File renamed without changes.

frontend/app/[locale]/setup/agents/components/agent/AgentCallRelationshipModal.tsx renamed to frontend/app/[locale]/agents/components/agent/AgentCallRelationshipModal.tsx

File renamed without changes.

frontend/app/[locale]/setup/agents/components/agent/AgentConfigModal.tsx renamed to frontend/app/[locale]/agents/components/agent/AgentConfigModal.tsx

File renamed without changes.

frontend/app/[locale]/setup/agents/components/agent/CollaborativeAgentDisplay.tsx renamed to frontend/app/[locale]/agents/components/agent/CollaborativeAgentDisplay.tsx

File renamed without changes.

0 commit comments

Comments
 (0)