Skip to content

Commit 40da5e9

Browse files
committed
Refactor PlanChat input into PlanChatBody component
Moved the chat input UI from PlanChat.tsx into a new PlanChatBody.tsx component for better separation of concerns and maintainability. Also performed minor variable renaming in StreamingUserPlanMessage.tsx and removed an unused import in StreamingUserPlan.tsx.
1 parent e1f5f75 commit 40da5e9

File tree

4 files changed

+69
-32
lines changed

4 files changed

+69
-32
lines changed

src/frontend/src/components/content/PlanChat.tsx

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import renderUserPlanMessage from "./streaming/StreamingUserPlanMessage";
3030
import renderPlanResponse from "./streaming/StreamingPlanResponse";
3131
import renderThinkingState from "./streaming/StreamingPlanState";
3232
import ContentNotFound from "../NotFound/ContentNotFound";
33+
import PlanChatBody from "./PlanChatBody";
3334
interface SimplifiedPlanChatProps extends PlanChatProps {
3435
onPlanReceived?: (planData: MPlanData) => void;
3536
initialTask?: string;
@@ -55,6 +56,7 @@ const PlanChat: React.FC<SimplifiedPlanChatProps> = ({
5556
const [userFeedback, setUserFeedback] = useState('');
5657
const [showFeedbackInput, setShowFeedbackInput] = useState(false);
5758

59+
5860
// Auto-scroll helper
5961
const scrollToBottom = useCallback(() => {
6062
setTimeout(() => {
@@ -193,35 +195,16 @@ const PlanChat: React.FC<SimplifiedPlanChatProps> = ({
193195
{renderPlanResponse(planApprovalRequest, handleApprovePlan, handleRejectPlan, processingApproval)}
194196
</div>
195197

196-
<div style={{
197-
padding: '20px 24px 32px',
198-
borderTop: '1px solid var(--colorNeutralStroke2)',
199-
backgroundColor: 'var(--colorNeutralBackground1)',
200-
maxWidth: '800px',
201-
margin: '0 auto',
202-
width: '100%'
203-
}}>
204-
<ChatInput
205-
value={input}
206-
onChange={setInput}
207-
onEnter={() => OnChatSubmit(input)}
208-
disabledChat={submittingChatDisableInput || waitingForPlan}
209-
placeholder={
210-
waitingForPlan
211-
? "Creating plan..."
212-
: "Send a message..."
213-
}
214-
>
215-
<Button
216-
appearance="transparent"
217-
onClick={() => OnChatSubmit(input)}
218-
icon={<SendRegular />}
219-
disabled={submittingChatDisableInput || waitingForPlan}
220-
style={{ height: '40px', width: '40px' }}
221-
/>
222-
</ChatInput>
223-
</div>
224-
198+
{/* Chat Input - only show if no plan is waiting for approval */}
199+
<PlanChatBody
200+
planData={planData}
201+
input={input}
202+
setInput={setInput}
203+
submittingChatDisableInput={submittingChatDisableInput}
204+
OnChatSubmit={OnChatSubmit}
205+
showChatInput={!planApprovalRequest}
206+
waitingForPlan={waitingForPlan}
207+
loading={false} />
225208
</div>
226209
);
227210
};
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import ChatInput from "@/coral/modules/ChatInput";
2+
import { PlanChatProps } from "@/models";
3+
import { Button } from "@fluentui/react-components";
4+
import { SendRegular } from "@fluentui/react-icons";
5+
6+
interface SimplifiedPlanChatProps extends PlanChatProps {
7+
showChatInput: boolean;
8+
waitingForPlan: boolean;
9+
}
10+
const PlanChatBody: React.FC<SimplifiedPlanChatProps> = ({
11+
planData,
12+
input,
13+
setInput,
14+
submittingChatDisableInput,
15+
OnChatSubmit,
16+
showChatInput,
17+
waitingForPlan
18+
19+
}) => {
20+
if (!showChatInput) {
21+
return null;
22+
}
23+
return (
24+
25+
<div style={{
26+
padding: '20px 24px 32px',
27+
borderTop: '1px solid var(--colorNeutralStroke2)',
28+
backgroundColor: 'var(--colorNeutralBackground1)',
29+
maxWidth: '800px',
30+
margin: '0 auto',
31+
width: '100%'
32+
}}>
33+
<ChatInput
34+
value={input}
35+
onChange={setInput}
36+
onEnter={() => OnChatSubmit(input)}
37+
disabledChat={submittingChatDisableInput || waitingForPlan}
38+
placeholder={
39+
waitingForPlan
40+
? "Creating plan..."
41+
: "Send a message..."
42+
}
43+
>
44+
<Button
45+
appearance="transparent"
46+
onClick={() => OnChatSubmit(input)}
47+
icon={<SendRegular />}
48+
disabled={submittingChatDisableInput || waitingForPlan}
49+
style={{ height: '40px', width: '40px' }}
50+
/>
51+
</ChatInput>
52+
</div>);
53+
}
54+
55+
export default PlanChatBody;

src/frontend/src/components/content/streaming/StreamingUserPlan.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { MPlanData, ProcessedPlanData } from "@/models";
2-
import { get } from "http";
32

43
const getUserPlan = (
54
planApprovalRequest: MPlanData | null,

src/frontend/src/components/content/streaming/StreamingUserPlanMessage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { MPlanData, ProcessedPlanData } from "@/models";
66
const renderUserPlanMessage = (planApprovalRequest: MPlanData | null,
77
initialTask?: string,
88
planData?: ProcessedPlanData) => {
9-
const userTask = getUserTask(planApprovalRequest, initialTask, planData);
9+
const userPlan = getUserTask(planApprovalRequest, initialTask, planData);
1010

1111
return (
1212
<div style={{
@@ -38,7 +38,7 @@ const renderUserPlanMessage = (planApprovalRequest: MPlanData | null,
3838
color: 'var(--colorNeutralForeground1)',
3939
wordWrap: 'break-word'
4040
}}>
41-
{userTask}
41+
{userPlan}
4242
</div>
4343
</div>
4444
</div>

0 commit comments

Comments
 (0)