Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added conversation support #11

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add buttons for private and stored chats in the sidebar.
  • Loading branch information
o-stahl committed May 6, 2024
commit 1f2f9e2d953116752079b78c2635f2d31f772a0c
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ function App() {
{currentConversation ? (
<span className="text-lg font-medium">{currentConversation.name}</span>
) : (
<span className="text-lg font-medium">Temporary Chat</span>
<span className="text-lg font-medium">Private Chat</span>
)}
</div>

Expand Down
23 changes: 21 additions & 2 deletions src/components/Conversations.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState, useRef } from 'react';
import { FaTrash, FaPen, FaEllipsisV, FaCheck, FaPlus } from 'react-icons/fa';
import { FaTrash, FaPen, FaEllipsisV, FaCheck, FaEdit, FaUserSecret } from 'react-icons/fa';
import { Button } from './ui/button'; // Import the Button component
import useChatStore, { Conversation } from '../hooks/useChatStore';

Expand All @@ -14,6 +14,18 @@ const Conversations: React.FC = () => {
const setCurrentConversationId = useChatStore((state) => state.setCurrentConversationId);
const [newConversationName, setNewConversationName] = useState('');

const handleCreatePrivateConversation = () => {
const newConversation: Conversation = {
id: `private-${Date.now()}`, // A unique ID prefixed with 'private-'
name: 'Private Conversation',
messages: [],
};

setSelectedConversation(newConversation);
setCurrentConversation(newConversation.messages);
setCurrentConversationId(newConversation.id);
};

const handleCreateConversation = () => {
const preString = 'Untitled';
const existingUntitledNumbers = conversations
Expand Down Expand Up @@ -47,6 +59,10 @@ const Conversations: React.FC = () => {
};

const handleEditName = (conversationId: string) => {
const currentConversation = conversations.find(conversation => conversation.id === conversationId);
if (currentConversation) {
setNewConversationName(currentConversation.name); // Set the current name in the input field
}
setEditingConversationId(conversationId);
};

Expand Down Expand Up @@ -74,8 +90,11 @@ const Conversations: React.FC = () => {

return (
<div className="">
<Button onClick={handleCreatePrivateConversation} variant="outline" className="items-center justify-start text-xs text-left flex items-left mr-auto px-4 py-2 rounded shadow mb-2 w-full">
<FaUserSecret className="mr-2" /> New Private Chat
</Button>
<Button onClick={handleCreateConversation} variant="outline" className="items-center justify-start text-xs text-left flex items-left mr-auto px-4 py-2 rounded shadow mb-4 w-full">
<FaPlus className="mr-2" /> Create New Conversation
<FaEdit className="mr-2" /> New Stored Chat
</Button>
<h2 className="text-base bold font-medium">Conversations</h2>
<ul className="divide-y divide-gray-200">
Expand Down
61 changes: 22 additions & 39 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
resolved "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.24.4.tgz"
integrity sha512-vg8Gih2MLK+kOkHJp4gBEIkyaIi00jgWot2D9QOmmfLC8jINSOzmCLta6Bvz/JSBCqnegV0L80jhxkol5GWNfQ==

"@babel/core@^7.0.0", "@babel/core@^7.0.0-0", "@babel/core@^7.23.5":
"@babel/core@^7.23.5":
version "7.24.5"
resolved "https://registry.npmjs.org/@babel/core/-/core-7.24.5.tgz"
integrity sha512-tVQRucExLQ02Boi4vdPp49svNGcfL2GhdTCT9aldhXgCJVAI21EtRfBettiuLUwce/7r6bFdgs6JFkcdTiFttA==
Expand Down Expand Up @@ -479,7 +479,7 @@
"@nodelib/fs.stat" "2.0.5"
run-parallel "^1.1.9"

"@nodelib/fs.stat@^2.0.2", "@nodelib/[email protected].5":
"@nodelib/[email protected].5", "@nodelib/fs.stat@^2.0.2":
version "2.0.5"
resolved "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz"
integrity sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==
Expand Down Expand Up @@ -654,7 +654,7 @@
aria-hidden "^1.1.1"
react-remove-scroll "2.5.5"

"@radix-ui/react-slot@^1.0.2", "@radix-ui/[email protected]":
"@radix-ui/[email protected]", "@radix-ui/react-slot@^1.0.2":
version "1.0.2"
resolved "https://registry.npmjs.org/@radix-ui/react-slot/-/react-slot-1.0.2.tgz"
integrity sha512-YeTpuq4deV+6DusvVUW4ivBgnkHwECUu0BiN43L5UCDFgdhsRUWAghhTF5MbvNTPzmiFOx90asDSUjWuCNapwg==
Expand Down Expand Up @@ -875,7 +875,7 @@
dependencies:
"@types/estree" "*"

"@types/estree@*", "@types/estree@^1.0.0", "@types/[email protected].5":
"@types/estree@*", "@types/[email protected].5", "@types/estree@^1.0.0":
version "1.0.5"
resolved "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz"
integrity sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==
Expand Down Expand Up @@ -911,7 +911,7 @@
resolved "https://registry.npmjs.org/@types/ms/-/ms-0.7.34.tgz"
integrity sha512-nG96G3Wp6acyAgJqGasjODb+acrI7KltPiRxzHPXnP3NgI28bpQDRv53olbqGXbfcgF5aiiHmO3xpwEpS5Ld9g==

"@types/node@^18.0.0 || >=20.0.0", "@types/node@^20.12.7":
"@types/node@^20.12.7":
version "20.12.7"
resolved "https://registry.npmjs.org/@types/node/-/node-20.12.7.tgz"
integrity sha512-wq0cICSkRLVaf3UGLMGItu/PtdY7oaXaI/RVU+xliKVOtRna3PRY57ZDfztpDL0n11vfymMUnXv8QwYCO7L1wg==
Expand All @@ -923,7 +923,7 @@
resolved "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.12.tgz"
integrity sha512-5zvhXYtRNRluoE/jAp4GVsSduVUzNWKkOZrCDBWYtE7biZywwdC2AcEzg+cSMLFRfVgeAFqpfNabiPjxFddV1Q==

"@types/react-dom@*", "@types/react-dom@^18.2.22":
"@types/react-dom@^18.2.22":
version "18.3.0"
resolved "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.3.0.tgz"
integrity sha512-EhwApuTmMBmXuFOikhQLIBUn6uFg81SwLMOAUgodJF14SOBOCMdU04gDoYi0WOJJHD144TL32z4yDqCW3dnkQg==
Expand Down Expand Up @@ -977,7 +977,7 @@
semver "^7.6.0"
ts-api-utils "^1.3.0"

"@typescript-eslint/parser@^7.0.0", "@typescript-eslint/parser@^7.2.0":
"@typescript-eslint/parser@^7.2.0":
version "7.8.0"
resolved "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-7.8.0.tgz"
integrity sha512-KgKQly1pv0l4ltcftP59uQZCi4HUYswCLbTqVZEJu7uLX8CTLyswqMLqLN+2QFz4jCptqWVV4SB7vdxcH2+0kQ==
Expand Down Expand Up @@ -1067,7 +1067,7 @@ acorn-jsx@^5.3.2:
resolved "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz"
integrity sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==

"acorn@^6.0.0 || ^7.0.0 || ^8.0.0", acorn@^8.8.2, acorn@^8.9.0:
acorn@^8.8.2, acorn@^8.9.0:
version "8.11.3"
resolved "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz"
integrity sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==
Expand Down Expand Up @@ -1212,7 +1212,7 @@ braces@^3.0.2, braces@~3.0.2:
dependencies:
fill-range "^7.0.1"

browserslist@^4.22.2, browserslist@^4.23.0, "browserslist@>= 4.21.0":
browserslist@^4.22.2, browserslist@^4.23.0:
version "4.23.0"
resolved "https://registry.npmjs.org/browserslist/-/browserslist-4.23.0.tgz"
integrity sha512-QW8HiM1shhT2GuzkvklfjcKDiWFXHOeFCIA/huJPwHsslwcydgk7X+z2zXpEijP98UCY7HbubZt5J2Zgvf0CaQ==
Expand Down Expand Up @@ -1351,11 +1351,6 @@ clsx@^2.1.1:
resolved "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz"
integrity sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==

[email protected]:
version "2.0.0"
resolved "https://registry.npmjs.org/clsx/-/clsx-2.0.0.tgz"
integrity sha512-rQ1+kcj+ttHG0MKVGBUXwayCCF1oh39BF5COIpRzuCEv8Mwjv0XucrI2ExNTOn9IlLifGClWQcU9BrZORvtw6Q==

color-convert@^1.9.0:
version "1.9.3"
resolved "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz"
Expand All @@ -1380,11 +1375,6 @@ color-name@~1.1.4:
resolved "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz"
integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==

[email protected]:
version "1.1.3"
resolved "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz"
integrity sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==

colorette@^2.0.16:
version "2.0.20"
resolved "https://registry.npmjs.org/colorette/-/colorette-2.0.20.tgz"
Expand Down Expand Up @@ -1677,7 +1667,7 @@ eslint-visitor-keys@^3.3.0, eslint-visitor-keys@^3.4.1, eslint-visitor-keys@^3.4
resolved "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz"
integrity sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==

"eslint@^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0", "eslint@^6.0.0 || ^7.0.0 || >=8.0.0", eslint@^8.56.0, eslint@^8.57.0, eslint@>=7:
eslint@^8.57.0:
version "8.57.0"
resolved "https://registry.npmjs.org/eslint/-/eslint-8.57.0.tgz"
integrity sha512-dZ6+mexnaTIbSBZWgou51U6OmzIhYM2VcNdtiTtI7qPNZm35Akpr0f6vtw3w1Kmn5PYo+tZVfh13WrhpS6oLqQ==
Expand Down Expand Up @@ -2726,14 +2716,7 @@ minimatch@^5.0.1:
dependencies:
brace-expansion "^2.0.1"

minimatch@^9.0.1:
version "9.0.4"
resolved "https://registry.npmjs.org/minimatch/-/minimatch-9.0.4.tgz"
integrity sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==
dependencies:
brace-expansion "^2.0.1"

minimatch@^9.0.4:
minimatch@^9.0.1, minimatch@^9.0.4:
version "9.0.4"
resolved "https://registry.npmjs.org/minimatch/-/minimatch-9.0.4.tgz"
integrity sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==
Expand Down Expand Up @@ -2831,7 +2814,7 @@ once@^1.3.0:
dependencies:
wrappy "1"

optionator@^0.9.1, optionator@^0.9.3:
optionator@^0.9.3:
version "0.9.4"
resolved "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz"
integrity sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==
Expand Down Expand Up @@ -2995,10 +2978,10 @@ postcss-nested@^6.0.1:
dependencies:
postcss-selector-parser "^6.0.11"

postcss-selector-parser@^6.0.11:
version "6.0.16"
resolved "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.0.16.tgz"
integrity sha512-A0RVJrX+IUkVZbW3ClroRWurercFhieevHB38sr2+l9eUClMqome3LmEmnhlNy+5Mr2EYN6B2Kaw9wYdd+VHiw==
[email protected].10:
version "6.0.10"
resolved "https://registry.yarnpkg.com/postcss-selector-parser/-/postcss-selector-parser-6.0.10.tgz#79b61e2c0d1bfc2602d549e11d0876256f8df88d"
integrity sha512-IQ7TZdoaqbT+LCpShg46jnZVlhWD2w6iQYAcYXfHARZ7X1t/UGhhceQDs5X0cGqKvYlHNOuv7Oa1xmb0oQuA3w==
dependencies:
cssesc "^3.0.0"
util-deprecate "^1.0.2"
Expand All @@ -3016,7 +2999,7 @@ postcss-value-parser@^4.0.0, postcss-value-parser@^4.2.0:
resolved "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz"
integrity sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==

postcss@^8.0.0, postcss@^8.1.0, postcss@^8.2.14, postcss@^8.4.21, postcss@^8.4.23, postcss@^8.4.38, postcss@>=8.0.9:
postcss@^8.4.23, postcss@^8.4.38:
version "8.4.38"
resolved "https://registry.npmjs.org/postcss/-/postcss-8.4.38.tgz"
integrity sha512-Wglpdk03BSfXkHoQa3b/oulrotAkwrlLDRSOb9D0bN86FdRyE9lppSp33aHNPgBa0JKCoB+drFLZkQoRRYae5A==
Expand Down Expand Up @@ -3062,7 +3045,7 @@ queue-microtask@^1.2.2:
resolved "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz"
integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==

"react-dom@^16.8 || ^17.0 || ^18.0", react-dom@^18.2.0, react-dom@>=16.8.0:
react-dom@^18.2.0:
version "18.3.1"
resolved "https://registry.npmjs.org/react-dom/-/react-dom-18.3.1.tgz"
integrity sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==
Expand Down Expand Up @@ -3435,7 +3418,7 @@ tailwindcss-animate@^1.0.7:
resolved "https://registry.npmjs.org/tailwindcss-animate/-/tailwindcss-animate-1.0.7.tgz"
integrity sha512-bl6mpH3T7I3UFxuvDEXLxy/VuFxBk5bbzplh7tXI68mwMokNYd1t9qPBHlnyTwfa4JGC4zP516I1hYYtQ/vspA==

tailwindcss@^3.4.3, "tailwindcss@>=3.0.0 || insiders":
tailwindcss@^3.4.3:
version "3.4.3"
resolved "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.3.tgz"
integrity sha512-U7sxQk/n397Bmx4JHbJx/iSOOv5G+II3f1kpLpY2QeUv5DcPdcTsYLlusZfq1NthHS1c1cZoyFmmkex1rzke0A==
Expand Down Expand Up @@ -3463,7 +3446,7 @@ tailwindcss@^3.4.3, "tailwindcss@>=3.0.0 || insiders":
resolve "^1.22.2"
sucrase "^3.32.0"

terser@^5.10.0, terser@^5.4.0:
terser@^5.10.0:
version "5.31.0"
resolved "https://registry.npmjs.org/terser/-/terser-5.31.0.tgz"
integrity sha512-Q1JFAoUKE5IMfI4Z/lkE/E6+SwgzO+x4tq4v1AyBLRj8VSYvRO6A/rQrPg1yud4g0En9EKI1TvFRF2tQFcoUkg==
Expand Down Expand Up @@ -3551,7 +3534,7 @@ type-fest@^0.21.3:
resolved "https://registry.npmjs.org/type-fest/-/type-fest-0.21.3.tgz"
integrity sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==

typescript@*, typescript@^5.2.2, typescript@>=4.2.0:
typescript@^5.2.2:
version "5.4.5"
resolved "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz"
integrity sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==
Expand Down Expand Up @@ -3721,7 +3704,7 @@ vite-plugin-html@^3.2.2:
node-html-parser "^5.3.3"
pathe "^0.2.0"

"vite@^4.2.0 || ^5.0.0", vite@^5.2.0, vite@>=2.0.0:
vite@^5.2.0:
version "5.2.10"
resolved "https://registry.npmjs.org/vite/-/vite-5.2.10.tgz"
integrity sha512-PAzgUZbP7msvQvqdSD+ErD5qGnSFiGOoWmV5yAKUEI0kdhjbH6nMWVyZQC/hSc4aXwc0oJ9aEdIiF9Oje0JFCw==
Expand Down