Skip to content

Commit 5fb99bd

Browse files
committed
chore: address PR comments
1 parent 1f0c4df commit 5fb99bd

File tree

3 files changed

+29
-49
lines changed

3 files changed

+29
-49
lines changed

site/src/contexts/useAgenticChat.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { experiments } from "api/queries/experiments";
22

33
import { useEmbeddedMetadata } from "hooks/useEmbeddedMetadata";
4-
import { useEffect, useState } from "react";
54
import { useQuery } from "react-query";
65

76
interface AgenticChat {
@@ -11,13 +10,7 @@ interface AgenticChat {
1110
export const useAgenticChat = (): AgenticChat => {
1211
const { metadata } = useEmbeddedMetadata();
1312
const enabledExperimentsQuery = useQuery(experiments(metadata.experiments));
14-
15-
const [enabled, setEnabled] = useState<boolean>(false);
16-
useEffect(() => {
17-
if (enabledExperimentsQuery.data?.includes("agentic-chat")) {
18-
setEnabled(true);
19-
}
20-
});
21-
22-
return { enabled };
13+
return {
14+
enabled: enabledExperimentsQuery.data?.includes("agentic-chat") ?? false,
15+
};
2316
};

site/src/pages/ChatPage/ChatLanding.tsx

Lines changed: 18 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -27,33 +27,6 @@ const ChatLanding: FC = () => {
2727
const queryClient = useQueryClient();
2828
const createChatMutation = useMutation(createChat(queryClient));
2929

30-
const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
31-
setInput(event.target.value);
32-
};
33-
34-
// Placeholder submit handler
35-
const handleFormSubmit = (e: FormEvent<HTMLFormElement>) => {
36-
e.preventDefault();
37-
if (!input.trim()) return;
38-
// Actual submission logic will go elsewhere
39-
setInput(""); // Clear input after submit (optional)
40-
41-
createChatMutation.mutateAsync().then((chat) => {
42-
navigate(`/chat/${chat.id}`, {
43-
state: {
44-
chat,
45-
message: input,
46-
},
47-
});
48-
});
49-
};
50-
51-
// Placeholder suggestion handler
52-
const handleSuggestionClick = (suggestion: string) => {
53-
setInput(suggestion);
54-
// Optionally trigger focus on the input field here
55-
};
56-
5730
return (
5831
<Margins>
5932
<div
@@ -117,33 +90,37 @@ const ChatLanding: FC = () => {
11790
>
11891
<Button
11992
variant="outlined"
120-
onClick={() =>
121-
handleSuggestionClick("Help me work on issue #...")
122-
}
93+
onClick={() => setInput("Help me work on issue #...")}
12394
>
12495
Work on Issue
12596
</Button>
12697
<Button
12798
variant="outlined"
128-
onClick={() =>
129-
handleSuggestionClick("Help me build a template for...")
130-
}
99+
onClick={() => setInput("Help me build a template for...")}
131100
>
132101
Build a Template
133102
</Button>
134103
<Button
135104
variant="outlined"
136-
onClick={() =>
137-
handleSuggestionClick("Help me start a new project using...")
138-
}
105+
onClick={() => setInput("Help me start a new project using...")}
139106
>
140107
Start a Project
141108
</Button>
142109
</Stack>
143110
<LanguageModelSelector />
144111
<Paper
145112
component="form"
146-
onSubmit={handleFormSubmit}
113+
onSubmit={async (e: FormEvent<HTMLFormElement>) => {
114+
e.preventDefault();
115+
setInput("");
116+
const chat = await createChatMutation.mutateAsync();
117+
navigate(`/chat/${chat.id}`, {
118+
state: {
119+
chat,
120+
message: input,
121+
},
122+
});
123+
}}
147124
elevation={2}
148125
css={{
149126
padding: "16px",
@@ -156,8 +133,11 @@ const ChatLanding: FC = () => {
156133
>
157134
<TextField
158135
value={input}
159-
onChange={handleInputChange}
136+
onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
137+
setInput(event.target.value);
138+
}}
160139
placeholder="Ask Coder..."
140+
required
161141
fullWidth
162142
variant="outlined"
163143
multiline

site/src/pages/ChatPage/LanguageModelSelector.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,14 @@ export const LanguageModelSelector: FC = () => {
3030
);
3131
}
3232

33-
const models = languageModelConfig.models ?? [];
33+
const models = Array.from(languageModelConfig.models).toSorted((a, b) => {
34+
// Sort by provider first, then by display name
35+
const compareProvider = a.provider.localeCompare(b.provider);
36+
if (compareProvider !== 0) {
37+
return compareProvider;
38+
}
39+
return a.display_name.localeCompare(b.display_name);
40+
});
3441

3542
if (models.length === 0) {
3643
return (

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy