Skip to content

Commit 2b4f9bb

Browse files
committed
Move project files below input box
1 parent fae36e2 commit 2b4f9bb

File tree

19 files changed

+2859
-125
lines changed

19 files changed

+2859
-125
lines changed

dist/19.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/540.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/715.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

dist/main.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/remoteEntry.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 855 additions & 66 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,14 @@
5757
},
5858
"dependencies": {
5959
"@microsoft/fetch-event-source": "^2.0.1",
60+
"@radix-ui/react-scroll-area": "^1.2.10",
61+
"@radix-ui/react-select": "^2.2.6",
6062
"@radix-ui/react-slot": "^1.2.3",
6163
"@tailwindcss/postcss": "^4.1.14",
6264
"axios": "^1.12.2",
6365
"class-variance-authority": "^0.7.1",
6466
"clsx": "^2.1.1",
67+
"framer-motion": "^12.23.24",
6568
"lucide-react": "^0.525.0",
6669
"node-fetch": "^3.3.2",
6770
"react": "^18.2.0",
@@ -71,7 +74,8 @@
7174
"remark-gfm": "^4.0.1",
7275
"tailwind-merge": "^3.3.1",
7376
"tailwindcss": "^4.1.14",
74-
"tw-animate-css": "^1.4.0"
77+
"tw-animate-css": "^1.4.0",
78+
"usehooks-ts": "^3.1.1"
7579
},
7680
"peerDependencies": {
7781
"react": "^18.2.0",
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import { useState } from "react";
2+
import { Textarea } from "@/components/ui/textarea";
3+
import { Button } from "@/components/ui/button";
4+
import { Send } from "lucide-react";
5+
import { useChatMessages } from "./context/chat-messages-provider";
6+
7+
8+
export function ChatInput() {
9+
const { sendMessage, isLoading: isSessionLoading } = useChatMessages(); // Get sendMessage and isLoading from hook
10+
const [message, setMessage] = useState("");
11+
const [isSendingMessage, setIsSendingMessage] = useState(false); // Local state for message sending
12+
13+
// Determine overall loading state (session loading OR message sending)
14+
const isLoading = isSessionLoading || isSendingMessage;
15+
16+
const handleSend = async (e?: React.FormEvent) => {
17+
e?.preventDefault();
18+
const trimmedMessage = message.trim();
19+
20+
if (!trimmedMessage || isLoading) return; // Prevent sending if empty or loading
21+
22+
setIsSendingMessage(true); // Set local sending state
23+
setMessage(""); // Clear input immediately for better UX
24+
25+
try {
26+
await sendMessage(trimmedMessage); // Call the hook's sendMessage
27+
// toast.success("Message sent."); // useChatSession already handles toasts for success/failure
28+
} catch (error) {
29+
console.error("Error sending message from input:", error);
30+
// The hook should already show a toast for this, but if not, you could add one here.
31+
setMessage(trimmedMessage); // Restore message on failure
32+
} finally {
33+
setIsSendingMessage(false); // Reset local sending state
34+
}
35+
};
36+
37+
return (
38+
<div className="relative flex w-full flex-col gap-4">
39+
<form onSubmit={handleSend} className="max-w-4xl mx-auto">
40+
<div className="relative flex items-end">
41+
<Textarea
42+
placeholder="Send a message..."
43+
value={message}
44+
onChange={(e) => setMessage(e.target.value)}
45+
onKeyDown={(e) => {
46+
if (e.key === "Enter" && !e.shiftKey) {
47+
handleSend(e);
48+
}
49+
}}
50+
className="min-h-[50px] pr-16 resize-none"
51+
disabled={isLoading}
52+
/>
53+
54+
{/* Buttons overlay */}
55+
<div className="absolute right-2 bottom-2 flex items-center space-x-1">
56+
<Button
57+
type="submit"
58+
size="icon"
59+
disabled={!message.trim() || isLoading}
60+
title="Send Message"
61+
>
62+
<Send className="h-5 w-5" />
63+
</Button>
64+
</div>
65+
</div>
66+
</form>
67+
</div>
68+
);
69+
}

src/collection-chat-view/CollectionChatViewShell.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131

3232
// Import services
3333
import { AIService, DocumentService } from '../services';
34+
import { DocumentManagerModal } from '../document-view/DocumentManagerModal';
3435

3536
// Import icons
3637
// Icons previously used in the bottom history panel are no longer needed here
@@ -2549,6 +2550,13 @@ export class CollectionChatViewShell extends React.Component<CollectionChatProps
25492550

25502551

25512552
{/* Chat input area */}
2553+
{/* <div className="chat-input-container">
2554+
<div className="chat-input-wrapper">
2555+
<div className="sticky bottom-0 z-1 mx-auto flex w-full max-w-4xl gap-2 border-t-0 bg-background px-2 pb-3 md:px-4 md:pb-4">
2556+
<ChatInput />
2557+
</div>
2558+
</div>
2559+
</div> */}
25522560
<ChatInput
25532561
inputText={inputText}
25542562
isLoading={isLoading}
@@ -2568,6 +2576,14 @@ export class CollectionChatViewShell extends React.Component<CollectionChatProps
25682576
onPersonaToggle={this.handlePersonaToggle}
25692577
showPersonaSelection={false} // Moved to header
25702578
/>
2579+
<DocumentManagerModal
2580+
apiService={services.api}
2581+
dataRepository={this.props.dataRepository}
2582+
collectionId={selectedCollection.id}
2583+
onDocumentListChange={() => console.log("document changed")}
2584+
documents={[]}
2585+
chatSessions={[]}
2586+
/>
25712587
</>
25722588
)}
25732589

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
// import { useState, useEffect, useRef, useCallback } from "react";
2+
// import { Textarea } from "@/components/ui/textarea";
3+
// import { Button } from "@/components/ui/button";
4+
// import { Send } from "lucide-react";
5+
// import {
6+
// PromptInput,
7+
// PromptInputModelSelect,
8+
// PromptInputModelSelectContent,
9+
// PromptInputSubmit,
10+
// PromptInputTextarea,
11+
// PromptInputToolbar,
12+
// PromptInputTools,
13+
// } from "./elements/prompt-input";
14+
// import {
15+
// ArrowUpIcon,
16+
// ChevronDownIcon,
17+
// CpuIcon,
18+
// PaperclipIcon,
19+
// StopIcon,
20+
// } from "./icons";
21+
// import { useChatMessages } from "./context/chat-messages-provider";
22+
// import { cn } from "@/lib/utils";
23+
// import { useWindowSize } from "usehooks-ts";
24+
25+
26+
// export function ChatInput({className}: {className?: string}) {
27+
// const { sendMessage, isLoading: isSessionLoading, status: chatStatus } = useChatMessages();
28+
// const [message, setMessage] = useState("");
29+
// const [isSendingMessage, setIsSendingMessage] = useState(false);
30+
31+
// const textareaRef = useRef<HTMLTextAreaElement>(null);
32+
// const { width } = useWindowSize();
33+
34+
// const adjustHeight = useCallback(() => {
35+
// if (textareaRef.current) {
36+
// textareaRef.current.style.height = "44px";
37+
// }
38+
// }, []);
39+
40+
// useEffect(() => {
41+
// if (textareaRef.current) {
42+
// adjustHeight();
43+
// }
44+
// }, [adjustHeight]);
45+
46+
// const resetHeight = useCallback(() => {
47+
// if (textareaRef.current) {
48+
// textareaRef.current.style.height = "44px";
49+
// }
50+
// }, []);
51+
52+
// // Determine overall loading state (session loading OR message sending)
53+
// const isLoading = isSessionLoading || isSendingMessage;
54+
55+
// const handleSend = async (e?: React.FormEvent) => {
56+
// e?.preventDefault();
57+
// const trimmedMessage = message.trim();
58+
59+
// if (!trimmedMessage || isLoading) return; // Prevent sending if empty or loading
60+
61+
// setIsSendingMessage(true); // Set local sending state
62+
// setMessage(""); // Clear input immediately for better UX
63+
64+
// try {
65+
// await sendMessage(trimmedMessage); // Call the hook's sendMessage
66+
// // toast.success("Message sent."); // useChatSession already handles toasts for success/failure
67+
// } catch (error) {
68+
// console.error("Error sending message from input:", error);
69+
// // The hook should already show a toast for this, but if not, you could add one here.
70+
// setMessage(trimmedMessage); // Restore message on failure
71+
// } finally {
72+
// setIsSendingMessage(false); // Reset local sending state
73+
// }
74+
// };
75+
76+
// const handleInput = (event: React.ChangeEvent<HTMLTextAreaElement>) => {
77+
// setMessage(event.target.value);
78+
// };
79+
80+
// return (
81+
// <div className={cn("relative flex w-full flex-col gap-4", className)}>
82+
// <PromptInput
83+
// className="rounded-xl border border-border bg-background p-3 shadow-xs transition-all duration-200 focus-within:border-border hover:border-muted-foreground/50"
84+
// onSubmit={(event) => {
85+
// event.preventDefault();
86+
// if (status !== "ready") {
87+
// toast.error("Please wait for the model to finish its response!");
88+
// } else {
89+
// handleSend();
90+
// }
91+
// }}
92+
// >
93+
// <div className="flex flex-row items-start gap-1 sm:gap-2">
94+
// <PromptInputTextarea
95+
// autoFocus
96+
// className="grow resize-none border-0! border-none! bg-transparent p-2 text-sm outline-none ring-0 [-ms-overflow-style:none] [scrollbar-width:none] placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-0 focus-visible:ring-offset-0 [&::-webkit-scrollbar]:hidden"
97+
// data-testid="multimodal-input"
98+
// disableAutoResize={true}
99+
// maxHeight={200}
100+
// minHeight={44}
101+
// onChange={handleInput}
102+
// placeholder="Send a message..."
103+
// ref={textareaRef}
104+
// rows={1}
105+
// value={message}
106+
// />{" "}
107+
// <Context {...contextProps} />
108+
// </div>
109+
// <PromptInputToolbar className="!border-top-0 border-t-0! p-0 shadow-none dark:border-0 dark:border-transparent!">
110+
111+
// {status === "submitted" ? (
112+
// <StopButton setMessages={setMessages} stop={stop} />
113+
// ) : (
114+
// <PromptInputSubmit
115+
// className="size-8 rounded-full bg-primary text-primary-foreground transition-colors duration-200 hover:bg-primary/90 disabled:bg-muted disabled:text-muted-foreground"
116+
// disabled={!message.trim()}
117+
// status={status}
118+
// data-testid="send-button"
119+
// >
120+
// <ArrowUpIcon size={14} />
121+
// </PromptInputSubmit>
122+
// )}
123+
// </PromptInputToolbar>
124+
// </PromptInput>
125+
// </div>
126+
// // <form onSubmit={handleSend} className="max-w-4xl mx-auto">
127+
// // <div className="relative flex items-end w-xl">
128+
// // <Textarea
129+
// // placeholder="Send a message..."
130+
// // value={message}
131+
// // onChange={(e) => setMessage(e.target.value)}
132+
// // onKeyDown={(e) => {
133+
// // if (e.key === "Enter" && !e.shiftKey) {
134+
// // handleSend(e);
135+
// // }
136+
// // }}
137+
// // className="min-h-[50px] pr-16 resize-none"
138+
// // disabled={isLoading}
139+
// // />
140+
141+
// // {/* Buttons overlay */}
142+
// // <div className="absolute right-2 bottom-2 flex items-center space-x-1">
143+
// // <Button
144+
// // type="submit"
145+
// // size="icon"
146+
// // disabled={!message.trim() || isLoading}
147+
// // title="Send Message"
148+
// // >
149+
// // <Send className="h-5 w-5" />
150+
// // </Button>
151+
// // </div>
152+
// // </div>
153+
// // </form>
154+
// );
155+
// }

0 commit comments

Comments
 (0)