mirror of
https://github.com/eigent-ai/eigent.git
synced 2026-05-20 17:53:54 +00:00
feat: connect chatStore adapter
This commit is contained in:
parent
db945f0dcc
commit
8ff4e80072
19 changed files with 137 additions and 21 deletions
|
|
@ -26,6 +26,7 @@ import { Tag } from "../ui/tag";
|
|||
import { useTranslation } from "react-i18next";
|
||||
import { TooltipSimple } from "../ui/tooltip";
|
||||
import { toast } from "sonner";
|
||||
import useChatStoreAdapter from "@/hooks/useChatStoreAdapter";
|
||||
|
||||
export const BottomInput = ({
|
||||
message,
|
||||
|
|
@ -56,7 +57,12 @@ export const BottomInput = ({
|
|||
setIsTakeControl?: (v: boolean) => void;
|
||||
useCloudModelInDev: boolean;
|
||||
}) => {
|
||||
const chatStore = useChatStore();
|
||||
//Get Chatstore for the active project's task
|
||||
const { chatStore } = useChatStoreAdapter();
|
||||
if (!chatStore) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
||||
const {t} = useTranslation();
|
||||
const [isConfirm, setIsConfirm] = useState(true);
|
||||
const [hasSubTask, setHasSubTask] = useState(false);
|
||||
|
|
|
|||
|
|
@ -8,12 +8,18 @@ import { useChatStore } from "@/store/chatStore";
|
|||
|
||||
import { ChevronDown, SquareCode } from "lucide-react";
|
||||
import { useMemo, useState, useRef, useEffect } from "react";
|
||||
import useChatStoreAdapter from "@/hooks/useChatStoreAdapter";
|
||||
|
||||
export function NoticeCard() {
|
||||
const [isExpanded, setIsExpanded] = useState(false);
|
||||
const contentRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
const chatStore = useChatStore();
|
||||
//Get Chatstore for the active project's task
|
||||
const { chatStore } = useChatStoreAdapter();
|
||||
if (!chatStore) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
||||
|
||||
// when cotList is added, smooth scroll to the bottom
|
||||
useEffect(() => {
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import {
|
|||
} from "lucide-react";
|
||||
import { useMemo, useState, useRef, useEffect } from "react";
|
||||
import { TaskState, TaskStateType } from "../TaskState";
|
||||
import useChatStoreAdapter from "@/hooks/useChatStoreAdapter";
|
||||
|
||||
interface TaskCardProps {
|
||||
taskInfo: any[];
|
||||
|
|
@ -51,7 +52,12 @@ export function TaskCard({
|
|||
const [isExpanded, setIsExpanded] = useState(true);
|
||||
const contentRef = useRef<HTMLDivElement>(null);
|
||||
const [contentHeight, setContentHeight] = useState<number | "auto">("auto");
|
||||
const chatStore = useChatStore();
|
||||
//Get Chatstore for the active project's task
|
||||
const { chatStore } = useChatStoreAdapter();
|
||||
if (!chatStore) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
||||
|
||||
const [selectedState, setSelectedState] = useState<TaskStateType>("all");
|
||||
const [filterTasks, setFilterTasks] = useState<any[]>([]);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { useState, useRef, useEffect, useCallback } from "react";
|
||||
import { useState, useRef, useEffect, useCallback, useMemo } from "react";
|
||||
import { fetchPost, proxyFetchPut } from "@/api/http";
|
||||
import { BottomInput } from "./BottomInput";
|
||||
import { TaskCard } from "./TaskCard";
|
||||
|
|
@ -6,17 +6,23 @@ import { MessageCard } from "./MessageCard";
|
|||
import { TypeCardSkeleton } from "./TypeCardSkeleton";
|
||||
import { FileText, TriangleAlert } from "lucide-react";
|
||||
import { generateUniqueId } from "@/lib";
|
||||
import { useChatStore } from "@/store/chatStore";
|
||||
import { proxyFetchGet } from "@/api/http";
|
||||
import { useNavigate, useSearchParams } from "react-router-dom";
|
||||
import { NoticeCard } from "./NoticeCard";
|
||||
import { useAuthStore } from "@/store/authStore";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { TaskStateType } from "../TaskState";
|
||||
import useChatStoreAdapter from "@/hooks/useChatStoreAdapter";
|
||||
|
||||
export default function ChatBox(): JSX.Element {
|
||||
const [message, setMessage] = useState<string>("");
|
||||
const chatStore = useChatStore();
|
||||
|
||||
//Get Chatstore for the active project's task
|
||||
const { chatStore } = useChatStoreAdapter();
|
||||
if (!chatStore) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
||||
const { t } = useTranslation();
|
||||
const textareaRef = useRef<HTMLTextAreaElement>(null);
|
||||
const scrollContainerRef = useRef<HTMLDivElement>(null);
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import { MarkDown } from "@/components/ChatBox/MarkDown";
|
|||
import { useAuthStore } from "@/store/authStore";
|
||||
import { proxyFetchGet } from "@/api/http";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import useChatStoreAdapter from "@/hooks/useChatStoreAdapter";
|
||||
|
||||
// Type definitions
|
||||
interface FileTreeNode {
|
||||
|
|
@ -154,7 +155,12 @@ function downloadByBrowser(url: string) {
|
|||
}
|
||||
|
||||
export default function Folder({ data }: { data?: Agent }) {
|
||||
const chatStore = useChatStore();
|
||||
//Get Chatstore for the active project's task
|
||||
const { chatStore } = useChatStoreAdapter();
|
||||
if (!chatStore) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
||||
const authStore = useAuthStore();
|
||||
const { t } = useTranslation();
|
||||
const [selectedFile, setSelectedFile] = useState<FileInfo | null>(null);
|
||||
|
|
|
|||
|
|
@ -37,12 +37,18 @@ import { proxyFetchGet, proxyFetchDelete, proxyFetchPost } from "@/api/http";
|
|||
import { Tag } from "../ui/tag";
|
||||
import { share } from "@/lib/share";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import useChatStoreAdapter from "@/hooks/useChatStoreAdapter";
|
||||
|
||||
export default function HistorySidebar() {
|
||||
const { t } = useTranslation();
|
||||
const { isOpen, close } = useSidebarStore();
|
||||
const navigate = useNavigate();
|
||||
const chatStore = useChatStore();
|
||||
//Get Chatstore for the active project's task
|
||||
const { chatStore } = useChatStoreAdapter();
|
||||
if (!chatStore) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
||||
const getTokens = chatStore.getTokens;
|
||||
const { history_type, toggleHistoryType } = useGlobalStore();
|
||||
const [searchValue, setSearchValue] = useState("");
|
||||
|
|
|
|||
|
|
@ -11,10 +11,18 @@ import { useChatStore } from "@/store/chatStore";
|
|||
import { useInstallationUI } from "@/store/installationStore";
|
||||
import { useInstallationSetup } from "@/hooks/useInstallationSetup";
|
||||
import InstallationErrorDialog from "../InstallStep/InstallationErrorDialog/InstallationErrorDialog";
|
||||
import useChatStoreAdapter from "@/hooks/useChatStoreAdapter";
|
||||
const Layout = () => {
|
||||
const { initState, isFirstLaunch, setIsFirstLaunch, setInitState } = useAuthStore();
|
||||
const [noticeOpen, setNoticeOpen] = useState(false);
|
||||
const chatStore = useChatStore();
|
||||
//Get Chatstore for the active project's task
|
||||
const { chatStore } = useChatStoreAdapter();
|
||||
if (!chatStore) {
|
||||
console.log(chatStore);
|
||||
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
||||
const {
|
||||
installationState,
|
||||
latestLog,
|
||||
|
|
|
|||
|
|
@ -17,9 +17,15 @@ import {
|
|||
import { Button } from "../ui/button";
|
||||
import { fetchPut } from "@/api/http";
|
||||
import { TaskState } from "../TaskState";
|
||||
import useChatStoreAdapter from "@/hooks/useChatStoreAdapter";
|
||||
|
||||
export default function Home() {
|
||||
const chatStore = useChatStore();
|
||||
//Get Chatstore for the active project's task
|
||||
const { chatStore } = useChatStoreAdapter();
|
||||
if (!chatStore) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
||||
const [isSingleMode, setIsSingleMode] = useState(false);
|
||||
const scrollContainerRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
|
|
|
|||
|
|
@ -30,12 +30,18 @@ import { useChatStore } from "@/store/chatStore";
|
|||
import { useNavigate } from "react-router-dom";
|
||||
import { generateUniqueId } from "@/lib";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import useChatStoreAdapter from "@/hooks/useChatStoreAdapter";
|
||||
|
||||
export function SearchHistoryDialog() {
|
||||
const {t} = useTranslation()
|
||||
const [open, setOpen] = useState(false);
|
||||
const [historyTasks, setHistoryTasks] = useState<any[]>([]);
|
||||
const chatStore = useChatStore();
|
||||
//Get Chatstore for the active project's task
|
||||
const { chatStore } = useChatStoreAdapter();
|
||||
if (!chatStore) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
||||
const navigate = useNavigate();
|
||||
const handleSetActive = (taskId: string, question: string) => {
|
||||
const task = chatStore.tasks[taskId];
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { CircleCheckBig, CircleSlash2, LoaderCircle } from "lucide-react";
|
||||
import { useChatStore } from "@/store/chatStore";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import useChatStoreAdapter from "@/hooks/useChatStoreAdapter";
|
||||
|
||||
export type TaskStateType =
|
||||
| "all"
|
||||
|
|
@ -35,7 +36,12 @@ export const TaskState = ({
|
|||
onStateChange,
|
||||
clickable = true,
|
||||
}: TaskStateProps) => {
|
||||
const chatStore = useChatStore();
|
||||
//Get Chatstore for the active project's task
|
||||
const { chatStore } = useChatStoreAdapter();
|
||||
if (!chatStore) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
||||
const { t } = useTranslation();
|
||||
const handleStateClick = (state: TaskStateType) => {
|
||||
if (!clickable || !onStateChange) return;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import { Terminal } from "@xterm/xterm";
|
|||
import { FitAddon } from "@xterm/addon-fit";
|
||||
import { WebLinksAddon } from "@xterm/addon-web-links";
|
||||
import "@xterm/xterm/css/xterm.css";
|
||||
import useChatStoreAdapter from "@/hooks/useChatStoreAdapter";
|
||||
|
||||
// Terminal Component Properties Interface
|
||||
interface TerminalComponentProps {
|
||||
|
|
@ -17,7 +18,12 @@ export default function TerminalComponent({
|
|||
instanceId = "default",
|
||||
showWelcome = false,
|
||||
}: TerminalComponentProps) {
|
||||
const chatStore = useChatStore();
|
||||
//Get Chatstore for the active project's task
|
||||
const { chatStore } = useChatStoreAdapter();
|
||||
if (!chatStore) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
||||
|
||||
// DOM references
|
||||
const terminalContainerRef = useRef<HTMLDivElement>(null); // terminal container reference
|
||||
|
|
|
|||
|
|
@ -18,9 +18,15 @@ import { Button } from "../ui/button";
|
|||
import { fetchPut } from "@/api/http";
|
||||
import Terminal from "@/components/Terminal";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import useChatStoreAdapter from "@/hooks/useChatStoreAdapter";
|
||||
|
||||
export default function TerminalAgentWrokSpace() {
|
||||
const chatStore = useChatStore();
|
||||
//Get Chatstore for the active project's task
|
||||
const { chatStore } = useChatStoreAdapter();
|
||||
if (!chatStore) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
||||
const { t } = useTranslation();
|
||||
const [isSingleMode, setIsSingleMode] = useState(false);
|
||||
const scrollContainerRef = useRef<HTMLDivElement>(null);
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import { getAuthStore } from "@/store/authStore";
|
|||
import { useTranslation } from "react-i18next";
|
||||
import { proxyFetchGet } from "@/api/http";
|
||||
import { toast } from "sonner";
|
||||
import useChatStoreAdapter from "@/hooks/useChatStoreAdapter";
|
||||
function HeaderWin() {
|
||||
const { t } = useTranslation();
|
||||
const titlebarRef = useRef<HTMLDivElement>(null);
|
||||
|
|
@ -27,7 +28,12 @@ function HeaderWin() {
|
|||
const [platform, setPlatform] = useState<string>("");
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
const chatStore = useChatStore();
|
||||
//Get Chatstore for the active project's task
|
||||
const { chatStore } = useChatStoreAdapter();
|
||||
if (!chatStore) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
||||
const { toggle } = useSidebarStore();
|
||||
const [isFullscreen, setIsFullscreen] = useState(false);
|
||||
const { token } = getAuthStore();
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import { useChatStore } from "@/store/chatStore";
|
|||
import { useWorkerList } from "@/store/authStore";
|
||||
import { share } from "@/lib/share";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import useChatStoreAdapter from "@/hooks/useChatStoreAdapter";
|
||||
|
||||
interface NodeData {
|
||||
agent: Agent;
|
||||
|
|
@ -37,7 +38,12 @@ export default function Workflow({
|
|||
taskAssigning: Agent[];
|
||||
}) {
|
||||
const {t} = useTranslation();
|
||||
const chatStore = useChatStore();
|
||||
//Get Chatstore for the active project's task
|
||||
const { chatStore } = useChatStoreAdapter();
|
||||
if (!chatStore) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
||||
const [isEditMode, setIsEditMode] = useState(false);
|
||||
const [lastViewport, setLastViewport] = useState({ x: 0, y: 0, zoom: 1 });
|
||||
const [nodes, setNodes, onNodesChange] = useNodesState<CustomNode>([]);
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import {
|
|||
PopoverTrigger,
|
||||
} from "../ui/popover";
|
||||
import { AddWorker } from "@/components/AddWorker";
|
||||
import useChatStoreAdapter from "@/hooks/useChatStoreAdapter";
|
||||
|
||||
interface NodeProps {
|
||||
id: string;
|
||||
|
|
@ -99,7 +100,12 @@ export function Node({ id, data }: NodeProps) {
|
|||
}
|
||||
}, [selectedState, data.agent?.tasks]);
|
||||
|
||||
const chatStore = useChatStore();
|
||||
//Get Chatstore for the active project's task
|
||||
const { chatStore } = useChatStoreAdapter();
|
||||
if (!chatStore) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
||||
const { setCenter, getNode, setViewport, setNodes } = useReactFlow();
|
||||
const workerList = useWorkerList();
|
||||
const { setWorkerList } = useAuthStore();
|
||||
|
|
|
|||
|
|
@ -15,9 +15,15 @@ import { motion, AnimatePresence } from "framer-motion";
|
|||
import { useEffect, useState } from "react";
|
||||
import { AddWorker } from "@/components/AddWorker";
|
||||
import { Badge } from "../ui/badge";
|
||||
import useChatStoreAdapter from "@/hooks/useChatStoreAdapter";
|
||||
|
||||
export function WorkSpaceMenu() {
|
||||
const chatStore = useChatStore();
|
||||
//Get Chatstore for the active project's task
|
||||
const { chatStore } = useChatStoreAdapter();
|
||||
if (!chatStore) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
||||
const workerList = useWorkerList();
|
||||
const baseWorker: Agent[] = [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -45,11 +45,17 @@ import { SearchHistoryDialog } from "@/components/SearchHistoryDialog";
|
|||
import { Tag } from "@/components/ui/tag";
|
||||
import { share } from "@/lib/share";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import useChatStoreAdapter from "@/hooks/useChatStoreAdapter";
|
||||
|
||||
export default function Home() {
|
||||
const {t} = useTranslation()
|
||||
const navigate = useNavigate();
|
||||
const chatStore = useChatStore();
|
||||
//Get Chatstore for the active project's task
|
||||
const { chatStore } = useChatStoreAdapter();
|
||||
if (!chatStore) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
||||
const { history_type, setHistoryType } = useGlobalStore();
|
||||
const [historyTasks, setHistoryTasks] = useState<any[]>([]);
|
||||
const [deleteModalOpen, setDeleteModalOpen] = useState(false);
|
||||
|
|
|
|||
|
|
@ -16,10 +16,16 @@ import {
|
|||
ResizablePanel,
|
||||
ResizablePanelGroup,
|
||||
} from "@/components/ui/resizable"
|
||||
import useChatStoreAdapter from "@/hooks/useChatStoreAdapter";
|
||||
|
||||
export default function Home() {
|
||||
const { toggle } = useSidebarStore();
|
||||
const chatStore = useChatStore();
|
||||
//Get Chatstore for the active project's task
|
||||
const { chatStore } = useChatStoreAdapter();
|
||||
if (!chatStore) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
||||
const [activeWebviewId, setActiveWebviewId] = useState<string | null>(null);
|
||||
|
||||
window.ipcRenderer?.on("webview-show", (_event, id: string) => {
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import {
|
|||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
import useChatStoreAdapter from "@/hooks/useChatStoreAdapter";
|
||||
|
||||
export default function SettingGeneral() {
|
||||
const { t } = useTranslation();
|
||||
|
|
@ -36,7 +37,12 @@ export default function SettingGeneral() {
|
|||
const fullNameRef: RefObject<HTMLInputElement> = createRef();
|
||||
const nickNameRef: RefObject<HTMLInputElement> = createRef();
|
||||
const workDescRef: RefObject<HTMLInputElement> = createRef();
|
||||
const chatStore = useChatStore();
|
||||
//Get Chatstore for the active project's task
|
||||
const { chatStore } = useChatStoreAdapter();
|
||||
if (!chatStore) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
||||
|
||||
const [themeList, setThemeList] = useState<any>([
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue