Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
johnstcn merged 1 commit intomainfromcj/rebase/chat-ui
May 13, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
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
3 changes: 3 additions & 0 deletionssite/package.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,6 +35,8 @@
"update-emojis": "cp -rf ./node_modules/emoji-datasource-apple/img/apple/64/* ./static/emojis"
},
"dependencies": {
"@ai-sdk/provider-utils": "2.2.6",
"@ai-sdk/react": "1.2.6",
"@emoji-mart/data": "1.2.1",
"@emoji-mart/react": "1.1.1",
"@emotion/cache": "11.14.0",
Expand DownExpand Up@@ -111,6 +113,7 @@
"react-virtualized-auto-sizer": "1.0.24",
"react-window": "1.8.11",
"recharts": "2.15.0",
"rehype-raw": "7.0.0",
"remark-gfm": "4.0.0",
"resize-observer-polyfill": "1.5.1",
"rollup-plugin-visualizer": "5.14.0",
Expand Down
216 changes: 216 additions & 0 deletionssite/pnpm-lock.yaml
View file
Open in desktop

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletionssite/src/api/api.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -827,6 +827,13 @@ class ApiMethods {
return response.data;
};

getDeploymentLLMs = async (): Promise<TypesGen.LanguageModelConfig> => {
const response = await this.axios.get<TypesGen.LanguageModelConfig>(
"/api/v2/deployment/llms",
);
return response.data;
};

getOrganizationIdpSyncClaimFieldValues = async (
organization: string,
field: string,
Expand DownExpand Up@@ -2489,6 +2496,23 @@ class ApiMethods {
markAllInboxNotificationsAsRead = async () => {
await this.axios.put<void>("/api/v2/notifications/inbox/mark-all-as-read");
};

createChat = async () => {
const res = await this.axios.post<TypesGen.Chat>("/api/v2/chats");
return res.data;
};

getChats = async () => {
const res = await this.axios.get<TypesGen.Chat[]>("/api/v2/chats");
return res.data;
};

getChatMessages = async (chatId: string) => {
const res = await this.axios.get<TypesGen.ChatMessage[]>(
`/api/v2/chats/${chatId}/messages`,
);
return res.data;
};
}

// This is a hard coded CSRF token/cookie pair for local development. In prod,
Expand Down
25 changes: 25 additions & 0 deletionssite/src/api/queries/chats.ts
View file
Open in desktop
Original file line numberDiff line numberDiff 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),
};
};
7 changes: 7 additions & 0 deletionssite/src/api/queries/deployment.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -36,3 +36,10 @@ export const deploymentIdpSyncFieldValues = (field: string) => {
queryFn: () => API.getDeploymentIdpSyncFieldValues(field),
};
};

export const deploymentLanguageModels = () => {
return {
queryKey: ["deployment", "llms"],
queryFn: API.getDeploymentLLMs,
};
};
16 changes: 16 additions & 0 deletionssite/src/contexts/useAgenticChat.ts
View file
Open in desktop
Copy link
Collaborator

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 tosites/src/modules/chat/useAgenticChat.ts.

Copy link
MemberAuthor

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 inmodules/dashboard/NavBar/NavbarView?

Copy link
Collaborator

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.

johnstcn reacted with thumbs up emoji
Copy link
MemberAuthor

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.

Original file line numberDiff line numberDiff 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,
};
};
31 changes: 25 additions & 6 deletionssite/src/modules/dashboard/Navbar/NavbarView.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,7 @@ import { Button } from "components/Button/Button";
import { ExternalImage } from "components/ExternalImage/ExternalImage";
import { CoderIcon } from "components/Icons/CoderIcon";
import type { ProxyContextValue } from "contexts/ProxyContext";
import { useAgenticChat } from "contexts/useAgenticChat";
import { useWebpushNotifications } from "contexts/useWebpushNotifications";
import { NotificationsInbox } from "modules/notifications/NotificationsInbox/NotificationsInbox";
import type { FC } from "react";
Expand DownExpand Up@@ -45,8 +46,7 @@ export const NavbarView: FC<NavbarViewProps> = ({
canViewAuditLog,
proxyContextValue,
}) => {
const { subscribed, enabled, loading, subscribe, unsubscribe } =
useWebpushNotifications();
const webPush = useWebpushNotifications();

return (
<div className="border-0 border-b border-solid h-[72px] flex items-center leading-none px-6">
Expand DownExpand Up@@ -76,13 +76,21 @@ export const NavbarView: FC<NavbarViewProps> = ({
/>
</div>

{enabled ? (
subscribed ? (
<Button variant="outline" disabled={loading} onClick={unsubscribe}>
{webPush.enabled ? (
webPush.subscribed ? (
<Button
variant="outline"
disabled={webPush.loading}
onClick={webPush.unsubscribe}
>
Disable WebPush
</Button>
) : (
<Button variant="outline" disabled={loading} onClick={subscribe}>
<Button
variant="outline"
disabled={webPush.loading}
onClick={webPush.subscribe}
>
Enable WebPush
</Button>
)
Expand DownExpand Up@@ -132,6 +140,7 @@ interface NavItemsProps {

const NavItems: FC<NavItemsProps> = ({ className }) => {
const location = useLocation();
const agenticChat = useAgenticChat();

return (
<nav className={cn("flex items-center gap-4 h-full", className)}>
Expand All@@ -154,6 +163,16 @@ const NavItems: FC<NavItemsProps> = ({ className }) => {
>
Templates
</NavLink>
{agenticChat.enabled ? (
<NavLink
className={({ isActive }) => {
return cn(linkStyles.default, isActive ? linkStyles.active : "");
}}
to="/chat"
>
Chat
</NavLink>
) : null}
</nav>
);
};
164 changes: 164 additions & 0 deletionssite/src/pages/ChatPage/ChatLanding.tsx
View file
Open in desktop
Copy link
Collaborator

Choose a reason for hiding this comment

The 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 numberDiff line numberDiff 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;
Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp