Skip to content

πŸ™Œ OpenHands: AI-Driven Development

Fix for delete conversation (#6097)

tofarreaf4c610b255
diff --git a/openhands/storage/conversation/file_conversation_store.py b/openhands/storage/conversation/file_conversation_store.py
index 622b72f4bb..15679f4049 100644
--- a/openhands/storage/conversation/file_conversation_store.py
+++ b/openhands/storage/conversation/file_conversation_store.py
@@ -1,6 +1,7 @@
from __future__ import annotations
from dataclasses import dataclass
+from pathlib import Path
from pydantic import TypeAdapter
@@ -39,7 +40,9 @@ class FileConversationStore(ConversationStore):
return result
async def delete_metadata(self, conversation_id: str) -> None:
- path = self.get_conversation_metadata_filename(conversation_id)
+ path = str(
+ Path(self.get_conversation_metadata_filename(conversation_id)).parent
+ )
await call_sync_from_async(self.file_store.delete, path)
async def exists(self, conversation_id: str) -> bool:
diff --git a/tests/unit/test_conversation.py b/tests/unit/test_conversation.py
index 91731a601d..7610cf2525 100644
--- a/tests/unit/test_conversation.py
+++ b/tests/unit/test_conversation.py
@@ -6,6 +6,7 @@ from unittest.mock import MagicMock, patch
import pytest
from openhands.server.routes.manage_conversations import (
+ delete_conversation,
get_conversation,
search_conversations,
update_conversation,
@@ -114,3 +115,16 @@ async def test_update_conversation():
selected_repository='foobar',
)
assert conversation == expected
+
+
+async def test_delete_conversation():
+ with _patch_store():
+ await delete_conversation(
+ 'some_conversation_id',
+ MagicMock(state=MagicMock(github_token='')),
+ )
+ conversation = await get_conversation(
+ 'some_conversation_id', MagicMock(state=MagicMock(github_token=''))
+ )
+ assert conversation is None