Skip to content

Commit 56aec82

Browse files
committed
fix missing messages
1 parent dc8cfa1 commit 56aec82

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

src/backend/app_kernel.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -620,9 +620,10 @@ async def get_plans(
620620

621621
# Use get_steps_by_plan to match the original implementation
622622
steps = await memory_store.get_steps_by_plan(plan_id=plan.id)
623-
messages = await memory_store.get_data_by_type_and_plan_id(
624-
"agent_message", plan_id=plan.id
623+
messages = await memory_store.get_data_by_type_and_session_id(
624+
"agent_message", session_id=plan.session_id
625625
)
626+
626627
plan_with_steps = PlanWithSteps(**plan.model_dump(), steps=steps)
627628
plan_with_steps.update_step_counts()
628629
return [plan_with_steps, messages]

src/backend/context/cosmos_memory_kernel.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -443,8 +443,8 @@ async def get_data_by_type(self, data_type: str) -> List[BaseDataModel]:
443443
logging.exception(f"Failed to query data by type from Cosmos DB: {e}")
444444
return []
445445

446-
async def get_data_by_type_and_plan_id(
447-
self, data_type: str, plan_id: str
446+
async def get_data_by_type_and_session_id(
447+
self, data_type: str, session_id: str
448448
) -> List[BaseDataModel]:
449449
"""Query the Cosmos DB for documents with the matching data_type, session_id and user_id."""
450450
await self.ensure_initialized()
@@ -453,11 +453,11 @@ async def get_data_by_type_and_plan_id(
453453

454454
model_class = self.MODEL_CLASS_MAPPING.get(data_type, BaseDataModel)
455455
try:
456-
query = "SELECT * FROM c WHERE c.user_id=@user_id AND c.data_type=@data_type AND c.plan_id=@plan_id ORDER BY c._ts ASC"
456+
query = "SELECT * FROM c WHERE c.session_id=@session_id AND c.user_id=@user_id AND c.data_type=@data_type ORDER BY c._ts ASC"
457457
parameters = [
458+
{"name": "@session_id", "value": session_id},
458459
{"name": "@data_type", "value": data_type},
459460
{"name": "@user_id", "value": self.user_id},
460-
{"name": "@plan_id", "value": plan_id},
461461
]
462462
return await self.query_items(query, parameters, model_class)
463463
except Exception as e:

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Copy, Send } from "@/coral/imports/bundleicons";
33
import ChatInput from "@/coral/modules/ChatInput";
44
import remarkGfm from "remark-gfm";
55
import rehypePrism from "rehype-prism";
6-
import { PlanChatProps } from "@/models";
6+
import { AgentType, PlanChatProps, role } from "@/models";
77
import {
88
Body1,
99
Button,
@@ -48,10 +48,10 @@ const PlanChat: React.FC<PlanChatProps> = ({
4848
<div className="messages" ref={messagesContainerRef}>
4949
<div className="message-wrapper">
5050
{messages.map((msg, index) => {
51-
const isHuman = msg.source.includes("human");
51+
const isHuman = msg.source === AgentType.HUMAN;
5252

5353
return (
54-
<div key={index} className={`message ${isHuman ? "user" : "assistant"}`}>
54+
<div key={index} className={`message ${isHuman ? role.user : role.assistant}`}>
5555
{!isHuman && (
5656
<div className="plan-chat-header">
5757
<div className="plan-chat-speaker">
@@ -119,7 +119,7 @@ const PlanChat: React.FC<PlanChatProps> = ({
119119
appearance="transparent"
120120
onClick={() => OnChatSubmit(inputValue)}
121121
icon={<Send />}
122-
disabled={!planData?.enableChat}
122+
disabled={!planData?.enableChat && !inputValue.trim()}
123123
/>
124124
</ChatInput>
125125
</div>

src/frontend_react/src/models/enums.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ export enum AgentType {
1717
PLANNER = "Planner_Agent"
1818
}
1919

20+
export enum role {
21+
user = "user",
22+
assistant = "assistant"
23+
}
2024
/**
2125
* Enumeration of possible statuses for a step.
2226
*/

0 commit comments

Comments
 (0)