mirror of
https://github.com/eigent-ai/eigent.git
synced 2026-05-20 01:09:26 +00:00
fix: create new project + new task on "new project"
This commit is contained in:
parent
8ff4e80072
commit
6a94cabe89
7 changed files with 27 additions and 13 deletions
|
|
@ -58,7 +58,7 @@ export const BottomInput = ({
|
|||
useCloudModelInDev: boolean;
|
||||
}) => {
|
||||
//Get Chatstore for the active project's task
|
||||
const { chatStore } = useChatStoreAdapter();
|
||||
const { chatStore, projectStore } = useChatStoreAdapter();
|
||||
if (!chatStore) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
|
@ -212,7 +212,10 @@ export const BottomInput = ({
|
|||
chatStore.tasks[chatStore.activeTaskId as string].messages[
|
||||
messageIndex - 2
|
||||
].content;
|
||||
let id = chatStore.create();
|
||||
//Create new chat in same project
|
||||
if(!projectStore.activeProjectId) return
|
||||
let id = projectStore.createChatStore(projectStore.activeProjectId);
|
||||
|
||||
chatStore.setHasMessages(id, true);
|
||||
chatStore.removeTask(tempTaskId as string);
|
||||
proxyFetchDelete(`/api/chat/history/${tempTaskId}`);
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ export default function HistorySidebar() {
|
|||
const { isOpen, close } = useSidebarStore();
|
||||
const navigate = useNavigate();
|
||||
//Get Chatstore for the active project's task
|
||||
const { chatStore } = useChatStoreAdapter();
|
||||
const { chatStore, projectStore } = useChatStoreAdapter();
|
||||
if (!chatStore) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
|
@ -87,7 +87,8 @@ export default function HistorySidebar() {
|
|||
chatStore.tasks[chatStore.activeTaskId as string].messages.length === 0
|
||||
) {
|
||||
}
|
||||
chatStore.create();
|
||||
//Create a new project
|
||||
projectStore.createProject("new project");
|
||||
navigate("/");
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import useChatStoreAdapter from "@/hooks/useChatStoreAdapter";
|
|||
|
||||
export default function Home() {
|
||||
//Get Chatstore for the active project's task
|
||||
const { chatStore } = useChatStoreAdapter();
|
||||
const { chatStore, projectStore } = useChatStoreAdapter();
|
||||
if (!chatStore) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
|
@ -115,8 +115,9 @@ export default function Home() {
|
|||
|
||||
// listen to webview container size
|
||||
useEffect(() => {
|
||||
if (!chatStore.activeTaskId) {
|
||||
chatStore.create();
|
||||
if (!projectStore.activeProjectId) {
|
||||
projectStore.createProject("new project");
|
||||
console.warn("No active projectId found in WorkSpace, creating a new project");
|
||||
}
|
||||
|
||||
const webviewContainer = document.getElementById("webview-container");
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ function HeaderWin() {
|
|||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
//Get Chatstore for the active project's task
|
||||
const { chatStore } = useChatStoreAdapter();
|
||||
const { chatStore, projectStore } = useChatStoreAdapter();
|
||||
if (!chatStore) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
|
@ -99,7 +99,7 @@ function HeaderWin() {
|
|||
navigate("/");
|
||||
return;
|
||||
}
|
||||
chatStore.create();
|
||||
projectStore.createProject("new project");
|
||||
navigate("/");
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ export default function Home() {
|
|||
const {t} = useTranslation()
|
||||
const navigate = useNavigate();
|
||||
//Get Chatstore for the active project's task
|
||||
const { chatStore } = useChatStoreAdapter();
|
||||
const { chatStore, projectStore } = useChatStoreAdapter();
|
||||
if (!chatStore) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
|
@ -224,7 +224,7 @@ export default function Home() {
|
|||
navigate(`/`);
|
||||
return;
|
||||
}
|
||||
chatStore.create();
|
||||
projectStore.createProject("new project");
|
||||
navigate("/");
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import useChatStoreAdapter from "@/hooks/useChatStoreAdapter";
|
|||
export default function Home() {
|
||||
const { toggle } = useSidebarStore();
|
||||
//Get Chatstore for the active project's task
|
||||
const { chatStore } = useChatStoreAdapter();
|
||||
const { chatStore, projectStore } = useChatStoreAdapter();
|
||||
if (!chatStore) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
|
@ -144,7 +144,7 @@ export default function Home() {
|
|||
|
||||
useEffect(() => {
|
||||
if (!chatStore.activeTaskId) {
|
||||
chatStore.create();
|
||||
projectStore.createProject("new project");
|
||||
}
|
||||
|
||||
const webviewContainer = document.getElementById("webview-container");
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { create } from 'zustand';
|
||||
import { generateUniqueId } from "@/lib";
|
||||
import { useChatStore, VanillaChatStore } from './chatStore';
|
||||
import { devtools } from 'zustand/middleware';
|
||||
|
||||
interface Project {
|
||||
id: string;
|
||||
|
|
@ -54,6 +55,9 @@ const projectStore = create<ProjectStore>()((set, get) => ({
|
|||
const initialChatId = generateUniqueId();
|
||||
const initialChatStore = useChatStore();
|
||||
|
||||
// Initialize the chat store with a task using the create() function
|
||||
initialChatStore.getState().create();
|
||||
|
||||
// Create new project with default chat store
|
||||
const newProject: Project = {
|
||||
id: projectId,
|
||||
|
|
@ -70,6 +74,8 @@ const projectStore = create<ProjectStore>()((set, get) => ({
|
|||
}
|
||||
};
|
||||
|
||||
console.log("[store] Creating a new project");
|
||||
|
||||
set((state) => ({
|
||||
projects: {
|
||||
...state.projects,
|
||||
|
|
@ -114,6 +120,9 @@ const projectStore = create<ProjectStore>()((set, get) => ({
|
|||
const chatId = generateUniqueId();
|
||||
const newChatStore = useChatStore();
|
||||
|
||||
// Initialize the chat store with a task using the create() function
|
||||
newChatStore.getState().create();
|
||||
|
||||
set((state) => ({
|
||||
projects: {
|
||||
...state.projects,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue