Skip to content

Commit 3842ace

Browse files
committed
plan page loading fixing process
1 parent 0828ecc commit 3842ace

File tree

5 files changed

+65
-58
lines changed

5 files changed

+65
-58
lines changed

src/frontend_react/src/components/content/PlanChat.tsx

Lines changed: 46 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import "../../styles/prism-material-oceanic.css"
1414
import InlineToaster from "../toast/InlineToaster";
1515
const PlanChat: React.FC<PlanChatProps> = ({
1616
planData,
17+
loading,
1718
OnChatSubmit
1819
}) => {
1920
// const [messages, setMessages] = useState<{ role: string; content: string }[]>([]);
@@ -25,7 +26,7 @@ const PlanChat: React.FC<PlanChatProps> = ({
2526

2627
const messagesContainerRef = useRef<HTMLDivElement>(null);
2728
const inputContainerRef = useRef<HTMLDivElement>(null);
28-
const messages = planData.messages || [];
29+
const messages = planData?.messages || [];
2930
const scrollToBottom = () => {
3031
};
3132
const clearChat = async () => {
@@ -34,15 +35,18 @@ const PlanChat: React.FC<PlanChatProps> = ({
3435
};
3536
return (
3637
<div className="chat-container">
37-
<div className="messages" ref={messagesContainerRef}>
38-
<div className="message-wrapper">
39-
{messages.map((msg, index) => (<div key={index} className={`message ${msg.source !== "human" ? "assistant" : "user"}`}>
40-
<Body1>
41-
<div className="plan-chat-message-content">
42-
<ReactMarkdown remarkPlugins={[remarkGfm]} rehypePlugins={[rehypePrism]}>
43-
{msg.content}
44-
</ReactMarkdown>
45-
{/* {msg.role === "assistant" && (
38+
{planData && (
39+
<>
40+
<div className="messages" ref={messagesContainerRef}>
41+
<div className="message-wrapper">
42+
43+
{messages.map((msg, index) => (<div key={index} className={`message ${msg.source !== "human" ? "assistant" : "user"}`}>
44+
<Body1>
45+
<div className="plan-chat-message-content">
46+
<ReactMarkdown remarkPlugins={[remarkGfm]} rehypePlugins={[rehypePrism]}>
47+
{msg.content}
48+
</ReactMarkdown>
49+
{/* {msg.role === "assistant" && (
4650
<div className="assistant-footer">
4751
<div className="assistant-actions">
4852
<Button
@@ -62,44 +66,43 @@ const PlanChat: React.FC<PlanChatProps> = ({
6266
</div>
6367
</div>
6468
)} */}
69+
</div>
70+
</Body1>
6571
</div>
66-
</Body1>
72+
))}</div>
6773
</div>
68-
))}</div>
69-
</div>
70-
{showScrollButton && (
71-
<Tag
72-
onClick={scrollToBottom}
73-
className="scroll-to-bottom plan-chat-scroll-button"
74-
shape="circular"
75-
style={{ bottom: inputHeight }}
76-
>
77-
Back to bottom
78-
</Tag>
79-
)}
80-
81-
<InlineToaster />
82-
<div ref={inputContainerRef} className="plan-chat-input-container">
83-
<div className="plan-chat-input-wrapper">
84-
<ChatInput
85-
value={input}
86-
onChange={setInput}
87-
onEnter={() => OnChatSubmit(input)}
88-
disabledChat={!planData.hasHumanClarificationRequest}
89-
>
90-
<Button
91-
appearance="transparent"
92-
onClick={() => OnChatSubmit(input)}
93-
icon={<Send />}
94-
disabled={!planData.hasHumanClarificationRequest && (!input.trim())}
95-
/>
74+
{showScrollButton && (
75+
<Tag
76+
onClick={scrollToBottom}
77+
className="scroll-to-bottom plan-chat-scroll-button"
78+
shape="circular"
79+
style={{ bottom: inputHeight }}
80+
>
81+
Back to bottom
82+
</Tag>
83+
)}
9684

97-
</ChatInput>
98-
</div>
99-
100-
</div>
85+
<InlineToaster />
86+
<div ref={inputContainerRef} className="plan-chat-input-container">
87+
<div className="plan-chat-input-wrapper">
88+
<ChatInput
89+
value={input}
90+
onChange={setInput}
91+
onEnter={() => OnChatSubmit(input)}
92+
disabledChat={!planData.hasHumanClarificationRequest}
93+
>
94+
<Button
95+
appearance="transparent"
96+
onClick={() => OnChatSubmit(input)}
97+
icon={<Send />}
98+
disabled={!planData?.hasHumanClarificationRequest && (!input.trim())}
99+
/>
101100

101+
</ChatInput>
102+
</div>
102103

104+
</div>
105+
</>)}
103106
</div>
104107
);
105108
};

src/frontend_react/src/components/content/PlanPanelRight.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { TaskDetailsProps } from "@/models";
1010

1111
const PlanPanelRight: React.FC<TaskDetailsProps> = ({
1212
planData,
13-
13+
loading,
1414
OnApproveStep,
1515
OnRejectStep,
1616
processingSubtaskId
@@ -31,6 +31,7 @@ const PlanPanelRight: React.FC<TaskDetailsProps> = ({
3131
OnApproveStep={OnApproveStep}
3232
OnRejectStep={OnRejectStep}
3333
processingSubtaskId={processingSubtaskId}
34+
loading={loading}
3435
/>
3536
</div>
3637
</PanelRight>

src/frontend_react/src/models/plan.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,5 +115,6 @@ export interface ProcessedPlanData {
115115

116116
export interface PlanChatProps {
117117
planData: ProcessedPlanData;
118+
loading: boolean;
118119
OnChatSubmit: (message: string) => void;
119120
}

src/frontend_react/src/models/taskDetails.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export interface Human {
2222

2323
export interface TaskDetailsProps {
2424
planData: ProcessedPlanData;
25+
loading: boolean;
2526
processingSubtaskId: string | null;
2627
OnApproveStep: (step: Step) => void;
2728
OnRejectStep: (step: Step) => void;

src/frontend_react/src/pages/PlanPage.tsx

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -151,29 +151,30 @@ const PlanPage: React.FC = () => {
151151
<CoralShellRow>
152152
<PlanPanelLeft onNewTaskButton={handleNewTaskButton} />
153153
<Content>
154-
{loading && <Spinner />}
155-
{!loading && (
156-
<>
157-
<ContentToolbar
158-
panelTitle={planData?.plan?.initial_goal || 'Plan Details'}
159-
panelIcon={<Sparkle20Filled />}
160-
></ContentToolbar>
161-
<PlanChat
162-
planData={planData}
163-
OnChatSubmit={handleOnchatSubmit}
164-
/>
165-
</>
166-
)}
154+
155+
156+
<ContentToolbar
157+
panelTitle={planData?.plan?.initial_goal || 'Plan Details'}
158+
panelIcon={<Sparkle20Filled />}
159+
></ContentToolbar>
160+
<PlanChat
161+
planData={planData}
162+
OnChatSubmit={handleOnchatSubmit}
163+
loading={loading}
164+
/>
165+
166+
167167
</Content>
168168

169169
<PlanPanelRight
170170
planData={planData}
171171
OnApproveStep={handleApproveStep}
172172
OnRejectStep={handleRejectStep}
173173
processingSubtaskId={processingSubtaskId}
174+
loading={loading}
174175
/>
175176
</CoralShellRow>
176-
</CoralShellColumn>
177+
</CoralShellColumn >
177178
);
178179

179180

0 commit comments

Comments
 (0)