mirror of
https://github.com/leonvanzyl/autocoder.git
synced 2026-01-30 14:22:04 +00:00
fix: address CodeRabbitAI review comments for conversation history
- Fix duplicate onConversationCreated callbacks by tracking activeConversationId - Fix history loss when switching conversations with Map-based deduplication - Disable input while conversation is loading to prevent message routing issues - Gate WebSocket debug logs behind DEV flag (import.meta.env.DEV) - Downgrade server logging from info to debug level for reduced noise - Fix .gitignore prefixes for playwright paths (ui/playwright-report/, ui/test-results/) - Remove debug console.log from ConversationHistory.tsx - Add staleTime (30s) to single conversation query for better caching - Increase history message cap from 20 to 35 for better context - Replace fixed timeouts with condition-based waits in e2e tests
This commit is contained in:
@@ -260,7 +260,7 @@ async def assistant_chat_websocket(websocket: WebSocket, project_name: str):
|
||||
data = await websocket.receive_text()
|
||||
message = json.loads(data)
|
||||
msg_type = message.get("type")
|
||||
logger.info(f"Assistant received message type: {msg_type}")
|
||||
logger.debug(f"Assistant received message type: {msg_type}")
|
||||
|
||||
if msg_type == "ping":
|
||||
await websocket.send_json({"type": "pong"})
|
||||
@@ -269,23 +269,24 @@ async def assistant_chat_websocket(websocket: WebSocket, project_name: str):
|
||||
elif msg_type == "start":
|
||||
# Get optional conversation_id to resume
|
||||
conversation_id = message.get("conversation_id")
|
||||
logger.info(f"Processing start message with conversation_id={conversation_id}")
|
||||
logger.debug(f"Processing start message with conversation_id={conversation_id}")
|
||||
|
||||
try:
|
||||
# Create a new session
|
||||
logger.info(f"Creating session for {project_name}")
|
||||
logger.debug(f"Creating session for {project_name}")
|
||||
session = await create_session(
|
||||
project_name,
|
||||
project_dir,
|
||||
conversation_id=conversation_id,
|
||||
)
|
||||
logger.info(f"Session created, starting...")
|
||||
logger.debug("Session created, starting...")
|
||||
|
||||
# Stream the initial greeting
|
||||
async for chunk in session.start():
|
||||
logger.info(f"Sending chunk: {chunk.get('type')}")
|
||||
if logger.isEnabledFor(logging.DEBUG):
|
||||
logger.debug(f"Sending chunk: {chunk.get('type')}")
|
||||
await websocket.send_json(chunk)
|
||||
logger.info("Session start complete")
|
||||
logger.debug("Session start complete")
|
||||
except Exception as e:
|
||||
logger.exception(f"Error starting assistant session for {project_name}")
|
||||
await websocket.send_json({
|
||||
|
||||
@@ -345,6 +345,8 @@ class AssistantChatSession:
|
||||
history = get_messages(self.project_dir, self.conversation_id)
|
||||
# Exclude the message we just added (last one)
|
||||
history = history[:-1] if history else []
|
||||
# Cap history to last 35 messages to prevent context overload
|
||||
history = history[-35:] if len(history) > 35 else history
|
||||
if history:
|
||||
# Format history as context for Claude
|
||||
history_lines = ["[Previous conversation history for context:]"]
|
||||
|
||||
Reference in New Issue
Block a user