Skip to content

Commit bb8424e

Browse files
committed
excel fixes
1 parent c03ce51 commit bb8424e

File tree

7 files changed

+50
-21
lines changed

7 files changed

+50
-21
lines changed

src/frontend_react/src/components/content/HomeInput.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const HomeInput: React.FC<HomeInputProps> = ({
4646
const handleSubmit = async () => {
4747
if (input.trim()) {
4848
setSubmitting(true);
49-
showToast("Creating a task...", "progress", { dismissible: false });
49+
showToast("Creating a plan..", "progress", { dismissible: false });
5050
try {
5151
const response = await TaskService.submitInputTask(input.trim());
5252

@@ -55,7 +55,7 @@ const HomeInput: React.FC<HomeInputProps> = ({
5555
textareaRef.current.style.height = "auto";
5656
}
5757

58-
showToast("Task created!", "success");
58+
showToast("Plan created!", "success");
5959
navigate(`/plan/${response.plan_id}`);
6060
console.log('Task response', response);
6161
if (response.plan_id != null) {
@@ -64,10 +64,10 @@ const HomeInput: React.FC<HomeInputProps> = ({
6464
} else {
6565
// plan_id is not valid, handle accordingly
6666
console.log('Invalid plan:', response.status);
67-
showToast("Failed to create task", "error");
67+
showToast("Failed to create plan", "error");
6868
}
6969
} catch (error) {
70-
console.error("Failed to create task:", error);
70+
console.error("Failed to create plan:", error);
7171
showToast("Something went wrong", "error");
7272
} finally {
7373
setSubmitting(false);

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ import "../../styles/prism-material-oceanic.css"
1414
import InlineToaster from "../toast/InlineToaster";
1515
const PlanChat: React.FC<PlanChatProps> = ({
1616
planData,
17+
input,
1718
loading,
1819
OnChatSubmit
1920
}) => {
2021
// const [messages, setMessages] = useState<{ role: string; content: string }[]>([]);
21-
const [input, setInput] = useState("");
22+
const [inputValue, setInput] = useState(input);
2223
const [isTyping, setIsTyping] = useState(false);
2324
const [showScrollButton, setShowScrollButton] = useState(false);
2425
const [inputHeight, setInputHeight] = useState(0);
@@ -30,7 +31,6 @@ const PlanChat: React.FC<PlanChatProps> = ({
3031
const scrollToBottom = () => {
3132
};
3233
const clearChat = async () => {
33-
setInput("");
3434
setCurrentConversationId(undefined);
3535
};
3636
return (
@@ -86,16 +86,17 @@ const PlanChat: React.FC<PlanChatProps> = ({
8686
<div ref={inputContainerRef} className="plan-chat-input-container">
8787
<div className="plan-chat-input-wrapper">
8888
<ChatInput
89-
value={input}
89+
value={inputValue}
9090
onChange={setInput}
91-
onEnter={() => OnChatSubmit(input)}
92-
disabledChat={!planData.hasHumanClarificationRequest}
91+
onEnter={() => OnChatSubmit(inputValue)}
92+
disabledChat={!planData.enableChat}
93+
placeholder="Add more info to this task..."
9394
>
9495
<Button
9596
appearance="transparent"
96-
onClick={() => OnChatSubmit(input)}
97+
onClick={() => OnChatSubmit(inputValue)}
9798
icon={<Send />}
98-
disabled={!planData?.hasHumanClarificationRequest && (!input.trim())}
99+
disabled={!planData?.enableChat && (!input.trim())}
99100
/>
100101

101102
</ChatInput>

src/frontend_react/src/components/content/TaskDetails.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ const TaskDetails: React.FC<TaskDetailsProps> = ({
9696
const { description, functionOrDetails } = TaskService.splitSubtaskAction(
9797
subtask.action
9898
);
99-
const canInteract = planData.plan.human_clarification_response !== null
99+
const canInteract = planData.enableStepButtons;
100100

101101
return (<div key={subtask.id} className="task-details-subtask-item">
102102
<div className="task-details-status-icon">

src/frontend_react/src/coral/modules/ChatInput.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,11 @@ const ChatInput: React.FC<ChatInputProps> = ({
106106
maxHeight: "32px",
107107
}}
108108
>
109-
109+
<FluentTooltip content="AI-generated content may be incorrect." relationship="label">
110+
<Tag appearance="filled" size="small">
111+
AI Generated
112+
</Tag>
113+
</FluentTooltip>
110114
<HeaderTools>
111115
{children}
112116
</HeaderTools>

src/frontend_react/src/models/plan.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,16 @@ export interface ProcessedPlanData {
109109
plan: PlanWithSteps;
110110
agents: AgentType[];
111111
steps: Step[];
112-
hasHumanClarificationRequest: boolean;
112+
hasClarificationRequest: boolean;
113+
hasClarificationResponse: boolean;
114+
enableChat: boolean;
115+
enableStepButtons: boolean;
113116
messages: PlanMessage[];
114117
}
115118

116119
export interface PlanChatProps {
117120
planData: ProcessedPlanData;
121+
input: string;
118122
loading: boolean;
119123
OnChatSubmit: (message: string) => void;
120124
}

src/frontend_react/src/pages/PlanPage.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const PlanPage: React.FC = () => {
3838
const { planId } = useParams<{ planId: string }>();
3939
const navigate = useNavigate();
4040
const { showToast } = useInlineToaster();
41-
41+
const [input, setInput] = useState("");
4242
// State for plan data
4343
const [planData, setPlanData] = useState<ProcessedPlanData | any>(null);
4444
const [loading, setLoading] = useState<boolean>(true);
@@ -51,9 +51,9 @@ const PlanPage: React.FC = () => {
5151
if (!planId) return;
5252

5353
try {
54+
setPlanData(null);
5455
setLoading(true);
5556
setError(null);
56-
5757
const data = await PlanDataService.fetchPlanData(planId);
5858
console.log('Fetched plan data:', data);
5959
setPlanData(data);
@@ -66,6 +66,7 @@ const PlanPage: React.FC = () => {
6666
}, [planId]);
6767

6868
const loadPlanData2 = useCallback(async () => {
69+
console.log('loadPlanData2 called with planId:', planId);
6970
if (!planId) return;
7071

7172
try {
@@ -94,9 +95,13 @@ const PlanPage: React.FC = () => {
9495
planData.plan.session_id, // session_id
9596
chatInput // human_clarification
9697
);
98+
showToast("Clarification submitted successfully", "success");
9799
await loadPlanData2();
98100
} catch (error) {
101+
showToast("Failed to submit clarification", "error");
99102
console.error('Failed to submit clarification:', error);
103+
} finally {
104+
setInput(""); // Clear input after submission
100105
}
101106
},
102107
[planData, loadPlanData2]
@@ -108,8 +113,11 @@ const PlanPage: React.FC = () => {
108113
showToast("Submitting approval...", "progress", { dismissible: false });
109114
try {
110115
await PlanDataService.approveStep(step);
116+
showToast("Step approved successfully", "success");
111117
await loadPlanData2();
112118
} catch (error) {
119+
showToast("Failed to approve step", "error");
120+
// Log the error for debugging
113121
console.error('Failed to reject step:', error);
114122
} finally {
115123
setProcessingSubtaskId(null);
@@ -121,8 +129,10 @@ const PlanPage: React.FC = () => {
121129
showToast("Submitting rejection...", "progress", { dismissible: false });
122130
try {
123131
await PlanDataService.rejectStep(step);
132+
showToast("Step rejected successfully", "success");
124133
await loadPlanData2();
125134
} catch (error) {
135+
showToast("Failed to reject step", "error");
126136
console.error('Failed to reject step:', error);
127137
} finally {
128138
setProcessingSubtaskId(null);
@@ -161,6 +171,7 @@ const PlanPage: React.FC = () => {
161171
planData={planData}
162172
OnChatSubmit={handleOnchatSubmit}
163173
loading={loading}
174+
input={input}
164175
/>
165176

166177

src/frontend_react/src/services/PlanDataService.tsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,18 @@ export class PlanDataService { /**
4242
const steps = plan.steps;
4343

4444
// Check if human_clarification_request is not null
45-
const hasHumanClarificationRequest = plan.human_clarification_request != null &&
46-
plan.human_clarification_request.trim().length > 0;
47-
45+
const hasClarificationRequest = plan.human_clarification_request != null && plan.human_clarification_request.trim().length > 0;
46+
const hasClarificationResponse = plan.human_clarification_response != null && plan.human_clarification_response.trim().length > 0;
47+
const enableChat = hasClarificationRequest && !hasClarificationResponse;
48+
const enableStepButtons = hasClarificationRequest && hasClarificationResponse;
4849
return {
4950
plan,
5051
agents,
5152
steps,
52-
hasHumanClarificationRequest,
53+
hasClarificationRequest,
54+
hasClarificationResponse,
55+
enableChat,
56+
enableStepButtons,
5357
messages
5458
};
5559
}
@@ -127,6 +131,11 @@ export class PlanDataService { /**
127131
* @returns Promise with API response
128132
*/
129133
static async submitClarification(planId: string, sessionId: string, clarification: string) {
130-
return apiService.submitClarification(planId, sessionId, clarification);
134+
try {
135+
return apiService.submitClarification(planId, sessionId, clarification);
136+
} catch (error) {
137+
console.error('Failed to submit clarification:', error);
138+
throw error;
139+
}
131140
}
132141
}

0 commit comments

Comments
 (0)