Skip to content

Commit 9a70f0f

Browse files
committed
Improve conditional rendering and logging in chat components
PlanChat now conditionally renders the plan response only when approval buttons are shown. Added targeted logging for messages containing 'clarification' in WebSocketService. PlanPage received additional comments for clarity on WebSocket message types. StreamingAgentMessage includes commented-out style suggestions for agent message container.
1 parent 34a92aa commit 9a70f0f

File tree

4 files changed

+21
-7
lines changed

4 files changed

+21
-7
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ const PlanChat: React.FC<SimplifiedPlanChatProps> = ({
159159
{renderThinkingState(waitingForPlan)}
160160

161161
{/* Plan response with all information */}
162-
{renderPlanResponse(planApprovalRequest, handleApprovePlan, handleRejectPlan, processingApproval, showApprovalButtons)}
162+
{showApprovalButtons && renderPlanResponse(planApprovalRequest, handleApprovePlan, handleRejectPlan, processingApproval, showApprovalButtons)}
163163
{renderAgentMessages(agentMessages)}
164164

165165

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,16 @@ const renderAgentMessages = (agentMessages: AgentMessageData[]) => {
88
if (!agentMessages || agentMessages.length === 0) return null;
99

1010
return (
11-
<div >
11+
<div
12+
// style={{
13+
// height: 200,
14+
// maxHeight: 200,
15+
// overflowY: 'auto', // or 'hidden' if you don't want scrolling
16+
// overflowX: 'hidden',
17+
// flex: '0 0 200px' // prevents flex parents from stretching it
18+
// }}
19+
20+
>
1221
{agentMessages.map((msg, index) => {
1322
const trimmed = msg.raw_content?.trim();
1423
if (!trimmed) return null; // skip if empty, null, or whitespace

src/frontend/src/pages/PlanPage.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ const PlanPage: React.FC = () => {
8282
}, 100);
8383
}, []);
8484

85+
//WebsocketMessageType.PLAN_APPROVAL_REQUEST
8586
useEffect(() => {
8687
const unsubscribe = webSocketService.on(WebsocketMessageType.PLAN_APPROVAL_REQUEST, (approvalRequest: any) => {
8788
console.log('📋 Plan received:', approvalRequest);
@@ -122,7 +123,7 @@ const PlanPage: React.FC = () => {
122123
return () => unsubscribe();
123124
}, [scrollToBottom]); //onPlanReceived, scrollToBottom
124125

125-
126+
//(WebsocketMessageType.AGENT_MESSAGE_STREAMING
126127
useEffect(() => {
127128
const unsubscribe = webSocketService.on(WebsocketMessageType.AGENT_MESSAGE_STREAMING, (streamingMessage: any) => {
128129
// console.log('📋 Streaming Message', streamingMessage);
@@ -134,6 +135,7 @@ const PlanPage: React.FC = () => {
134135
return () => unsubscribe();
135136
}, [scrollToBottom]); //onPlanReceived, scrollToBottom
136137

138+
//WebsocketMessageType.USER_CLARIFICATION_REQUEST
137139
useEffect(() => {
138140
const unsubscribe = webSocketService.on(WebsocketMessageType.USER_CLARIFICATION_REQUEST, (clarificationMessage: any) => {
139141
console.log('📋 Clarification Message', clarificationMessage);
@@ -143,7 +145,7 @@ const PlanPage: React.FC = () => {
143145

144146
return () => unsubscribe();
145147
}, [scrollToBottom]);
146-
148+
//WebsocketMessageType.AGENT_TOOL_MESSAGE
147149
useEffect(() => {
148150
const unsubscribe = webSocketService.on(WebsocketMessageType.AGENT_TOOL_MESSAGE, (toolMessage: any) => {
149151
console.log('📋 Tool Message', toolMessage);
@@ -154,7 +156,7 @@ const PlanPage: React.FC = () => {
154156
return () => unsubscribe();
155157
}, [scrollToBottom]);
156158

157-
159+
//WebsocketMessageType.AGENT_MESSAGE
158160
useEffect(() => {
159161
const unsubscribe = webSocketService.on(WebsocketMessageType.AGENT_MESSAGE, (agentMessage: any) => {
160162
console.log('📋 Agent Message', agentMessage);

src/frontend/src/services/WebSocketService.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,11 @@ class WebSocketService {
166166

167167
private handleMessage(message: StreamMessage): void {
168168

169-
170-
console.log('WebSocket message received:', message);
169+
//console.log('WebSocket message received:', message);
170+
const hasClarification = /\bclarifications?\b/i.test(message.data || '');
171+
if (hasClarification) {
172+
console.log("Message contains 'clarification':", message.data);
173+
}
171174
switch (message.type) {
172175
case WebsocketMessageType.PLAN_APPROVAL_REQUEST: {
173176
console.log("enter plan approval request");

0 commit comments

Comments
 (0)