- Notifications
You must be signed in to change notification settings - Fork923
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Uh oh!
There was an error while loading.Please reload this page.
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), | ||
}; | ||
}; |
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. I would move this file to 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. Even though it's imported in 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. 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 commentThe 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. |
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, | ||
}; | ||
}; |
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. |
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; |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.