Skip to content

Commit

Permalink
Merge branch 'main' into 0.5.1-deployment-patches
Browse files Browse the repository at this point in the history
  • Loading branch information
VVoruganti committed Dec 12, 2023
2 parents 185e32f + d4792da commit 067f2d4
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 101 deletions.
102 changes: 51 additions & 51 deletions www/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,8 @@ export default function Home() {

return (
<main
className={`flex h-[100dvh] w-screen flex-col pb-[env(keyboard-inset-height)] text-sm lg:text-base overflow-hidden relative ${
isDarkMode ? "dark" : ""
}`}
className={`flex h-[100dvh] w-screen flex-col pb-[env(keyboard-inset-height)] text-sm lg:text-base overflow-hidden relative ${isDarkMode ? "dark" : ""
}`}
>
<Sidebar
conversations={conversations || []}
Expand Down Expand Up @@ -266,59 +265,60 @@ export default function Home() {
className="flex flex-col flex-1 overflow-y-auto lg:px-5 dark:text-white"
ref={messageContainerRef}
>
{messagesLoading || messages === undefined ? (
<MessageBox loading />
) : (
messages.map((message, i) => (
<MessageBox isUser={message.isUser} key={i}>
<MarkdownWrapper text={message.text} />
</MessageBox>
))
)}
</section>
<form
id="send"
className="flex p-3 lg:p-5 gap-3 border-gray-300"
onSubmit={(e) => {
{
messagesLoading || messages === undefined ? (
<MessageBox loading />
) : (
messages.map((message, i) => (
<MessageBox isUser={message.isUser} key={i}>
<MarkdownWrapper text={message.text} />
</MessageBox>
))
)
}
</section >
<form
id="send"
className="flex p-3 lg:p-5 gap-3 border-gray-300"
onSubmit={(e) => {
e.preventDefault();
if (canSend && input.current?.value) {
posthog.capture("user_sent_message");
chat();
}
}}
>
{/* TODO: validate input */}
<textarea
ref={input}
placeholder="Type a message..."
className={`flex-1 px-3 py-1 lg:px-5 lg:py-3 bg-gray-100 dark:bg-gray-800 text-gray-400 rounded-2xl border-2 resize-none ${canSend ? " border-green-200" : "border-red-200 opacity-50"
}`}
disabled={!canSend}
rows={1}
onKeyDown={(e) => {
if (e.key === "Enter" && !e.shiftKey) {
e.preventDefault();
if (canSend && input.current?.value) {
posthog.capture("user_sent_message");
chat();
}
}}
>
{/* TODO: validate input */}
<textarea
ref={input}
placeholder="Type a message..."
className={`flex-1 px-3 py-1 lg:px-5 lg:py-3 bg-gray-100 dark:bg-gray-800 text-gray-400 rounded-2xl border-2 resize-none ${
canSend ? " border-green-200" : "border-red-200 opacity-50"
}`}
disabled={!canSend}
rows={1}
onKeyDown={(e) => {
if (e.key === "Enter" && !e.shiftKey) {
e.preventDefault();
if (canSend && input.current?.value) {
posthog.capture("user_sent_message");
chat();
}
}
}}
/>
<button
className="bg-dark-green text-neon-green rounded-full px-4 py-2 lg:px-7 lg:py-3 flex justify-center items-center gap-2"
type="submit"
>
<FaPaperPlane className="inline" />
</button>
</form>
</div>
<Thoughts
thought={thought}
setIsThoughtsOpen={setIsThoughtsOpen}
isThoughtsOpen={isThoughtsOpen}
}
}}
/>
</main>
<button
className="bg-dark-green text-neon-green rounded-full px-4 py-2 lg:px-7 lg:py-3 flex justify-center items-center gap-2"
type="submit"
>
<FaPaperPlane className="inline" />
</button>
</form>
</div >
<Thoughts
thought={thought}
setIsThoughtsOpen={setIsThoughtsOpen}
isThoughtsOpen={isThoughtsOpen}
/>
</main >
);
}
85 changes: 43 additions & 42 deletions www/components/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,12 @@ export default function Sidebar({

return (
<div
className={`fixed lg:static z-20 inset-0 flex-none h-full w-full lg:absolute lg:h-auto lg:overflow-visible lg:pt-0 lg:w-60 xl:w-72 lg:block lg:shadow-lg border-r border-gray-300 dark:border-gray-700 ${
isSidebarOpen ? "" : "hidden"
}`}
className={`fixed lg:static z-20 inset-0 flex-none h-full w-full lg:absolute lg:h-auto lg:overflow-visible lg:pt-0 lg:w-60 xl:w-72 lg:block lg:shadow-lg border-r border-gray-300 dark:border-gray-700 ${isSidebarOpen ? "" : "hidden"
}`}
>
<div
className={`h-full scrollbar-trigger overflow-hidden bg-white dark:bg-gray-950 dark:text-white sm:w-3/5 w-4/5 lg:w-full flex flex-col ${
isSidebarOpen ? "fixed lg:static" : "sticky"
} top-0 left-0`}
className={`h-full scrollbar-trigger overflow-hidden bg-white dark:bg-gray-950 dark:text-white sm:w-3/5 w-4/5 lg:w-full flex flex-col ${isSidebarOpen ? "fixed lg:static" : "sticky"
} top-0 left-0`}
>
{/* Section 1: Top buttons */}
<div className="flex justify-between items-center p-4 gap-2 border-b border-gray-300 dark:border-gray-700">
Expand All @@ -143,44 +141,47 @@ export default function Sidebar({

{/* Section 2: Scrollable items */}
<div className="flex flex-col flex-1 overflow-y-auto divide-y divide-gray-300 dark:divide-gray-700">
{conversations.length > 0
? conversations.map((cur, i) => (
<ConversationTab
conversation={cur}
select={() => setConversationId(cur.conversationId)}
selected={conversationId === cur.conversationId}
edit={() => editConversation(cur)}
del={() => deleteConversation(cur)}
key={i}
/>
))
: Array.from({ length: 5 }).map((_, i) => (
<ConversationTab loading key={i} />
))}
</div>
{
conversations.length > 0
? conversations.map((cur, i) => (
<ConversationTab
conversation={cur}
select={() => setConversationId(cur.conversationId)}
selected={conversationId === cur.conversationId}
edit={() => editConversation(cur)}
del={() => deleteConversation(cur)}
key={i}
/>
))
: Array.from({ length: 5 }).map((_, i) => (
<ConversationTab loading key={i} />
))
}
</div >

{/* Section 3: Authentication information */}
<div className="border-t border-gray-300 dark:border-gray-700 p-4 w-full">
{/* Replace this with your authentication information */}
{session ? (
<button
className="bg-neon-green text-black rounded-lg px-4 py-2 w-full"
onClick={async () => {
await signOut();
location.reload();
}}
>
Sign Out
{/* Section 3: Authentication information */ }
< div className = "border-t border-gray-300 dark:border-gray-700 p-4 w-full" >
{/* Replace this with your authentication information */ }
{
session ? (
<button
className="bg-neon-green text-black rounded-lg px-4 py-2 w-full"
onClick={async () => {
await signOut();
location.reload();
}}
>
Sign Out
</button>
) : (
<Link href={"/auth"}>
<button className="bg-neon-green text-black rounded-lg px-4 py-2 w-full">
Sign In
</button>
) : (
<Link href={"/auth"}>
<button className="bg-neon-green text-black rounded-lg px-4 py-2 w-full">
Sign In
</button>
</Link>
</Link>
)}
</div>
</div>
</div>
</div >
</div >
);
}
}
16 changes: 8 additions & 8 deletions www/utils/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ export class Conversation {
async getMessages() {
const req = await fetch(
`${this.api.url}/api/messages?` +
new URLSearchParams({
conversation_id: this.conversationId,
user_id: this.api.userId,
})
new URLSearchParams({
conversation_id: this.conversationId,
user_id: this.api.userId,
})
);
const { messages: rawMessages } = await req.json();
// console.log(rawMessages);
Expand Down Expand Up @@ -146,10 +146,10 @@ export class API {
async getMessages(conversationId: string) {
const req = await fetch(
`${this.url}/api/messages?` +
new URLSearchParams({
conversation_id: conversationId,
user_id: this.userId,
})
new URLSearchParams({
conversation_id: conversationId,
user_id: this.userId,
})
);
const { messages: rawMessages } = await req.json();
// console.log(rawMessages);
Expand Down

0 comments on commit 067f2d4

Please sign in to comment.