-
Notifications
You must be signed in to change notification settings - Fork 928
feat: add experimental Chat UI #17650
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { API } from "api/api"; | ||
import type { QueryClient } from "react-query"; | ||
|
||
export const createChat = (queryClient: QueryClient) => { | ||
return { | ||
mutationFn: API.createChat, | ||
onSuccess: async () => { | ||
await queryClient.invalidateQueries(["chats"]); | ||
}, | ||
}; | ||
}; | ||
|
||
export const getChats = () => { | ||
return { | ||
queryKey: ["chats"], | ||
queryFn: API.getChats, | ||
}; | ||
}; | ||
|
||
export const getChatMessages = (chatID: string) => { | ||
return { | ||
queryKey: ["chatMessages", chatID], | ||
queryFn: () => API.getChatMessages(chatID), | ||
}; | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { experiments } from "api/queries/experiments"; | ||
|
||
import { useEmbeddedMetadata } from "hooks/useEmbeddedMetadata"; | ||
import { useQuery } from "react-query"; | ||
|
||
interface AgenticChat { | ||
readonly enabled: boolean; | ||
} | ||
|
||
export const useAgenticChat = (): AgenticChat => { | ||
const { metadata } = useEmbeddedMetadata(); | ||
const enabledExperimentsQuery = useQuery(experiments(metadata.experiments)); | ||
return { | ||
enabled: enabledExperimentsQuery.data?.includes("agentic-chat") ?? false, | ||
}; | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if this should be included in the scope of this PR, but all the new pages and components are made using shadcn/ui components, TailwindCSS styles, and Lucide icons as part of our redesign effort. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
import { useTheme } from "@emotion/react"; | ||
import SendIcon from "@mui/icons-material/Send"; | ||
import Button from "@mui/material/Button"; | ||
import IconButton from "@mui/material/IconButton"; | ||
import Paper from "@mui/material/Paper"; | ||
import Stack from "@mui/material/Stack"; | ||
import TextField from "@mui/material/TextField"; | ||
import { createChat } from "api/queries/chats"; | ||
import type { Chat } from "api/typesGenerated"; | ||
import { Margins } from "components/Margins/Margins"; | ||
import { useAuthenticated } from "hooks"; | ||
import { type FC, type FormEvent, useState } from "react"; | ||
import { useMutation, useQueryClient } from "react-query"; | ||
import { useNavigate } from "react-router-dom"; | ||
import { LanguageModelSelector } from "./LanguageModelSelector"; | ||
|
||
export interface ChatLandingLocationState { | ||
chat: Chat; | ||
message: string; | ||
} | ||
|
||
const ChatLanding: FC = () => { | ||
const { user } = useAuthenticated(); | ||
const theme = useTheme(); | ||
const [input, setInput] = useState(""); | ||
const navigate = useNavigate(); | ||
const queryClient = useQueryClient(); | ||
const createChatMutation = useMutation(createChat(queryClient)); | ||
|
||
return ( | ||
<Margins> | ||
<div | ||
css={{ | ||
display: "flex", | ||
flexDirection: "column", | ||
marginTop: theme.spacing(24), | ||
alignItems: "center", | ||
paddingBottom: theme.spacing(4), | ||
}} | ||
> | ||
{/* Initial Welcome Message Area */} | ||
<div | ||
css={{ | ||
flexGrow: 1, | ||
display: "flex", | ||
flexDirection: "column", | ||
justifyContent: "center", | ||
alignItems: "center", | ||
gap: theme.spacing(1), | ||
padding: theme.spacing(1), | ||
width: "100%", | ||
maxWidth: "700px", | ||
marginBottom: theme.spacing(4), | ||
}} | ||
> | ||
<h1 | ||
css={{ | ||
fontSize: theme.typography.h4.fontSize, | ||
fontWeight: theme.typography.h4.fontWeight, | ||
lineHeight: theme.typography.h4.lineHeight, | ||
marginBottom: theme.spacing(1), | ||
textAlign: "center", | ||
}} | ||
> | ||
Good evening, {user?.name.split(" ")[0]} | ||
</h1> | ||
<p | ||
css={{ | ||
fontSize: theme.typography.h6.fontSize, | ||
fontWeight: theme.typography.h6.fontWeight, | ||
lineHeight: theme.typography.h6.lineHeight, | ||
color: theme.palette.text.secondary, | ||
textAlign: "center", | ||
margin: 0, | ||
maxWidth: "500px", | ||
marginInline: "auto", | ||
}} | ||
> | ||
How can I help you today? | ||
</p> | ||
</div> | ||
|
||
{/* Input Form and Suggestions - Always Visible */} | ||
<div css={{ width: "100%", maxWidth: "700px", marginTop: "auto" }}> | ||
<Stack | ||
direction="row" | ||
spacing={2} | ||
justifyContent="center" | ||
sx={{ mb: 2 }} | ||
> | ||
<Button | ||
variant="outlined" | ||
onClick={() => setInput("Help me work on issue #...")} | ||
> | ||
Work on Issue | ||
</Button> | ||
<Button | ||
variant="outlined" | ||
onClick={() => setInput("Help me build a template for...")} | ||
> | ||
Build a Template | ||
</Button> | ||
<Button | ||
variant="outlined" | ||
onClick={() => setInput("Help me start a new project using...")} | ||
> | ||
Start a Project | ||
</Button> | ||
</Stack> | ||
<LanguageModelSelector /> | ||
<Paper | ||
component="form" | ||
onSubmit={async (e: FormEvent<HTMLFormElement>) => { | ||
e.preventDefault(); | ||
setInput(""); | ||
const chat = await createChatMutation.mutateAsync(); | ||
navigate(`/chat/${chat.id}`, { | ||
state: { | ||
chat, | ||
message: input, | ||
}, | ||
}); | ||
}} | ||
elevation={2} | ||
css={{ | ||
padding: "16px", | ||
display: "flex", | ||
alignItems: "center", | ||
width: "100%", | ||
borderRadius: "12px", | ||
border: `1px solid ${theme.palette.divider}`, | ||
}} | ||
> | ||
<TextField | ||
value={input} | ||
onChange={(event: React.ChangeEvent<HTMLInputElement>) => { | ||
setInput(event.target.value); | ||
}} | ||
placeholder="Ask Coder..." | ||
required | ||
fullWidth | ||
variant="outlined" | ||
multiline | ||
maxRows={5} | ||
css={{ | ||
marginRight: theme.spacing(1), | ||
"& .MuiOutlinedInput-root": { | ||
borderRadius: "8px", | ||
padding: "10px 14px", | ||
}, | ||
}} | ||
autoFocus | ||
/> | ||
<IconButton type="submit" color="primary" disabled={!input.trim()}> | ||
<SendIcon /> | ||
</IconButton> | ||
</Paper> | ||
</div> | ||
</div> | ||
</Margins> | ||
); | ||
}; | ||
|
||
export default ChatLanding; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move this file to
sites/src/modules/chat/useAgenticChat.ts
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even though it's imported in
modules/dashboard/NavBar/NavbarView
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeap! I think it makes more sense. But no strong thoughts, you can leave as it is if it makes more sense to you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to leave it where it is for now; I think there's more scope to refactor here.