diff --git a/ui/desktop/package-lock.json b/ui/desktop/package-lock.json
index b3e4b6ee3..bf065167d 100644
--- a/ui/desktop/package-lock.json
+++ b/ui/desktop/package-lock.json
@@ -36,7 +36,8 @@
"react-router-dom": "^6.28.0",
"react-syntax-highlighter": "^15.6.1",
"tailwind-merge": "^2.5.4",
- "tailwindcss-animate": "^1.0.7"
+ "tailwindcss-animate": "^1.0.7",
+ "uuid": "^11.0.3"
},
"devDependencies": {
"@electron-forge/cli": "^7.5.0",
@@ -11961,6 +11962,19 @@
"node": ">= 0.4.0"
}
},
+ "node_modules/uuid": {
+ "version": "11.0.3",
+ "resolved": "https://registry.npmjs.org/uuid/-/uuid-11.0.3.tgz",
+ "integrity": "sha512-d0z310fCWv5dJwnX1Y/MncBAqGMKEzlBb1AOf7z9K8ALnd0utBX/msg/fA0+sbyN1ihbMsLhrBlnl1ak7Wa0rg==",
+ "funding": [
+ "https://github.com/sponsors/broofa",
+ "https://github.com/sponsors/ctavan"
+ ],
+ "license": "MIT",
+ "bin": {
+ "uuid": "dist/esm/bin/uuid"
+ }
+ },
"node_modules/validate-npm-package-license": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz",
diff --git a/ui/desktop/package.json b/ui/desktop/package.json
index da0999b83..63e19e05b 100644
--- a/ui/desktop/package.json
+++ b/ui/desktop/package.json
@@ -64,6 +64,7 @@
"react-router-dom": "^6.28.0",
"react-syntax-highlighter": "^15.6.1",
"tailwind-merge": "^2.5.4",
- "tailwindcss-animate": "^1.0.7"
+ "tailwindcss-animate": "^1.0.7",
+ "uuid": "^11.0.3"
}
}
diff --git a/ui/desktop/src/ChatWindow.tsx b/ui/desktop/src/ChatWindow.tsx
index 82b838ff7..9b95b484a 100644
--- a/ui/desktop/src/ChatWindow.tsx
+++ b/ui/desktop/src/ChatWindow.tsx
@@ -1,16 +1,18 @@
-import React, { useEffect, useRef, useState } from 'react';
-import { Message, useChat } from './ai-sdk-fork/useChat';
-import { Route, Routes, Navigate } from 'react-router-dom';
-import { getApiUrl } from './config';
-import { Card } from './components/ui/card';
-import { ScrollArea } from './components/ui/scroll-area';
+import React, {useEffect, useRef, useState} from 'react';
+import {Message,useChat} from './ai-sdk-fork/useChat';
+import {Navigate, Route, Routes} from 'react-router-dom';
+import {getApiUrl} from './config';
+import {Card} from './components/ui/card';
+import {ScrollArea} from './components/ui/scroll-area';
import Splash from './components/Splash';
import GooseMessage from './components/GooseMessage';
import UserMessage from './components/UserMessage';
import Input from './components/Input';
import MoreMenu from './components/MoreMenu';
+import {Bird} from './components/ui/icons';
import LoadingGoose from './components/LoadingGoose';
-import { ApiKeyWarning } from './components/ApiKeyWarning';
+import {ApiKeyWarning} from './components/ApiKeyWarning';
+
import { askAi, getPromptTemplates } from './utils/askAI';
import WingToWing, { Working } from './components/WingToWing';
@@ -89,8 +91,23 @@ function ChatContent({
c.id === selectedChatId ? { ...c, messages } : c
);
setChats(updatedChats);
+ const currentChat = chats.find(chat => chat.id === selectedChatId);
+ if (currentChat) {
+ const sessionToSave = {
+ messages: currentChat.messages,
+ directory: window.appConfig.get("GOOSE_WORKING_DIR")
+ };
+ saveSession(sessionToSave);
+ }
}, [messages, selectedChatId]);
+ // Function to save a session
+ const saveSession = (session) => {
+ if(session.messages === undefined || session.messages.length === 0) return
+ window.electron.saveSession(session);
+ };
+
+
const initialQueryAppended = useRef(false);
useEffect(() => {
if (initialQuery && !initialQueryAppended.current) {
@@ -149,11 +166,11 @@ function ChatContent({
}
}),
};
-
+
const updatedMessages = [...messages.slice(0, -1), newLastMessage];
setMessages(updatedMessages);
}
-
+
};
return (
@@ -225,6 +242,24 @@ export default function ChatWindow() {
window.electron.createChatWindow();
};
+ // Function to get a session by ID
+ const getSession = async (sessionId) => {
+ try {
+ return window.electron.getSession(sessionId);
+ } catch (error) {
+ console.error('Failed to load session:', error);
+ }
+ };
+
+ const convertSessionToChat = (session) => {
+ const chat = {
+ id: 1,
+ title: session.name,
+ messages: session.messages,
+ };
+ return chat;
+ }
+
// Add keyboard shortcut handler
useEffect(() => {
const handleKeyDown = (event: KeyboardEvent) => {
@@ -259,6 +294,12 @@ export default function ChatWindow() {
title: initialQuery || 'Chat 1',
messages: initialHistory.length > 0 ? initialHistory : [],
};
+ const sessionId = window.appConfig.get("GOOSE_SESSION_ID");
+ getSession(sessionId).then((session) => {
+ if (session) {
+ setChats([convertSessionToChat(session)]);
+ }
+ });
return [firstChat];
});
@@ -308,11 +349,11 @@ export default function ChatWindow() {
} />
-
+
-
+
>
)}
);
-}
\ No newline at end of file
+}
diff --git a/ui/desktop/src/LauncherWindow.tsx b/ui/desktop/src/LauncherWindow.tsx
index ce1955ced..fb7a48d95 100644
--- a/ui/desktop/src/LauncherWindow.tsx
+++ b/ui/desktop/src/LauncherWindow.tsx
@@ -3,6 +3,10 @@ import React, { useState, useRef } from 'react';
declare global {
interface Window {
electron: {
+ getConfig(): object;
+ getSession(arg0: string): object;
+ logInfo(arg0: string): object;
+ saveSession(arg0: { name: string; messages: Array